diff options
author | 2018-03-23 16:20:09 +0530 | |
---|---|---|
committer | 2018-03-26 11:32:39 +0000 | |
commit | 6cc3acdc6d3140a8f702939568ab4c7cda06beaa (patch) | |
tree | 8b4a4fdaca000304a7a207707e69cbad3befebc0 /services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImpl.java | |
parent | ed12890b0bb0c07acd3eb7bcbd10bfcca3046a2b (diff) |
Enhance Activity Spec Update error messages
Updating error messages
Change-Id: I5660e5ba773141db3df440eb94e0b6aa521dbc73
Issue-ID: SDC-1048
Signed-off-by: shrikantawachar <shrikant.awachar@amdocs.com>
Diffstat (limited to 'services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImpl.java')
-rw-r--r-- | services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImpl.java | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImpl.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImpl.java index 614728cc11..07863234c3 100644 --- a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImpl.java +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/openecomp/activityspec/be/impl/ActivitySpecManagerImpl.java @@ -84,7 +84,7 @@ public class ActivitySpecManagerImpl implements ActivitySpecManager { @Override public ActivitySpecEntity createActivitySpec(ActivitySpecEntity activitySpecEntity) { - uniqueValueUtil.validateUniqueValue(ACTIVITY_SPEC_NAME, activitySpecEntity.getName()); + validateUniqueValue(activitySpecEntity); Item item = getActivitySpecItem(activitySpecEntity); item = itemManager.create(item); @@ -99,6 +99,17 @@ public class ActivitySpecManagerImpl implements ActivitySpecManager { return activitySpecEntity; } + private void validateUniqueValue(ActivitySpecEntity activitySpecEntity) { + try { + uniqueValueUtil.validateUniqueValue(ACTIVITY_SPEC_NAME, activitySpecEntity.getName()); + } catch (CoreException exception) { + throw new CoreException(new ErrorCode.ErrorCodeBuilder() + .withCategory(ErrorCategory.APPLICATION) + .withId(exception.code().id()) + .withMessage("Name already in use").build()); + } + } + private Version getActivitySpecVersion(ActivitySpecEntity activitySpecEntity) { return activitySpecEntity.getVersion() == null ? new Version() : activitySpecEntity.getVersion(); @@ -113,7 +124,8 @@ public class ActivitySpecManagerImpl implements ActivitySpecManager { try { retrieved = activitySpecDao.get(activitySpec); } catch (SdcRuntimeException runtimeException) { - LOGGER.error("Failed to retrieve activity spec for activitySpecId: " + activitySpec.getId() + " and version: " + LOGGER.error("Failed to retrieve activity spec for activitySpecId: " + activitySpec.getId() + + " and version: " + activitySpec.getVersion().getId(), runtimeException); validateActivitySpecExistence(activitySpec.getId(), activitySpec.getVersion()); } @@ -132,7 +144,7 @@ public class ActivitySpecManagerImpl implements ActivitySpecManager { ActivitySpecEntity previousActivitySpec = get(activitySpec); if (!activitySpec.getName().equals(previousActivitySpec.getName())) { - uniqueValueUtil.validateUniqueValue(ACTIVITY_SPEC_NAME, activitySpec.getName()); + validateUniqueValue(activitySpec); } activitySpecDao.update(activitySpec); @@ -175,8 +187,8 @@ public class ActivitySpecManagerImpl implements ActivitySpecManager { try { retrievedVersion = versioningManager.get(activitySpecId, version); } catch (SdcRuntimeException exception) { - LOGGER.error("Failed to get version for activitySpecId: " + activitySpecId + " and version: " + version.getId(), - exception); + LOGGER.error("Failed to get version for activitySpecId: " + activitySpecId + + " and version: " + version.getId(), exception); validateActivitySpecExistence(activitySpecId, version); } @@ -184,7 +196,7 @@ public class ActivitySpecManagerImpl implements ActivitySpecManager { VersionStatus status = version.getStatus(); Transition transition = TRANSITIONS.get(status); if (transition != null) { - String errMsg = String.format("%s ActivitySpec With Id %s failed since it is not in %s status", + String errMsg = String.format("Activity Spec is in an invalid state", transition.action, activitySpecId, transition.prevStatus); validateStatus(Objects.nonNull(retrievedVersion) ? retrievedVersion.getStatus() : null, transition.prevStatus, errMsg); @@ -225,7 +237,8 @@ public class ActivitySpecManagerImpl implements ActivitySpecManager { try { list = versioningManager.list(activitySpecId); } catch (SdcRuntimeException runtimeException) { - LOGGER.error("Failed to list versions for activitySpecId " + activitySpecId, runtimeException); + LOGGER.error("Failed to list versions for activitySpecId " + + activitySpecId, runtimeException); validateActivitySpecExistence(activitySpecId, version); } if (Objects.nonNull(list) && !list.isEmpty()) { |