From 5a7f092400ddb7a86e4be77531dcbe26f81c1c26 Mon Sep 17 00:00:00 2001 From: sheetalm Date: Mon, 7 May 2018 11:41:36 +0530 Subject: ActivitySpec validation for mandatory action Add validation for mandatory action Change-Id: Iff84526e1a6a359529124ab014c864260d8c2a8d Issue-ID: SDC-1303 Signed-off-by: sheetalm --- .../sdc/activityspec/api/rest/services/ActivitySpecsImpl.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'services/activity-spec/activity-spec-web') diff --git a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/onap/sdc/activityspec/api/rest/services/ActivitySpecsImpl.java b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/onap/sdc/activityspec/api/rest/services/ActivitySpecsImpl.java index e0eec80fcb..168f4ffb8e 100644 --- a/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/onap/sdc/activityspec/api/rest/services/ActivitySpecsImpl.java +++ b/services/activity-spec/activity-spec-web/activity-spec-service/src/main/java/org/onap/sdc/activityspec/api/rest/services/ActivitySpecsImpl.java @@ -33,6 +33,8 @@ import org.onap.sdc.activityspec.api.rest.types.ActivitySpecCreateResponse; import org.onap.sdc.activityspec.be.dao.impl.ActivitySpecDaoZusammenImpl; import org.openecomp.core.dao.UniqueValueDaoFactory; import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.versioning.ItemManagerFactory; import org.openecomp.sdc.versioning.VersioningManagerFactory; import org.openecomp.sdc.versioning.dao.types.Version; @@ -94,6 +96,10 @@ public class ActivitySpecsImpl implements ActivitySpecs { @Override public Response actOnActivitySpec(ActivitySpecActionRequestDto request, String activitySpecId, String versionId) { + if (request.getAction() == null) { + throw new CoreException(new ErrorCode.ErrorCodeBuilder().withMessage("Mandatory action field is missing") + .build()); + } activitySpecManager.actOnAction(activitySpecId, versionId, request.getAction()); return Response.ok(new InternalEmptyObject()).build(); } @@ -105,10 +111,9 @@ public class ActivitySpecsImpl implements ActivitySpecs { MapItemToListResponseDto mapper = new MapItemToListResponseDto(); activitySpecManager.list(versionStatus).stream() .sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime())).forEach( - activitySpecItem -> results.add( - mapper.applyMapping(activitySpecItem, ActivitySpecListResponseDto.class))); + activitySpecItem -> results.add(mapper.applyMapping(activitySpecItem, + ActivitySpecListResponseDto.class))); return Response.ok(results).build(); } - } -- cgit 1.2.3-korg