diff options
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services')
2 files changed, 31 insertions, 38 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java index 369e90c928..5dc79ebdfe 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java @@ -23,10 +23,10 @@ package org.openecomp.sdcrests.action.rest; import com.sun.jersey.multipart.FormDataParam; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.apache.cxf.jaxrs.ext.multipart.Multipart; import org.springframework.validation.annotation.Validated; +import java.io.InputStream; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.Consumes; import javax.ws.rs.HeaderParam; @@ -39,8 +39,6 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.InputStream; - @Path("/workflow/v1.0/actions") @Produces(MediaType.APPLICATION_JSON) diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java index e6f5e6b1a3..53ebf0baab 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java @@ -830,7 +830,6 @@ public class ActionsImpl implements Actions { HttpServletRequest servletRequest) { ListResponseWrapper responseList = null; Map<String, String> errorMap = validateRequestHeaders(servletRequest); - ; Map<String, String> queryParamErrors = validateQueryParam(componentID); errorMap.putAll(queryParamErrors); if (errorMap.isEmpty()) { @@ -992,37 +991,36 @@ public class ActionsImpl implements Actions { if (StringUtils.isEmpty(requestJSON) || requestJSON.equals(REQUEST_EMPTY_BODY)) { requestBodyErrorMap.put(ACTION_INVALID_REQUEST_BODY_CODE, ACTION_REQUEST_BODY_EMPTY); } else { - switch (requestType) { - case ActionConstants.REQUEST_TYPE_CREATE_ACTION: - case ActionConstants.REQUEST_TYPE_UPDATE_ACTION: - //Semantic request specific validations - Action action = JsonUtil.json2Object(requestJSON, Action.class); - if (StringUtils.isEmpty(action.getName())) { - setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_PARAM_NAME, - requestBodyErrorMap); - } else { - //Added check for action name not allowing whitespaces - if (action.getName().matches(whitespaceRegex)) { - requestBodyErrorMap - .put(ACTION_ARTIFACT_INVALID_NAME_CODE, ACTION_REQUEST_INVALID_NAME); - } + if(requestType == ActionConstants.REQUEST_TYPE_CREATE_ACTION){ + //placeholder for future implementation + } + if(requestType == ActionConstants.REQUEST_TYPE_UPDATE_ACTION){ + //Semantic request specific validations + Action action = JsonUtil.json2Object(requestJSON, Action.class); + if(StringUtils.isEmpty(action.getName())){ + setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_PARAM_NAME, + requestBodyErrorMap); + } else { + //Added check for action names not allowing whitespaces + if (action.getName().matches(whitespaceRegex)){ + requestBodyErrorMap.put(ACTION_ARTIFACT_INVALID_NAME_CODE, ACTION_REQUEST_INVALID_NAME); } + } - if (action.getSupportedModels() != null && - !isIDPresentInMap(action.getSupportedModels(), SUPPORTED_MODELS_VERSION_ID)) { - setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, - ACTION_REQUEST_PARAM_SUPPORTED_MODELS, requestBodyErrorMap); - } - if (action.getSupportedComponents() != null && - !isIDPresentInMap(action.getSupportedComponents(), SUPPORTED_COMPONENTS_ID)) { - setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, - ACTION_REQUEST_PARAM_SUPPORTED_COMPONENTS, requestBodyErrorMap); - } - if (action.getArtifacts() != null) { - setErrorValue(ACTION_UPDATE_NOT_ALLOWED_CODE, ACTION_REQUEST_ARTIFACT_OPERATION_ALLOWED, - requestBodyErrorMap); - } - break; + if(action.getSupportedModels() != null && !isIDPresentInMap(action.getSupportedModels(), + SUPPORTED_MODELS_VERSION_ID)){ + setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, + ACTION_REQUEST_PARAM_SUPPORTED_MODELS, requestBodyErrorMap); + } + if(action.getSupportedComponents() != null && !isIDPresentInMap(action + .getSupportedComponents(), SUPPORTED_COMPONENTS_ID)){ + setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, + ACTION_REQUEST_PARAM_SUPPORTED_MODELS, requestBodyErrorMap); + } + if(action.getArtifacts() != null){ + setErrorValue(ACTION_UPDATE_NOT_ALLOWED_CODE, + ACTION_REQUEST_ARTIFACT_OPERATION_ALLOWED, requestBodyErrorMap); + } } } @@ -1037,11 +1035,8 @@ public class ActionsImpl implements Actions { if (errorMessage != null) { message = errorMessage + ", " + message; } else { - switch (key) { - case ACTION_REQUEST_INVALID_GENERIC_CODE: - message = ACTION_REQUEST_MISSING_MANDATORY_PARAM + message; - break; - } + if(key == ACTION_REQUEST_INVALID_GENERIC_CODE) + message = ACTION_REQUEST_MISSING_MANDATORY_PARAM + message; } errorMap.put(key, message); } |