diff options
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main')
140 files changed, 9636 insertions, 9699 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java index 67bbc3db8e..b921f5beea 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java @@ -23,7 +23,6 @@ package org.onap.so.apihandler.common; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -31,31 +30,31 @@ import org.springframework.stereotype.Component; @Component public class ResponseBuilder { - - @Value("${mso.infra.default.versions.apiMinorVersion}") - private String apiMinorVersion; - @Value("${mso.infra.default.versions.apiPatchVersion}") - private String apiPatchVersion; - - public Response buildResponse(int status, String requestId, Object jsonResponse, String apiVersion) { - - if (apiVersion.matches("v[1-9]")) { - apiVersion = apiVersion.substring(1); - } - - String latestVersion = apiVersion + "." + apiMinorVersion + "." + apiPatchVersion; - - javax.ws.rs.core.Response.ResponseBuilder builder = Response.status(status) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .header(CommonConstants.X_MINOR_VERSION, apiMinorVersion) - .header(CommonConstants.X_PATCH_VERSION, apiPatchVersion) - .header(CommonConstants.X_LATEST_VERSION, latestVersion); - - if(StringUtils.isNotBlank(requestId)) { - builder.header(CommonConstants.X_TRANSACTION_ID, requestId); - } - - return builder.entity(jsonResponse).build(); - } + + @Value("${mso.infra.default.versions.apiMinorVersion}") + private String apiMinorVersion; + @Value("${mso.infra.default.versions.apiPatchVersion}") + private String apiPatchVersion; + + public Response buildResponse(int status, String requestId, Object jsonResponse, String apiVersion) { + + if (apiVersion.matches("v[1-9]")) { + apiVersion = apiVersion.substring(1); + } + + String latestVersion = apiVersion + "." + apiMinorVersion + "." + apiPatchVersion; + + javax.ws.rs.core.Response.ResponseBuilder builder = + Response.status(status).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .header(CommonConstants.X_MINOR_VERSION, apiMinorVersion) + .header(CommonConstants.X_PATCH_VERSION, apiPatchVersion) + .header(CommonConstants.X_LATEST_VERSION, latestVersion); + + if (StringUtils.isNotBlank(requestId)) { + builder.header(CommonConstants.X_TRANSACTION_ID, requestId); + } + + return builder.entity(jsonResponse).build(); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/filters/RequestUriFilter.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/filters/RequestUriFilter.java index 91ab580b07..a3ff1ab95d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/filters/RequestUriFilter.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/filters/RequestUriFilter.java @@ -22,37 +22,40 @@ package org.onap.so.apihandler.filters; import java.io.IOException; import java.net.URI; - import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.container.ContainerRequestFilter; import javax.ws.rs.container.PreMatching; import javax.ws.rs.core.UriInfo; - import org.onap.so.apihandlerinfra.Constants; @PreMatching public class RequestUriFilter implements ContainerRequestFilter { - private String requestURI; - @Override - public void filter(ContainerRequestContext context) throws IOException { - UriInfo uriInfo = context.getUriInfo(); - URI baseURI = uriInfo.getBaseUri(); - requestURI = uriInfo.getPath(); - - if(requestURI.contains("onap/so/infra/serviceInstances")){ - requestURI = requestURI.replaceFirst("serviceInstances", "serviceInstantiation"); - if(!requestURI.contains(Constants.SERVICE_INSTANCE_PATH)){ - //Adds /serviceInstances after the version provided in the URI - requestURI = new StringBuilder(requestURI).insert(requestURI.indexOf(Constants.SERVICE_INSTANTIATION_PATH) + 24, Constants.SERVICE_INSTANCE_PATH).toString(); - } - requestURI = baseURI + requestURI; - URI uri = URI.create(requestURI); - context.setRequestUri(uri); - } - } - public String getRequestUri(){ - return requestURI; - } + private String requestURI; + + @Override + public void filter(ContainerRequestContext context) throws IOException { + UriInfo uriInfo = context.getUriInfo(); + URI baseURI = uriInfo.getBaseUri(); + requestURI = uriInfo.getPath(); + + if (requestURI.contains("onap/so/infra/serviceInstances")) { + requestURI = requestURI.replaceFirst("serviceInstances", "serviceInstantiation"); + if (!requestURI.contains(Constants.SERVICE_INSTANCE_PATH)) { + // Adds /serviceInstances after the version provided in the URI + requestURI = new StringBuilder(requestURI) + .insert(requestURI.indexOf(Constants.SERVICE_INSTANTIATION_PATH) + 24, + Constants.SERVICE_INSTANCE_PATH) + .toString(); + } + requestURI = baseURI + requestURI; + URI uri = URI.create(requestURI); + context.setRequestUri(uri); + } + } + + public String getRequestUri() { + return requestURI; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandler.java index 74d5f7a9e6..71c56733b6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandler.java @@ -23,7 +23,6 @@ package org.onap.so.apihandler.recipe; import java.io.IOException; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; @@ -32,20 +31,19 @@ import org.springframework.web.client.ResponseErrorHandler; -public class CamundaClientErrorHandler implements ResponseErrorHandler{ - - private static Logger logger = LoggerFactory.getLogger(CamundaClientErrorHandler.class); - - @Override - public void handleError(ClientHttpResponse response) throws IOException { - logger.debug(response.getBody().toString()); - } +public class CamundaClientErrorHandler implements ResponseErrorHandler { + + private static Logger logger = LoggerFactory.getLogger(CamundaClientErrorHandler.class); + + @Override + public void handleError(ClientHttpResponse response) throws IOException { + logger.debug(response.getBody().toString()); + } + + @Override + public boolean hasError(ClientHttpResponse response) throws IOException { + HttpStatus.Series series = response.getStatusCode().series(); + return (HttpStatus.Series.CLIENT_ERROR.equals(series) || HttpStatus.Series.SERVER_ERROR.equals(series)); + } - @Override - public boolean hasError(ClientHttpResponse response) throws IOException { - HttpStatus.Series series = response.getStatusCode().series(); - return (HttpStatus.Series.CLIENT_ERROR.equals(series) - || HttpStatus.Series.SERVER_ERROR.equals(series)); - } - } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java index 897e2a5fc8..77dbff9ebb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java @@ -22,29 +22,7 @@ package org.onap.so.apihandlerinfra; /* * Enum for Status values returned by API Handler to Tail-F -*/ -public enum Action implements Actions{ - createInstance, - updateInstance, - deleteInstance, - configureInstance, - replaceInstance, - activateInstance, - deactivateInstance, - enablePort, - disablePort, - addRelationships, - removeRelationships, - inPlaceSoftwareUpdate, - applyUpdatedConfig, - completeTask, - assignInstance, - unassignInstance, - compareModel, - scaleInstance, - deactivateAndCloudDelete, - scaleOut, - recreateInstance, - addMembers, - removeMembers + */ +public enum Action implements Actions { + createInstance, updateInstance, deleteInstance, configureInstance, replaceInstance, activateInstance, deactivateInstance, enablePort, disablePort, addRelationships, removeRelationships, inPlaceSoftwareUpdate, applyUpdatedConfig, completeTask, assignInstance, unassignInstance, compareModel, scaleInstance, deactivateAndCloudDelete, scaleOut, recreateInstance, addMembers, removeMembers } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java index f3f98f3f2a..bc1972a593 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java @@ -21,7 +21,6 @@ package org.onap.so.apihandlerinfra; import java.util.concurrent.Executor; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; @@ -31,43 +30,43 @@ import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator; -@SpringBootApplication(scanBasePackages = { "org.onap"}) +@SpringBootApplication(scanBasePackages = {"org.onap"}) @EnableAsync public class ApiHandlerApplication { - - @Value("${mso.async.core-pool-size}") - private int corePoolSize; - @Value("${mso.async.max-pool-size}") - private int maxPoolSize; + @Value("${mso.async.core-pool-size}") + private int corePoolSize; + + @Value("${mso.async.max-pool-size}") + private int maxPoolSize; - @Value("${mso.async.queue-capacity}") - private int queueCapacity; + @Value("${mso.async.queue-capacity}") + private int queueCapacity; - private static final String LOGS_DIR = "logs_dir"; + private static final String LOGS_DIR = "logs_dir"; - private static void setLogsDir() { - if (System.getProperty(LOGS_DIR) == null) { - System.getProperties().setProperty(LOGS_DIR, "./logs/apih/"); - } - } + private static void setLogsDir() { + if (System.getProperty(LOGS_DIR) == null) { + System.getProperties().setProperty(LOGS_DIR, "./logs/apih/"); + } + } - public static void main(String[] args) { - SpringApplication.run(ApiHandlerApplication.class, args); - System.getProperties().setProperty("mso.db", "MARIADB"); - System.getProperties().setProperty("server.name", "Springboot"); - setLogsDir(); - } + public static void main(String[] args) { + SpringApplication.run(ApiHandlerApplication.class, args); + System.getProperties().setProperty("mso.db", "MARIADB"); + System.getProperties().setProperty("server.name", "Springboot"); + setLogsDir(); + } - @Bean - public Executor asyncExecutor() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(corePoolSize); - executor.setMaxPoolSize(maxPoolSize); - executor.setQueueCapacity(queueCapacity); - executor.setThreadNamePrefix("mso-apihandler-infra-"); - executor.setTaskDecorator(new MDCTaskDecorator()); - executor.initialize(); - return executor; - } + @Bean + public Executor asyncExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(corePoolSize); + executor.setMaxPoolSize(maxPoolSize); + executor.setQueueCapacity(queueCapacity); + executor.setThreadNamePrefix("mso-apihandler-infra-"); + executor.setTaskDecorator(new MDCTaskDecorator()); + executor.initialize(); + return executor; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java index de38bc717a..449aa4ba3f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java @@ -28,7 +28,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; - import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -39,7 +38,6 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.json.JSONObject; @@ -64,7 +62,6 @@ import org.onap.so.db.request.beans.OperationStatus; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; - import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.RequestDetails; @@ -76,9 +73,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import com.fasterxml.jackson.databind.ObjectMapper; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -88,678 +83,308 @@ import io.swagger.annotations.ApiOperation; @Api(value = "/onap/so/infra/e2eServiceInstances", description = "API Requests for E2E Service Instances") public class E2EServiceInstances { - private HashMap<String, String> instanceIdMap = new HashMap<>(); - private static final Logger logger = LoggerFactory.getLogger(E2EServiceInstances.class); - - private static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; - - private static final String END_OF_THE_TRANSACTION = "End of the transaction, the final response is: "; - - @Autowired - private MsoRequest msoRequest; - - @Autowired - private RequestClientFactory requestClientFactory; - - @Autowired - private RequestsDbClient requestsDbClient; - - @Autowired - private CatalogDbClient catalogDbClient; - - @Autowired - private ResponseBuilder builder; - - /** - * POST Requests for E2E Service create Instance on a version provided - * @throws ApiException - */ - - @POST - @Path("/{version:[vV][3-5]}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Create an E2E Service Instance on a version provided", response = Response.class) - public Response createE2EServiceInstance(String request, - @PathParam("version") String version) throws ApiException { - - return processE2EserviceInstances(request, Action.createInstance, null, - version); - } - - /** - * PUT Requests for E2E Service update Instance on a version provided - * @throws ApiException - */ - - @PUT - @Path("/{version:[vV][3-5]}/{serviceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Update an E2E Service Instance on a version provided and serviceId", response = Response.class) - public Response updateE2EServiceInstance(String request, - @PathParam("version") String version, - @PathParam("serviceId") String serviceId) throws ApiException { - - instanceIdMap.put("serviceId", serviceId); - - return updateE2EserviceInstances(request, Action.updateInstance, instanceIdMap, - version); - } - - /** - * DELETE Requests for E2E Service delete Instance on a specified version - * and serviceId - * @throws ApiException - */ - - @DELETE - @Path("/{version:[vV][3-5]}/{serviceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Delete E2E Service Instance on a specified version and serviceId", response = Response.class) - public Response deleteE2EServiceInstance(String request, - @PathParam("version") String version, - @PathParam("serviceId") String serviceId) throws ApiException { - - instanceIdMap.put("serviceId", serviceId); - - return deleteE2EserviceInstances(request, Action.deleteInstance, - instanceIdMap, version); - } - - @GET - @Path("/{version:[vV][3-5]}/{serviceId}/operations/{operationId}") - @ApiOperation(value = "Find e2eServiceInstances Requests for a given serviceId and operationId", response = Response.class) - @Produces(MediaType.APPLICATION_JSON) - public Response getE2EServiceInstances( - @PathParam("serviceId") String serviceId, - @PathParam("version") String version, - @PathParam("operationId") String operationId) { - return getE2EServiceInstance(serviceId, operationId, version); - } - + private HashMap<String, String> instanceIdMap = new HashMap<>(); + private static final Logger logger = LoggerFactory.getLogger(E2EServiceInstances.class); + + private static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA"; + + private static final String END_OF_THE_TRANSACTION = "End of the transaction, the final response is: "; + + @Autowired + private MsoRequest msoRequest; + + @Autowired + private RequestClientFactory requestClientFactory; + + @Autowired + private RequestsDbClient requestsDbClient; + + @Autowired + private CatalogDbClient catalogDbClient; + + @Autowired + private ResponseBuilder builder; + + /** + * POST Requests for E2E Service create Instance on a version provided + * + * @throws ApiException + */ + + @POST + @Path("/{version:[vV][3-5]}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Create an E2E Service Instance on a version provided", response = Response.class) + public Response createE2EServiceInstance(String request, @PathParam("version") String version) throws ApiException { + + return processE2EserviceInstances(request, Action.createInstance, null, version); + } + + /** + * PUT Requests for E2E Service update Instance on a version provided + * + * @throws ApiException + */ + + @PUT + @Path("/{version:[vV][3-5]}/{serviceId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Update an E2E Service Instance on a version provided and serviceId", + response = Response.class) + public Response updateE2EServiceInstance(String request, @PathParam("version") String version, + @PathParam("serviceId") String serviceId) throws ApiException { + + instanceIdMap.put("serviceId", serviceId); + + return updateE2EserviceInstances(request, Action.updateInstance, instanceIdMap, version); + } + + /** + * DELETE Requests for E2E Service delete Instance on a specified version and serviceId + * + * @throws ApiException + */ + + @DELETE + @Path("/{version:[vV][3-5]}/{serviceId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Delete E2E Service Instance on a specified version and serviceId", response = Response.class) + public Response deleteE2EServiceInstance(String request, @PathParam("version") String version, + @PathParam("serviceId") String serviceId) throws ApiException { + + instanceIdMap.put("serviceId", serviceId); + + return deleteE2EserviceInstances(request, Action.deleteInstance, instanceIdMap, version); + } + + @GET + @Path("/{version:[vV][3-5]}/{serviceId}/operations/{operationId}") + @ApiOperation(value = "Find e2eServiceInstances Requests for a given serviceId and operationId", + response = Response.class) + @Produces(MediaType.APPLICATION_JSON) + public Response getE2EServiceInstances(@PathParam("serviceId") String serviceId, + @PathParam("version") String version, @PathParam("operationId") String operationId) { + return getE2EServiceInstance(serviceId, operationId, version); + } + + /** + * Scale Requests for E2E Service scale Instance on a specified version + * + * @throws ApiException + */ + + @POST + @Path("/{version:[vV][3-5]}/{serviceId}/scale") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Scale E2E Service Instance on a specified version", response = Response.class) + public Response scaleE2EServiceInstance(String request, @PathParam("version") String version, + @PathParam("serviceId") String serviceId) throws ApiException { + + logger.debug("------------------scale begin------------------"); + instanceIdMap.put("serviceId", serviceId); + return scaleE2EserviceInstances(request, Action.scaleInstance, instanceIdMap, version); + } + /** - * Scale Requests for E2E Service scale Instance on a specified version - * @throws ApiException + * GET Requests for Comparing model of service instance with target version + * + * @throws ApiException */ - - @POST - @Path("/{version:[vV][3-5]}/{serviceId}/scale") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Scale E2E Service Instance on a specified version",response=Response.class) - public Response scaleE2EServiceInstance(String request, - @PathParam("version") String version, - @PathParam("serviceId") String serviceId) throws ApiException { - - logger.debug("------------------scale begin------------------"); - instanceIdMap.put("serviceId", serviceId); - return scaleE2EserviceInstances(request, Action.scaleInstance, instanceIdMap, version); - } - /** - * GET Requests for Comparing model of service instance with target version - * @throws ApiException - */ - - @POST - @Path("/{version:[vV][3-5]}/{serviceId}/modeldifferences") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value = "Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId ", response = Response.class) - public Response compareModelwithTargetVersion(String request, - @PathParam("serviceId") String serviceId, - @PathParam("version") String version) throws ApiException { - - instanceIdMap.put("serviceId", serviceId); - - return compareModelwithTargetVersion(request, Action.compareModel, instanceIdMap, version); - } - - private Response compareModelwithTargetVersion(String requestJSON, Action action, - HashMap<String, String> instanceIdMap, String version) throws ApiException { - - String requestId = UUID.randomUUID().toString(); - long startTime = System.currentTimeMillis(); - - CompareModelsRequest e2eCompareModelReq; - - ObjectMapper mapper = new ObjectMapper(); - try { - e2eCompareModelReq = mapper.readValue(requestJSON, CompareModelsRequest.class); - - } catch (Exception e) { - - logger.debug("Mapping of request to JSON object failed : ", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, - MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), - ErrorNumbers.SVC_BAD_PARAMETER, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.SchemaError.getValue(), requestJSON, e); - logger.debug(END_OF_THE_TRANSACTION + response.getEntity().toString()); - - return response; - } - - return runCompareModelBPMWorkflow(e2eCompareModelReq, requestJSON, requestId, startTime, action, version); - - } - - private Response runCompareModelBPMWorkflow(CompareModelsRequest e2eCompareModelReq, - String requestJSON, String requestId, long startTime, Action action, String version) throws ApiException { - - // Define RecipeLookupResult info here instead of query DB for efficiency - String workflowUrl = "/mso/async/services/CompareModelofE2EServiceInstance"; - int recipeTimeout = 180; - - RequestClient requestClient; - HttpResponse response; - - long subStartTime = System.currentTimeMillis(); - - try { - requestClient = requestClientFactory.getRequestClient(workflowUrl); - - JSONObject jjo = new JSONObject(requestJSON); - String bpmnRequest = jjo.toString(); - - // Capture audit event - logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); - String serviceId = instanceIdMap.get("serviceId"); - String serviceType = e2eCompareModelReq.getServiceType(); - RequestClientParameter postParam = new RequestClientParameter.Builder() - .setRequestId(requestId) - .setBaseVfModule(false) - .setRecipeTimeout(recipeTimeout) - .setRequestAction(action.name()) - .setServiceInstanceId(serviceId) - .setServiceType(serviceType) - .setRequestDetails(bpmnRequest) - .setALaCarte(false).build(); - response = requestClient.post(postParam); - } catch (Exception e) { - Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, - MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(), - ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", - ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine",e); - logger.debug(END_OF_THE_TRANSACTION + resp.getEntity().toString()); - return resp; - } - - if (response == null) { - Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, - "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); - logger.debug(END_OF_THE_TRANSACTION + resp.getEntity().toString()); - return resp; - } - - ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType()); - int bpelStatus = respHandler.getStatus(); - - return beplStatusUpdate(requestId, startTime, requestClient, respHandler, bpelStatus, action, - instanceIdMap, version); - } - - private Response getE2EServiceInstance(String serviceId, String operationId, String version) { - - GetE2EServiceInstanceResponse e2eServiceResponse = new GetE2EServiceInstanceResponse(); - - String apiVersion = version.substring(1); - - long startTime = System.currentTimeMillis(); - - OperationStatus operationStatus; - - try { - operationStatus = requestsDbClient.getOneByServiceIdAndOperationId(serviceId, - operationId); - } catch (Exception e) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.AvailabilityError.getValue(), - "Exception while communciate with Request DB - Infra Request Lookup", e); - Response response = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, - e.getMessage(), - ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, null, version); - logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); - return response; - - } - - if (operationStatus == null) { - Response resp = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_NO_CONTENT, MsoException.ServiceException, - "E2E serviceId " + serviceId + " is not found in DB", - ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.BusinessProcesssError.getValue(), - "Null response from RequestDB when searching by serviceId"); - logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); - return resp; - - } - - e2eServiceResponse.setOperation(operationStatus); - - return builder.buildResponse(HttpStatus.SC_OK, null, e2eServiceResponse, apiVersion); - } - - private Response deleteE2EserviceInstances(String requestJSON, - Action action, HashMap<String, String> instanceIdMap, String version) throws ApiException { - // TODO should be a new one or the same service instance Id - long startTime = System.currentTimeMillis(); - E2EServiceInstanceDeleteRequest e2eDelReq; - - ObjectMapper mapper = new ObjectMapper(); - try { - e2eDelReq = mapper.readValue(requestJSON, - E2EServiceInstanceDeleteRequest.class); - - } catch (Exception e) { - - logger.debug("Mapping of request to JSON object failed : ", e); - Response response = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_BAD_REQUEST, - MsoException.ServiceException, - "Mapping of request to JSON object failed. " - + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, - null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.SchemaError.getValue(), requestJSON, e); - logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); - return response; - } - - String requestId = UUID.randomUUID().toString(); - RecipeLookupResult recipeLookupResult; - try { - //TODO Get the service template model version uuid from AAI. - recipeLookupResult = getServiceInstanceOrchestrationURI(null, action); - } catch (Exception e) { - logger.error(MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); - - Response response = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, - "No communication to catalog DB " + e.getMessage(), - ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - - msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "Exception while communciate with " - + "Catalog DB", action, - ModelType.service.name(), requestJSON); - logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); - return response; - } - if (recipeLookupResult == null) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.DataError.getValue(), "No recipe found in DB"); - Response response = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, - "Recipe does not exist in catalog DB", - ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); - - msoRequest.createErrorRequestRecord(Status.FAILED, requestId,"Recipe does not exist in catalog DB", action, ModelType.service.name(), requestJSON); - logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); - return response; - } - - RequestClient requestClient; - HttpResponse response; - - long subStartTime = System.currentTimeMillis(); - try { - requestClient = requestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI()); - - JSONObject jjo = new JSONObject(requestJSON); - jjo.put("operationId", requestId); - - String bpmnRequest = jjo.toString(); - - // Capture audit event - logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); - String serviceId = instanceIdMap.get("serviceId"); - String serviceInstanceType = e2eDelReq.getServiceType(); - RequestClientParameter clientParam = new RequestClientParameter.Builder() - .setRequestId(requestId) - .setBaseVfModule(false) - .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) - .setRequestAction(action.name()) - .setServiceInstanceId(serviceId) - .setServiceType(serviceInstanceType) - .setRequestDetails(bpmnRequest) - .setApiVersion(version) - .setALaCarte(false) - .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build(); - response = requestClient.post(clientParam); - - } catch (Exception e) { - Response resp = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, - "Failed calling bpmn " + e.getMessage(), - ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.AvailabilityError.getValue(), "Exception while communicate with BPMN engine"); - logger.debug("End of the transaction, the final response is: " + resp.getEntity()); - return resp; - } - - if (response == null) { - Response resp = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, - "bpelResponse is null", - ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); - logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); - return resp; - } - - ResponseHandler respHandler = new ResponseHandler(response, - requestClient.getType()); - int bpelStatus = respHandler.getStatus(); - - return beplStatusUpdate(requestId, startTime, requestClient, respHandler, - bpelStatus, action, instanceIdMap, version); - } - - private Response updateE2EserviceInstances(String requestJSON, Action action, - HashMap<String, String> instanceIdMap, String version) throws ApiException { - - String requestId = UUID.randomUUID().toString(); - long startTime = System.currentTimeMillis(); - E2EServiceInstanceRequest e2eSir; - String serviceId = instanceIdMap.get("serviceId"); - - ObjectMapper mapper = new ObjectMapper(); - try { - e2eSir = mapper.readValue(requestJSON, E2EServiceInstanceRequest.class); - - } catch (Exception e) { - - logger.debug("Mapping of request to JSON object failed : ", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, - MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), - ErrorNumbers.SVC_BAD_PARAMETER, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.SchemaError.getValue(), requestJSON, e); - logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); - return response; - } - - ServiceInstancesRequest sir = mapReqJsonToSvcInstReq(e2eSir, requestJSON); - sir.getRequestDetails().getRequestParameters().setaLaCarte(true); - try { - parseRequest(sir, instanceIdMap, action, version, requestJSON, false, requestId); - } catch (Exception e) { - logger.debug("Validation failed: ", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, - MsoException.ServiceException, "Error parsing request. " + e.getMessage(), - ErrorNumbers.SVC_BAD_PARAMETER, null, version); - if (requestId != null) { - logger.debug("Logging failed message to the database"); - } - logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.SchemaError.getValue(), requestJSON, e); - logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); - return response; - } - - RecipeLookupResult recipeLookupResult; - try { - recipeLookupResult = getServiceInstanceOrchestrationURI(e2eSir.getService().getServiceUuid(), action); - } catch (Exception e) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, - MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), - ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - - logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); - - return response; - } - - if (recipeLookupResult == null) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.DataError.getValue(), "No recipe found in DB"); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, - MsoException.ServiceException, "Recipe does not exist in catalog DB", - ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); - logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); - - return response; - } - - String serviceInstanceType = e2eSir.getService().getServiceType(); - - RequestClient requestClient; - HttpResponse response; - - long subStartTime = System.currentTimeMillis(); - String sirRequestJson = convertToString(sir); - - try { - requestClient = requestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI()); - - // Capture audit event - logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); - RequestClientParameter postParam = new RequestClientParameter.Builder() - .setRequestId(requestId) - .setBaseVfModule(false) - .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) - .setRequestAction(action.name()) - .setServiceInstanceId(serviceId) - .setServiceType(serviceInstanceType) - .setRequestDetails(sirRequestJson) - .setApiVersion(version) - .setALaCarte(false) - .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build(); - response = requestClient.post(postParam); - } catch (Exception e) { - logger.debug("Exception while communicate with BPMN engine", e); - Response getBPMNResp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, - MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(), - ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.AvailabilityError.getValue(), "Exception while communicate with BPMN engine"); - logger.debug(END_OF_THE_TRANSACTION + getBPMNResp.getEntity()); - - return getBPMNResp; - } - - if (response == null) { - Response getBPMNResp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, - MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); - logger.debug(END_OF_THE_TRANSACTION + getBPMNResp.getEntity()); - return getBPMNResp; - } - - ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType()); - int bpelStatus = respHandler.getStatus(); - - return beplStatusUpdate(serviceId, startTime, requestClient, respHandler, - bpelStatus, action, instanceIdMap, version); - } - - private Response processE2EserviceInstances(String requestJSON, Action action, - HashMap<String, String> instanceIdMap, String version) throws ApiException { - - String requestId = UUID.randomUUID().toString(); - long startTime = System.currentTimeMillis(); - E2EServiceInstanceRequest e2eSir; - - MsoRequest msoRequest = new MsoRequest(); - ObjectMapper mapper = new ObjectMapper(); - try { - e2eSir = mapper.readValue(requestJSON, E2EServiceInstanceRequest.class); - - } catch (Exception e) { - - logger.debug("Mapping of request to JSON object failed : ", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, - MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), - ErrorNumbers.SVC_BAD_PARAMETER, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.SchemaError.getValue(), requestJSON, e); - logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); - return response; - } - - ServiceInstancesRequest sir = mapReqJsonToSvcInstReq(e2eSir, requestJSON); - sir.getRequestDetails().getRequestParameters().setaLaCarte(true); - try { - parseRequest(sir, instanceIdMap, action, version, requestJSON, false, requestId); - } catch (Exception e) { - logger.debug("Validation failed: ", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, - MsoException.ServiceException, "Error parsing request. " + e.getMessage(), - ErrorNumbers.SVC_BAD_PARAMETER, null, version); - if (requestId != null) { - logger.debug("Logging failed message to the database"); - } - logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.SchemaError.getValue(), requestJSON, e); - logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); - return response; - } - - RecipeLookupResult recipeLookupResult; - try { - recipeLookupResult = getServiceInstanceOrchestrationURI(e2eSir.getService().getServiceUuid(), action); - } catch (Exception e) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, - MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), - ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); - return response; - } - - if (recipeLookupResult == null) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.DataError.getValue(), "No recipe found in DB"); - Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, - MsoException.ServiceException, "Recipe does not exist in catalog DB", - ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); - logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); - return response; - } - - String serviceInstanceType = e2eSir.getService().getServiceType(); - - String serviceId = ""; - RequestClient requestClient; - HttpResponse response; - - long subStartTime = System.currentTimeMillis(); - String sirRequestJson = convertToString(sir); - - try { - requestClient = requestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI()); - - // Capture audit event - logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); - RequestClientParameter parameter = new RequestClientParameter.Builder() - .setRequestId(requestId) - .setBaseVfModule(false) - .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) - .setRequestAction(action.name()) - .setServiceInstanceId(serviceId) - .setServiceType(serviceInstanceType) - .setRequestDetails(sirRequestJson) - .setApiVersion(version) - .setALaCarte(false) - .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build(); - response = requestClient.post(parameter); - } catch (Exception e) { - Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, - MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(), - ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.AvailabilityError.getValue(), "Exception while communicate with BPMN engine"); - logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); - return resp; - } - - if (response == null) { - Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, - MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); - logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); - return resp; - } - - ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType()); - int bpelStatus = respHandler.getStatus(); - - return beplStatusUpdate(requestId, startTime, requestClient, respHandler, - bpelStatus, action, instanceIdMap, version); - } - - private Response scaleE2EserviceInstances(String requestJSON, - Action action, HashMap<String, String> instanceIdMap, String version) throws ApiException { + + @POST + @Path("/{version:[vV][3-5]}/{serviceId}/modeldifferences") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation( + value = "Find added and deleted resources of target model for the e2eserviceInstance on a given serviceId ", + response = Response.class) + public Response compareModelwithTargetVersion(String request, @PathParam("serviceId") String serviceId, + @PathParam("version") String version) throws ApiException { + + instanceIdMap.put("serviceId", serviceId); + + return compareModelwithTargetVersion(request, Action.compareModel, instanceIdMap, version); + } + + private Response compareModelwithTargetVersion(String requestJSON, Action action, + HashMap<String, String> instanceIdMap, String version) throws ApiException { String requestId = UUID.randomUUID().toString(); long startTime = System.currentTimeMillis(); - E2EServiceInstanceScaleRequest e2eScaleReq; + + CompareModelsRequest e2eCompareModelReq; ObjectMapper mapper = new ObjectMapper(); try { - e2eScaleReq = mapper.readValue(requestJSON, - E2EServiceInstanceScaleRequest.class); + e2eCompareModelReq = mapper.readValue(requestJSON, CompareModelsRequest.class); } catch (Exception e) { logger.debug("Mapping of request to JSON object failed : ", e); - Response response = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_BAD_REQUEST, - MsoException.ServiceException, - "Mapping of request to JSON object failed. " - + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, - null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.SchemaError.getValue(), requestJSON, e); - logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); - return response; + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, + MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), + ErrorNumbers.SVC_BAD_PARAMETER, null, version); + logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.SchemaError.getValue(), requestJSON, e); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity().toString()); + + return response; } + return runCompareModelBPMWorkflow(e2eCompareModelReq, requestJSON, requestId, startTime, action, version); + + } + + private Response runCompareModelBPMWorkflow(CompareModelsRequest e2eCompareModelReq, String requestJSON, + String requestId, long startTime, Action action, String version) throws ApiException { + + // Define RecipeLookupResult info here instead of query DB for efficiency + String workflowUrl = "/mso/async/services/CompareModelofE2EServiceInstance"; + int recipeTimeout = 180; + + RequestClient requestClient; + HttpResponse response; + + long subStartTime = System.currentTimeMillis(); + + try { + requestClient = requestClientFactory.getRequestClient(workflowUrl); + + JSONObject jjo = new JSONObject(requestJSON); + String bpmnRequest = jjo.toString(); + + // Capture audit event + logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); + String serviceId = instanceIdMap.get("serviceId"); + String serviceType = e2eCompareModelReq.getServiceType(); + RequestClientParameter postParam = new RequestClientParameter.Builder().setRequestId(requestId) + .setBaseVfModule(false).setRecipeTimeout(recipeTimeout).setRequestAction(action.name()) + .setServiceInstanceId(serviceId).setServiceType(serviceType).setRequestDetails(bpmnRequest) + .setALaCarte(false).build(); + response = requestClient.post(postParam); + } catch (Exception e) { + Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, + MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(), + ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + logger.error("", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", + ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine", e); + logger.debug(END_OF_THE_TRANSACTION + resp.getEntity().toString()); + return resp; + } + + if (response == null) { + Response resp = + msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, + "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); + logger.debug(END_OF_THE_TRANSACTION + resp.getEntity().toString()); + return resp; + } + + ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType()); + int bpelStatus = respHandler.getStatus(); + + return beplStatusUpdate(requestId, startTime, requestClient, respHandler, bpelStatus, action, instanceIdMap, + version); + } + + private Response getE2EServiceInstance(String serviceId, String operationId, String version) { + + GetE2EServiceInstanceResponse e2eServiceResponse = new GetE2EServiceInstanceResponse(); + + String apiVersion = version.substring(1); + + long startTime = System.currentTimeMillis(); + + OperationStatus operationStatus; + + try { + operationStatus = requestsDbClient.getOneByServiceIdAndOperationId(serviceId, operationId); + } catch (Exception e) { + logger.error("{} {} {} {}", MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.AvailabilityError.getValue(), + "Exception while communciate with Request DB - Infra Request Lookup", e); + Response response = + msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, + e.getMessage(), ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, null, version); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + + } + + if (operationStatus == null) { + Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NO_CONTENT, + MsoException.ServiceException, "E2E serviceId " + serviceId + " is not found in DB", + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null, version); + logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.BusinessProcesssError.getValue(), + "Null response from RequestDB when searching by serviceId"); + logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); + return resp; + + } + + e2eServiceResponse.setOperation(operationStatus); + + return builder.buildResponse(HttpStatus.SC_OK, null, e2eServiceResponse, apiVersion); + } + + private Response deleteE2EserviceInstances(String requestJSON, Action action, HashMap<String, String> instanceIdMap, + String version) throws ApiException { + // TODO should be a new one or the same service instance Id + long startTime = System.currentTimeMillis(); + E2EServiceInstanceDeleteRequest e2eDelReq; + + ObjectMapper mapper = new ObjectMapper(); + try { + e2eDelReq = mapper.readValue(requestJSON, E2EServiceInstanceDeleteRequest.class); + + } catch (Exception e) { + + logger.debug("Mapping of request to JSON object failed : ", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, + MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), + ErrorNumbers.SVC_BAD_PARAMETER, null, version); + logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.SchemaError.getValue(), requestJSON, e); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + String requestId = UUID.randomUUID().toString(); RecipeLookupResult recipeLookupResult; try { - //TODO Get the service template model version uuid from AAI. - recipeLookupResult = getServiceInstanceOrchestrationURI(null, action); + // TODO Get the service template model version uuid from AAI. + recipeLookupResult = getServiceInstanceOrchestrationURI(null, action); } catch (Exception e) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); + logger.error(MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); - Response response = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, - "No communication to catalog DB " + e.getMessage(), + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - - msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "No communication to catalog DB " + e.getMessage(), action, ModelType.service.name(), requestJSON); - logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); - return response; + + msoRequest.createErrorRequestRecord(Status.FAILED, requestId, + "Exception while communciate with " + "Catalog DB", action, ModelType.service.name(), requestJSON); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; } if (recipeLookupResult == null) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.DataError.getValue(), "No recipe found in DB"); - - Response response = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, - "Recipe does not exist in catalog DB", - ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); - msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "No recipe found in DB", action, ModelType.service.name(), requestJSON); - logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); - return response; + logger.error("{} {} {} {}", MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.DataError.getValue(), "No recipe found in DB"); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "Recipe does not exist in catalog DB", + ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); + + msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "Recipe does not exist in catalog DB", action, + ModelType.service.name(), requestJSON); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; } RequestClient requestClient; @@ -775,274 +400,591 @@ public class E2EServiceInstances { String bpmnRequest = jjo.toString(); // Capture audit event - logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); - String serviceId = instanceIdMap.get("serviceId"); - String serviceInstanceType = e2eScaleReq.getService().getServiceType(); - RequestClientParameter postParam = new RequestClientParameter.Builder() - .setRequestId(requestId) - .setBaseVfModule(false) - .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) - .setRequestAction(action.name()) - .setServiceInstanceId(serviceId) - .setServiceType(serviceInstanceType) - .setRequestDetails(bpmnRequest) - .setApiVersion(version) - .setALaCarte(false) - .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build(); + logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); + String serviceId = instanceIdMap.get("serviceId"); + String serviceInstanceType = e2eDelReq.getServiceType(); + RequestClientParameter clientParam = new RequestClientParameter.Builder().setRequestId(requestId) + .setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) + .setRequestAction(action.name()).setServiceInstanceId(serviceId).setServiceType(serviceInstanceType) + .setRequestDetails(bpmnRequest).setApiVersion(version).setALaCarte(false) + .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build(); + response = requestClient.post(clientParam); + + } catch (Exception e) { + Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, + MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(), + ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.AvailabilityError.getValue(), "Exception while communicate with BPMN engine"); + logger.debug("End of the transaction, the final response is: " + resp.getEntity()); + return resp; + } + + if (response == null) { + Response resp = + msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, + "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); + logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); + return resp; + } + + ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType()); + int bpelStatus = respHandler.getStatus(); + + return beplStatusUpdate(requestId, startTime, requestClient, respHandler, bpelStatus, action, instanceIdMap, + version); + } + + private Response updateE2EserviceInstances(String requestJSON, Action action, HashMap<String, String> instanceIdMap, + String version) throws ApiException { + + String requestId = UUID.randomUUID().toString(); + long startTime = System.currentTimeMillis(); + E2EServiceInstanceRequest e2eSir; + String serviceId = instanceIdMap.get("serviceId"); + + ObjectMapper mapper = new ObjectMapper(); + try { + e2eSir = mapper.readValue(requestJSON, E2EServiceInstanceRequest.class); + + } catch (Exception e) { + + logger.debug("Mapping of request to JSON object failed : ", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, + MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), + ErrorNumbers.SVC_BAD_PARAMETER, null, version); + logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.SchemaError.getValue(), requestJSON, e); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + ServiceInstancesRequest sir = mapReqJsonToSvcInstReq(e2eSir, requestJSON); + sir.getRequestDetails().getRequestParameters().setaLaCarte(true); + try { + parseRequest(sir, instanceIdMap, action, version, requestJSON, false, requestId); + } catch (Exception e) { + logger.debug("Validation failed: ", e); + Response response = + msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, + "Error parsing request. " + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, null, version); + if (requestId != null) { + logger.debug("Logging failed message to the database"); + } + logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.SchemaError.getValue(), requestJSON, e); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + RecipeLookupResult recipeLookupResult; + try { + recipeLookupResult = getServiceInstanceOrchestrationURI(e2eSir.getService().getServiceUuid(), action); + } catch (Exception e) { + logger.error("{} {} {} {}", MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), + ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + + return response; + } + + if (recipeLookupResult == null) { + logger.error("{} {} {} {}", MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.DataError.getValue(), "No recipe found in DB"); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "Recipe does not exist in catalog DB", + ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + + return response; + } + + String serviceInstanceType = e2eSir.getService().getServiceType(); + + RequestClient requestClient; + HttpResponse response; + + long subStartTime = System.currentTimeMillis(); + String sirRequestJson = convertToString(sir); + + try { + requestClient = requestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI()); + + // Capture audit event + logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); + RequestClientParameter postParam = new RequestClientParameter.Builder().setRequestId(requestId) + .setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) + .setRequestAction(action.name()).setServiceInstanceId(serviceId).setServiceType(serviceInstanceType) + .setRequestDetails(sirRequestJson).setApiVersion(version).setALaCarte(false) + .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build(); response = requestClient.post(postParam); - } catch (Exception e) { - Response resp = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, - "Failed calling bpmn " + e.getMessage(), + } catch (Exception e) { + logger.debug("Exception while communicate with BPMN engine", e); + Response getBPMNResp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, + MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(), ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.AvailabilityError.getValue(), "Exception while communicate with BPMN engine", e); - logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); - return resp; + logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.AvailabilityError.getValue(), "Exception while communicate with BPMN engine"); + logger.debug(END_OF_THE_TRANSACTION + getBPMNResp.getEntity()); + + return getBPMNResp; } if (response == null) { - Response resp = msoRequest.buildServiceErrorResponse( - HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, - "bpelResponse is null", + Response getBPMNResp = + msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, + "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); + logger.debug(END_OF_THE_TRANSACTION + getBPMNResp.getEntity()); + return getBPMNResp; + } + + ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType()); + int bpelStatus = respHandler.getStatus(); + + return beplStatusUpdate(serviceId, startTime, requestClient, respHandler, bpelStatus, action, instanceIdMap, + version); + } + + private Response processE2EserviceInstances(String requestJSON, Action action, + HashMap<String, String> instanceIdMap, String version) throws ApiException { + + String requestId = UUID.randomUUID().toString(); + long startTime = System.currentTimeMillis(); + E2EServiceInstanceRequest e2eSir; + + MsoRequest msoRequest = new MsoRequest(); + ObjectMapper mapper = new ObjectMapper(); + try { + e2eSir = mapper.readValue(requestJSON, E2EServiceInstanceRequest.class); + + } catch (Exception e) { + + logger.debug("Mapping of request to JSON object failed : ", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, + MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), + ErrorNumbers.SVC_BAD_PARAMETER, null, version); + logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.SchemaError.getValue(), requestJSON, e); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + ServiceInstancesRequest sir = mapReqJsonToSvcInstReq(e2eSir, requestJSON); + sir.getRequestDetails().getRequestParameters().setaLaCarte(true); + try { + parseRequest(sir, instanceIdMap, action, version, requestJSON, false, requestId); + } catch (Exception e) { + logger.debug("Validation failed: ", e); + Response response = + msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, + "Error parsing request. " + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, null, version); + if (requestId != null) { + logger.debug("Logging failed message to the database"); + } + logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.SchemaError.getValue(), requestJSON, e); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + RecipeLookupResult recipeLookupResult; + try { + recipeLookupResult = getServiceInstanceOrchestrationURI(e2eSir.getService().getServiceUuid(), action); + } catch (Exception e) { + logger.error("{} {} {} {}", MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), + ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + if (recipeLookupResult == null) { + logger.error("{} {} {} {}", MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.DataError.getValue(), "No recipe found in DB"); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "Recipe does not exist in catalog DB", + ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + String serviceInstanceType = e2eSir.getService().getServiceType(); + + String serviceId = ""; + RequestClient requestClient; + HttpResponse response; + + long subStartTime = System.currentTimeMillis(); + String sirRequestJson = convertToString(sir); + + try { + requestClient = requestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI()); + + // Capture audit event + logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); + RequestClientParameter parameter = new RequestClientParameter.Builder().setRequestId(requestId) + .setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) + .setRequestAction(action.name()).setServiceInstanceId(serviceId).setServiceType(serviceInstanceType) + .setRequestDetails(sirRequestJson).setApiVersion(version).setALaCarte(false) + .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build(); + response = requestClient.post(parameter); + } catch (Exception e) { + Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, + MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(), + ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + + logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.AvailabilityError.getValue(), "Exception while communicate with BPMN engine"); + logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); + return resp; + } + + if (response == null) { + Response resp = + msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, + "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); + logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); + return resp; + } + + ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType()); + int bpelStatus = respHandler.getStatus(); + + return beplStatusUpdate(requestId, startTime, requestClient, respHandler, bpelStatus, action, instanceIdMap, + version); + } + + private Response scaleE2EserviceInstances(String requestJSON, Action action, HashMap<String, String> instanceIdMap, + String version) throws ApiException { + + String requestId = UUID.randomUUID().toString(); + long startTime = System.currentTimeMillis(); + E2EServiceInstanceScaleRequest e2eScaleReq; + + ObjectMapper mapper = new ObjectMapper(); + try { + e2eScaleReq = mapper.readValue(requestJSON, E2EServiceInstanceScaleRequest.class); + + } catch (Exception e) { + + logger.debug("Mapping of request to JSON object failed : ", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, + MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), + ErrorNumbers.SVC_BAD_PARAMETER, null, version); + logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.SchemaError.getValue(), requestJSON, e); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + RecipeLookupResult recipeLookupResult; + try { + // TODO Get the service template model version uuid from AAI. + recipeLookupResult = getServiceInstanceOrchestrationURI(null, action); + } catch (Exception e) { + logger.error("{} {} {} {}", MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); + + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), + ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + + msoRequest.createErrorRequestRecord(Status.FAILED, requestId, + "No communication to catalog DB " + e.getMessage(), action, ModelType.service.name(), requestJSON); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + if (recipeLookupResult == null) { + logger.error("{} {} {} {}", MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.DataError.getValue(), "No recipe found in DB"); + + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, + MsoException.ServiceException, "Recipe does not exist in catalog DB", + ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); + msoRequest.createErrorRequestRecord(Status.FAILED, requestId, "No recipe found in DB", action, + ModelType.service.name(), requestJSON); + logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); + return response; + } + + RequestClient requestClient; + HttpResponse response; + + long subStartTime = System.currentTimeMillis(); + try { + requestClient = requestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI()); + + JSONObject jjo = new JSONObject(requestJSON); + jjo.put("operationId", requestId); + + String bpmnRequest = jjo.toString(); + + // Capture audit event + logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); + String serviceId = instanceIdMap.get("serviceId"); + String serviceInstanceType = e2eScaleReq.getService().getServiceType(); + RequestClientParameter postParam = new RequestClientParameter.Builder().setRequestId(requestId) + .setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) + .setRequestAction(action.name()).setServiceInstanceId(serviceId).setServiceType(serviceInstanceType) + .setRequestDetails(bpmnRequest).setApiVersion(version).setALaCarte(false) + .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build(); + response = requestClient.post(postParam); + } catch (Exception e) { + Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, + MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(), ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); - logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); - return resp; + + logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.AvailabilityError.getValue(), "Exception while communicate with BPMN engine", e); + logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); + return resp; } - ResponseHandler respHandler = new ResponseHandler(response, - requestClient.getType()); + if (response == null) { + Response resp = + msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, + "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); + logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); + logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); + return resp; + } + + ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType()); int bpelStatus = respHandler.getStatus(); - return beplStatusUpdate(requestId, startTime, requestClient, respHandler, - bpelStatus, action, instanceIdMap, version); + return beplStatusUpdate(requestId, startTime, requestClient, respHandler, bpelStatus, action, instanceIdMap, + version); } - private Response beplStatusUpdate(String serviceId, long startTime, - RequestClient requestClient, - ResponseHandler respHandler, int bpelStatus, Action action, - HashMap<String, String> instanceIdMap, String version) { - - String apiVersion = version.substring(1); - - // BPMN accepted the request, the request is in progress - if (bpelStatus == HttpStatus.SC_ACCEPTED) { - String camundaJSONResponseBody = respHandler.getResponseBody(); - logger.debug("Received from Camunda: " + camundaJSONResponseBody); - logger.debug(END_OF_THE_TRANSACTION + camundaJSONResponseBody); - return builder.buildResponse(HttpStatus.SC_ACCEPTED, null, camundaJSONResponseBody, apiVersion); - } else { - List<String> variables = new ArrayList<>(); - variables.add(bpelStatus + ""); - String camundaJSONResponseBody = respHandler.getResponseBody(); - if (camundaJSONResponseBody != null - && !camundaJSONResponseBody.isEmpty()) { - Response resp = msoRequest.buildServiceErrorResponse( - bpelStatus, MsoException.ServiceException, - "Request Failed due to BPEL error with HTTP Status= %1 " - + '\n' + camundaJSONResponseBody, - ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_RESPONSE_ERROR.toString(), requestClient.getUrl(), - ErrorCode.BusinessProcesssError.getValue(), - "Response from BPEL engine is failed with HTTP Status=" + bpelStatus); - logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); - return resp; - } else { - Response resp = msoRequest - .buildServiceErrorResponse( - bpelStatus, - MsoException.ServiceException, - "Request Failed due to BPEL error with HTTP Status= %1", - ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, - variables, version); - logger.error("", MessageEnum.APIH_BPEL_RESPONSE_ERROR.toString(), requestClient.getUrl(), - ErrorCode.BusinessProcesssError.getValue(), - "Response from BPEL engine is empty"); - logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); - return resp; - } - } - } - - /** - * Getting recipes from catalogDb - * - * @param serviceModelUUID the service model version uuid - * @param action the action for the service - * @return the service recipe result - */ - private RecipeLookupResult getServiceInstanceOrchestrationURI(String serviceModelUUID, Action action) { - - RecipeLookupResult recipeLookupResult = getServiceURI(serviceModelUUID, action); - - if (recipeLookupResult != null) { - logger.debug( - "Orchestration URI is: " + recipeLookupResult.getOrchestrationURI() + ", recipe Timeout is: " + Integer - .toString(recipeLookupResult.getRecipeTimeout())); - } else { - logger.debug("No matching recipe record found"); - } - return recipeLookupResult; - } - - /** - * Getting recipes from catalogDb - * If Service recipe is not set, use default recipe, if set , use special recipe. - * @param serviceModelUUID the service version uuid - * @param action the action of the service. - * @return the service recipe result. - */ - private RecipeLookupResult getServiceURI(String serviceModelUUID, Action action) { - - String defaultServiceModelName = "UUI_DEFAULT"; - - Service defaultServiceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); - //set recipe as default generic recipe - ServiceRecipe recipe = catalogDbClient.getFirstByServiceModelUUIDAndAction(defaultServiceRecord.getModelUUID(), action.name()); - //check the service special recipe - if(null != serviceModelUUID && ! serviceModelUUID.isEmpty()){ - ServiceRecipe serviceSpecialRecipe = catalogDbClient.getFirstByServiceModelUUIDAndAction( - serviceModelUUID, action.name()); - if(null != serviceSpecialRecipe){ - //set service special recipe. - recipe = serviceSpecialRecipe; - } - } - - if (recipe == null) { - return null; - } - return new RecipeLookupResult(recipe.getOrchestrationUri(), - recipe.getRecipeTimeout(), recipe.getParamXsd()); - - } - - /** - * Converting E2EServiceInstanceRequest to ServiceInstanceRequest and - * passing it to camunda engine. - * - * @param e2eSir - * @return - */ - private ServiceInstancesRequest mapReqJsonToSvcInstReq(E2EServiceInstanceRequest e2eSir, - String requestJSON) { - - ServiceInstancesRequest sir = new ServiceInstancesRequest(); - - String returnString = null; - RequestDetails requestDetails = new RequestDetails(); - ModelInfo modelInfo = new ModelInfo(); - - // ModelInvariantId - modelInfo.setModelInvariantId(e2eSir.getService().getServiceInvariantUuid()); - - // modelNameVersionId - modelInfo.setModelNameVersionId(e2eSir.getService().getServiceUuid()); - - // String modelInfoValue = - // e2eSir.getService().getParameters().getNodeTemplateName(); - // String[] arrayOfInfo = modelInfoValue.split(":"); - // String modelName = arrayOfInfo[0]; - // String modelVersion = arrayOfInfo[1]; - - // TODO: To ensure, if we dont get the values from the UUI - String modelName = "voLTE"; - String modelVersion = "1.0"; - // modelName - modelInfo.setModelName(modelName); - - // modelVersion - modelInfo.setModelVersion(modelVersion); - - // modelType - modelInfo.setModelType(ModelType.service); - - // setting modelInfo to requestDetails - requestDetails.setModelInfo(modelInfo); - - SubscriberInfo subscriberInfo = new SubscriberInfo(); - - // globalsubscriberId - subscriberInfo.setGlobalSubscriberId(e2eSir.getService().getGlobalSubscriberId()); - - // setting subscriberInfo to requestDetails - requestDetails.setSubscriberInfo(subscriberInfo); - - RequestInfo requestInfo = new RequestInfo(); - - // instanceName - requestInfo.setInstanceName(e2eSir.getService().getName()); - - // source - requestInfo.setSource("UUI"); - - // suppressRollback - requestInfo.setSuppressRollback(true); - - // setting requestInfo to requestDetails - requestDetails.setRequestInfo(requestInfo); - - RequestParameters requestParameters = new RequestParameters(); - - // subscriptionServiceType - requestParameters.setSubscriptionServiceType("MOG"); - - // Userparams - //List<E2EUserParam> userParams; - // userParams = - // e2eSir.getService().getParameters().getRequestParameters().getUserParams(); - List<Map<String, Object>> userParamList = new ArrayList<>(); - Map<String, Object> userParamMap = new HashMap<>(); - // complete json request updated in the camunda - userParamMap.put("UUIRequest", requestJSON); - userParamMap.put("ServiceInstanceName", e2eSir.getService().getName()); - - // Map<String, String> userParamMap3 = null; - // for (E2EUserParam userp : userParams) { - // userParamMap.put(userp.getName(), userp.getValue()); - // - // } - userParamList.add(userParamMap); - requestParameters.setUserParams(userParamList); - - // setting requestParameters to requestDetails - requestDetails.setRequestParameters(requestParameters); - - sir.setRequestDetails(requestDetails); - - return sir; - } - - - private void parseRequest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Action action, String version, - String requestJSON, Boolean aLaCarte, String requestId) throws ValidateException { - int reqVersion = Integer.parseInt(version.substring(1)); - try { - msoRequest.parse(sir, instanceIdMap, action, version, requestJSON, reqVersion, aLaCarte); - } catch (Exception e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - ValidateException validateException = new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) - .errorInfo(errorLoggerInfo).build(); - - msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, ModelType.service.name(), requestJSON); - - throw validateException; - } - } - - private String convertToString(ServiceInstancesRequest sir) { - String returnString = null; - // converting to string - ObjectMapper mapper = new ObjectMapper(); - try { - returnString = mapper.writeValueAsString(sir); - } catch (IOException e) { - logger.debug("Exception while converting ServiceInstancesRequest object to string", e); - } - - return returnString; - } + private Response beplStatusUpdate(String serviceId, long startTime, RequestClient requestClient, + ResponseHandler respHandler, int bpelStatus, Action action, HashMap<String, String> instanceIdMap, + String version) { + + String apiVersion = version.substring(1); + + // BPMN accepted the request, the request is in progress + if (bpelStatus == HttpStatus.SC_ACCEPTED) { + String camundaJSONResponseBody = respHandler.getResponseBody(); + logger.debug("Received from Camunda: " + camundaJSONResponseBody); + logger.debug(END_OF_THE_TRANSACTION + camundaJSONResponseBody); + return builder.buildResponse(HttpStatus.SC_ACCEPTED, null, camundaJSONResponseBody, apiVersion); + } else { + List<String> variables = new ArrayList<>(); + variables.add(bpelStatus + ""); + String camundaJSONResponseBody = respHandler.getResponseBody(); + if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty()) { + Response resp = msoRequest.buildServiceErrorResponse(bpelStatus, MsoException.ServiceException, + "Request Failed due to BPEL error with HTTP Status= %1 " + '\n' + camundaJSONResponseBody, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables, version); + logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_RESPONSE_ERROR.toString(), requestClient.getUrl(), + ErrorCode.BusinessProcesssError.getValue(), + "Response from BPEL engine is failed with HTTP Status=" + bpelStatus); + logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); + return resp; + } else { + Response resp = msoRequest.buildServiceErrorResponse(bpelStatus, MsoException.ServiceException, + "Request Failed due to BPEL error with HTTP Status= %1", + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables, version); + logger.error("", MessageEnum.APIH_BPEL_RESPONSE_ERROR.toString(), requestClient.getUrl(), + ErrorCode.BusinessProcesssError.getValue(), "Response from BPEL engine is empty"); + logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); + return resp; + } + } + } + + /** + * Getting recipes from catalogDb + * + * @param serviceModelUUID the service model version uuid + * @param action the action for the service + * @return the service recipe result + */ + private RecipeLookupResult getServiceInstanceOrchestrationURI(String serviceModelUUID, Action action) { + + RecipeLookupResult recipeLookupResult = getServiceURI(serviceModelUUID, action); + + if (recipeLookupResult != null) { + logger.debug("Orchestration URI is: " + recipeLookupResult.getOrchestrationURI() + ", recipe Timeout is: " + + Integer.toString(recipeLookupResult.getRecipeTimeout())); + } else { + logger.debug("No matching recipe record found"); + } + return recipeLookupResult; + } + + /** + * Getting recipes from catalogDb If Service recipe is not set, use default recipe, if set , use special recipe. + * + * @param serviceModelUUID the service version uuid + * @param action the action of the service. + * @return the service recipe result. + */ + private RecipeLookupResult getServiceURI(String serviceModelUUID, Action action) { + + String defaultServiceModelName = "UUI_DEFAULT"; + + Service defaultServiceRecord = + catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); + // set recipe as default generic recipe + ServiceRecipe recipe = + catalogDbClient.getFirstByServiceModelUUIDAndAction(defaultServiceRecord.getModelUUID(), action.name()); + // check the service special recipe + if (null != serviceModelUUID && !serviceModelUUID.isEmpty()) { + ServiceRecipe serviceSpecialRecipe = + catalogDbClient.getFirstByServiceModelUUIDAndAction(serviceModelUUID, action.name()); + if (null != serviceSpecialRecipe) { + // set service special recipe. + recipe = serviceSpecialRecipe; + } + } + + if (recipe == null) { + return null; + } + return new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout(), recipe.getParamXsd()); + + } + + /** + * Converting E2EServiceInstanceRequest to ServiceInstanceRequest and passing it to camunda engine. + * + * @param e2eSir + * @return + */ + private ServiceInstancesRequest mapReqJsonToSvcInstReq(E2EServiceInstanceRequest e2eSir, String requestJSON) { + + ServiceInstancesRequest sir = new ServiceInstancesRequest(); + + String returnString = null; + RequestDetails requestDetails = new RequestDetails(); + ModelInfo modelInfo = new ModelInfo(); + + // ModelInvariantId + modelInfo.setModelInvariantId(e2eSir.getService().getServiceInvariantUuid()); + + // modelNameVersionId + modelInfo.setModelNameVersionId(e2eSir.getService().getServiceUuid()); + + // String modelInfoValue = + // e2eSir.getService().getParameters().getNodeTemplateName(); + // String[] arrayOfInfo = modelInfoValue.split(":"); + // String modelName = arrayOfInfo[0]; + // String modelVersion = arrayOfInfo[1]; + + // TODO: To ensure, if we dont get the values from the UUI + String modelName = "voLTE"; + String modelVersion = "1.0"; + // modelName + modelInfo.setModelName(modelName); + + // modelVersion + modelInfo.setModelVersion(modelVersion); + + // modelType + modelInfo.setModelType(ModelType.service); + + // setting modelInfo to requestDetails + requestDetails.setModelInfo(modelInfo); + + SubscriberInfo subscriberInfo = new SubscriberInfo(); + + // globalsubscriberId + subscriberInfo.setGlobalSubscriberId(e2eSir.getService().getGlobalSubscriberId()); + + // setting subscriberInfo to requestDetails + requestDetails.setSubscriberInfo(subscriberInfo); + + RequestInfo requestInfo = new RequestInfo(); + + // instanceName + requestInfo.setInstanceName(e2eSir.getService().getName()); + + // source + requestInfo.setSource("UUI"); + + // suppressRollback + requestInfo.setSuppressRollback(true); + + // setting requestInfo to requestDetails + requestDetails.setRequestInfo(requestInfo); + + RequestParameters requestParameters = new RequestParameters(); + + // subscriptionServiceType + requestParameters.setSubscriptionServiceType("MOG"); + + // Userparams + // List<E2EUserParam> userParams; + // userParams = + // e2eSir.getService().getParameters().getRequestParameters().getUserParams(); + List<Map<String, Object>> userParamList = new ArrayList<>(); + Map<String, Object> userParamMap = new HashMap<>(); + // complete json request updated in the camunda + userParamMap.put("UUIRequest", requestJSON); + userParamMap.put("ServiceInstanceName", e2eSir.getService().getName()); + + // Map<String, String> userParamMap3 = null; + // for (E2EUserParam userp : userParams) { + // userParamMap.put(userp.getName(), userp.getValue()); + // + // } + userParamList.add(userParamMap); + requestParameters.setUserParams(userParamList); + + // setting requestParameters to requestDetails + requestDetails.setRequestParameters(requestParameters); + + sir.setRequestDetails(requestDetails); + + return sir; + } + + + private void parseRequest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Action action, + String version, String requestJSON, Boolean aLaCarte, String requestId) throws ValidateException { + int reqVersion = Integer.parseInt(version.substring(1)); + try { + msoRequest.parse(sir, instanceIdMap, action, version, requestJSON, reqVersion, aLaCarte); + } catch (Exception e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + ValidateException validateException = + new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); + + msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, + ModelType.service.name(), requestJSON); + + throw validateException; + } + } + + private String convertToString(ServiceInstancesRequest sir) { + String returnString = null; + // converting to string + ObjectMapper mapper = new ObjectMapper(); + try { + returnString = mapper.writeValueAsString(sir); + } catch (IOException e) { + logger.debug("Exception while converting ServiceInstancesRequest object to string", e); + } + + return returnString; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java index ad20c5c527..4d283f26b1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java @@ -25,12 +25,10 @@ package org.onap.so.apihandlerinfra; import java.net.URI; import java.util.Collections; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; - import javax.annotation.PostConstruct; import javax.transaction.Transactional; import javax.ws.rs.DefaultValue; @@ -42,7 +40,6 @@ import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; - import org.apache.http.HttpStatus; import org.onap.so.logger.MessageEnum; import org.springframework.beans.factory.annotation.Autowired; @@ -58,166 +55,163 @@ import io.swagger.annotations.ApiOperation; @Component @Path("/globalhealthcheck") -@Api(value="/globalhealthcheck",description="APIH Infra Global Health Check") +@Api(value = "/globalhealthcheck", description = "APIH Infra Global Health Check") public class GlobalHealthcheckHandler { - private static Logger logger = LoggerFactory.getLogger(GlobalHealthcheckHandler.class); - private static final String CONTEXTPATH_PROPERTY = "management.context-path"; - private static final String PROPERTY_DOMAIN = "mso.health.endpoints"; - private static final String CATALOGDB_PROPERTY = PROPERTY_DOMAIN + ".catalogdb"; - private static final String REQUESTDB_PROPERTY = PROPERTY_DOMAIN + ".requestdb"; - private static final String SDNC_PROPERTY = PROPERTY_DOMAIN + ".sdnc"; - private static final String OPENSTACK_PROPERTY = PROPERTY_DOMAIN + ".openstack"; - private static final String BPMN_PROPERTY = PROPERTY_DOMAIN + ".bpmn"; - private static final String ASDC_PROPERTY = PROPERTY_DOMAIN + ".asdc"; - private static final String REQUESTDBATTSVC_PROPERTY = PROPERTY_DOMAIN + ".requestdbattsvc"; - private static final String DEFAULT_PROPERTY_VALUE = ""; - + private static Logger logger = LoggerFactory.getLogger(GlobalHealthcheckHandler.class); + private static final String CONTEXTPATH_PROPERTY = "management.context-path"; + private static final String PROPERTY_DOMAIN = "mso.health.endpoints"; + private static final String CATALOGDB_PROPERTY = PROPERTY_DOMAIN + ".catalogdb"; + private static final String REQUESTDB_PROPERTY = PROPERTY_DOMAIN + ".requestdb"; + private static final String SDNC_PROPERTY = PROPERTY_DOMAIN + ".sdnc"; + private static final String OPENSTACK_PROPERTY = PROPERTY_DOMAIN + ".openstack"; + private static final String BPMN_PROPERTY = PROPERTY_DOMAIN + ".bpmn"; + private static final String ASDC_PROPERTY = PROPERTY_DOMAIN + ".asdc"; + private static final String REQUESTDBATTSVC_PROPERTY = PROPERTY_DOMAIN + ".requestdbattsvc"; + private static final String DEFAULT_PROPERTY_VALUE = ""; + // e.g. /manage private String actuatorContextPath; - private String endpointCatalogdb; - private String endpointRequestdb; - private String endpointSdnc; - private String endpointOpenstack; - private String endpointBpmn; - private String endpointAsdc; - private String endpointRequestdbAttsvc; - - @Autowired - private Environment env; - - @Autowired - private RestTemplate restTemplate; - private final String health = "/health"; - - - @PostConstruct - protected void init() { - actuatorContextPath = env.getProperty(CONTEXTPATH_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); - endpointCatalogdb = env.getProperty(CATALOGDB_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); - endpointRequestdb = env.getProperty(REQUESTDB_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); - endpointSdnc = env.getProperty(SDNC_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); - endpointOpenstack = env.getProperty(OPENSTACK_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); - endpointBpmn = env.getProperty(BPMN_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); - endpointAsdc = env.getProperty(ASDC_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); - endpointRequestdbAttsvc = env.getProperty(REQUESTDBATTSVC_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); - } - + private String endpointCatalogdb; + private String endpointRequestdb; + private String endpointSdnc; + private String endpointOpenstack; + private String endpointBpmn; + private String endpointAsdc; + private String endpointRequestdbAttsvc; + + @Autowired + private Environment env; + + @Autowired + private RestTemplate restTemplate; + private final String health = "/health"; + + + @PostConstruct + protected void init() { + actuatorContextPath = env.getProperty(CONTEXTPATH_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); + endpointCatalogdb = env.getProperty(CATALOGDB_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); + endpointRequestdb = env.getProperty(REQUESTDB_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); + endpointSdnc = env.getProperty(SDNC_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); + endpointOpenstack = env.getProperty(OPENSTACK_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); + endpointBpmn = env.getProperty(BPMN_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); + endpointAsdc = env.getProperty(ASDC_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); + endpointRequestdbAttsvc = env.getProperty(REQUESTDBATTSVC_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); + } + @GET @Produces("application/json") - @ApiOperation(value="Performing global health check",response=Response.class) + @ApiOperation(value = "Performing global health check", response = Response.class) @Transactional - public Response globalHealthcheck (@DefaultValue("true") @QueryParam("enableBpmn") boolean enableBpmn, - @Context ContainerRequestContext requestContext) { - Response HEALTH_CHECK_RESPONSE = null; + public Response globalHealthcheck(@DefaultValue("true") @QueryParam("enableBpmn") boolean enableBpmn, + @Context ContainerRequestContext requestContext) { + Response HEALTH_CHECK_RESPONSE = null; // Build internal response object HealthcheckResponse rsp = new HealthcheckResponse(); - - try{ + + try { // Generated RequestId String requestId = requestContext.getProperty("requestId").toString(); logger.info("{} {}", MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); - + // set APIH status, this is the main entry point rsp.setApih(HealthcheckStatus.UP.toString()); // set BPMN rsp.setBpmn(querySubsystemHealth(MsoSubsystems.BPMN)); // set SDNCAdapter - rsp.setSdncAdapter(querySubsystemHealth(MsoSubsystems.SDNC)); + rsp.setSdncAdapter(querySubsystemHealth(MsoSubsystems.SDNC)); // set ASDCController - rsp.setAsdcController(querySubsystemHealth(MsoSubsystems.ASDC)); + rsp.setAsdcController(querySubsystemHealth(MsoSubsystems.ASDC)); // set CatalogDbAdapter - rsp.setCatalogdbAdapter(querySubsystemHealth(MsoSubsystems.CATALOGDB)); + rsp.setCatalogdbAdapter(querySubsystemHealth(MsoSubsystems.CATALOGDB)); // set RequestDbAdapter - rsp.setRequestdbAdapter(querySubsystemHealth(MsoSubsystems.REQUESTDB)); + rsp.setRequestdbAdapter(querySubsystemHealth(MsoSubsystems.REQUESTDB)); // set OpenStackAdapter - rsp.setOpenstackAdapter(querySubsystemHealth(MsoSubsystems.OPENSTACK)); + rsp.setOpenstackAdapter(querySubsystemHealth(MsoSubsystems.OPENSTACK)); // set RequestDbAdapterAttSvc rsp.setRequestdbAdapterAttsvc(querySubsystemHealth(MsoSubsystems.REQUESTDBATT)); // set Message rsp.setMessage(String.format("HttpStatus: %s", HttpStatus.SC_OK)); logger.info(rsp.toString()); - HEALTH_CHECK_RESPONSE = Response.status (HttpStatus.SC_OK) - .entity (rsp) - .build (); - - }catch (Exception ex){ - logger.error("Exception occurred", ex); - rsp.setMessage(ex.getMessage()); - HEALTH_CHECK_RESPONSE = Response.status (HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity (rsp) - .build (); - } - + HEALTH_CHECK_RESPONSE = Response.status(HttpStatus.SC_OK).entity(rsp).build(); + + } catch (Exception ex) { + logger.error("Exception occurred", ex); + rsp.setMessage(ex.getMessage()); + HEALTH_CHECK_RESPONSE = Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(rsp).build(); + } + return HEALTH_CHECK_RESPONSE; } - - protected HttpEntity<String> buildHttpEntityForRequest(){ + + protected HttpEntity<String> buildHttpEntityForRequest() { HttpHeaders headers = new HttpHeaders(); - headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); headers.set("Content-Type", "application/json"); - HttpEntity<String> entity = new HttpEntity<>("parameters", headers); + HttpEntity<String> entity = new HttpEntity<>("parameters", headers); return entity; } - - protected String querySubsystemHealth(MsoSubsystems subsystem){ - try{ + + protected String querySubsystemHealth(MsoSubsystems subsystem) { + try { // get port number for the subsystem - String ept = getEndpointUrlForSubsystemEnum(subsystem); - - // build final endpoint url - UriBuilder builder = UriBuilder.fromPath(ept).path(actuatorContextPath).path(health); - URI uri = builder.build(); - logger.info("Calculated URL: {}", uri.toString()); - - ResponseEntity<SubsystemHealthcheckResponse> result = - restTemplate.exchange(uri, HttpMethod.GET, buildHttpEntityForRequest(), SubsystemHealthcheckResponse.class); - - return processResponseFromSubsystem(result,subsystem); - - }catch(Exception ex){ - logger.error("Exception occured in GlobalHealthcheckHandler.querySubsystemHealth() ", ex); - return HealthcheckStatus.DOWN.toString(); - } + String ept = getEndpointUrlForSubsystemEnum(subsystem); + + // build final endpoint url + UriBuilder builder = UriBuilder.fromPath(ept).path(actuatorContextPath).path(health); + URI uri = builder.build(); + logger.info("Calculated URL: {}", uri.toString()); + + ResponseEntity<SubsystemHealthcheckResponse> result = restTemplate.exchange(uri, HttpMethod.GET, + buildHttpEntityForRequest(), SubsystemHealthcheckResponse.class); + + return processResponseFromSubsystem(result, subsystem); + + } catch (Exception ex) { + logger.error("Exception occured in GlobalHealthcheckHandler.querySubsystemHealth() ", ex); + return HealthcheckStatus.DOWN.toString(); + } } - protected String processResponseFromSubsystem(ResponseEntity<SubsystemHealthcheckResponse> result, MsoSubsystems subsystem){ - if(result == null || result.getStatusCodeValue() != HttpStatus.SC_OK){ - logger.error(String.format("Globalhealthcheck: checking subsystem: %s failed ! result object is: %s", - subsystem, - result == null? "NULL": result)); - return HealthcheckStatus.DOWN.toString(); + + protected String processResponseFromSubsystem(ResponseEntity<SubsystemHealthcheckResponse> result, + MsoSubsystems subsystem) { + if (result == null || result.getStatusCodeValue() != HttpStatus.SC_OK) { + logger.error(String.format("Globalhealthcheck: checking subsystem: %s failed ! result object is: %s", + subsystem, result == null ? "NULL" : result)); + return HealthcheckStatus.DOWN.toString(); } - + SubsystemHealthcheckResponse body = result.getBody(); - String status = body.getStatus(); - if("UP".equalsIgnoreCase(status)){ - return HealthcheckStatus.UP.toString(); - }else{ - logger.error("{}, query health endpoint did not return UP status!", subsystem); - return HealthcheckStatus.DOWN.toString(); - } - } - - - protected String getEndpointUrlForSubsystemEnum(MsoSubsystems subsystem){ - switch (subsystem){ - case SDNC: - return this.endpointSdnc; - case ASDC: - return this.endpointAsdc; - case BPMN: - return this.endpointBpmn; - case CATALOGDB: - return this.endpointCatalogdb; - case OPENSTACK: - return this.endpointOpenstack; - case REQUESTDB: - return this.endpointRequestdb; - case REQUESTDBATT: - return this.endpointRequestdbAttsvc; - default: - return ""; - } + String status = body.getStatus(); + if ("UP".equalsIgnoreCase(status)) { + return HealthcheckStatus.UP.toString(); + } else { + logger.error("{}, query health endpoint did not return UP status!", subsystem); + return HealthcheckStatus.DOWN.toString(); + } + } + + + protected String getEndpointUrlForSubsystemEnum(MsoSubsystems subsystem) { + switch (subsystem) { + case SDNC: + return this.endpointSdnc; + case ASDC: + return this.endpointAsdc; + case BPMN: + return this.endpointBpmn; + case CATALOGDB: + return this.endpointCatalogdb; + case OPENSTACK: + return this.endpointOpenstack; + case REQUESTDB: + return this.endpointRequestdb; + case REQUESTDBATT: + return this.endpointRequestdbAttsvc; + default: + return ""; + } } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthcheckResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthcheckResponse.java index 8f0bbc4e1f..fad3dd4055 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthcheckResponse.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthcheckResponse.java @@ -22,100 +22,95 @@ package org.onap.so.apihandlerinfra; import org.apache.commons.lang3.builder.ToStringBuilder; public class HealthcheckResponse { - private String apih; - private String bpmn; - private String sdncAdapter; - private String asdcController; - private String catalogdbAdapter; - private String requestdbAdapter; - private String openstackAdapter; - private String requestdbAdapterAttsvc; - private String message = ""; - - public String getApih() { - return apih; - } - - public void setApih(String apih) { - this.apih = apih; - } - - public String getBpmn() { - return bpmn; - } - - public void setBpmn(String bpmn) { - this.bpmn = bpmn; - } - - public String getSdncAdapter() { - return sdncAdapter; - } - - public void setSdncAdapter(String sdncAdapter) { - this.sdncAdapter = sdncAdapter; - } - - public String getAsdcController() { - return asdcController; - } - - public void setAsdcController(String asdcController) { - this.asdcController = asdcController; - } - - public String getCatalogdbAdapter() { - return catalogdbAdapter; - } - - public void setCatalogdbAdapter(String catalogdbAdapter) { - this.catalogdbAdapter = catalogdbAdapter; - } - - public String getRequestdbAdapter() { - return requestdbAdapter; - } - - public void setRequestdbAdapter(String requestdbAdapter) { - this.requestdbAdapter = requestdbAdapter; - } - - public String getOpenstackAdapter() { - return openstackAdapter; - } - - public void setOpenstackAdapter(String openstackAdapter) { - this.openstackAdapter = openstackAdapter; - } - - public String getRequestdbAdapterAttsvc() { - return requestdbAdapterAttsvc; - } - - public void setRequestdbAdapterAttsvc(String requestdbAdapterAttsvc) { - this.requestdbAdapterAttsvc = requestdbAdapterAttsvc; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public String toString() { - return new ToStringBuilder(this). - append("apih", this.apih). - append("pbmn", this.bpmn). - append("sdncAdapter", this.sdncAdapter). - append("asdcController", this.asdcController). - append("catalogdbAdapter", this.catalogdbAdapter). - append("requestdbAdapter", this.requestdbAdapter). - append("openstackAdapter", this.openstackAdapter). - append("requestdbAdapterAttsvc", this.requestdbAdapterAttsvc). - append("message", this.message). - toString(); - } + private String apih; + private String bpmn; + private String sdncAdapter; + private String asdcController; + private String catalogdbAdapter; + private String requestdbAdapter; + private String openstackAdapter; + private String requestdbAdapterAttsvc; + private String message = ""; + + public String getApih() { + return apih; + } + + public void setApih(String apih) { + this.apih = apih; + } + + public String getBpmn() { + return bpmn; + } + + public void setBpmn(String bpmn) { + this.bpmn = bpmn; + } + + public String getSdncAdapter() { + return sdncAdapter; + } + + public void setSdncAdapter(String sdncAdapter) { + this.sdncAdapter = sdncAdapter; + } + + public String getAsdcController() { + return asdcController; + } + + public void setAsdcController(String asdcController) { + this.asdcController = asdcController; + } + + public String getCatalogdbAdapter() { + return catalogdbAdapter; + } + + public void setCatalogdbAdapter(String catalogdbAdapter) { + this.catalogdbAdapter = catalogdbAdapter; + } + + public String getRequestdbAdapter() { + return requestdbAdapter; + } + + public void setRequestdbAdapter(String requestdbAdapter) { + this.requestdbAdapter = requestdbAdapter; + } + + public String getOpenstackAdapter() { + return openstackAdapter; + } + + public void setOpenstackAdapter(String openstackAdapter) { + this.openstackAdapter = openstackAdapter; + } + + public String getRequestdbAdapterAttsvc() { + return requestdbAdapterAttsvc; + } + + public void setRequestdbAdapterAttsvc(String requestdbAdapterAttsvc) { + this.requestdbAdapterAttsvc = requestdbAdapterAttsvc; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("apih", this.apih).append("pbmn", this.bpmn) + .append("sdncAdapter", this.sdncAdapter).append("asdcController", this.asdcController) + .append("catalogdbAdapter", this.catalogdbAdapter).append("requestdbAdapter", this.requestdbAdapter) + .append("openstackAdapter", this.openstackAdapter) + .append("requestdbAdapterAttsvc", this.requestdbAdapterAttsvc).append("message", this.message) + .toString(); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthcheckStatus.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthcheckStatus.java index 89c4e0efda..077a3c2d60 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthcheckStatus.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthcheckStatus.java @@ -20,15 +20,16 @@ package org.onap.so.apihandlerinfra; public enum HealthcheckStatus { - UP("UP"), DOWN("DOWN"); - - private String status; - private HealthcheckStatus(String status) { - this.status = status; - } - - @Override - public String toString(){ - return status; - } + UP("UP"), DOWN("DOWN"); + + private String status; + + private HealthcheckStatus(String status) { + this.status = status; + } + + @Override + public String toString() { + return status; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java index 51962f2b9e..c491444f39 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java @@ -48,7 +48,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import javax.transaction.Transactional; import javax.ws.rs.Consumes; import javax.ws.rs.POST; @@ -64,182 +63,201 @@ import java.util.HashMap; @Component @Path("/onap/so/infra/instanceManagement") -@Api(value="/onap/so/infra/instanceManagement",description="Infrastructure API Requests for Instance Management") +@Api(value = "/onap/so/infra/instanceManagement", description = "Infrastructure API Requests for Instance Management") public class InstanceManagement { - private static Logger logger = LoggerFactory.getLogger(InstanceManagement.class); - private static String uriPrefix = "/instanceManagement/"; - private static final String SAVE_TO_DB = "save instance to db"; - - @Autowired - private RequestsDbClient infraActiveRequestsClient; - - @Autowired - private CatalogDbClient catalogDbClient; - - @Autowired - private MsoRequest msoRequest; - - @Autowired - private RequestHandlerUtils requestHandlerUtils; - - @POST - @Path("/{version:[vV][1]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/workflows/{workflowUuid}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Execute custom workflow",response=Response.class) - @Transactional - public Response executeCustomWorkflow(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, @PathParam("workflowUuid") String workflowUuid, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - instanceIdMap.put("workflowUuid", workflowUuid); - return processCustomWorkflowRequest(request, Action.inPlaceSoftwareUpdate, instanceIdMap, version, requestId, requestContext); - } - - private Response processCustomWorkflowRequest(String requestJSON, Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, ContainerRequestContext requestContext) throws ApiException { - String serviceInstanceId = null; - if (instanceIdMap != null) { - serviceInstanceId = instanceIdMap.get("serviceInstanceId"); - } - Boolean aLaCarte = true; - long startTime = System.currentTimeMillis (); - ServiceInstancesRequest sir = null; - String apiVersion = version.substring(1); - - String requestUri = requestHandlerUtils.getRequestUri(requestContext, uriPrefix); - - sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri); - String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri); - InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope); - - try { - requestHandlerUtils.validateHeaders(requestContext); - } catch (ValidationException e) { - logger.error("Exception occurred", e); - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) - .errorInfo(errorLoggerInfo).build(); + private static Logger logger = LoggerFactory.getLogger(InstanceManagement.class); + private static String uriPrefix = "/instanceManagement/"; + private static final String SAVE_TO_DB = "save instance to db"; + + @Autowired + private RequestsDbClient infraActiveRequestsClient; + + @Autowired + private CatalogDbClient catalogDbClient; + + @Autowired + private MsoRequest msoRequest; + + @Autowired + private RequestHandlerUtils requestHandlerUtils; + + @POST + @Path("/{version:[vV][1]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/workflows/{workflowUuid}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Execute custom workflow", response = Response.class) + @Transactional + public Response executeCustomWorkflow(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @PathParam("workflowUuid") String workflowUuid, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + instanceIdMap.put("workflowUuid", workflowUuid); + return processCustomWorkflowRequest(request, Action.inPlaceSoftwareUpdate, instanceIdMap, version, requestId, + requestContext); + } + + private Response processCustomWorkflowRequest(String requestJSON, Actions action, + HashMap<String, String> instanceIdMap, String version, String requestId, + ContainerRequestContext requestContext) throws ApiException { + String serviceInstanceId = null; + if (instanceIdMap != null) { + serviceInstanceId = instanceIdMap.get("serviceInstanceId"); + } + Boolean aLaCarte = true; + long startTime = System.currentTimeMillis(); + ServiceInstancesRequest sir = null; + String apiVersion = version.substring(1); + + String requestUri = requestHandlerUtils.getRequestUri(requestContext, uriPrefix); + + sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, + requestId, requestUri); + String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri); + InfraActiveRequests currentActiveReq = + msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope); + + try { + requestHandlerUtils.validateHeaders(requestContext); + } catch (ValidationException e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + ValidateException validateException = + new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); throw validateException; - } - - requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq); - requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap); - - int requestVersion = Integer.parseInt(version.substring(1)); - String vnfType = msoRequest.getVnfType(sir,requestScope,action,requestVersion); - - if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && vnfType != null){ - currentActiveReq.setVnfType(vnfType); - } - - InfraActiveRequests dup = null; - boolean inProgress = false; - - dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, startTime, msoRequest, null, requestScope, currentActiveReq); - - if(dup != null){ - inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq); - } - - if (dup != null && inProgress) { - requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, null, requestScope, dup); - } - ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse(); - - RequestReferences referencesResponse = new RequestReferences(); - - referencesResponse.setRequestId(requestId); - - serviceResponse.setRequestReferences(referencesResponse); - Boolean isBaseVfModule = false; - - String workflowUuid = null; - if (instanceIdMap !=null) { - workflowUuid = instanceIdMap.get("workflowUuid"); - } + } + + requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, + currentActiveReq); + requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap); + + int requestVersion = Integer.parseInt(version.substring(1)); + String vnfType = msoRequest.getVnfType(sir, requestScope, action, requestVersion); + + if (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && vnfType != null) { + currentActiveReq.setVnfType(vnfType); + } + + InfraActiveRequests dup = null; + boolean inProgress = false; + + dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, startTime, msoRequest, null, requestScope, + currentActiveReq); + + if (dup != null) { + inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq); + } + + if (dup != null && inProgress) { + requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, + msoRequest, null, requestScope, dup); + } + ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse(); + + RequestReferences referencesResponse = new RequestReferences(); + + referencesResponse.setRequestId(requestId); + + serviceResponse.setRequestReferences(referencesResponse); + Boolean isBaseVfModule = false; + + String workflowUuid = null; + if (instanceIdMap != null) { + workflowUuid = instanceIdMap.get("workflowUuid"); + } RecipeLookupResult recipeLookupResult = getInstanceManagementWorkflowRecipe(currentActiveReq, workflowUuid); - - String serviceInstanceType = requestHandlerUtils.getServiceType(requestScope, sir, true); - - serviceInstanceId = requestHandlerUtils.setServiceInstanceId(requestScope, sir); - String vnfId = ""; - - if(sir.getVnfInstanceId () != null){ - vnfId = sir.getVnfInstanceId (); - } - - try{ + + String serviceInstanceType = requestHandlerUtils.getServiceType(requestScope, sir, true); + + serviceInstanceId = requestHandlerUtils.setServiceInstanceId(requestScope, sir); + String vnfId = ""; + + if (sir.getVnfInstanceId() != null) { + vnfId = sir.getVnfInstanceId(); + } + + try { infraActiveRequestsClient.save(currentActiveReq); - }catch(Exception e){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) - .errorInfo(errorLoggerInfo).build(); - } - - RequestClientParameter requestClientParameter = null; - try { - requestClientParameter = new RequestClientParameter.Builder() - .setRequestId(requestId) - .setBaseVfModule(isBaseVfModule) - .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) - .setRequestAction(action.toString()) - .setServiceInstanceId(serviceInstanceId) - .setVnfId(vnfId) - .setServiceType(serviceInstanceType) - .setVnfType(vnfType) - .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action)) - .setApiVersion(apiVersion) - .setALaCarte(aLaCarte) - .setRequestUri(requestUri) - .build(); - } catch (IOException e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER) - .errorInfo(errorLoggerInfo).build(); - } - return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope); - } - - private RecipeLookupResult getInstanceManagementWorkflowRecipe(InfraActiveRequests currentActiveReq, String workflowUuid) throws ApiException { - RecipeLookupResult recipeLookupResult = null; - + } catch (Exception e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build(); + } + + RequestClientParameter requestClientParameter = null; try { - recipeLookupResult = getCustomWorkflowUri(workflowUuid); - } catch (IOException e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) - .errorInfo(errorLoggerInfo).build(); - requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); - throw validateException; - } - + requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId) + .setBaseVfModule(isBaseVfModule).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) + .setRequestAction(action.toString()).setServiceInstanceId(serviceInstanceId).setVnfId(vnfId) + .setServiceType(serviceInstanceType).setVnfType(vnfType) + .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action)) + .setApiVersion(apiVersion).setALaCarte(aLaCarte).setRequestUri(requestUri).build(); + } catch (IOException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo) + .build(); + } + return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, + recipeLookupResult.getOrchestrationURI(), requestScope); + } + + private RecipeLookupResult getInstanceManagementWorkflowRecipe(InfraActiveRequests currentActiveReq, + String workflowUuid) throws ApiException { + RecipeLookupResult recipeLookupResult = null; + + try { + recipeLookupResult = getCustomWorkflowUri(workflowUuid); + } catch (IOException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + ValidateException validateException = + new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); + requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); + throw validateException; + } + if (recipeLookupResult == null) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - RecipeNotFoundException recipeNotFoundExceptionException = new RecipeNotFoundException.Builder("Recipe could not be retrieved from catalog DB.", HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR) - .errorInfo(errorLoggerInfo).build(); - requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, recipeNotFoundExceptionException.getMessage()); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + RecipeNotFoundException recipeNotFoundExceptionException = + new RecipeNotFoundException.Builder("Recipe could not be retrieved from catalog DB.", + HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).errorInfo(errorLoggerInfo) + .build(); + requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, + recipeNotFoundExceptionException.getMessage()); throw recipeNotFoundExceptionException; - } - + } + return recipeLookupResult; - } - + } + private RecipeLookupResult getCustomWorkflowUri(String workflowUuid) throws IOException { - - String recipeUri = null; - Workflow workflow = catalogDbClient.findWorkflowByArtifactUUID(workflowUuid); - if (workflow == null) { - return null; - } - else { - String workflowName = workflow.getArtifactName(); - recipeUri = "/mso/async/services/" + workflowName; - } - return new RecipeLookupResult(recipeUri, 180); - } + + String recipeUri = null; + Workflow workflow = catalogDbClient.findWorkflowByArtifactUUID(workflowUuid); + if (workflow == null) { + return null; + } else { + String workflowName = workflow.getArtifactName(); + recipeUri = "/mso/async/services/" + workflowName; + } + return new RecipeLookupResult(recipeUri, 180); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java index 866a4e7ca1..67d6a0d1fc 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/JerseyConfiguration.java @@ -22,7 +22,6 @@ package org.onap.so.apihandlerinfra; import javax.annotation.PostConstruct; import javax.ws.rs.ApplicationPath; - import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.servlet.ServletProperties; import org.onap.so.apihandler.filters.RequestUriFilter; @@ -34,7 +33,6 @@ import org.onap.so.apihandlerinfra.tenantisolation.ModelDistributionRequest; import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging; import org.onap.so.web.exceptions.RuntimeExceptionMapper; import org.springframework.context.annotation.Configuration; - import io.swagger.jaxrs.config.BeanConfig; import io.swagger.jaxrs.listing.ApiListingResource; import io.swagger.jaxrs.listing.SwaggerSerializers; @@ -45,38 +43,38 @@ public class JerseyConfiguration extends ResourceConfig { - @PostConstruct - public void setUp() { - register(GlobalHealthcheckHandler.class); - register(NodeHealthcheckHandler.class); - register(ServiceInstances.class); - register(TasksHandler.class); - register(CloudOrchestration.class); - register(CloudResourcesOrchestration.class); - register(OrchestrationRequests.class); - register(JaxRsFilterLogging.class); - register(ManualTasks.class); - register(TasksHandler.class); - register(ApiListingResource.class); - register(SwaggerSerializers.class); - register(ApiExceptionMapper.class); - register(RuntimeExceptionMapper.class); - register(RequestUriFilter.class); - register(RequestIdFilter.class); - register(E2EServiceInstances.class); - register(WorkflowSpecificationsHandler.class); - register(InstanceManagement.class); - // this registration seems to be needed to get predictable - // execution behavior for the above JSON Exception Mappers - register(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider.class); - register(ModelDistributionRequest.class); - property(ServletProperties.FILTER_FORWARD_ON_404, true); - BeanConfig beanConfig = new BeanConfig(); - beanConfig.setVersion("1.0.2"); - beanConfig.setSchemes(new String[] { "https" }); - beanConfig.setResourcePackage("org.onap.so.apihandlerinfra"); - beanConfig.setPrettyPrint(true); - beanConfig.setScan(true); - } + @PostConstruct + public void setUp() { + register(GlobalHealthcheckHandler.class); + register(NodeHealthcheckHandler.class); + register(ServiceInstances.class); + register(TasksHandler.class); + register(CloudOrchestration.class); + register(CloudResourcesOrchestration.class); + register(OrchestrationRequests.class); + register(JaxRsFilterLogging.class); + register(ManualTasks.class); + register(TasksHandler.class); + register(ApiListingResource.class); + register(SwaggerSerializers.class); + register(ApiExceptionMapper.class); + register(RuntimeExceptionMapper.class); + register(RequestUriFilter.class); + register(RequestIdFilter.class); + register(E2EServiceInstances.class); + register(WorkflowSpecificationsHandler.class); + register(InstanceManagement.class); + // this registration seems to be needed to get predictable + // execution behavior for the above JSON Exception Mappers + register(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider.class); + register(ModelDistributionRequest.class); + property(ServletProperties.FILTER_FORWARD_ON_404, true); + BeanConfig beanConfig = new BeanConfig(); + beanConfig.setVersion("1.0.2"); + beanConfig.setSchemes(new String[] {"https"}); + beanConfig.setResourcePackage("org.onap.so.apihandlerinfra"); + beanConfig.setPrettyPrint(true); + beanConfig.setScan(true); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java index ad589ddc9c..3c06804594 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java @@ -24,7 +24,6 @@ package org.onap.so.apihandlerinfra; import java.io.IOException; - import javax.transaction.Transactional; import javax.ws.rs.Consumes; import javax.ws.rs.POST; @@ -35,7 +34,6 @@ import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.onap.so.apihandler.common.ErrorNumbers; @@ -46,7 +44,6 @@ import org.onap.so.apihandler.common.ResponseHandler; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; - import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.apihandlerinfra.tasksbeans.TaskRequestReference; import org.onap.so.apihandlerinfra.tasksbeans.TasksRequest; @@ -56,193 +53,212 @@ import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; - import io.swagger.annotations.ApiOperation; @Path("/tasks") @Component public class ManualTasks { - private static Logger logger = LoggerFactory.getLogger(ManualTasks.class); - - - @org.springframework.beans.factory.annotation.Value("${mso.camunda.rest.task.uri}") - private String taskUri; - - @Autowired - private RequestClientFactory reqClientFactory; - - @Autowired - private MsoRequest msoRequest; - - @Autowired - private ResponseBuilder builder; - - @POST - @Path("/{version:[vV]1}/{taskId}/complete") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Complete specified task",response=Response.class) - @Transactional - public Response completeTask(String request, @PathParam("version") String version, @PathParam("taskId") String taskId, - @Context ContainerRequestContext requestContext) throws ApiException { - - String requestId = requestContext.getProperty("requestId").toString(); - logger.info("{} {}", MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); - long startTime = System.currentTimeMillis (); - logger.debug ("requestId is: {}", requestId); - TasksRequest taskRequest = null; - String apiVersion = version.substring(1); - - try{ - ObjectMapper mapper = new ObjectMapper(); - taskRequest= mapper.readValue(request, TasksRequest.class); - - if (taskRequest.getRequestDetails() == null) { - throw new ValidationException("requestDetails"); - } - if (taskRequest.getRequestDetails().getRequestInfo() == null) { - throw new ValidationException("requestInfo"); - } - if (empty(taskRequest.getRequestDetails().getRequestInfo().getSource())) { - throw new ValidationException("source"); - } - if (empty(taskRequest.getRequestDetails().getRequestInfo().getRequestorId())) { - throw new ValidationException("requestorId"); - } - - }catch(IOException e){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).build(); - - - ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed: " + e.getMessage(), - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); - - throw validateException; - } - catch(ValidationException e){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - - - ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON Object failed. " + e.getMessage(), - HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build(); - throw validateException; - - } - //Create Request Record - InfraActiveRequests currentActiveReq = msoRequest.createRequestObject(taskRequest,Action.completeTask,requestId,Status.PENDING,request); - - // Transform the request to Camunda-style Complete request - Variables variablesForComplete = new Variables(); - Value sourceValue = new Value(); - sourceValue.setValue(taskRequest.getRequestDetails().getRequestInfo().getSource()); - Value responseValue = new Value(); - responseValue.setValue(taskRequest.getRequestDetails().getRequestInfo().getResponseValue().name()); - Value requestorIdValue = new Value(); - requestorIdValue.setValue(taskRequest.getRequestDetails().getRequestInfo().getRequestorId()); - variablesForComplete.setSource(sourceValue); - variablesForComplete.setResponseValue(responseValue); - variablesForComplete.setRequestorId(requestorIdValue); - - String camundaJsonReq = null; - try { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); - camundaJsonReq = mapper.writeValueAsString(variablesForComplete); - } catch(JsonProcessingException e){ - - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.UnknownError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - - - ValidateException validateException = new ValidateException.Builder("Mapping of JSON object to Camunda request failed", - HttpStatus.SC_INTERNAL_SERVER_ERROR,ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); - throw validateException; - } - - RequestClient requestClient = null; - HttpResponse response = null; - long subStartTime = System.currentTimeMillis(); - String requestUrl = taskUri + "/" + taskId + "/complete"; - try { - requestClient = reqClientFactory.getRequestClient (requestUrl); - // Capture audit event - - response = requestClient.post(camundaJsonReq); - - } catch (Exception e) { - - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - - - - BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY), - HttpStatus.SC_BAD_GATEWAY,ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo).build(); - - throw bpmnFailureException; - } - - if (response == null) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.BusinessProcesssError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - - - BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY), - HttpStatus.SC_BAD_GATEWAY,ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo).build(); + private static Logger logger = LoggerFactory.getLogger(ManualTasks.class); + + + @org.springframework.beans.factory.annotation.Value("${mso.camunda.rest.task.uri}") + private String taskUri; + + @Autowired + private RequestClientFactory reqClientFactory; + + @Autowired + private MsoRequest msoRequest; + + @Autowired + private ResponseBuilder builder; + + @POST + @Path("/{version:[vV]1}/{taskId}/complete") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Complete specified task", response = Response.class) + @Transactional + public Response completeTask(String request, @PathParam("version") String version, + @PathParam("taskId") String taskId, @Context ContainerRequestContext requestContext) throws ApiException { + + String requestId = requestContext.getProperty("requestId").toString(); + logger.info("{} {}", MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); + long startTime = System.currentTimeMillis(); + logger.debug("requestId is: {}", requestId); + TasksRequest taskRequest = null; + String apiVersion = version.substring(1); + + try { + ObjectMapper mapper = new ObjectMapper(); + taskRequest = mapper.readValue(request, TasksRequest.class); + + if (taskRequest.getRequestDetails() == null) { + throw new ValidationException("requestDetails"); + } + if (taskRequest.getRequestDetails().getRequestInfo() == null) { + throw new ValidationException("requestInfo"); + } + if (empty(taskRequest.getRequestDetails().getRequestInfo().getSource())) { + throw new ValidationException("source"); + } + if (empty(taskRequest.getRequestDetails().getRequestInfo().getRequestorId())) { + throw new ValidationException("requestorId"); + } + + } catch (IOException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .build(); + + + ValidateException validateException = + new ValidateException.Builder("Mapping of request to JSON object failed: " + e.getMessage(), + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); + + throw validateException; + } catch (ValidationException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + + + ValidateException validateException = + new ValidateException.Builder("Mapping of request to JSON Object failed. " + e.getMessage(), + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo) + .build(); + throw validateException; + + } + // Create Request Record + InfraActiveRequests currentActiveReq = + msoRequest.createRequestObject(taskRequest, Action.completeTask, requestId, Status.PENDING, request); + + // Transform the request to Camunda-style Complete request + Variables variablesForComplete = new Variables(); + Value sourceValue = new Value(); + sourceValue.setValue(taskRequest.getRequestDetails().getRequestInfo().getSource()); + Value responseValue = new Value(); + responseValue.setValue(taskRequest.getRequestDetails().getRequestInfo().getResponseValue().name()); + Value requestorIdValue = new Value(); + requestorIdValue.setValue(taskRequest.getRequestDetails().getRequestInfo().getRequestorId()); + variablesForComplete.setSource(sourceValue); + variablesForComplete.setResponseValue(responseValue); + variablesForComplete.setRequestorId(requestorIdValue); + + String camundaJsonReq = null; + try { + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + camundaJsonReq = mapper.writeValueAsString(variablesForComplete); + } catch (JsonProcessingException e) { + + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.UnknownError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + + + ValidateException validateException = + new ValidateException.Builder("Mapping of JSON object to Camunda request failed", + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR) + .errorInfo(errorLoggerInfo).build(); + throw validateException; + } + + RequestClient requestClient = null; + HttpResponse response = null; + long subStartTime = System.currentTimeMillis(); + String requestUrl = taskUri + "/" + taskId + "/complete"; + try { + requestClient = reqClientFactory.getRequestClient(requestUrl); + // Capture audit event + + response = requestClient.post(camundaJsonReq); + + } catch (Exception e) { + + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + + + + BPMNFailureException bpmnFailureException = + new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY), + HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo) + .build(); throw bpmnFailureException; + } - } + if (response == null) { + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, + ErrorCode.BusinessProcesssError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ()); - int bpelStatus = respHandler.getStatus (); - // BPEL accepted the request, the request is in progress - if (bpelStatus == HttpStatus.SC_NO_CONTENT || bpelStatus == HttpStatus.SC_ACCEPTED) { - logger.debug ("Received good response from Camunda"); - TaskRequestReference trr = new TaskRequestReference(); - trr.setTaskId(taskId); - String completeResp = null; - try { - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); - completeResp = mapper.writeValueAsString(trr); - } - catch (JsonProcessingException e) { + BPMNFailureException bpmnFailureException = + new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY), + HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo) + .build(); + + throw bpmnFailureException; - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError).build(); + } + ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType()); + int bpelStatus = respHandler.getStatus(); - ValidateException validateException = new ValidateException.Builder("Request Failed due to bad response format" , - bpelStatus,ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); + // BPEL accepted the request, the request is in progress + if (bpelStatus == HttpStatus.SC_NO_CONTENT || bpelStatus == HttpStatus.SC_ACCEPTED) { + logger.debug("Received good response from Camunda"); + TaskRequestReference trr = new TaskRequestReference(); + trr.setTaskId(taskId); + String completeResp = null; + try { + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); + completeResp = mapper.writeValueAsString(trr); + } catch (JsonProcessingException e) { + + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, + ErrorCode.BusinessProcesssError).build(); + + + ValidateException validateException = + new ValidateException.Builder("Request Failed due to bad response format", bpelStatus, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); throw validateException; - } - logger.debug("Response to the caller: {}", completeResp); - logger.debug ("End of the transaction, the final response is: {}", completeResp); - return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestId, completeResp, apiVersion); - } else { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError).build(); + } + logger.debug("Response to the caller: {}", completeResp); + logger.debug("End of the transaction, the final response is: {}", completeResp); + return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestId, completeResp, apiVersion); + } else { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError) + .build(); BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(bpelStatus), - bpelStatus,ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); + bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); throw bpmnFailureException; - - } - - } - - private static boolean empty(String s) { - return (s == null || s.trim().isEmpty()); - } - + + } + + } + + private static boolean empty(String s) { + return (s == null || s.trim().isEmpty()); + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java index dc8e6b6958..277675f310 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java @@ -34,7 +34,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Optional; import java.util.StringTokenizer; - import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.xml.XMLConstants; @@ -43,7 +42,6 @@ import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; - import org.onap.so.apihandler.common.ResponseBuilder; import org.onap.so.apihandlerinfra.tasksbeans.TasksRequest; import org.onap.so.apihandlerinfra.validation.MembersValidation; @@ -95,7 +93,6 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; - import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonMappingException; @@ -104,351 +101,358 @@ import com.fasterxml.jackson.databind.ObjectMapper; @Component public class MsoRequest { - - @Autowired - private RequestsDbClient requestsDbClient; - - @Autowired - private ResponseBuilder builder; - + + @Autowired + private RequestsDbClient requestsDbClient; + + @Autowired + private ResponseBuilder builder; + private static Logger logger = LoggerFactory.getLogger(MsoRequest.class); - - public Response buildServiceErrorResponse (int httpResponseCode, MsoException exceptionType, - String errorText, String messageId, List<String> variables, String version) { - - if(errorText.length() > 1999){ - errorText = errorText.substring(0, 1999); - } - - RequestError re = new RequestError(); - - if("PolicyException".equals(exceptionType.name())){ - - PolicyException pe = new PolicyException(); - pe.setMessageId(messageId); - pe.setText(errorText); - if(variables != null){ - for(String variable: variables){ - pe.getVariables().add(variable); - } - } - re.setPolicyException(pe); - - } else { - - ServiceException se = new ServiceException(); - se.setMessageId(messageId); - se.setText(errorText); - if(variables != null){ - for(String variable: variables){ - se.getVariables().add(variable); - } - } - re.setServiceException(se); - } + + public Response buildServiceErrorResponse(int httpResponseCode, MsoException exceptionType, String errorText, + String messageId, List<String> variables, String version) { + + if (errorText.length() > 1999) { + errorText = errorText.substring(0, 1999); + } + + RequestError re = new RequestError(); + + if ("PolicyException".equals(exceptionType.name())) { + + PolicyException pe = new PolicyException(); + pe.setMessageId(messageId); + pe.setText(errorText); + if (variables != null) { + for (String variable : variables) { + pe.getVariables().add(variable); + } + } + re.setPolicyException(pe); + + } else { + + ServiceException se = new ServiceException(); + se.setMessageId(messageId); + se.setText(errorText); + if (variables != null) { + for (String variable : variables) { + se.getVariables().add(variable); + } + } + re.setServiceException(se); + } String requestErrorStr = null; - try{ - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_DEFAULT); - requestErrorStr = mapper.writeValueAsString(re); - }catch(Exception e){ - logger.error("{} {} {}", MessageEnum.APIH_VALIDATION_ERROR.toString(), ErrorCode.DataError.getValue(), - "Exception in buildServiceErrorResponse writing exceptionType to string ", e); - } + try { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_DEFAULT); + requestErrorStr = mapper.writeValueAsString(re); + } catch (Exception e) { + logger.error("{} {} {}", MessageEnum.APIH_VALIDATION_ERROR.toString(), ErrorCode.DataError.getValue(), + "Exception in buildServiceErrorResponse writing exceptionType to string ", e); + } return builder.buildResponse(httpResponseCode, null, requestErrorStr, version); } - + // Parse request JSON - public void parse (ServiceInstancesRequest sir, HashMap<String,String> instanceIdMap, Actions action, String version, - String originalRequestJSON, int reqVersion, Boolean aLaCarteFlag) throws ValidationException, IOException { - - logger.debug ("Validating the Service Instance request"); + public void parse(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, + String version, String originalRequestJSON, int reqVersion, Boolean aLaCarteFlag) + throws ValidationException, IOException { + + logger.debug("Validating the Service Instance request"); List<ValidationRule> rules = new ArrayList<>(); - logger.debug ("Incoming version is: {} coverting to int: {}", version, reqVersion); - RequestParameters requestParameters = sir.getRequestDetails().getRequestParameters(); - ValidationInformation info = new ValidationInformation(sir, instanceIdMap, action, - reqVersion, aLaCarteFlag, requestParameters); - + logger.debug("Incoming version is: {} coverting to int: {}", version, reqVersion); + RequestParameters requestParameters = sir.getRequestDetails().getRequestParameters(); + ValidationInformation info = + new ValidationInformation(sir, instanceIdMap, action, reqVersion, aLaCarteFlag, requestParameters); + rules.add(new InstanceIdMapValidation()); - + String workflowUuid = null; if (instanceIdMap != null) { - workflowUuid = instanceIdMap.get("workflowUuid"); + workflowUuid = instanceIdMap.get("workflowUuid"); } - + if (workflowUuid != null) { - rules.add(new CustomWorkflowValidation()); - }else if(reqVersion >= 6 && action == Action.inPlaceSoftwareUpdate){ - rules.add(new InPlaceSoftwareUpdateValidation()); - }else if(reqVersion >= 6 && action == Action.applyUpdatedConfig){ - rules.add(new ApplyUpdatedConfigValidation()); - }else if(action == Action.addMembers || action == Action.removeMembers){ - rules.add(new MembersValidation()); - }else{ - rules.add(new RequestScopeValidation()); - rules.add(new RequestParametersValidation()); - rules.add(new RequestInfoValidation()); - rules.add(new ModelInfoValidation()); - rules.add(new CloudConfigurationValidation()); - rules.add(new SubscriberInfoValidation()); - rules.add(new PlatformLOBValidation()); - rules.add(new ProjectOwningEntityValidation()); - rules.add(new RelatedInstancesValidation()); - rules.add(new ConfigurationParametersValidation()); - } - if(reqVersion >= 7 && requestParameters != null && requestParameters.getUserParams() != null){ - for(Map<String, Object> params : requestParameters.getUserParams()){ - if(params.containsKey("service")){ - ObjectMapper obj = new ObjectMapper(); - String input = obj.writeValueAsString(params.get("service")); - Service validate = obj.readValue(input, Service.class); - info.setUserParams(validate); - rules.add(new UserParamsValidation()); - break; - } - } - } - for(ValidationRule rule : rules){ - rule.validate(info); - } + rules.add(new CustomWorkflowValidation()); + } else if (reqVersion >= 6 && action == Action.inPlaceSoftwareUpdate) { + rules.add(new InPlaceSoftwareUpdateValidation()); + } else if (reqVersion >= 6 && action == Action.applyUpdatedConfig) { + rules.add(new ApplyUpdatedConfigValidation()); + } else if (action == Action.addMembers || action == Action.removeMembers) { + rules.add(new MembersValidation()); + } else { + rules.add(new RequestScopeValidation()); + rules.add(new RequestParametersValidation()); + rules.add(new RequestInfoValidation()); + rules.add(new ModelInfoValidation()); + rules.add(new CloudConfigurationValidation()); + rules.add(new SubscriberInfoValidation()); + rules.add(new PlatformLOBValidation()); + rules.add(new ProjectOwningEntityValidation()); + rules.add(new RelatedInstancesValidation()); + rules.add(new ConfigurationParametersValidation()); + } + if (reqVersion >= 7 && requestParameters != null && requestParameters.getUserParams() != null) { + for (Map<String, Object> params : requestParameters.getUserParams()) { + if (params.containsKey("service")) { + ObjectMapper obj = new ObjectMapper(); + String input = obj.writeValueAsString(params.get("service")); + Service validate = obj.readValue(input, Service.class); + info.setUserParams(validate); + rules.add(new UserParamsValidation()); + break; + } + } + } + for (ValidationRule rule : rules) { + rule.validate(info); + } } - void parseOrchestration (ServiceInstancesRequest sir) throws ValidationException { + + void parseOrchestration(ServiceInstancesRequest sir) throws ValidationException { RequestInfo requestInfo = sir.getRequestDetails().getRequestInfo(); if (requestInfo == null) { - throw new ValidationException ("requestInfo"); + throw new ValidationException("requestInfo"); } - if (empty (requestInfo.getSource ())) { - throw new ValidationException ("source"); + if (empty(requestInfo.getSource())) { + throw new ValidationException("source"); } - if (empty (requestInfo.getRequestorId ())) { - throw new ValidationException ("requestorId"); + if (empty(requestInfo.getRequestorId())) { + throw new ValidationException("requestorId"); } } - public Map<String, List<String>> getOrchestrationFilters (MultivaluedMap<String, String> queryParams) throws ValidationException { + + public Map<String, List<String>> getOrchestrationFilters(MultivaluedMap<String, String> queryParams) + throws ValidationException { String queryParam = null; Map<String, List<String>> orchestrationFilterParams = new HashMap<>(); - for (Entry<String,List<String>> entry : queryParams.entrySet()) { + for (Entry<String, List<String>> entry : queryParams.entrySet()) { queryParam = entry.getKey(); - try{ - if("filter".equalsIgnoreCase(queryParam)){ - for(String value : entry.getValue()) { - StringTokenizer st = new StringTokenizer(value, ":"); - - int counter=0; - String mapKey=null; - List<String> orchestrationList = new ArrayList<>(); - while (st.hasMoreElements()) { - if(counter == 0){ - mapKey = st.nextElement() + ""; - } else{ - orchestrationList.add(st.nextElement() + ""); - } - counter++; - } - orchestrationFilterParams.put(mapKey, orchestrationList); - } - } - - }catch(Exception e){ - throw new ValidationException ("QueryParam ServiceInfo", e); - } + try { + if ("filter".equalsIgnoreCase(queryParam)) { + for (String value : entry.getValue()) { + StringTokenizer st = new StringTokenizer(value, ":"); + + int counter = 0; + String mapKey = null; + List<String> orchestrationList = new ArrayList<>(); + while (st.hasMoreElements()) { + if (counter == 0) { + mapKey = st.nextElement() + ""; + } else { + orchestrationList.add(st.nextElement() + ""); + } + counter++; + } + orchestrationFilterParams.put(mapKey, orchestrationList); + } + } + + } catch (Exception e) { + throw new ValidationException("QueryParam ServiceInfo", e); + } } return orchestrationFilterParams; - } + } - public InfraActiveRequests createRequestObject (ServiceInstancesRequest servInsReq, Actions action, String requestId, - Status status, String originalRequestJSON, String requestScope) { - InfraActiveRequests aq = new InfraActiveRequests (); + public InfraActiveRequests createRequestObject(ServiceInstancesRequest servInsReq, Actions action, String requestId, + Status status, String originalRequestJSON, String requestScope) { + InfraActiveRequests aq = new InfraActiveRequests(); try { if (null == servInsReq) { - servInsReq = new ServiceInstancesRequest (); + servInsReq = new ServiceInstancesRequest(); } String networkType = ""; String vnfType = ""; - aq.setRequestId (requestId); + aq.setRequestId(requestId); aq.setRequestAction(action.toString()); aq.setAction(action.toString()); aq.setRequestUrl(MDC.get(LogConstants.HTTP_URL)); - Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis()); - - aq.setStartTime (startTimeStamp); - if(requestScope.equals(ModelType.instanceGroup.name()) && action == Action.deleteInstance){ - aq.setRequestScope(requestScope); - }else{ - RequestInfo requestInfo =servInsReq.getRequestDetails().getRequestInfo(); - if (requestInfo != null) { - - if(requestInfo.getSource() != null){ - aq.setSource(requestInfo.getSource()); - } - if(requestInfo.getCallbackUrl() != null){ - aq.setCallBackUrl(requestInfo.getCallbackUrl()); - } - if(requestInfo.getCorrelator() != null){ - aq.setCorrelator(requestInfo.getCorrelator()); - } - - if(requestInfo.getRequestorId() != null) { - aq.setRequestorId(requestInfo.getRequestorId()); - } - } - - if (servInsReq.getRequestDetails().getModelInfo() != null || (action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig)) { - aq.setRequestScope(requestScope); - } - - if (servInsReq.getRequestDetails().getCloudConfiguration() != null) { - CloudConfiguration cloudConfiguration = servInsReq.getRequestDetails().getCloudConfiguration(); - if(cloudConfiguration.getLcpCloudRegionId() != null) { - aq.setAicCloudRegion(cloudConfiguration.getLcpCloudRegionId()); - } - - if(cloudConfiguration.getTenantId() != null) { - aq.setTenantId(cloudConfiguration.getTenantId()); - } - - } - - if(servInsReq.getServiceInstanceId() != null){ - aq.setServiceInstanceId(servInsReq.getServiceInstanceId()); - } - - if(servInsReq.getVnfInstanceId() != null){ - aq.setVnfId(servInsReq.getVnfInstanceId()); - } - - if(ModelType.service.name().equalsIgnoreCase(requestScope)){ - if(servInsReq.getRequestDetails().getRequestInfo().getInstanceName() != null){ - aq.setServiceInstanceName(requestInfo.getInstanceName()); - } - } - - if(ModelType.network.name().equalsIgnoreCase(requestScope)){ - aq.setNetworkName(servInsReq.getRequestDetails().getRequestInfo().getInstanceName()); - aq.setNetworkType(networkType); - aq.setNetworkId(servInsReq.getNetworkInstanceId()); - } - - if(ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)){ - aq.setVolumeGroupId(servInsReq.getVolumeGroupInstanceId()); - aq.setVolumeGroupName(servInsReq.getRequestDetails().getRequestInfo().getInstanceName()); - aq.setVnfType(vnfType); - - } - - if(ModelType.vfModule.name().equalsIgnoreCase(requestScope)){ - aq.setVfModuleName(requestInfo.getInstanceName()); - aq.setVfModuleModelName(servInsReq.getRequestDetails().getModelInfo().getModelName()); - aq.setVfModuleId(servInsReq.getVfModuleInstanceId()); - aq.setVolumeGroupId(servInsReq.getVolumeGroupInstanceId()); - aq.setVnfType(vnfType); - - } - - if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) { - aq.setConfigurationId(servInsReq.getConfigurationId()); - aq.setConfigurationName(requestInfo.getInstanceName()); - } - if(requestScope.equalsIgnoreCase(ModelType.instanceGroup.name())){ - aq.setInstanceGroupId(servInsReq.getInstanceGroupId()); - aq.setInstanceGroupName(requestInfo.getInstanceName()); - } - if(ModelType.vnf.name().equalsIgnoreCase(requestScope)){ - if (requestInfo != null) { - aq.setVnfName(requestInfo.getInstanceName()); - } - if (null != servInsReq.getRequestDetails()) { - RelatedInstanceList[] instanceList = servInsReq.getRequestDetails().getRelatedInstanceList(); - - if (instanceList != null) { - - for(RelatedInstanceList relatedInstanceList : instanceList){ - - RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); - if(relatedInstance.getModelInfo().getModelType().equals(ModelType.service)){ - aq.setVnfType(vnfType); - } - } - } - } - } + Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis()); + + aq.setStartTime(startTimeStamp); + if (requestScope.equals(ModelType.instanceGroup.name()) && action == Action.deleteInstance) { + aq.setRequestScope(requestScope); + } else { + RequestInfo requestInfo = servInsReq.getRequestDetails().getRequestInfo(); + if (requestInfo != null) { + + if (requestInfo.getSource() != null) { + aq.setSource(requestInfo.getSource()); + } + if (requestInfo.getCallbackUrl() != null) { + aq.setCallBackUrl(requestInfo.getCallbackUrl()); + } + if (requestInfo.getCorrelator() != null) { + aq.setCorrelator(requestInfo.getCorrelator()); + } + + if (requestInfo.getRequestorId() != null) { + aq.setRequestorId(requestInfo.getRequestorId()); + } + } + + if (servInsReq.getRequestDetails().getModelInfo() != null + || (action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig)) { + aq.setRequestScope(requestScope); + } + + if (servInsReq.getRequestDetails().getCloudConfiguration() != null) { + CloudConfiguration cloudConfiguration = servInsReq.getRequestDetails().getCloudConfiguration(); + if (cloudConfiguration.getLcpCloudRegionId() != null) { + aq.setAicCloudRegion(cloudConfiguration.getLcpCloudRegionId()); + } + + if (cloudConfiguration.getTenantId() != null) { + aq.setTenantId(cloudConfiguration.getTenantId()); + } + + } + + if (servInsReq.getServiceInstanceId() != null) { + aq.setServiceInstanceId(servInsReq.getServiceInstanceId()); + } + + if (servInsReq.getVnfInstanceId() != null) { + aq.setVnfId(servInsReq.getVnfInstanceId()); + } + + if (ModelType.service.name().equalsIgnoreCase(requestScope)) { + if (servInsReq.getRequestDetails().getRequestInfo().getInstanceName() != null) { + aq.setServiceInstanceName(requestInfo.getInstanceName()); + } + } + + if (ModelType.network.name().equalsIgnoreCase(requestScope)) { + aq.setNetworkName(servInsReq.getRequestDetails().getRequestInfo().getInstanceName()); + aq.setNetworkType(networkType); + aq.setNetworkId(servInsReq.getNetworkInstanceId()); + } + + if (ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)) { + aq.setVolumeGroupId(servInsReq.getVolumeGroupInstanceId()); + aq.setVolumeGroupName(servInsReq.getRequestDetails().getRequestInfo().getInstanceName()); + aq.setVnfType(vnfType); + + } + + if (ModelType.vfModule.name().equalsIgnoreCase(requestScope)) { + aq.setVfModuleName(requestInfo.getInstanceName()); + aq.setVfModuleModelName(servInsReq.getRequestDetails().getModelInfo().getModelName()); + aq.setVfModuleId(servInsReq.getVfModuleInstanceId()); + aq.setVolumeGroupId(servInsReq.getVolumeGroupInstanceId()); + aq.setVnfType(vnfType); + + } + + if (ModelType.configuration.name().equalsIgnoreCase(requestScope)) { + aq.setConfigurationId(servInsReq.getConfigurationId()); + aq.setConfigurationName(requestInfo.getInstanceName()); + } + if (requestScope.equalsIgnoreCase(ModelType.instanceGroup.name())) { + aq.setInstanceGroupId(servInsReq.getInstanceGroupId()); + aq.setInstanceGroupName(requestInfo.getInstanceName()); + } + if (ModelType.vnf.name().equalsIgnoreCase(requestScope)) { + if (requestInfo != null) { + aq.setVnfName(requestInfo.getInstanceName()); + } + if (null != servInsReq.getRequestDetails()) { + RelatedInstanceList[] instanceList = servInsReq.getRequestDetails().getRelatedInstanceList(); + + if (instanceList != null) { + + for (RelatedInstanceList relatedInstanceList : instanceList) { + + RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + if (relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) { + aq.setVnfType(vnfType); + } + } + } + } + } + } + + aq.setRequestBody(originalRequestJSON); + + aq.setRequestStatus(status.toString()); + aq.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); + } catch (Exception e) { + logger.error("{} {} {}", MessageEnum.APIH_DB_INSERT_EXC.toString(), ErrorCode.DataError.getValue(), + "Exception when creation record request", e); + + if (!status.equals(Status.FAILED)) { + throw e; + } + } + return aq; + } + + public InfraActiveRequests createRequestObject(TasksRequest taskRequest, Action action, String requestId, + Status status, String originalRequestJSON) { + InfraActiveRequests aq = new InfraActiveRequests(); + try { + + org.onap.so.apihandlerinfra.tasksbeans.RequestInfo requestInfo = + taskRequest.getRequestDetails().getRequestInfo(); + aq.setRequestId(requestId); + aq.setRequestAction(action.name()); + aq.setAction(action.name()); + aq.setRequestUrl(MDC.get(LogConstants.HTTP_URL)); + + Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis()); + + aq.setStartTime(startTimeStamp); + if (requestInfo != null) { + + if (requestInfo.getSource() != null) { + aq.setSource(requestInfo.getSource()); + } + + if (requestInfo.getRequestorId() != null) { + aq.setRequestorId(requestInfo.getRequestorId()); + } } - aq.setRequestBody (originalRequestJSON); + aq.setRequestBody(originalRequestJSON); + aq.setRequestStatus(status.toString()); + aq.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); - aq.setRequestStatus (status.toString ()); - aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER); } catch (Exception e) { - logger.error("{} {} {}", MessageEnum.APIH_DB_INSERT_EXC.toString(), ErrorCode.DataError.getValue(), - "Exception when creation record request", e); + logger.error("{} {} {}", MessageEnum.APIH_DB_INSERT_EXC.toString(), ErrorCode.DataError.getValue(), + "Exception when creation record request", e); - if (!status.equals (Status.FAILED)) { + if (!status.equals(Status.FAILED)) { throw e; } } return aq; } - - public InfraActiveRequests createRequestObject (TasksRequest taskRequest, Action action, String requestId, - Status status, String originalRequestJSON) { - InfraActiveRequests aq = new InfraActiveRequests (); - try { - - org.onap.so.apihandlerinfra.tasksbeans.RequestInfo requestInfo = taskRequest.getRequestDetails().getRequestInfo(); - aq.setRequestId (requestId); - aq.setRequestAction(action.name()); - aq.setAction(action.name()); - aq.setRequestUrl(MDC.get(LogConstants.HTTP_URL)); - - Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis()); - - aq.setStartTime (startTimeStamp); - if (requestInfo != null) { - - if(requestInfo.getSource() != null){ - aq.setSource(requestInfo.getSource()); - } - - if(requestInfo.getRequestorId() != null) { - aq.setRequestorId(requestInfo.getRequestorId()); - } - } - - aq.setRequestBody (originalRequestJSON); - aq.setRequestStatus (status.toString ()); - aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER); - - } catch (Exception e) { - logger.error("{} {} {}", MessageEnum.APIH_DB_INSERT_EXC.toString(), ErrorCode.DataError.getValue(), - "Exception when creation record request", e); - - if (!status.equals (Status.FAILED)) { - throw e; - } - } - return aq; - } - - public void createErrorRequestRecord (Status status, String requestId, String errorMessage, Actions action, String requestScope, String requestJSON) { + + public void createErrorRequestRecord(Status status, String requestId, String errorMessage, Actions action, + String requestScope, String requestJSON) { try { InfraActiveRequests request = new InfraActiveRequests(requestId); - Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis()); - request.setStartTime (startTimeStamp); + Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis()); + request.setStartTime(startTimeStamp); request.setRequestStatus(status.toString()); request.setStatusMessage(errorMessage); request.setProgress((long) 100); @@ -458,338 +462,345 @@ public class MsoRequest { request.setRequestBody(requestJSON); Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis()); request.setEndTime(endTimeStamp); - request.setRequestUrl(MDC.get(LogConstants.HTTP_URL)); - requestsDbClient.save(request); + request.setRequestUrl(MDC.get(LogConstants.HTTP_URL)); + requestsDbClient.save(request); } catch (Exception e) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_UPDATE_EXC.toString(), e.getMessage(), - ErrorCode.DataError.getValue(), "Exception when updating record in DB"); - logger.debug("Exception: ", e); - } + logger.error("{} {} {} {}", MessageEnum.APIH_DB_UPDATE_EXC.toString(), e.getMessage(), + ErrorCode.DataError.getValue(), "Exception when updating record in DB"); + logger.debug("Exception: ", e); + } } - - - public Response buildResponse (int httpResponseCode, String errorCode, InfraActiveRequests inProgress) { - return buildResponseWithError (httpResponseCode, errorCode, inProgress, null); + + public Response buildResponse(int httpResponseCode, String errorCode, InfraActiveRequests inProgress) { + return buildResponseWithError(httpResponseCode, errorCode, inProgress, null); } - public Response buildResponseWithError (int httpResponseCode, - String errorCode, - InfraActiveRequests inProgress, - String errorString) { + public Response buildResponseWithError(int httpResponseCode, String errorCode, InfraActiveRequests inProgress, + String errorString) { // Log the failed request into the MSO Requests database - return Response.status (httpResponseCode).entity (null).build (); + return Response.status(httpResponseCode).entity(null).build(); } - public Response buildResponseFailedValidation (int httpResponseCode, String exceptionMessage) { + public Response buildResponseFailedValidation(int httpResponseCode, String exceptionMessage) { - return Response.status (httpResponseCode).entity (null).build (); + return Response.status(httpResponseCode).entity(null).build(); } - - - - public String getServiceType (VnfInputs vnfInputs) { - if (vnfInputs.getServiceType () != null) - return vnfInputs.getServiceType (); - if (vnfInputs.getServiceId () != null) - return vnfInputs.getServiceId (); - return null; + + + + public String getServiceType(VnfInputs vnfInputs) { + if (vnfInputs.getServiceType() != null) + return vnfInputs.getServiceType(); + if (vnfInputs.getServiceId() != null) + return vnfInputs.getServiceId(); + return null; } - public long translateStatus (RequestStatusType status) { + public long translateStatus(RequestStatusType status) { switch (status) { - case FAILED: - case COMPLETE: - return Constants.PROGRESS_REQUEST_COMPLETED; - case IN_PROGRESS: - return Constants.PROGRESS_REQUEST_IN_PROGRESS; - default: - return 0; + case FAILED: + case COMPLETE: + return Constants.PROGRESS_REQUEST_COMPLETED; + case IN_PROGRESS: + return Constants.PROGRESS_REQUEST_IN_PROGRESS; + default: + return 0; } } - public static String domToStr (Document doc) { + public static String domToStr(Document doc) { if (doc == null) { return null; } try { - StringWriter sw = new StringWriter (); - StreamResult sr = new StreamResult (sw); - TransformerFactory tf = TransformerFactory.newInstance (); - tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); - tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET,""); - Transformer t = tf.newTransformer (); - t.setOutputProperty (OutputKeys.STANDALONE, "yes"); - NodeList nl = doc.getDocumentElement ().getChildNodes (); + StringWriter sw = new StringWriter(); + StreamResult sr = new StreamResult(sw); + TransformerFactory tf = TransformerFactory.newInstance(); + tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); + tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); + Transformer t = tf.newTransformer(); + t.setOutputProperty(OutputKeys.STANDALONE, "yes"); + NodeList nl = doc.getDocumentElement().getChildNodes(); DOMSource source = null; - for (int x = 0; x < nl.getLength (); x++) { - Node e = nl.item (x); + for (int x = 0; x < nl.getLength(); x++) { + Node e = nl.item(x); if (e instanceof Element) { - source = new DOMSource (e); + source = new DOMSource(e); break; } } if (source != null) { - t.transform (source, sr); + t.transform(source, sr); - String s = sw.toString (); + String s = sw.toString(); return s; } return null; } catch (Exception e) { - logger.error("{} {} {}", MessageEnum.APIH_DOM2STR_ERROR.toString(), ErrorCode.DataError.getValue(), - "Exception in domToStr", e); - } + logger.error("{} {} {}", MessageEnum.APIH_DOM2STR_ERROR.toString(), ErrorCode.DataError.getValue(), + "Exception in domToStr", e); + } return null; } - public void addBPMNSpecificInputs(VnfRequest vnfReq, VnfInputs vnfInputs, String personaModelId, String personaModelVersion, Boolean isBaseVfModule, - String vnfPersonaModelId, String vnfPersonaModelVersion) { - vnfInputs.setPersonaModelId(personaModelId); - vnfInputs.setPersonaModelVersion(personaModelVersion); - vnfInputs.setIsBaseVfModule(isBaseVfModule); - vnfInputs.setVnfPersonaModelId(vnfPersonaModelId); - vnfInputs.setVnfPersonaModelVersion(vnfPersonaModelVersion); + public void addBPMNSpecificInputs(VnfRequest vnfReq, VnfInputs vnfInputs, String personaModelId, + String personaModelVersion, Boolean isBaseVfModule, String vnfPersonaModelId, + String vnfPersonaModelVersion) { + vnfInputs.setPersonaModelId(personaModelId); + vnfInputs.setPersonaModelVersion(personaModelVersion); + vnfInputs.setIsBaseVfModule(isBaseVfModule); + vnfInputs.setVnfPersonaModelId(vnfPersonaModelId); + vnfInputs.setVnfPersonaModelVersion(vnfPersonaModelVersion); + + vnfReq.setVnfInputs(vnfInputs); - vnfReq.setVnfInputs(vnfInputs); - } private static boolean empty(String s) { - return (s == null || s.trim().isEmpty()); + return (s == null || s.trim().isEmpty()); } - public String getRequestJSON(ServiceInstancesRequest sir) throws JsonGenerationException, JsonMappingException, IOException { - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); - //mapper.configure(Feature.WRAP_ROOT_VALUE, true); - logger.debug ("building sir from object {}", sir); - String requestJSON = mapper.writeValueAsString(sir); - - // Perform mapping from VID-style modelInfo fields to ASDC-style modelInfo fields - - logger.debug("REQUEST JSON before mapping: {}", requestJSON); - // modelUuid = modelVersionId - requestJSON = requestJSON.replaceAll("\"modelVersionId\":","\"modelUuid\":"); - // modelCustomizationUuid = modelCustomizationId - requestJSON = requestJSON.replaceAll("\"modelCustomizationId\":","\"modelCustomizationUuid\":"); - // modelInstanceName = modelCustomizationName - requestJSON = requestJSON.replaceAll("\"modelCustomizationName\":","\"modelInstanceName\":"); - // modelInvariantUuid = modelInvariantId - requestJSON = requestJSON.replaceAll("\"modelInvariantId\":","\"modelInvariantUuid\":"); - logger.debug("REQUEST JSON after mapping: {}", requestJSON); - - return requestJSON; + public String getRequestJSON(ServiceInstancesRequest sir) + throws JsonGenerationException, JsonMappingException, IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + // mapper.configure(Feature.WRAP_ROOT_VALUE, true); + logger.debug("building sir from object {}", sir); + String requestJSON = mapper.writeValueAsString(sir); + + // Perform mapping from VID-style modelInfo fields to ASDC-style modelInfo fields + + logger.debug("REQUEST JSON before mapping: {}", requestJSON); + // modelUuid = modelVersionId + requestJSON = requestJSON.replaceAll("\"modelVersionId\":", "\"modelUuid\":"); + // modelCustomizationUuid = modelCustomizationId + requestJSON = requestJSON.replaceAll("\"modelCustomizationId\":", "\"modelCustomizationUuid\":"); + // modelInstanceName = modelCustomizationName + requestJSON = requestJSON.replaceAll("\"modelCustomizationName\":", "\"modelInstanceName\":"); + // modelInvariantUuid = modelInvariantId + requestJSON = requestJSON.replaceAll("\"modelInvariantId\":", "\"modelInvariantUuid\":"); + logger.debug("REQUEST JSON after mapping: {}", requestJSON); + + return requestJSON; } - public boolean getAlacarteFlag(ServiceInstancesRequest sir) { - if(sir.getRequestDetails().getRequestParameters() != null && - sir.getRequestDetails().getRequestParameters().getALaCarte() != null) - return sir.getRequestDetails().getRequestParameters().getALaCarte(); - - return false; - } + public boolean getAlacarteFlag(ServiceInstancesRequest sir) { + if (sir.getRequestDetails().getRequestParameters() != null + && sir.getRequestDetails().getRequestParameters().getALaCarte() != null) + return sir.getRequestDetails().getRequestParameters().getALaCarte(); + + return false; + } - public String getNetworkType(ServiceInstancesRequest sir, String requestScope) { - if(requestScope.equalsIgnoreCase(ModelType.network.name())) - return sir.getRequestDetails().getModelInfo().getModelName(); - else return null; - } + public String getNetworkType(ServiceInstancesRequest sir, String requestScope) { + if (requestScope.equalsIgnoreCase(ModelType.network.name())) + return sir.getRequestDetails().getModelInfo().getModelName(); + else + return null; + } - public String getServiceInstanceType(ServiceInstancesRequest sir, String requestScope) { - if(requestScope.equalsIgnoreCase(ModelType.network.name())) - return sir.getRequestDetails().getModelInfo().getModelName(); - else return null; - } + public String getServiceInstanceType(ServiceInstancesRequest sir, String requestScope) { + if (requestScope.equalsIgnoreCase(ModelType.network.name())) + return sir.getRequestDetails().getModelInfo().getModelName(); + else + return null; + } - public String getSDCServiceModelVersion(ServiceInstancesRequest sir) { - String sdcServiceModelVersion = null; - if(sir.getRequestDetails().getRelatedInstanceList() != null) - for(RelatedInstanceList relatedInstanceList : sir.getRequestDetails().getRelatedInstanceList()){ - RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); - ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo (); - if(relatedInstanceModelInfo.getModelType().equals(ModelType.service)) - sdcServiceModelVersion = relatedInstanceModelInfo.getModelVersion (); - } + public String getSDCServiceModelVersion(ServiceInstancesRequest sir) { + String sdcServiceModelVersion = null; + if (sir.getRequestDetails().getRelatedInstanceList() != null) + for (RelatedInstanceList relatedInstanceList : sir.getRequestDetails().getRelatedInstanceList()) { + RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo(); + if (relatedInstanceModelInfo.getModelType().equals(ModelType.service)) + sdcServiceModelVersion = relatedInstanceModelInfo.getModelVersion(); + } return sdcServiceModelVersion; - } - - - public String getVfModuleType(ServiceInstancesRequest sir, String requestScope, Actions action, int reqVersion) { - - String serviceInstanceType = null; - String networkType = null; - String vnfType = null; - String vfModuleType = null; - String vfModuleModelName = null; - ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); - RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList(); - String serviceModelName = null; + } + + + public String getVfModuleType(ServiceInstancesRequest sir, String requestScope, Actions action, int reqVersion) { + + String serviceInstanceType = null; + String networkType = null; + String vnfType = null; + String vfModuleType = null; + String vfModuleModelName = null; + ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); + RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList(); + String serviceModelName = null; String vnfModelName = null; String asdcServiceModelVersion = null; String volumeGroupId = null; boolean isRelatedServiceInstancePresent = false; boolean isRelatedVnfInstancePresent = false; - boolean isSourceVnfPresent = false; - boolean isDestinationVnfPresent = false; - boolean isConnectionPointPresent = false; - - if (instanceList != null) { - for(RelatedInstanceList relatedInstanceList : instanceList){ - RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); - ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo (); - - if (action != Action.deleteInstance) { - - if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) { - if(InstanceDirection.source.equals(relatedInstance.getInstanceDirection()) && relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) { - isSourceVnfPresent = true; - } else if(InstanceDirection.destination.equals(relatedInstance.getInstanceDirection()) && - (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) && reqVersion == 6))) { - isDestinationVnfPresent = true; - } - } - - if(ModelType.connectionPoint.equals(relatedInstanceModelInfo.getModelType()) && ModelType.configuration.name().equalsIgnoreCase(requestScope)) { - isConnectionPointPresent = true; - } - } - - - if(relatedInstanceModelInfo.getModelType().equals(ModelType.service)) { - isRelatedServiceInstancePresent = true; - serviceModelName = relatedInstanceModelInfo.getModelName (); - asdcServiceModelVersion = relatedInstanceModelInfo.getModelVersion (); - } else if(relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) && !(ModelType.configuration.name().equalsIgnoreCase(requestScope))) { - isRelatedVnfInstancePresent = true; - vnfModelName = relatedInstanceModelInfo.getModelCustomizationName(); - } else if(relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup)) { - volumeGroupId = relatedInstance.getInstanceId (); - } - } - - if(requestScope.equalsIgnoreCase (ModelType.volumeGroup.name ())) { - serviceInstanceType = serviceModelName; - vnfType = serviceModelName + "/" + vnfModelName; - } - else if(requestScope.equalsIgnoreCase(ModelType.vfModule.name ())) { - vfModuleModelName = modelInfo.getModelName (); - serviceInstanceType = serviceModelName; - vnfType = serviceModelName + "/" + vnfModelName; - vfModuleType = vnfType + "::" + vfModuleModelName; - sir.setVolumeGroupInstanceId (volumeGroupId); - } - else if (requestScope.equalsIgnoreCase (ModelType.vnf.name ())) - vnfType = serviceModelName + "/" + sir.getRequestDetails().getModelInfo().getModelCustomizationName(); - - } - - return vfModuleType; - - } - - public String getVnfType(ServiceInstancesRequest sir, String requestScope, Actions action, int reqVersion) { - - String serviceInstanceType = null; - String networkType = null; - String vnfType = null; - String vfModuleType = null; - String vfModuleModelName = null; - ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); - RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList(); - String serviceModelName = null; + boolean isSourceVnfPresent = false; + boolean isDestinationVnfPresent = false; + boolean isConnectionPointPresent = false; + + if (instanceList != null) { + for (RelatedInstanceList relatedInstanceList : instanceList) { + RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo(); + + if (action != Action.deleteInstance) { + + if (ModelType.configuration.name().equalsIgnoreCase(requestScope)) { + if (InstanceDirection.source.equals(relatedInstance.getInstanceDirection()) + && relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) { + isSourceVnfPresent = true; + } else if (InstanceDirection.destination.equals(relatedInstance.getInstanceDirection()) + && (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) + || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) + && reqVersion == 6))) { + isDestinationVnfPresent = true; + } + } + + if (ModelType.connectionPoint.equals(relatedInstanceModelInfo.getModelType()) + && ModelType.configuration.name().equalsIgnoreCase(requestScope)) { + isConnectionPointPresent = true; + } + } + + + if (relatedInstanceModelInfo.getModelType().equals(ModelType.service)) { + isRelatedServiceInstancePresent = true; + serviceModelName = relatedInstanceModelInfo.getModelName(); + asdcServiceModelVersion = relatedInstanceModelInfo.getModelVersion(); + } else if (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) + && !(ModelType.configuration.name().equalsIgnoreCase(requestScope))) { + isRelatedVnfInstancePresent = true; + vnfModelName = relatedInstanceModelInfo.getModelCustomizationName(); + } else if (relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup)) { + volumeGroupId = relatedInstance.getInstanceId(); + } + } + + if (requestScope.equalsIgnoreCase(ModelType.volumeGroup.name())) { + serviceInstanceType = serviceModelName; + vnfType = serviceModelName + "/" + vnfModelName; + } else if (requestScope.equalsIgnoreCase(ModelType.vfModule.name())) { + vfModuleModelName = modelInfo.getModelName(); + serviceInstanceType = serviceModelName; + vnfType = serviceModelName + "/" + vnfModelName; + vfModuleType = vnfType + "::" + vfModuleModelName; + sir.setVolumeGroupInstanceId(volumeGroupId); + } else if (requestScope.equalsIgnoreCase(ModelType.vnf.name())) + vnfType = serviceModelName + "/" + sir.getRequestDetails().getModelInfo().getModelCustomizationName(); + + } + + return vfModuleType; + + } + + public String getVnfType(ServiceInstancesRequest sir, String requestScope, Actions action, int reqVersion) { + + String serviceInstanceType = null; + String networkType = null; + String vnfType = null; + String vfModuleType = null; + String vfModuleModelName = null; + ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); + RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList(); + String serviceModelName = null; String vnfModelName = null; String asdcServiceModelVersion = null; String volumeGroupId = null; boolean isRelatedServiceInstancePresent = false; boolean isRelatedVnfInstancePresent = false; - boolean isSourceVnfPresent = false; - boolean isDestinationVnfPresent = false; - boolean isConnectionPointPresent = false; - - if (instanceList != null) { - for(RelatedInstanceList relatedInstanceList : instanceList){ - RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); - ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo (); - - if (action != Action.deleteInstance) { - - if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) { - if(InstanceDirection.source.equals(relatedInstance.getInstanceDirection()) && relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) { - isSourceVnfPresent = true; - } else if(InstanceDirection.destination.equals(relatedInstance.getInstanceDirection()) && - (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) && reqVersion == 6))) { - isDestinationVnfPresent = true; - } - } - - if(ModelType.connectionPoint.equals(relatedInstanceModelInfo.getModelType()) && ModelType.configuration.name().equalsIgnoreCase(requestScope)) { - isConnectionPointPresent = true; - } - } - - - if(relatedInstanceModelInfo.getModelType().equals(ModelType.service)) { - isRelatedServiceInstancePresent = true; - serviceModelName = relatedInstanceModelInfo.getModelName (); - asdcServiceModelVersion = relatedInstanceModelInfo.getModelVersion (); - } else if(relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) && !(ModelType.configuration.name().equalsIgnoreCase(requestScope))) { - isRelatedVnfInstancePresent = true; - vnfModelName = relatedInstanceModelInfo.getModelCustomizationName(); - } else if(relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup)) { - volumeGroupId = relatedInstance.getInstanceId (); - } - } - - if(requestScope.equalsIgnoreCase (ModelType.volumeGroup.name ())) { - serviceInstanceType = serviceModelName; - vnfType = serviceModelName + "/" + vnfModelName; - } - else if(requestScope.equalsIgnoreCase(ModelType.vfModule.name ())) { - vfModuleModelName = modelInfo.getModelName (); - serviceInstanceType = serviceModelName; - vnfType = serviceModelName + "/" + vnfModelName; - vfModuleType = vnfType + "::" + vfModuleModelName; - sir.setVolumeGroupInstanceId (volumeGroupId); - } - else if (requestScope.equalsIgnoreCase (ModelType.vnf.name ())) - vnfType = serviceModelName + "/" + sir.getRequestDetails().getModelInfo().getModelCustomizationName(); - - } - - return vnfType; - - } - - public Optional<URL> buildSelfLinkUrl(String url, String requestId) { - Optional<URL> selfLinkUrl = Optional.empty(); - String version = ""; - try { - URL aUrl = new URL(url); - String aPath = aUrl.getPath(); - if (aPath.indexOf("/v") == -1) { - version = aPath.substring(aPath.indexOf("/V"), aPath.indexOf("/V")+4); - } else { - version = aPath.substring(aPath.indexOf("/v"), aPath.indexOf("/v")+4); - } - String selfLinkPath = Constants.ORCHESTRATION_REQUESTS_PATH.concat(version).concat(requestId); - selfLinkUrl = Optional.of(new URL(aUrl.getProtocol(), aUrl.getHost(), aUrl.getPort(), selfLinkPath)); - } catch (Exception e) { - selfLinkUrl = Optional.empty(); // ignore - } - return selfLinkUrl; - } + boolean isSourceVnfPresent = false; + boolean isDestinationVnfPresent = false; + boolean isConnectionPointPresent = false; + + if (instanceList != null) { + for (RelatedInstanceList relatedInstanceList : instanceList) { + RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo(); + + if (action != Action.deleteInstance) { + + if (ModelType.configuration.name().equalsIgnoreCase(requestScope)) { + if (InstanceDirection.source.equals(relatedInstance.getInstanceDirection()) + && relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) { + isSourceVnfPresent = true; + } else if (InstanceDirection.destination.equals(relatedInstance.getInstanceDirection()) + && (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) + || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) + && reqVersion == 6))) { + isDestinationVnfPresent = true; + } + } + + if (ModelType.connectionPoint.equals(relatedInstanceModelInfo.getModelType()) + && ModelType.configuration.name().equalsIgnoreCase(requestScope)) { + isConnectionPointPresent = true; + } + } + + + if (relatedInstanceModelInfo.getModelType().equals(ModelType.service)) { + isRelatedServiceInstancePresent = true; + serviceModelName = relatedInstanceModelInfo.getModelName(); + asdcServiceModelVersion = relatedInstanceModelInfo.getModelVersion(); + } else if (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) + && !(ModelType.configuration.name().equalsIgnoreCase(requestScope))) { + isRelatedVnfInstancePresent = true; + vnfModelName = relatedInstanceModelInfo.getModelCustomizationName(); + } else if (relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup)) { + volumeGroupId = relatedInstance.getInstanceId(); + } + } + + if (requestScope.equalsIgnoreCase(ModelType.volumeGroup.name())) { + serviceInstanceType = serviceModelName; + vnfType = serviceModelName + "/" + vnfModelName; + } else if (requestScope.equalsIgnoreCase(ModelType.vfModule.name())) { + vfModuleModelName = modelInfo.getModelName(); + serviceInstanceType = serviceModelName; + vnfType = serviceModelName + "/" + vnfModelName; + vfModuleType = vnfType + "::" + vfModuleModelName; + sir.setVolumeGroupInstanceId(volumeGroupId); + } else if (requestScope.equalsIgnoreCase(ModelType.vnf.name())) + vnfType = serviceModelName + "/" + sir.getRequestDetails().getModelInfo().getModelCustomizationName(); + + } + + return vnfType; + + } + + public Optional<URL> buildSelfLinkUrl(String url, String requestId) { + Optional<URL> selfLinkUrl = Optional.empty(); + String version = ""; + try { + URL aUrl = new URL(url); + String aPath = aUrl.getPath(); + if (aPath.indexOf("/v") == -1) { + version = aPath.substring(aPath.indexOf("/V"), aPath.indexOf("/V") + 4); + } else { + version = aPath.substring(aPath.indexOf("/v"), aPath.indexOf("/v") + 4); + } + String selfLinkPath = Constants.ORCHESTRATION_REQUESTS_PATH.concat(version).concat(requestId); + selfLinkUrl = Optional.of(new URL(aUrl.getProtocol(), aUrl.getHost(), aUrl.getPort(), selfLinkPath)); + } catch (Exception e) { + selfLinkUrl = Optional.empty(); // ignore + } + return selfLinkUrl; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoSubsystems.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoSubsystems.java index cfdce473a4..fd0df1d2b0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoSubsystems.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoSubsystems.java @@ -20,23 +20,19 @@ package org.onap.so.apihandlerinfra; public enum MsoSubsystems { - APIH ("API Handler"), - ASDC ("ASDC Controller"), - BPMN ("BPMN Infra"), - CATALOGDB ("CatalogDb Adapter"), - OPENSTACK ("Openstack Adapter"), - REQUESTDB ("RequestDB Adapter"), - REQUESTDBATT ("RequestDB Adapter ATT Svc"), - SDNC ("SDNC Adapter"); - private String subsystem; - private MsoSubsystems(String subsystem){ - this.subsystem = subsystem; - } - - @Override - public String toString(){ - return subsystem; - } - + APIH("API Handler"), ASDC("ASDC Controller"), BPMN("BPMN Infra"), CATALOGDB("CatalogDb Adapter"), OPENSTACK( + "Openstack Adapter"), REQUESTDB( + "RequestDB Adapter"), REQUESTDBATT("RequestDB Adapter ATT Svc"), SDNC("SDNC Adapter"); + private String subsystem; + + private MsoSubsystems(String subsystem) { + this.subsystem = subsystem; + } + + @Override + public String toString() { + return subsystem; + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/NodeHealthcheckHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/NodeHealthcheckHandler.java index 351a35826d..9810895ad9 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/NodeHealthcheckHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/NodeHealthcheckHandler.java @@ -23,7 +23,6 @@ package org.onap.so.apihandlerinfra; import java.net.UnknownHostException; - import javax.transaction.Transactional; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -31,34 +30,31 @@ import javax.ws.rs.Produces; import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; - import org.apache.http.HttpStatus; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @Path("/nodehealthcheck") -@Api(value="/nodehealthcheck",description="API Handler Infra Node Health Check") +@Api(value = "/nodehealthcheck", description = "API Handler Infra Node Health Check") @Component public class NodeHealthcheckHandler { private static Logger logger = LoggerFactory.getLogger(NodeHealthcheckHandler.class); - - private static final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>"; - public static final Response HEALTH_CHECK_RESPONSE = Response.status (HttpStatus.SC_OK) - .entity (CHECK_HTML) - .build (); - + private static final String CHECK_HTML = + "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>"; + + public static final Response HEALTH_CHECK_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build(); + @GET @Produces("text/html") - @ApiOperation(value="Performing node health check",response=Response.class) + @ApiOperation(value = "Performing node health check", response = Response.class) @Transactional - public Response nodeHealthcheck (@Context ContainerRequestContext requestContext) throws UnknownHostException { + public Response nodeHealthcheck(@Context ContainerRequestContext requestContext) throws UnknownHostException { // Generated RequestId String requestId = requestContext.getProperty("requestId").toString(); logger.info("{} {}", MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java index f613d3e193..34dcd4b0c4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java @@ -28,7 +28,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import javax.transaction.Transactional; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -41,14 +40,12 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; - import org.apache.commons.lang.StringUtils; import org.apache.http.HttpStatus; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandler.common.ResponseBuilder; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; - import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.RequestProcessingData; @@ -56,7 +53,6 @@ import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; - import org.onap.so.serviceinstancebeans.GetOrchestrationListResponse; import org.onap.so.serviceinstancebeans.GetOrchestrationResponse; import org.onap.so.serviceinstancebeans.InstanceReferences; @@ -69,365 +65,397 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import com.fasterxml.jackson.databind.ObjectMapper; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @Path("onap/so/infra/orchestrationRequests") -@Api(value="onap/so/infra/orchestrationRequests",description="API Requests for Orchestration requests") +@Api(value = "onap/so/infra/orchestrationRequests", description = "API Requests for Orchestration requests") @Component public class OrchestrationRequests { private static Logger logger = LoggerFactory.getLogger(OrchestrationRequests.class); - + @Autowired - private RequestsDbClient requestsDbClient; + private RequestsDbClient requestsDbClient; @Autowired private MsoRequest msoRequest; - - @Autowired - private ResponseBuilder builder; - @GET - @Path("/{version:[vV][4-7]}/{requestId}") - @ApiOperation(value="Find Orchestrated Requests for a given requestId",response=Response.class) - @Produces(MediaType.APPLICATION_JSON) - @Transactional - public Response getOrchestrationRequest(@PathParam("requestId") String requestId, @PathParam("version") String version) throws ApiException{ + @Autowired + private ResponseBuilder builder; + + @GET + @Path("/{version:[vV][4-7]}/{requestId}") + @ApiOperation(value = "Find Orchestrated Requests for a given requestId", response = Response.class) + @Produces(MediaType.APPLICATION_JSON) + @Transactional + public Response getOrchestrationRequest(@PathParam("requestId") String requestId, + @PathParam("version") String version) throws ApiException { - String apiVersion = version.substring(1); - GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse(); + String apiVersion = version.substring(1); + GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse(); - InfraActiveRequests infraActiveRequest = null; - List<org.onap.so.db.request.beans.RequestProcessingData> requestProcessingData = null; - try { - infraActiveRequest = requestsDbClient.getInfraActiveRequestbyRequestId(requestId); - requestProcessingData = requestsDbClient.getRequestProcessingDataBySoRequestId(requestId); + InfraActiveRequests infraActiveRequest = null; + List<org.onap.so.db.request.beans.RequestProcessingData> requestProcessingData = null; + try { + infraActiveRequest = requestsDbClient.getInfraActiveRequestbyRequestId(requestId); + requestProcessingData = requestsDbClient.getRequestProcessingDataBySoRequestId(requestId); - } catch (Exception e) { - logger.error("Exception occurred", e); - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.AvailabilityError).build(); + } catch (Exception e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.AvailabilityError).build(); + ValidateException validateException = + new ValidateException.Builder("Exception while communciate with Request DB - Infra Request Lookup", + HttpStatus.SC_NOT_FOUND, ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB).cause(e) + .errorInfo(errorLoggerInfo).build(); - ValidateException validateException = new ValidateException.Builder("Exception while communciate with Request DB - Infra Request Lookup", - HttpStatus.SC_NOT_FOUND,ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB).cause(e).errorInfo(errorLoggerInfo).build(); + throw validateException; - throw validateException; + } - } - - if(infraActiveRequest == null) { + if (infraActiveRequest == null) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.BusinessProcesssError).build(); + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, + ErrorCode.BusinessProcesssError).build(); - ValidateException validateException = new ValidateException.Builder("Orchestration RequestId " + requestId + " is not found in DB", - HttpStatus.SC_NO_CONTENT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); + ValidateException validateException = + new ValidateException.Builder("Orchestration RequestId " + requestId + " is not found in DB", + HttpStatus.SC_NO_CONTENT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR) + .errorInfo(errorLoggerInfo).build(); throw validateException; } - + Request request = mapInfraActiveRequestToRequest(infraActiveRequest); - if(!requestProcessingData.isEmpty()){ + if (!requestProcessingData.isEmpty()) { request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData)); } - request.setRequestId(requestId); + request.setRequestId(requestId); orchestrationResponse.setRequest(request); - + return builder.buildResponse(HttpStatus.SC_OK, requestId, orchestrationResponse, apiVersion); - } - - @GET - @Path("/{version:[vV][4-7]}") - @ApiOperation(value="Find Orchestrated Requests for a URI Information",response=Response.class) - @Produces(MediaType.APPLICATION_JSON) - @Transactional - public Response getOrchestrationRequest(@Context UriInfo ui, @PathParam("version") String version) throws ApiException{ - - long startTime = System.currentTimeMillis (); - - MultivaluedMap<String, String> queryParams = ui.getQueryParameters(); - - List<InfraActiveRequests> activeRequests = null; - - GetOrchestrationListResponse orchestrationList = null; - Map<String, List<String>> orchestrationMap; - String apiVersion = version.substring(1); - - try { - orchestrationMap = msoRequest.getOrchestrationFilters(queryParams); - if (orchestrationMap.isEmpty()) { - throw new ValidationException("At least one filter query param must be specified"); - } - }catch(ValidationException ex){ - logger.error("Exception occurred", ex); - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.DataError).build(); - ValidateException validateException = new ValidateException.Builder(ex.getMessage(), - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).cause(ex).errorInfo(errorLoggerInfo).build(); - throw validateException; - - } - - activeRequests = requestsDbClient.getOrchestrationFiltersFromInfraActive(orchestrationMap); - - orchestrationList = new GetOrchestrationListResponse(); - List<RequestList> requestLists = new ArrayList<>(); - - for(InfraActiveRequests infraActive : activeRequests){ - List<RequestProcessingData> requestProcessingData = requestsDbClient.getRequestProcessingDataBySoRequestId(infraActive.getRequestId()); - RequestList requestList = new RequestList(); - Request request = mapInfraActiveRequestToRequest(infraActive); - if(!requestProcessingData.isEmpty()){ - request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData)); - } - requestList.setRequest(request); - requestLists.add(requestList); - } - - orchestrationList.setRequestList(requestLists); - return builder.buildResponse(HttpStatus.SC_OK, null, orchestrationList, apiVersion); - } - - - @POST - @Path("/{version: [vV][4-7]}/{requestId}/unlock") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Unlock Orchestrated Requests for a given requestId",response=Response.class) - @Transactional - public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId, @PathParam("version") String version) throws ApiException{ - - long startTime = System.currentTimeMillis (); - logger.debug ("requestId is: {}", requestId); - ServiceInstancesRequest sir = null; - - InfraActiveRequests infraActiveRequest = null; - Request request = null; - - try{ - ObjectMapper mapper = new ObjectMapper(); - sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); - } catch(IOException e){ - logger.error("Exception occurred", e); - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).build(); - ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(), - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); + } + + @GET + @Path("/{version:[vV][4-7]}") + @ApiOperation(value = "Find Orchestrated Requests for a URI Information", response = Response.class) + @Produces(MediaType.APPLICATION_JSON) + @Transactional + public Response getOrchestrationRequest(@Context UriInfo ui, @PathParam("version") String version) + throws ApiException { + + long startTime = System.currentTimeMillis(); + + MultivaluedMap<String, String> queryParams = ui.getQueryParameters(); + + List<InfraActiveRequests> activeRequests = null; + + GetOrchestrationListResponse orchestrationList = null; + Map<String, List<String>> orchestrationMap; + String apiVersion = version.substring(1); + + try { + orchestrationMap = msoRequest.getOrchestrationFilters(queryParams); + if (orchestrationMap.isEmpty()) { + throw new ValidationException("At least one filter query param must be specified"); + } + } catch (ValidationException ex) { + logger.error("Exception occurred", ex); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.DataError).build(); + ValidateException validateException = + new ValidateException.Builder(ex.getMessage(), HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).cause(ex).errorInfo(errorLoggerInfo).build(); + throw validateException; + + } + + activeRequests = requestsDbClient.getOrchestrationFiltersFromInfraActive(orchestrationMap); + + orchestrationList = new GetOrchestrationListResponse(); + List<RequestList> requestLists = new ArrayList<>(); + + for (InfraActiveRequests infraActive : activeRequests) { + List<RequestProcessingData> requestProcessingData = + requestsDbClient.getRequestProcessingDataBySoRequestId(infraActive.getRequestId()); + RequestList requestList = new RequestList(); + Request request = mapInfraActiveRequestToRequest(infraActive); + if (!requestProcessingData.isEmpty()) { + request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData)); + } + requestList.setRequest(request); + requestLists.add(requestList); + } + + orchestrationList.setRequestList(requestLists); + return builder.buildResponse(HttpStatus.SC_OK, null, orchestrationList, apiVersion); + } + + + @POST + @Path("/{version: [vV][4-7]}/{requestId}/unlock") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Unlock Orchestrated Requests for a given requestId", response = Response.class) + @Transactional + public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId, + @PathParam("version") String version) throws ApiException { + + long startTime = System.currentTimeMillis(); + logger.debug("requestId is: {}", requestId); + ServiceInstancesRequest sir = null; + + InfraActiveRequests infraActiveRequest = null; + Request request = null; + + try { + ObjectMapper mapper = new ObjectMapper(); + sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + } catch (IOException e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .build(); + ValidateException validateException = + new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(), + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); throw validateException; - } - try{ - msoRequest.parseOrchestration(sir); - } catch (Exception e) { - logger.error("Exception occurred", e); - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).build(); - ValidateException validateException = new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) - .errorInfo(errorLoggerInfo).build(); + } + try { + msoRequest.parseOrchestration(sir); + } catch (Exception e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .build(); + ValidateException validateException = + new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); + throw validateException; + } + + infraActiveRequest = requestsDbClient.getInfraActiveRequestbyRequestId(requestId); + if (infraActiveRequest == null) { + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, + ErrorCode.BusinessProcesssError).build(); + + + ValidateException validateException = + new ValidateException.Builder("Null response from RequestDB when searching by RequestId", + HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo) + .build(); + throw validateException; - } - - infraActiveRequest = requestsDbClient.getInfraActiveRequestbyRequestId(requestId); - if(infraActiveRequest == null) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.BusinessProcesssError).build(); - - - ValidateException validateException = new ValidateException.Builder("Null response from RequestDB when searching by RequestId", - HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); - - throw validateException; - - }else{ - String status = infraActiveRequest.getRequestStatus(); - if(status.equalsIgnoreCase("IN_PROGRESS") || status.equalsIgnoreCase("PENDING") || status.equalsIgnoreCase("PENDING_MANUAL_TASK")){ - infraActiveRequest.setRequestStatus("UNLOCKED"); - infraActiveRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); - infraActiveRequest.setRequestId(requestId); - requestsDbClient.save(infraActiveRequest); - }else{ - - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.DataError).build(); - - - ValidateException validateException = new ValidateException.Builder("Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked", - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); - - throw validateException; - } - } - return Response.status (HttpStatus.SC_NO_CONTENT).entity ("").build (); - } - - private Request mapInfraActiveRequestToRequest(InfraActiveRequests iar) throws ApiException{ - - String requestBody = iar.getRequestBody(); - Request request = new Request(); - - ObjectMapper mapper = new ObjectMapper(); - - request.setRequestId(iar.getRequestId()); - request.setRequestScope(iar.getRequestScope()); - request.setRequestType(iar.getRequestAction()); - String rollbackStatusMessage = iar.getRollbackStatusMessage(); - String flowStatusMessage = iar.getFlowStatus(); - String retryStatusMessage = iar.getRetryStatusMessage(); - - - InstanceReferences ir = new InstanceReferences(); - if(iar.getNetworkId() != null) - ir.setNetworkInstanceId(iar.getNetworkId()); - if(iar.getNetworkName() != null) - ir.setNetworkInstanceName(iar.getNetworkName()); - if(iar.getServiceInstanceId() != null) - ir.setServiceInstanceId(iar.getServiceInstanceId()); - if(iar.getServiceInstanceName() != null) - ir.setServiceInstanceName(iar.getServiceInstanceName()); - if(iar.getVfModuleId() != null) - ir.setVfModuleInstanceId(iar.getVfModuleId()); - if(iar.getVfModuleName() != null) - ir.setVfModuleInstanceName(iar.getVfModuleName()); - if(iar.getVnfId() != null) - ir.setVnfInstanceId(iar.getVnfId()); - if(iar.getVnfName() != null) - ir.setVnfInstanceName(iar.getVnfName()); - if(iar.getVolumeGroupId() != null) - ir.setVolumeGroupInstanceId(iar.getVolumeGroupId()); - if(iar.getVolumeGroupName() != null) - ir.setVolumeGroupInstanceName(iar.getVolumeGroupName()); - if(iar.getRequestorId() != null) - ir.setRequestorId(iar.getRequestorId()); - if(iar.getInstanceGroupId() != null) - ir.setInstanceGroupId(iar.getInstanceGroupId()); - if(iar.getInstanceGroupName() != null) - ir.setInstanceGroupName(iar.getInstanceGroupName()); - - - - request.setInstanceReferences(ir); - - RequestDetails requestDetails = null; - - if(StringUtils.isNotBlank(requestBody)) { - try { - if(requestBody.contains("\"requestDetails\":")){ - ServiceInstancesRequest sir = mapper.readValue(requestBody, ServiceInstancesRequest.class); - requestDetails = sir.getRequestDetails(); - } else { - requestDetails = mapper.readValue(requestBody, RequestDetails.class); - } - } catch (IOException e) { - logger.error("Exception occurred", e); - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).build(); - ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : ", - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); - - throw validateException; - } - } - request.setRequestDetails(requestDetails); - - if(iar.getStartTime() != null) { - String startTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getStartTime()) + " GMT"; - request.setStartTime(startTimeStamp); - } - if(iar.getEndTime() != null){ - String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getEndTime()) + " GMT"; - request.setFinishTime(endTimeStamp); - } - String statusMessages = null; - RequestStatus status = new RequestStatus(); - if(iar.getStatusMessage() != null){ - statusMessages = "STATUS: " + iar.getStatusMessage(); - } - if(flowStatusMessage != null){ - if(statusMessages != null){ - statusMessages = statusMessages + " " + "FLOW STATUS: " + flowStatusMessage; - }else{ - statusMessages = "FLOW STATUS: " + flowStatusMessage; - } - } - if(retryStatusMessage != null){ - if(statusMessages != null){ - statusMessages = statusMessages + " " + "RETRY STATUS: " + retryStatusMessage; - }else{ - statusMessages = "RETRY STATUS: " + retryStatusMessage; - } - } - if(rollbackStatusMessage != null){ - if(statusMessages != null){ - statusMessages = statusMessages + " " + "ROLLBACK STATUS: " + rollbackStatusMessage; - }else{ - statusMessages = "ROLLBACK STATUS: " + rollbackStatusMessage; - } - } - if(statusMessages != null){ - status.setStatusMessage(statusMessages); - } - if(iar.getModifyTime() != null){ - String timeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getModifyTime()) + " GMT"; - status.setTimeStamp(timeStamp); - } - - - if(iar.getRequestStatus() != null){ - status.setRequestState(iar.getRequestStatus()); - } - - if(iar.getProgress() != null){ - status.setPercentProgress(iar.getProgress().intValue()); - } - - request.setRequestStatus(status); - - return request; - } - - public List<org.onap.so.serviceinstancebeans.RequestProcessingData> mapRequestProcessingData(List<org.onap.so.db.request.beans.RequestProcessingData> processingData){ - List<org.onap.so.serviceinstancebeans.RequestProcessingData> addedRequestProcessingData = new ArrayList<>(); - org.onap.so.serviceinstancebeans.RequestProcessingData finalProcessingData = new org.onap.so.serviceinstancebeans.RequestProcessingData(); - String currentGroupingId = null; - HashMap<String, String> tempMap = new HashMap<>(); - List<HashMap<String, String>> tempList = new ArrayList<>(); - for(RequestProcessingData data : processingData){ - String groupingId = data.getGroupingId(); - String tag = data.getTag(); - if(currentGroupingId == null || !currentGroupingId.equals(groupingId)){ - if(!tempMap.isEmpty()){ - tempList.add(tempMap); - finalProcessingData.setDataPairs(tempList); - addedRequestProcessingData.add(finalProcessingData); - } - finalProcessingData = new org.onap.so.serviceinstancebeans.RequestProcessingData(); - if(groupingId != null){ - finalProcessingData.setGroupingId(groupingId); - } - if(tag != null){ - finalProcessingData.setTag(tag); - } - currentGroupingId = groupingId; - tempMap = new HashMap<>(); - tempList = new ArrayList<>(); - if(data.getName() != null && data.getValue() != null){ - tempMap.put(data.getName(), data.getValue()); - } - }else{ - if(data.getName() != null && data.getValue() != null){ - tempMap.put(data.getName(), data.getValue()); - } - } - } - if(tempMap.size() > 0){ - tempList.add(tempMap); - finalProcessingData.setDataPairs(tempList); - } - addedRequestProcessingData.add(finalProcessingData); - return addedRequestProcessingData; - } - } + + } else { + String status = infraActiveRequest.getRequestStatus(); + if (status.equalsIgnoreCase("IN_PROGRESS") || status.equalsIgnoreCase("PENDING") + || status.equalsIgnoreCase("PENDING_MANUAL_TASK")) { + infraActiveRequest.setRequestStatus("UNLOCKED"); + infraActiveRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); + infraActiveRequest.setRequestId(requestId); + requestsDbClient.save(infraActiveRequest); + } else { + + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.DataError) + .build(); + + + ValidateException validateException = new ValidateException.Builder( + "Orchestration RequestId " + requestId + " has a status of " + status + + " and can not be unlocked", + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo) + .build(); + + throw validateException; + } + } + return Response.status(HttpStatus.SC_NO_CONTENT).entity("").build(); + } + + private Request mapInfraActiveRequestToRequest(InfraActiveRequests iar) throws ApiException { + + String requestBody = iar.getRequestBody(); + Request request = new Request(); + + ObjectMapper mapper = new ObjectMapper(); + + request.setRequestId(iar.getRequestId()); + request.setRequestScope(iar.getRequestScope()); + request.setRequestType(iar.getRequestAction()); + String rollbackStatusMessage = iar.getRollbackStatusMessage(); + String flowStatusMessage = iar.getFlowStatus(); + String retryStatusMessage = iar.getRetryStatusMessage(); + + + InstanceReferences ir = new InstanceReferences(); + if (iar.getNetworkId() != null) + ir.setNetworkInstanceId(iar.getNetworkId()); + if (iar.getNetworkName() != null) + ir.setNetworkInstanceName(iar.getNetworkName()); + if (iar.getServiceInstanceId() != null) + ir.setServiceInstanceId(iar.getServiceInstanceId()); + if (iar.getServiceInstanceName() != null) + ir.setServiceInstanceName(iar.getServiceInstanceName()); + if (iar.getVfModuleId() != null) + ir.setVfModuleInstanceId(iar.getVfModuleId()); + if (iar.getVfModuleName() != null) + ir.setVfModuleInstanceName(iar.getVfModuleName()); + if (iar.getVnfId() != null) + ir.setVnfInstanceId(iar.getVnfId()); + if (iar.getVnfName() != null) + ir.setVnfInstanceName(iar.getVnfName()); + if (iar.getVolumeGroupId() != null) + ir.setVolumeGroupInstanceId(iar.getVolumeGroupId()); + if (iar.getVolumeGroupName() != null) + ir.setVolumeGroupInstanceName(iar.getVolumeGroupName()); + if (iar.getRequestorId() != null) + ir.setRequestorId(iar.getRequestorId()); + if (iar.getInstanceGroupId() != null) + ir.setInstanceGroupId(iar.getInstanceGroupId()); + if (iar.getInstanceGroupName() != null) + ir.setInstanceGroupName(iar.getInstanceGroupName()); + + + + request.setInstanceReferences(ir); + + RequestDetails requestDetails = null; + + if (StringUtils.isNotBlank(requestBody)) { + try { + if (requestBody.contains("\"requestDetails\":")) { + ServiceInstancesRequest sir = mapper.readValue(requestBody, ServiceInstancesRequest.class); + requestDetails = sir.getRequestDetails(); + } else { + requestDetails = mapper.readValue(requestBody, RequestDetails.class); + } + } catch (IOException e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .build(); + ValidateException validateException = + new ValidateException.Builder("Mapping of request to JSON object failed : ", + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); + + throw validateException; + } + } + request.setRequestDetails(requestDetails); + + if (iar.getStartTime() != null) { + String startTimeStamp = + new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getStartTime()) + " GMT"; + request.setStartTime(startTimeStamp); + } + if (iar.getEndTime() != null) { + String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getEndTime()) + " GMT"; + request.setFinishTime(endTimeStamp); + } + String statusMessages = null; + RequestStatus status = new RequestStatus(); + if (iar.getStatusMessage() != null) { + statusMessages = "STATUS: " + iar.getStatusMessage(); + } + if (flowStatusMessage != null) { + if (statusMessages != null) { + statusMessages = statusMessages + " " + "FLOW STATUS: " + flowStatusMessage; + } else { + statusMessages = "FLOW STATUS: " + flowStatusMessage; + } + } + if (retryStatusMessage != null) { + if (statusMessages != null) { + statusMessages = statusMessages + " " + "RETRY STATUS: " + retryStatusMessage; + } else { + statusMessages = "RETRY STATUS: " + retryStatusMessage; + } + } + if (rollbackStatusMessage != null) { + if (statusMessages != null) { + statusMessages = statusMessages + " " + "ROLLBACK STATUS: " + rollbackStatusMessage; + } else { + statusMessages = "ROLLBACK STATUS: " + rollbackStatusMessage; + } + } + if (statusMessages != null) { + status.setStatusMessage(statusMessages); + } + if (iar.getModifyTime() != null) { + String timeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getModifyTime()) + " GMT"; + status.setTimeStamp(timeStamp); + } + + + if (iar.getRequestStatus() != null) { + status.setRequestState(iar.getRequestStatus()); + } + + if (iar.getProgress() != null) { + status.setPercentProgress(iar.getProgress().intValue()); + } + + request.setRequestStatus(status); + + return request; + } + + public List<org.onap.so.serviceinstancebeans.RequestProcessingData> mapRequestProcessingData( + List<org.onap.so.db.request.beans.RequestProcessingData> processingData) { + List<org.onap.so.serviceinstancebeans.RequestProcessingData> addedRequestProcessingData = new ArrayList<>(); + org.onap.so.serviceinstancebeans.RequestProcessingData finalProcessingData = + new org.onap.so.serviceinstancebeans.RequestProcessingData(); + String currentGroupingId = null; + HashMap<String, String> tempMap = new HashMap<>(); + List<HashMap<String, String>> tempList = new ArrayList<>(); + for (RequestProcessingData data : processingData) { + String groupingId = data.getGroupingId(); + String tag = data.getTag(); + if (currentGroupingId == null || !currentGroupingId.equals(groupingId)) { + if (!tempMap.isEmpty()) { + tempList.add(tempMap); + finalProcessingData.setDataPairs(tempList); + addedRequestProcessingData.add(finalProcessingData); + } + finalProcessingData = new org.onap.so.serviceinstancebeans.RequestProcessingData(); + if (groupingId != null) { + finalProcessingData.setGroupingId(groupingId); + } + if (tag != null) { + finalProcessingData.setTag(tag); + } + currentGroupingId = groupingId; + tempMap = new HashMap<>(); + tempList = new ArrayList<>(); + if (data.getName() != null && data.getValue() != null) { + tempMap.put(data.getName(), data.getValue()); + } + } else { + if (data.getName() != null && data.getValue() != null) { + tempMap.put(data.getName(), data.getValue()); + } + } + } + if (tempMap.size() > 0) { + tempList.add(tempMap); + finalProcessingData.setDataPairs(tempList); + } + addedRequestProcessingData.add(finalProcessingData); + return addedRequestProcessingData; + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RecipeLookupResult.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RecipeLookupResult.java index 83d270552d..8f7403a7f9 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RecipeLookupResult.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RecipeLookupResult.java @@ -27,35 +27,35 @@ public class RecipeLookupResult { private int recipeTimeout; // the service recipe param. private String recipeParamXsd; - + public RecipeLookupResult(String orchestrationURI, int recipeTimeout) { - this.orchestrationURI = orchestrationURI; - this.recipeTimeout = recipeTimeout; + this.orchestrationURI = orchestrationURI; + this.recipeTimeout = recipeTimeout; } - + public RecipeLookupResult(String orchestrationURI, int recipeTimeout, String recipeParamXsd) { this.orchestrationURI = orchestrationURI; this.recipeTimeout = recipeTimeout; this.recipeParamXsd = recipeParamXsd; } - - public String getOrchestrationURI () { - return orchestrationURI; + + public String getOrchestrationURI() { + return orchestrationURI; } - - public void setOrchestrationURI (String orchestrationURI) { - this.orchestrationURI = orchestrationURI; + + public void setOrchestrationURI(String orchestrationURI) { + this.orchestrationURI = orchestrationURI; } - - public int getRecipeTimeout () { - return recipeTimeout; + + public int getRecipeTimeout() { + return recipeTimeout; } - - public void setRecipeTimeout (int recipeTimeout) { - this.recipeTimeout = recipeTimeout; + + public void setRecipeTimeout(int recipeTimeout) { + this.recipeTimeout = recipeTimeout; } - + /** * @return Returns the recipeParamXsd. */ @@ -63,14 +63,14 @@ public class RecipeLookupResult { return recipeParamXsd; } - + /** * @param recipeParamXsd The recipeParamXsd to set. */ public void setRecipeParamXsd(String recipeParamXsd) { this.recipeParamXsd = recipeParamXsd; } - - + + } - + diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestActionMap.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestActionMap.java index 86dd048120..c97c80901e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestActionMap.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestActionMap.java @@ -25,7 +25,7 @@ import java.util.Map; /* * Map of actions to RequestActions -*/ + */ public class RequestActionMap { private static final Map<String, String> actionMap; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java index c02b40aeca..bbcc120ab6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java @@ -26,7 +26,6 @@ package org.onap.so.apihandlerinfra; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.ObjectMapper; - import org.apache.commons.lang.StringUtils; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; @@ -77,14 +76,11 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import org.springframework.web.client.HttpStatusCodeException; import org.springframework.web.client.RestTemplate; - import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.xml.bind.DatatypeConverter; - import static org.onap.so.logger.HttpHeadersConstants.REQUESTOR_ID; - import java.io.IOException; import java.net.URL; import java.security.GeneralSecurityException; @@ -98,470 +94,532 @@ import java.util.Optional; @Component public class RequestHandlerUtils { - private static Logger logger = LoggerFactory.getLogger(RequestHandlerUtils.class); - - private static final String SAVE_TO_DB = "save instance to db"; - - @Autowired - private Environment env; - - @Autowired - private RequestClientFactory reqClientFactory; - - @Autowired - private RequestsDbClient infraActiveRequestsClient; - - @Autowired - private ResponseBuilder builder; - - @Autowired - private MsoRequest msoRequest; - - @Autowired - private RestTemplate restTemplate; - - @Autowired - private CatalogDbClient catalogDbClient; - - public Response postBPELRequest(InfraActiveRequests currentActiveReq, RequestClientParameter requestClientParameter, String orchestrationUri, String requestScope)throws ApiException { - RequestClient requestClient = null; - HttpResponse response = null; - try { - requestClient = reqClientFactory.getRequestClient (orchestrationUri); - response = requestClient.post(requestClientParameter); - } catch (Exception e) { - - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + private static Logger logger = LoggerFactory.getLogger(RequestHandlerUtils.class); + + private static final String SAVE_TO_DB = "save instance to db"; + + @Autowired + private Environment env; + + @Autowired + private RequestClientFactory reqClientFactory; + + @Autowired + private RequestsDbClient infraActiveRequestsClient; + + @Autowired + private ResponseBuilder builder; + + @Autowired + private MsoRequest msoRequest; + + @Autowired + private RestTemplate restTemplate; + + @Autowired + private CatalogDbClient catalogDbClient; + + public Response postBPELRequest(InfraActiveRequests currentActiveReq, RequestClientParameter requestClientParameter, + String orchestrationUri, String requestScope) throws ApiException { + RequestClient requestClient = null; + HttpResponse response = null; + try { + requestClient = reqClientFactory.getRequestClient(orchestrationUri); + response = requestClient.post(requestClientParameter); + } catch (Exception e) { + + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); String url = requestClient != null ? requestClient.getUrl() : ""; - ClientConnectionException clientException = new ClientConnectionException.Builder(url, HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).cause(e).errorInfo(errorLoggerInfo).build(); + ClientConnectionException clientException = + new ClientConnectionException.Builder(url, HttpStatus.SC_BAD_GATEWAY, + ErrorNumbers.SVC_NO_SERVER_RESOURCES).cause(e).errorInfo(errorLoggerInfo).build(); updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage()); throw clientException; - } + } + + if (response == null) { - if (response == null) { - - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.BusinessProcesssError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - ClientConnectionException clientException = new ClientConnectionException.Builder(requestClient.getUrl(), HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo).build(); + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, + ErrorCode.BusinessProcesssError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + ClientConnectionException clientException = new ClientConnectionException.Builder(requestClient.getUrl(), + HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo).build(); updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage()); throw clientException; - } + } - ResponseHandler respHandler = null; + ResponseHandler respHandler = null; int bpelStatus = 500; try { - respHandler = new ResponseHandler (response, requestClient.getType ()); - bpelStatus = respHandler.getStatus (); + respHandler = new ResponseHandler(response, requestClient.getType()); + bpelStatus = respHandler.getStatus(); } catch (ApiException e) { logger.error("Exception occurred", e); - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) - .errorInfo(errorLoggerInfo).build(); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + ValidateException validateException = + new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); + updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); + throw validateException; + } + + // BPEL accepted the request, the request is in progress + if (bpelStatus == HttpStatus.SC_ACCEPTED) { + ServiceInstancesResponse jsonResponse; + CamundaResponse camundaResp = respHandler.getResponse(); + + if ("Success".equalsIgnoreCase(camundaResp.getMessage())) { + try { + ObjectMapper mapper = new ObjectMapper(); + jsonResponse = mapper.readValue(camundaResp.getResponse(), ServiceInstancesResponse.class); + jsonResponse.getRequestReferences().setRequestId(requestClientParameter.getRequestId()); + Optional<URL> selfLinkUrl = msoRequest.buildSelfLinkUrl(currentActiveReq.getRequestUrl(), + requestClientParameter.getRequestId()); + if (selfLinkUrl.isPresent()) { + jsonResponse.getRequestReferences().setRequestSelfLink(selfLinkUrl.get()); + } else { + jsonResponse.getRequestReferences().setRequestSelfLink(null); + } + } catch (IOException e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + ValidateException validateException = + new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", + HttpStatus.SC_NOT_ACCEPTABLE, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); + updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); + throw validateException; + } + return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestClientParameter.getRequestId(), + jsonResponse, requestClientParameter.getApiVersion()); + } + } + + List<String> variables = new ArrayList<>(); + variables.add(bpelStatus + ""); + String camundaJSONResponseBody = respHandler.getResponseBody(); + if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty()) { + + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError) + .errorSource(requestClient.getUrl()).build(); + BPMNFailureException bpmnException = + new BPMNFailureException.Builder(String.valueOf(bpelStatus) + camundaJSONResponseBody, bpelStatus, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); + + updateStatus(currentActiveReq, Status.FAILED, bpmnException.getMessage()); + + throw bpmnException; + } else { + + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError) + .errorSource(requestClient.getUrl()).build(); + + + BPMNFailureException servException = new BPMNFailureException.Builder(String.valueOf(bpelStatus), + bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); + updateStatus(currentActiveReq, Status.FAILED, servException.getMessage()); + + throw servException; + } + } + + public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage) + throws RequestDbFailureException { + if ((status == Status.FAILED) || (status == Status.COMPLETE)) { + aq.setStatusMessage(errorMessage); + aq.setProgress(new Long(100)); + aq.setRequestStatus(status.toString()); + Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis()); + aq.setEndTime(endTimeStamp); + try { + infraActiveRequestsClient.save(aq); + } catch (Exception e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + .errorInfo(errorLoggerInfo).build(); + } + } + } + + public String deriveRequestScope(Actions action, ServiceInstancesRequest sir, String requestUri) { + if (action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig) { + return (ModelType.vnf.name()); + } else if (action == Action.addMembers || action == Action.removeMembers) { + return (ModelType.instanceGroup.toString()); + } else { + String requestScope; + if (sir.getRequestDetails().getModelInfo().getModelType() == null) { + requestScope = requestScopeFromUri(requestUri); + } else { + requestScope = sir.getRequestDetails().getModelInfo().getModelType().name(); + } + return requestScope; + } + } + + + public void validateHeaders(ContainerRequestContext context) throws ValidationException { + MultivaluedMap<String, String> headers = context.getHeaders(); + if (!headers.containsKey(ONAPLogConstants.Headers.REQUEST_ID)) { + throw new ValidationException(ONAPLogConstants.Headers.REQUEST_ID + " header", true); + } + if (!headers.containsKey(ONAPLogConstants.Headers.PARTNER_NAME)) { + throw new ValidationException(ONAPLogConstants.Headers.PARTNER_NAME + " header", true); + } + if (!headers.containsKey(REQUESTOR_ID)) { + throw new ValidationException(REQUESTOR_ID + " header", true); + } + } + + public String getRequestUri(ContainerRequestContext context, String uriPrefix) { + String requestUri = context.getUriInfo().getPath(); + String httpUrl = MDC.get(LogConstants.URI_BASE).concat(requestUri); + MDC.put(LogConstants.HTTP_URL, httpUrl); + requestUri = requestUri.substring(requestUri.indexOf(uriPrefix) + uriPrefix.length()); + return requestUri; + } + + public InfraActiveRequests duplicateCheck(Actions action, HashMap<String, String> instanceIdMap, long startTime, + MsoRequest msoRequest, String instanceName, String requestScope, InfraActiveRequests currentActiveReq) + throws ApiException { + InfraActiveRequests dup = null; + try { + if (!(instanceName == null && requestScope.equals("service") && (action == Action.createInstance + || action == Action.activateInstance || action == Action.assignInstance))) { + dup = infraActiveRequestsClient.checkInstanceNameDuplicate(instanceIdMap, instanceName, requestScope); + } + } catch (Exception e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + RequestDbFailureException requestDbFailureException = + new RequestDbFailureException.Builder("check for duplicate instance", e.toString(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) + .errorInfo(errorLoggerInfo).build(); + updateStatus(currentActiveReq, Status.FAILED, requestDbFailureException.getMessage()); + throw requestDbFailureException; + } + return dup; + } + + public boolean camundaHistoryCheck(InfraActiveRequests duplicateRecord, InfraActiveRequests currentActiveReq) + throws RequestDbFailureException, ContactCamundaException { + String requestId = duplicateRecord.getRequestId(); + String path = env.getProperty("mso.camunda.rest.history.uri") + requestId; + String targetUrl = env.getProperty("mso.camundaURL") + path; + HttpHeaders headers = + setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey")); + HttpEntity<?> requestEntity = new HttpEntity<>(headers); + ResponseEntity<List<HistoricProcessInstanceEntity>> response = null; + try { + response = restTemplate.exchange(targetUrl, HttpMethod.GET, requestEntity, + new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {}); + } catch (HttpStatusCodeException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + ContactCamundaException contactCamundaException = + new ContactCamundaException.Builder(requestId, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build(); + updateStatus(currentActiveReq, Status.FAILED, contactCamundaException.getMessage()); + throw contactCamundaException; + } + if (response.getBody().isEmpty()) { + updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed"); + } + for (HistoricProcessInstance instance : response.getBody()) { + if (instance.getState().equals("ACTIVE")) { + return true; + } else { + updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed"); + } + } + return false; + } + + protected HttpHeaders setCamundaHeaders(String auth, String msoKey) { + HttpHeaders headers = new HttpHeaders(); + List<org.springframework.http.MediaType> acceptableMediaTypes = new ArrayList<>(); + acceptableMediaTypes.add(org.springframework.http.MediaType.APPLICATION_JSON); + headers.setAccept(acceptableMediaTypes); + try { + String userCredentials = CryptoUtils.decrypt(auth, msoKey); + if (userCredentials != null) { + headers.add(HttpHeaders.AUTHORIZATION, + "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes())); + } + } catch (GeneralSecurityException e) { + logger.error("Security exception", e); + } + return headers; + } + + public ServiceInstancesRequest convertJsonToServiceInstanceRequest(String requestJSON, Actions action, + long startTime, ServiceInstancesRequest sir, MsoRequest msoRequest, String requestId, String requestUri) + throws ApiException { + try { + ObjectMapper mapper = new ObjectMapper(); + return mapper.readValue(requestJSON, ServiceInstancesRequest.class); + + } catch (IOException e) { + + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + + ValidateException validateException = + new ValidateException.Builder("Error mapping request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); + String requestScope = requestScopeFromUri(requestUri); + + msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, + requestScope, requestJSON); + + throw validateException; + } + } + + public void parseRequest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, + String version, String requestJSON, Boolean aLaCarte, String requestId, + InfraActiveRequests currentActiveReq) throws ValidateException, RequestDbFailureException { + int reqVersion = Integer.parseInt(version.substring(1)); + try { + msoRequest.parse(sir, instanceIdMap, action, version, requestJSON, reqVersion, aLaCarte); + } catch (Exception e) { + logger.error("failed to parse request", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + ValidateException validateException = + new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); + updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); + throw validateException; } + } + + public void buildErrorOnDuplicateRecord(InfraActiveRequests currentActiveReq, Actions action, + HashMap<String, String> instanceIdMap, long startTime, MsoRequest msoRequest, String instanceName, + String requestScope, InfraActiveRequests dup) throws ApiException { + + String instance = null; + if (instanceName != null) { + instance = instanceName; + } else { + instance = instanceIdMap.get(requestScope + "InstanceId"); + } + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_FOUND, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + + DuplicateRequestException dupException = + new DuplicateRequestException.Builder(requestScope, instance, dup.getRequestStatus(), + dup.getRequestId(), HttpStatus.SC_CONFLICT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR) + .errorInfo(errorLoggerInfo).build(); + + updateStatus(currentActiveReq, Status.FAILED, dupException.getMessage()); + + throw dupException; + } + + public String getRequestId(ContainerRequestContext requestContext) throws ValidateException { + String requestId = null; + if (requestContext.getProperty("requestId") != null) { + requestId = requestContext.getProperty("requestId").toString(); + } + if (UUIDChecker.isValidUUID(requestId)) { + return requestId; + } else { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + ValidateException validateException = + new ValidateException.Builder("Request Id " + requestId + " is not a valid UUID", + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER) + .errorInfo(errorLoggerInfo).build(); + + throw validateException; + } + } + + public void setInstanceId(InfraActiveRequests currentActiveReq, String requestScope, String instanceId, + Map<String, String> instanceIdMap) { + if (StringUtils.isNotBlank(instanceId)) { + if (ModelType.service.name().equalsIgnoreCase(requestScope)) { + currentActiveReq.setServiceInstanceId(instanceId); + } else if (ModelType.vnf.name().equalsIgnoreCase(requestScope)) { + currentActiveReq.setVnfId(instanceId); + } else if (ModelType.vfModule.name().equalsIgnoreCase(requestScope)) { + currentActiveReq.setVfModuleId(instanceId); + } else if (ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)) { + currentActiveReq.setVolumeGroupId(instanceId); + } else if (ModelType.network.name().equalsIgnoreCase(requestScope)) { + currentActiveReq.setNetworkId(instanceId); + } else if (ModelType.configuration.name().equalsIgnoreCase(requestScope)) { + currentActiveReq.setConfigurationId(instanceId); + } else if (ModelType.instanceGroup.toString().equalsIgnoreCase(requestScope)) { + currentActiveReq.setInstanceGroupId(instanceId); + } + } else if (instanceIdMap != null && !instanceIdMap.isEmpty()) { + if (instanceIdMap.get("serviceInstanceId") != null) { + currentActiveReq.setServiceInstanceId(instanceIdMap.get("serviceInstanceId")); + } + if (instanceIdMap.get("vnfInstanceId") != null) { + currentActiveReq.setVnfId(instanceIdMap.get("vnfInstanceId")); + } + if (instanceIdMap.get("vfModuleInstanceId") != null) { + currentActiveReq.setVfModuleId(instanceIdMap.get("vfModuleInstanceId")); + } + if (instanceIdMap.get("volumeGroupInstanceId") != null) { + currentActiveReq.setVolumeGroupId(instanceIdMap.get("volumeGroupInstanceId")); + } + if (instanceIdMap.get("networkInstanceId") != null) { + currentActiveReq.setNetworkId(instanceIdMap.get("networkInstanceId")); + } + if (instanceIdMap.get("configurationInstanceId") != null) { + currentActiveReq.setConfigurationId(instanceIdMap.get("configurationInstanceId")); + } + if (instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID) != null) { + currentActiveReq.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID)); + } + } + } + + public String mapJSONtoMSOStyle(String msoRawRequest, ServiceInstancesRequest serviceInstRequest, + boolean isAlaCarte, Actions action) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + if (msoRawRequest != null) { + ServiceInstancesRequest sir = mapper.readValue(msoRawRequest, ServiceInstancesRequest.class); + if (serviceInstRequest != null && serviceInstRequest.getRequestDetails() != null + && serviceInstRequest.getRequestDetails().getRequestParameters() != null) { + if (!isAlaCarte && Action.createInstance.equals(action)) { + sir.getRequestDetails() + .setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration()); + sir.getRequestDetails().getRequestParameters().setUserParams( + serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams()); + } + sir.getRequestDetails().getRequestParameters() + .setUsePreload(serviceInstRequest.getRequestDetails().getRequestParameters().getUsePreload()); + } + + logger.debug("Value as string: {}", mapper.writeValueAsString(sir)); + return mapper.writeValueAsString(sir); + } + return null; + } + + public Optional<String> retrieveModelName(RequestParameters requestParams) { + String requestTestApi = null; + TestApi testApi = null; + + if (requestParams != null) { + requestTestApi = requestParams.getTestApi(); + } + + if (requestTestApi == null) { + if (requestParams != null && requestParams.getALaCarte() != null && !requestParams.getALaCarte()) { + requestTestApi = env.getProperty(CommonConstants.MACRO_TEST_API); + } else { + requestTestApi = env.getProperty(CommonConstants.ALACARTE_TEST_API); + } + } + + try { + testApi = TestApi.valueOf(requestTestApi); + return Optional.of(testApi.getModelName()); + } catch (Exception e) { + logger.warn("Catching the exception on the valueOf enum call and continuing", e); + throw new IllegalArgumentException("Invalid TestApi is provided", e); + } + } + + public String getDefaultModel(ServiceInstancesRequest sir) { + String defaultModel = sir.getRequestDetails().getRequestInfo().getSource() + "_DEFAULT"; + Optional<String> oModelName = retrieveModelName(sir.getRequestDetails().getRequestParameters()); + if (oModelName.isPresent()) { + defaultModel = oModelName.get(); + } + return defaultModel; + } + + public String getServiceType(String requestScope, ServiceInstancesRequest sir, Boolean aLaCarteFlag) { + String serviceType = null; + if (requestScope.equalsIgnoreCase(ModelType.service.toString())) { + String defaultServiceModelName = getDefaultModel(sir); + org.onap.so.db.catalog.beans.Service serviceRecord; + if (aLaCarteFlag) { + serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); + if (serviceRecord != null) { + serviceType = serviceRecord.getServiceType(); + } + } else { + serviceRecord = + catalogDbClient.getServiceByID(sir.getRequestDetails().getModelInfo().getModelVersionId()); + if (serviceRecord != null) { + serviceType = serviceRecord.getServiceType(); + } else { + serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); + if (serviceRecord != null) { + serviceType = serviceRecord.getServiceType(); + } + } + } + } else { + serviceType = msoRequest.getServiceInstanceType(sir, requestScope); + } + return serviceType; + } + + protected String setServiceInstanceId(String requestScope, ServiceInstancesRequest sir) { + if (sir.getServiceInstanceId() != null) { + return sir.getServiceInstanceId(); + } else if (requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())) { + RelatedInstanceList[] relatedInstances = sir.getRequestDetails().getRelatedInstanceList(); + if (relatedInstances != null) { + for (RelatedInstanceList relatedInstanceList : relatedInstances) { + RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + if (relatedInstance.getModelInfo().getModelType() == ModelType.service) { + return relatedInstance.getInstanceId(); + } + } + } + } + return null; + } + + private String requestScopeFromUri(String requestUri) { + String requestScope; + if (requestUri.contains(ModelType.network.name())) { + requestScope = ModelType.network.name(); + } else if (requestUri.contains(ModelType.vfModule.name())) { + requestScope = ModelType.vfModule.name(); + } else if (requestUri.contains(ModelType.volumeGroup.name())) { + requestScope = ModelType.volumeGroup.name(); + } else if (requestUri.contains(ModelType.configuration.name())) { + requestScope = ModelType.configuration.name(); + } else if (requestUri.contains(ModelType.vnf.name())) { + requestScope = ModelType.vnf.name(); + } else { + requestScope = ModelType.service.name(); + } + return requestScope; + } - // BPEL accepted the request, the request is in progress - if (bpelStatus == HttpStatus.SC_ACCEPTED) { - ServiceInstancesResponse jsonResponse; - CamundaResponse camundaResp = respHandler.getResponse(); - - if("Success".equalsIgnoreCase(camundaResp.getMessage())) { - try { - ObjectMapper mapper = new ObjectMapper(); - jsonResponse = mapper.readValue(camundaResp.getResponse(), ServiceInstancesResponse.class); - jsonResponse.getRequestReferences().setRequestId(requestClientParameter.getRequestId()); - Optional<URL> selfLinkUrl = msoRequest.buildSelfLinkUrl(currentActiveReq.getRequestUrl(), requestClientParameter.getRequestId()); - if(selfLinkUrl.isPresent()){ - jsonResponse.getRequestReferences().setRequestSelfLink(selfLinkUrl.get()); - } else { - jsonResponse.getRequestReferences().setRequestSelfLink(null); - } - } catch (IOException e) { - logger.error("Exception occurred", e); - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_NOT_ACCEPTABLE, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) - .errorInfo(errorLoggerInfo).build(); - updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); - throw validateException; - } - return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestClientParameter.getRequestId(), jsonResponse, requestClientParameter.getApiVersion()); - } - } - - List<String> variables = new ArrayList<>(); - variables.add(bpelStatus + ""); - String camundaJSONResponseBody = respHandler.getResponseBody (); - if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty ()) { - - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError).errorSource(requestClient.getUrl()).build(); - BPMNFailureException bpmnException = new BPMNFailureException.Builder(String.valueOf(bpelStatus) + camundaJSONResponseBody, bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR) - .errorInfo(errorLoggerInfo).build(); - - updateStatus(currentActiveReq, Status.FAILED, bpmnException.getMessage()); - - throw bpmnException; - } else { - - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError).errorSource(requestClient.getUrl()).build(); - - - BPMNFailureException servException = new BPMNFailureException.Builder(String.valueOf(bpelStatus), bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR) - .errorInfo(errorLoggerInfo).build(); - updateStatus(currentActiveReq, Status.FAILED, servException.getMessage()); - - throw servException; - } - } - - public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage) throws RequestDbFailureException{ - if ((status == Status.FAILED) || (status == Status.COMPLETE)) { - aq.setStatusMessage (errorMessage); - aq.setProgress(new Long(100)); - aq.setRequestStatus(status.toString()); - Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis()); - aq.setEndTime (endTimeStamp); - try{ - infraActiveRequestsClient.save(aq); - }catch(Exception e){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) - .errorInfo(errorLoggerInfo).build(); - } - } - } - - public String deriveRequestScope(Actions action, ServiceInstancesRequest sir, String requestUri) { - if(action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig){ - return (ModelType.vnf.name()); - }else if(action == Action.addMembers || action == Action.removeMembers){ - return(ModelType.instanceGroup.toString()); - }else{ - String requestScope; - if(sir.getRequestDetails().getModelInfo().getModelType() == null){ - requestScope = requestScopeFromUri(requestUri); - }else{ - requestScope = sir.getRequestDetails().getModelInfo().getModelType().name(); - } - return requestScope; - } - } - - - public void validateHeaders(ContainerRequestContext context) throws ValidationException{ - MultivaluedMap<String, String> headers = context.getHeaders(); - if(!headers.containsKey(ONAPLogConstants.Headers.REQUEST_ID)){ - throw new ValidationException(ONAPLogConstants.Headers.REQUEST_ID + " header", true); - } - if(!headers.containsKey(ONAPLogConstants.Headers.PARTNER_NAME)){ - throw new ValidationException(ONAPLogConstants.Headers.PARTNER_NAME + " header", true); - } - if(!headers.containsKey(REQUESTOR_ID)){ - throw new ValidationException(REQUESTOR_ID + " header", true); - } - } - - public String getRequestUri(ContainerRequestContext context, String uriPrefix){ - String requestUri = context.getUriInfo().getPath(); - String httpUrl = MDC.get(LogConstants.URI_BASE).concat(requestUri); - MDC.put(LogConstants.HTTP_URL, httpUrl); - requestUri = requestUri.substring(requestUri.indexOf(uriPrefix) + uriPrefix.length()); - return requestUri; - } - - public InfraActiveRequests duplicateCheck(Actions action, HashMap<String, String> instanceIdMap, long startTime, - MsoRequest msoRequest, String instanceName, String requestScope, InfraActiveRequests currentActiveReq) throws ApiException { - InfraActiveRequests dup = null; - try { - if(!(instanceName==null && requestScope.equals("service") && (action == Action.createInstance || action == Action.activateInstance || action == Action.assignInstance))){ - dup = infraActiveRequestsClient.checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope); - } - } catch (Exception e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - RequestDbFailureException requestDbFailureException = new RequestDbFailureException.Builder("check for duplicate instance", e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) - .errorInfo(errorLoggerInfo).build(); - updateStatus(currentActiveReq, Status.FAILED, requestDbFailureException.getMessage()); - throw requestDbFailureException; - } - return dup; - } - - public boolean camundaHistoryCheck(InfraActiveRequests duplicateRecord, InfraActiveRequests currentActiveReq) throws RequestDbFailureException, ContactCamundaException{ - String requestId = duplicateRecord.getRequestId(); - String path = env.getProperty("mso.camunda.rest.history.uri") + requestId; - String targetUrl = env.getProperty("mso.camundaURL") + path; - HttpHeaders headers = setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey")); - HttpEntity<?> requestEntity = new HttpEntity<>(headers); - ResponseEntity<List<HistoricProcessInstanceEntity>> response = null; - try{ - response = restTemplate.exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>(){}); - }catch(HttpStatusCodeException e){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - ContactCamundaException contactCamundaException= new ContactCamundaException.Builder(requestId, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) - .errorInfo(errorLoggerInfo).build(); - updateStatus(currentActiveReq, Status.FAILED, contactCamundaException.getMessage()); - throw contactCamundaException; - } - if(response.getBody().isEmpty()){ - updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed"); - } - for(HistoricProcessInstance instance : response.getBody()){ - if(instance.getState().equals("ACTIVE")){ - return true; - }else{ - updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed"); - } - } - return false; - } - - protected HttpHeaders setCamundaHeaders(String auth, String msoKey) { - HttpHeaders headers = new HttpHeaders(); - List<org.springframework.http.MediaType> acceptableMediaTypes = new ArrayList<>(); - acceptableMediaTypes.add(org.springframework.http.MediaType.APPLICATION_JSON); - headers.setAccept(acceptableMediaTypes); - try { - String userCredentials = CryptoUtils.decrypt(auth, msoKey); - if(userCredentials != null) { - headers.add(HttpHeaders.AUTHORIZATION, "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes())); - } - } catch(GeneralSecurityException e) { - logger.error("Security exception", e); - } - return headers; - } - - public ServiceInstancesRequest convertJsonToServiceInstanceRequest(String requestJSON, Actions action, long startTime, - ServiceInstancesRequest sir, MsoRequest msoRequest, String requestId, String requestUri) throws ApiException { - try{ - ObjectMapper mapper = new ObjectMapper(); - return mapper.readValue(requestJSON, ServiceInstancesRequest.class); - - } catch (IOException e) { - - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - - ValidateException validateException = new ValidateException.Builder("Error mapping request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) - .errorInfo(errorLoggerInfo).build(); - String requestScope = requestScopeFromUri(requestUri); - - msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, requestScope, requestJSON); - - throw validateException; - } - } - - public void parseRequest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, String version, - String requestJSON, Boolean aLaCarte, String requestId, InfraActiveRequests currentActiveReq) throws ValidateException, RequestDbFailureException { - int reqVersion = Integer.parseInt(version.substring(1)); - try { - msoRequest.parse(sir, instanceIdMap, action, version, requestJSON, reqVersion, aLaCarte); - } catch (Exception e) { - logger.error("failed to parse request", e); - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - ValidateException validateException = new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) - .errorInfo(errorLoggerInfo).build(); - - updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); - - throw validateException; - } - } - - public void buildErrorOnDuplicateRecord(InfraActiveRequests currentActiveReq, Actions action, HashMap<String, String> instanceIdMap, long startTime, MsoRequest msoRequest, - String instanceName, String requestScope, InfraActiveRequests dup) throws ApiException { - - String instance = null; - if(instanceName != null){ - instance = instanceName; - }else{ - instance = instanceIdMap.get(requestScope + "InstanceId"); - } - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_FOUND, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - - DuplicateRequestException dupException = new DuplicateRequestException.Builder(requestScope,instance,dup.getRequestStatus(),dup.getRequestId(), HttpStatus.SC_CONFLICT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR) - .errorInfo(errorLoggerInfo).build(); - - updateStatus(currentActiveReq, Status.FAILED, dupException.getMessage()); - - throw dupException; - } - - public String getRequestId(ContainerRequestContext requestContext) throws ValidateException { - String requestId = null; - if (requestContext.getProperty("requestId") != null) { - requestId = requestContext.getProperty("requestId").toString(); - } - if (UUIDChecker.isValidUUID(requestId)) { - return requestId; - } else { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - ValidateException validateException = new ValidateException.Builder("Request Id " + requestId + " is not a valid UUID", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER) - .errorInfo(errorLoggerInfo).build(); - - throw validateException; - } - } - - public void setInstanceId(InfraActiveRequests currentActiveReq, String requestScope, String instanceId, Map<String, String> instanceIdMap) { - if(StringUtils.isNotBlank(instanceId)) { - if(ModelType.service.name().equalsIgnoreCase(requestScope)) { - currentActiveReq.setServiceInstanceId(instanceId); - } else if(ModelType.vnf.name().equalsIgnoreCase(requestScope)) { - currentActiveReq.setVnfId(instanceId); - } else if(ModelType.vfModule.name().equalsIgnoreCase(requestScope)) { - currentActiveReq.setVfModuleId(instanceId); - } else if(ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)) { - currentActiveReq.setVolumeGroupId(instanceId); - } else if(ModelType.network.name().equalsIgnoreCase(requestScope)) { - currentActiveReq.setNetworkId(instanceId); - } else if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) { - currentActiveReq.setConfigurationId(instanceId); - }else if(ModelType.instanceGroup.toString().equalsIgnoreCase(requestScope)){ - currentActiveReq.setInstanceGroupId(instanceId); - } - } else if(instanceIdMap != null && !instanceIdMap.isEmpty()) { - if(instanceIdMap.get("serviceInstanceId") != null){ - currentActiveReq.setServiceInstanceId(instanceIdMap.get("serviceInstanceId")); - } - if(instanceIdMap.get("vnfInstanceId") != null){ - currentActiveReq.setVnfId(instanceIdMap.get("vnfInstanceId")); - } - if(instanceIdMap.get("vfModuleInstanceId") != null){ - currentActiveReq.setVfModuleId(instanceIdMap.get("vfModuleInstanceId")); - } - if(instanceIdMap.get("volumeGroupInstanceId") != null){ - currentActiveReq.setVolumeGroupId(instanceIdMap.get("volumeGroupInstanceId")); - } - if(instanceIdMap.get("networkInstanceId") != null){ - currentActiveReq.setNetworkId(instanceIdMap.get("networkInstanceId")); - } - if(instanceIdMap.get("configurationInstanceId") != null){ - currentActiveReq.setConfigurationId(instanceIdMap.get("configurationInstanceId")); - } - if(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID) != null){ - currentActiveReq.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID)); - } - } - } - - public String mapJSONtoMSOStyle(String msoRawRequest, ServiceInstancesRequest serviceInstRequest, boolean isAlaCarte, Actions action) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); - if(msoRawRequest != null){ - ServiceInstancesRequest sir = mapper.readValue(msoRawRequest, ServiceInstancesRequest.class); - if( serviceInstRequest != null && - serviceInstRequest.getRequestDetails() != null && - serviceInstRequest.getRequestDetails().getRequestParameters() != null) { - if( !isAlaCarte && Action.createInstance.equals(action)) { - sir.getRequestDetails().setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration()); - sir.getRequestDetails().getRequestParameters().setUserParams(serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams()); - } - sir.getRequestDetails().getRequestParameters().setUsePreload(serviceInstRequest.getRequestDetails().getRequestParameters().getUsePreload()); - } - - logger.debug("Value as string: {}", mapper.writeValueAsString(sir)); - return mapper.writeValueAsString(sir); - } - return null; - } - - public Optional<String> retrieveModelName(RequestParameters requestParams) { - String requestTestApi = null; - TestApi testApi = null; - - if (requestParams != null) { - requestTestApi = requestParams.getTestApi(); - } - - if (requestTestApi == null) { - if(requestParams != null && requestParams.getALaCarte() != null && !requestParams.getALaCarte()) { - requestTestApi = env.getProperty(CommonConstants.MACRO_TEST_API); - } else { - requestTestApi = env.getProperty(CommonConstants.ALACARTE_TEST_API); - } - } - - try { - testApi = TestApi.valueOf(requestTestApi); - return Optional.of(testApi.getModelName()); - } catch (Exception e) { - logger.warn("Catching the exception on the valueOf enum call and continuing", e); - throw new IllegalArgumentException("Invalid TestApi is provided", e); - } - } - - public String getDefaultModel(ServiceInstancesRequest sir) { - String defaultModel = sir.getRequestDetails().getRequestInfo().getSource() + "_DEFAULT"; - Optional<String> oModelName = retrieveModelName(sir.getRequestDetails().getRequestParameters()); - if (oModelName.isPresent()) { - defaultModel = oModelName.get(); - } - return defaultModel; - } - - public String getServiceType(String requestScope, ServiceInstancesRequest sir, Boolean aLaCarteFlag){ - String serviceType = null; - if(requestScope.equalsIgnoreCase(ModelType.service.toString())){ - String defaultServiceModelName = getDefaultModel(sir); - org.onap.so.db.catalog.beans.Service serviceRecord; - if(aLaCarteFlag){ - serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); - if(serviceRecord != null){ - serviceType = serviceRecord.getServiceType(); - } - }else{ - serviceRecord = catalogDbClient.getServiceByID(sir.getRequestDetails().getModelInfo().getModelVersionId()); - if(serviceRecord != null){ - serviceType = serviceRecord.getServiceType(); - }else{ - serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); - if(serviceRecord != null){ - serviceType = serviceRecord.getServiceType(); - } - } - } - }else{ - serviceType = msoRequest.getServiceInstanceType(sir, requestScope); - } - return serviceType; - } - - protected String setServiceInstanceId(String requestScope, ServiceInstancesRequest sir){ - if(sir.getServiceInstanceId () != null){ - return sir.getServiceInstanceId (); - }else if(requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())){ - RelatedInstanceList[] relatedInstances = sir.getRequestDetails().getRelatedInstanceList(); - if(relatedInstances != null){ - for(RelatedInstanceList relatedInstanceList : relatedInstances){ - RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); - if(relatedInstance.getModelInfo().getModelType() == ModelType.service){ - return relatedInstance.getInstanceId(); - } - } - } - } - return null; - } - - private String requestScopeFromUri(String requestUri){ - String requestScope; - if(requestUri.contains(ModelType.network.name())){ - requestScope = ModelType.network.name(); - }else if(requestUri.contains(ModelType.vfModule.name())){ - requestScope = ModelType.vfModule.name(); - }else if(requestUri.contains(ModelType.volumeGroup.name())){ - requestScope = ModelType.volumeGroup.name(); - }else if(requestUri.contains(ModelType.configuration.name())){ - requestScope = ModelType.configuration.name(); - }else if(requestUri.contains(ModelType.vnf.name())){ - requestScope = ModelType.vnf.name(); - }else{ - requestScope = ModelType.service.name(); - } - return requestScope; - } - } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index ad97918a03..931a1eb52b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -74,7 +74,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; - import javax.transaction.Transactional; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -96,1432 +95,1611 @@ import java.util.Optional; @Component @Path("/onap/so/infra/serviceInstantiation") -@Api(value="/onap/so/infra/serviceInstantiation",description="Infrastructure API Requests for Service Instances") +@Api(value = "/onap/so/infra/serviceInstantiation", description = "Infrastructure API Requests for Service Instances") public class ServiceInstances { - private static Logger logger = LoggerFactory.getLogger(MsoRequest.class); - private static String NAME = "name"; - private static String VALUE = "value"; - private static String uriPrefix = "/serviceInstantiation/"; - private static final String SAVE_TO_DB = "save instance to db"; - - @Autowired - private Environment env; - - @Autowired - private CatalogDbClient catalogDbClient; - - @Autowired - private RequestsDbClient infraActiveRequestsClient; - - @Autowired - private MsoRequest msoRequest; - - @Autowired - private RequestHandlerUtils requestHandlerUtils; - - @POST + private static Logger logger = LoggerFactory.getLogger(MsoRequest.class); + private static String NAME = "name"; + private static String VALUE = "value"; + private static String uriPrefix = "/serviceInstantiation/"; + private static final String SAVE_TO_DB = "save instance to db"; + + @Autowired + private Environment env; + + @Autowired + private CatalogDbClient catalogDbClient; + + @Autowired + private RequestsDbClient infraActiveRequestsClient; + + @Autowired + private MsoRequest msoRequest; + + @Autowired + private RequestHandlerUtils requestHandlerUtils; + + @POST @Path("/{version:[vV][5-7]}/serviceInstances") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Create a Service Instance on a version provided",response=Response.class) - @Transactional - public Response createServiceInstance(String request, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - return serviceInstances(request, Action.createInstance, null, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/activate") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Activate provided Service Instance",response=Response.class) - @Transactional - public Response activateServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - return serviceInstances(request, Action.activateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/deactivate") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Deactivate provided Service Instance",response=Response.class) - @Transactional - public Response deactivateServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - return serviceInstances(request, Action.deactivateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @DELETE - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Delete provided Service Instance",response=Response.class) - @Transactional - public Response deleteServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][7]}/serviceInstances/assign") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Assign Service Instance", response=Response.class) - @Transactional - public Response assignServiceInstance(String request, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - return serviceInstances(request, Action.assignInstance, null, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][7]}/serviceInstances/{serviceInstanceId}/unassign") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Unassign Service Instance", response=Response.class) - @Transactional - public Response unassignServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<String,String>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - return serviceInstances(request, Action.unassignInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Create Port Mirroring Configuration",response=Response.class) - @Transactional - public Response createPortConfiguration(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - return configurationRecipeLookup(request, Action.createInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @DELETE - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Delete provided Port",response=Response.class) - @Transactional - public Response deletePortConfiguration(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("configurationInstanceId", configurationInstanceId); - return configurationRecipeLookup(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}/enablePort") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Enable Port Mirroring",response=Response.class) - @Transactional - public Response enablePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("configurationInstanceId", configurationInstanceId); - return configurationRecipeLookup(request, Action.enablePort, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}/disablePort") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Disable Port Mirroring",response=Response.class) - @Transactional - public Response disablePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("configurationInstanceId", configurationInstanceId); - return configurationRecipeLookup(request, Action.disablePort, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}/activate") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Activate Port Mirroring",response=Response.class) - @Transactional - public Response activatePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("configurationInstanceId", configurationInstanceId); - return configurationRecipeLookup(request, Action.activateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}/deactivate") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Deactivate Port Mirroring",response=Response.class) - @Transactional - public Response deactivatePort(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("configurationInstanceId") String configurationInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("configurationInstanceId", configurationInstanceId); - return configurationRecipeLookup(request, Action.deactivateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][6-7]}/serviceInstances/{serviceInstanceId}/addRelationships") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Add Relationships to a Service Instance",response=Response.class) - @Transactional - public Response addRelationships(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - return configurationRecipeLookup(request, Action.addRelationships, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][6-7]}/serviceInstances/{serviceInstanceId}/removeRelationships") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Remove Relationships from Service Instance",response=Response.class) - @Transactional - public Response removeRelationships(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - return configurationRecipeLookup(request, Action.removeRelationships, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Create VNF on a specified version and serviceInstance",response=Response.class) - @Transactional - public Response createVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - try{ - return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - }catch (Exception e){ - logger.error("Error in vnf", e); - throw e; - } - } - - @POST - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/replace") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Replace provided VNF instance",response=Response.class) - @Transactional - public Response replaceVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - return serviceInstances(request, Action.replaceInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @PUT - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Update VNF on a specified version, serviceInstance and vnfInstance",response=Response.class) - @Transactional - public Response updateVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][6-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/applyUpdatedConfig") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Apply updated configuration",response=Response.class) - public Response applyUpdatedConfig(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - return serviceInstances(request, Action.applyUpdatedConfig, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/recreate") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Recreate VNF Instance",response=Response.class) - public Response recreateVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - return serviceInstances(request, Action.recreateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - - @DELETE - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Delete provided VNF instance",response=Response.class) - @Transactional - public Response deleteVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Create VfModule on a specified version, serviceInstance and vnfInstance",response=Response.class) - @Transactional - public Response createVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}/replace") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Create VfModule on a specified version, serviceInstance and vnfInstance",response=Response.class) - @Transactional - public Response replaceVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId); - return serviceInstances(request, Action.replaceInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @PUT - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Update VfModule on a specified version, serviceInstance, vnfInstance and vfModule",response=Response.class) - @Transactional - public Response updateVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId); - return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][6-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/inPlaceSoftwareUpdate") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Perform VNF software update",response=Response.class) - @Transactional - public Response inPlaceSoftwareUpdate(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - return serviceInstances(request, Action.inPlaceSoftwareUpdate, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @DELETE - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Delete provided VfModule instance",response=Response.class) - @Transactional - public Response deleteVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId); - return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}/deactivateAndCloudDelete") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Deactivate and Cloud Delete VfModule instance",response=Response.class) - @Transactional - public Response deactivateAndCloudDeleteVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId); - Response response = serviceInstances(request, Action.deactivateAndCloudDelete, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - return response; - } - - @POST - @Path("/{version:[vV][7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="VF Auto Scale Out",response=Response.class) - @Transactional - public Response scaleOutVfModule(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - return serviceInstances(request, Action.scaleOut, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - - @POST - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Create VolumeGroup on a specified version, serviceInstance, vnfInstance",response=Response.class) - @Transactional - public Response createVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @PUT - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Update VolumeGroup on a specified version, serviceInstance, vnfInstance and volumeGroup",response=Response.class) - @Transactional - public Response updateVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - instanceIdMap.put("volumeGroupInstanceId", volumeGroupInstanceId); - return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @DELETE - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Delete provided VolumeGroup instance",response=Response.class) - @Transactional - public Response deleteVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("vnfInstanceId") String vnfInstanceId, - @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("vnfInstanceId", vnfInstanceId); - instanceIdMap.put("volumeGroupInstanceId", volumeGroupInstanceId); - return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/networks") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Create NetworkInstance on a specified version and serviceInstance ",response=Response.class) - @Transactional - public Response createNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @PUT - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/networks/{networkInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Update VolumeGroup on a specified version, serviceInstance, networkInstance",response=Response.class) - @Transactional - public Response updateNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("networkInstanceId") String networkInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("networkInstanceId", networkInstanceId); - return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @DELETE - @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/networks/{networkInstanceId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Delete provided Network instance",response=Response.class) - @Transactional - public Response deleteNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId, - @PathParam("networkInstanceId") String networkInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - instanceIdMap.put("networkInstanceId", networkInstanceId); - return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Create a Service Instance on a version provided", response = Response.class) + @Transactional + public Response createServiceInstance(String request, @PathParam("version") String version, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + return serviceInstances(request, Action.createInstance, null, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/activate") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Activate provided Service Instance", response = Response.class) + @Transactional + public Response activateServiceInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + return serviceInstances(request, Action.activateInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/deactivate") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Deactivate provided Service Instance", response = Response.class) + @Transactional + public Response deactivateServiceInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + return serviceInstances(request, Action.deactivateInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @DELETE + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Delete provided Service Instance", response = Response.class) + @Transactional + public Response deleteServiceInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][7]}/serviceInstances/assign") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Assign Service Instance", response = Response.class) + @Transactional + public Response assignServiceInstance(String request, @PathParam("version") String version, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + return serviceInstances(request, Action.assignInstance, null, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][7]}/serviceInstances/{serviceInstanceId}/unassign") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Unassign Service Instance", response = Response.class) + @Transactional + public Response unassignServiceInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<String, String>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + return serviceInstances(request, Action.unassignInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Create Port Mirroring Configuration", response = Response.class) + @Transactional + public Response createPortConfiguration(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + return configurationRecipeLookup(request, Action.createInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @DELETE + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Delete provided Port", response = Response.class) + @Transactional + public Response deletePortConfiguration(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, + @PathParam("configurationInstanceId") String configurationInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("configurationInstanceId", configurationInstanceId); + return configurationRecipeLookup(request, Action.deleteInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}/enablePort") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Enable Port Mirroring", response = Response.class) + @Transactional + public Response enablePort(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, + @PathParam("configurationInstanceId") String configurationInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("configurationInstanceId", configurationInstanceId); + return configurationRecipeLookup(request, Action.enablePort, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}/disablePort") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Disable Port Mirroring", response = Response.class) + @Transactional + public Response disablePort(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, + @PathParam("configurationInstanceId") String configurationInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("configurationInstanceId", configurationInstanceId); + return configurationRecipeLookup(request, Action.disablePort, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}/activate") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Activate Port Mirroring", response = Response.class) + @Transactional + public Response activatePort(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, + @PathParam("configurationInstanceId") String configurationInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("configurationInstanceId", configurationInstanceId); + return configurationRecipeLookup(request, Action.activateInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/configurations/{configurationInstanceId}/deactivate") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Deactivate Port Mirroring", response = Response.class) + @Transactional + public Response deactivatePort(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, + @PathParam("configurationInstanceId") String configurationInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("configurationInstanceId", configurationInstanceId); + return configurationRecipeLookup(request, Action.deactivateInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][6-7]}/serviceInstances/{serviceInstanceId}/addRelationships") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Add Relationships to a Service Instance", response = Response.class) + @Transactional + public Response addRelationships(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + return configurationRecipeLookup(request, Action.addRelationships, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][6-7]}/serviceInstances/{serviceInstanceId}/removeRelationships") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Remove Relationships from Service Instance", response = Response.class) + @Transactional + public Response removeRelationships(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + return configurationRecipeLookup(request, Action.removeRelationships, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Create VNF on a specified version and serviceInstance", response = Response.class) + @Transactional + public Response createVnfInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + try { + return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } catch (Exception e) { + logger.error("Error in vnf", e); + throw e; + } + } + + @POST + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/replace") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Replace provided VNF instance", response = Response.class) + @Transactional + public Response replaceVnfInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + return serviceInstances(request, Action.replaceInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @PUT + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Update VNF on a specified version, serviceInstance and vnfInstance", + response = Response.class) + @Transactional + public Response updateVnfInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][6-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/applyUpdatedConfig") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Apply updated configuration", response = Response.class) + public Response applyUpdatedConfig(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + return serviceInstances(request, Action.applyUpdatedConfig, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/recreate") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Recreate VNF Instance", response = Response.class) + public Response recreateVnfInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + return serviceInstances(request, Action.recreateInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + + @DELETE + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Delete provided VNF instance", response = Response.class) + @Transactional + public Response deleteVnfInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Create VfModule on a specified version, serviceInstance and vnfInstance", + response = Response.class) + @Transactional + public Response createVfModuleInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}/replace") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Create VfModule on a specified version, serviceInstance and vnfInstance", + response = Response.class) + @Transactional + public Response replaceVfModuleInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId); + return serviceInstances(request, Action.replaceInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @PUT + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Update VfModule on a specified version, serviceInstance, vnfInstance and vfModule", + response = Response.class) + @Transactional + public Response updateVfModuleInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId); + return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][6-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/inPlaceSoftwareUpdate") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Perform VNF software update", response = Response.class) + @Transactional + public Response inPlaceSoftwareUpdate(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + return serviceInstances(request, Action.inPlaceSoftwareUpdate, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @DELETE + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Delete provided VfModule instance", response = Response.class) + @Transactional + public Response deleteVfModuleInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId); + return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}/deactivateAndCloudDelete") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Deactivate and Cloud Delete VfModule instance", response = Response.class) + @Transactional + public Response deactivateAndCloudDeleteVfModuleInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId); + Response response = serviceInstances(request, Action.deactivateAndCloudDelete, instanceIdMap, version, + requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + return response; + } + + @POST + @Path("/{version:[vV][7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "VF Auto Scale Out", response = Response.class) + @Transactional + public Response scaleOutVfModule(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + return serviceInstances(request, Action.scaleOut, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + + @POST + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Create VolumeGroup on a specified version, serviceInstance, vnfInstance", + response = Response.class) + @Transactional + public Response createVolumeGroupInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @PUT + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Update VolumeGroup on a specified version, serviceInstance, vnfInstance and volumeGroup", + response = Response.class) + @Transactional + public Response updateVolumeGroupInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + instanceIdMap.put("volumeGroupInstanceId", volumeGroupInstanceId); + return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @DELETE + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Delete provided VolumeGroup instance", response = Response.class) + @Transactional + public Response deleteVolumeGroupInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId, + @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("vnfInstanceId", vnfInstanceId); + instanceIdMap.put("volumeGroupInstanceId", volumeGroupInstanceId); + return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/networks") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Create NetworkInstance on a specified version and serviceInstance ", + response = Response.class) + @Transactional + public Response createNetworkInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + return serviceInstances(request, Action.createInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @PUT + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/networks/{networkInstanceId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Update VolumeGroup on a specified version, serviceInstance, networkInstance", + response = Response.class) + @Transactional + public Response updateNetworkInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, + @PathParam("networkInstanceId") String networkInstanceId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("networkInstanceId", networkInstanceId); + return serviceInstances(request, Action.updateInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @DELETE + @Path("/{version:[vV][5-7]}/serviceInstances/{serviceInstanceId}/networks/{networkInstanceId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Delete provided Network instance", response = Response.class) + @Transactional + public Response deleteNetworkInstance(String request, @PathParam("version") String version, + @PathParam("serviceInstanceId") String serviceInstanceId, + @PathParam("networkInstanceId") String networkInstanceId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put("serviceInstanceId", serviceInstanceId); + instanceIdMap.put("networkInstanceId", networkInstanceId); + return serviceInstances(request, Action.deleteInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST @Path("/{version:[vV][7]}/instanceGroups") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Create instanceGroups",response=Response.class) - @Transactional - public Response createInstanceGroups(String request, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - return serviceInstances(request, Action.createInstance, null, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @DELETE - @Path("/{version:[vV][7]}/instanceGroups/{instanceGroupId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Delete instanceGroup",response=Response.class) - @Transactional - public Response deleteInstanceGroups(@PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId); - return deleteInstanceGroups(Action.deleteInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix), requestContext); - } - - @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Create instanceGroups", response = Response.class) + @Transactional + public Response createInstanceGroups(String request, @PathParam("version") String version, + @Context ContainerRequestContext requestContext) throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + return serviceInstances(request, Action.createInstance, null, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @DELETE + @Path("/{version:[vV][7]}/instanceGroups/{instanceGroupId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Delete instanceGroup", response = Response.class) + @Transactional + public Response deleteInstanceGroups(@PathParam("version") String version, + @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId); + return deleteInstanceGroups(Action.deleteInstance, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix), requestContext); + } + + @POST @Path("/{version:[vV][7]}/instanceGroups/{instanceGroupId}/addMembers") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Add instanceGroup members",response=Response.class) - @Transactional - public Response addInstanceGroupMembers(String request, @PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId); - return serviceInstances(request, Action.addMembers, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Add instanceGroup members", response = Response.class) + @Transactional + public Response addInstanceGroupMembers(String request, @PathParam("version") String version, + @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId); + return serviceInstances(request, Action.addMembers, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + @POST @Path("/{version:[vV][7]}/instanceGroups/{instanceGroupId}/removeMembers") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Remove instanceGroup members",response=Response.class) - @Transactional - public Response removeInstanceGroupMembers(String request, @PathParam("version") String version, @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) throws ApiException { - String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId); - return serviceInstances(request, Action.removeMembers, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); - } - - public Response serviceInstances(String requestJSON, Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException { - String serviceInstanceId = (instanceIdMap ==null)? null:instanceIdMap.get("serviceInstanceId"); - Boolean aLaCarte = null; - long startTime = System.currentTimeMillis (); - ServiceInstancesRequest sir = null; - String apiVersion = version.substring(1); - - sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri); - String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri); - InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope); - if(sir.getRequestDetails().getRequestParameters() != null){ - aLaCarte = sir.getRequestDetails().getRequestParameters().getALaCarte(); - } - requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq); - requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap); - - int requestVersion = Integer.parseInt(version.substring(1)); - String instanceName = null; - if (sir.getRequestDetails().getRequestInfo() != null) { - instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName(); - } - boolean alaCarteFlag = msoRequest.getAlacarteFlag(sir); - String vnfType = msoRequest.getVnfType(sir,requestScope,action,requestVersion); - String networkType = msoRequest.getNetworkType(sir,requestScope); - String sdcServiceModelVersion = msoRequest.getSDCServiceModelVersion(sir); - String vfModuleType = msoRequest.getVfModuleType(sir,requestScope,action,requestVersion); - - if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && vnfType != null){ - currentActiveReq.setVnfType(vnfType); - }else if(requestScope.equalsIgnoreCase(ModelType.network.name()) && networkType != null){ - currentActiveReq.setNetworkType(networkType); - } - - InfraActiveRequests dup = null; - boolean inProgress = false; - - dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName,requestScope, currentActiveReq); - - if(dup != null){ - inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq); - } - - if (dup != null && inProgress) { - requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, instanceName, requestScope, dup); - } - ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse(); - - RequestReferences referencesResponse = new RequestReferences(); - - referencesResponse.setRequestId(requestId); - - serviceResponse.setRequestReferences(referencesResponse); - Boolean isBaseVfModule = false; - - RecipeLookupResult recipeLookupResult = getServiceInstanceOrchestrationURI(sir, action, alaCarteFlag, currentActiveReq); - String serviceInstanceType = requestHandlerUtils.getServiceType(requestScope, sir, alaCarteFlag); - ModelType modelType; - ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); - if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) { - modelType = ModelType.vnf; - }else if(action == Action.addMembers || action == Action.removeMembers){ - modelType = ModelType.instanceGroup; - }else { - modelType =modelInfo.getModelType(); - } - - if (modelType.equals(ModelType.vfModule)) { - - - // Get VF Module-specific base module indicator - VfModule vfm = null; - - String modelVersionId = modelInfo.getModelVersionId(); - - if(modelVersionId != null) { - vfm = catalogDbClient.getVfModuleByModelUUID(modelVersionId); - } else if(modelInfo.getModelInvariantId() != null && modelInfo.getModelVersion() != null){ - vfm = catalogDbClient.getVfModuleByModelInvariantUUIDAndModelVersion(modelInfo.getModelInvariantId(), modelInfo.getModelVersion()); - } - - if (vfm != null) { - if (vfm.getIsBase()) { - isBaseVfModule = true; - } + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Remove instanceGroup members", response = Response.class) + @Transactional + public Response removeInstanceGroupMembers(String request, @PathParam("version") String version, + @PathParam("instanceGroupId") String instanceGroupId, @Context ContainerRequestContext requestContext) + throws ApiException { + String requestId = requestHandlerUtils.getRequestId(requestContext); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, instanceGroupId); + return serviceInstances(request, Action.removeMembers, instanceIdMap, version, requestId, + requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); + } + + public Response serviceInstances(String requestJSON, Actions action, HashMap<String, String> instanceIdMap, + String version, String requestId, String requestUri) throws ApiException { + String serviceInstanceId = (instanceIdMap == null) ? null : instanceIdMap.get("serviceInstanceId"); + Boolean aLaCarte = null; + long startTime = System.currentTimeMillis(); + ServiceInstancesRequest sir = null; + String apiVersion = version.substring(1); + + sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, + requestId, requestUri); + String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri); + InfraActiveRequests currentActiveReq = + msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope); + if (sir.getRequestDetails().getRequestParameters() != null) { + aLaCarte = sir.getRequestDetails().getRequestParameters().getALaCarte(); + } + requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, + currentActiveReq); + requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap); + + int requestVersion = Integer.parseInt(version.substring(1)); + String instanceName = null; + if (sir.getRequestDetails().getRequestInfo() != null) { + instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName(); + } + boolean alaCarteFlag = msoRequest.getAlacarteFlag(sir); + String vnfType = msoRequest.getVnfType(sir, requestScope, action, requestVersion); + String networkType = msoRequest.getNetworkType(sir, requestScope); + String sdcServiceModelVersion = msoRequest.getSDCServiceModelVersion(sir); + String vfModuleType = msoRequest.getVfModuleType(sir, requestScope, action, requestVersion); + + if (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && vnfType != null) { + currentActiveReq.setVnfType(vnfType); + } else if (requestScope.equalsIgnoreCase(ModelType.network.name()) && networkType != null) { + currentActiveReq.setNetworkType(networkType); + } + + InfraActiveRequests dup = null; + boolean inProgress = false; + + dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName, + requestScope, currentActiveReq); + + if (dup != null) { + inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq); + } + + if (dup != null && inProgress) { + requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, + msoRequest, instanceName, requestScope, dup); + } + ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse(); + + RequestReferences referencesResponse = new RequestReferences(); + + referencesResponse.setRequestId(requestId); + + serviceResponse.setRequestReferences(referencesResponse); + Boolean isBaseVfModule = false; + + RecipeLookupResult recipeLookupResult = + getServiceInstanceOrchestrationURI(sir, action, alaCarteFlag, currentActiveReq); + String serviceInstanceType = requestHandlerUtils.getServiceType(requestScope, sir, alaCarteFlag); + ModelType modelType; + ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); + if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) { + modelType = ModelType.vnf; + } else if (action == Action.addMembers || action == Action.removeMembers) { + modelType = ModelType.instanceGroup; + } else { + modelType = modelInfo.getModelType(); + } + + if (modelType.equals(ModelType.vfModule)) { + + + // Get VF Module-specific base module indicator + VfModule vfm = null; + + String modelVersionId = modelInfo.getModelVersionId(); + + if (modelVersionId != null) { + vfm = catalogDbClient.getVfModuleByModelUUID(modelVersionId); + } else if (modelInfo.getModelInvariantId() != null && modelInfo.getModelVersion() != null) { + vfm = catalogDbClient.getVfModuleByModelInvariantUUIDAndModelVersion(modelInfo.getModelInvariantId(), + modelInfo.getModelVersion()); + } + + if (vfm != null) { + if (vfm.getIsBase()) { + isBaseVfModule = true; + } } else if (action == Action.createInstance || action == Action.updateInstance) { - // There is no entry for this vfModuleType with this version, if specified, in VF_MODULE table in Catalog DB. - // This request cannot proceed - - String serviceVersionText = ""; - if (sdcServiceModelVersion != null && !sdcServiceModelVersion.isEmpty ()) { - serviceVersionText = " with version " + sdcServiceModelVersion; - } - - String errorMessage = "VnfType " + vnfType + " and VF Module Model Name " + modelInfo.getModelName() + serviceVersionText + " not found in MSO Catalog DB"; - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - VfModuleNotFoundException vfModuleException = new VfModuleNotFoundException.Builder(errorMessage, HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build(); + // There is no entry for this vfModuleType with this version, if specified, in VF_MODULE table in + // Catalog DB. + // This request cannot proceed + + String serviceVersionText = ""; + if (sdcServiceModelVersion != null && !sdcServiceModelVersion.isEmpty()) { + serviceVersionText = " with version " + sdcServiceModelVersion; + } + + String errorMessage = "VnfType " + vnfType + " and VF Module Model Name " + modelInfo.getModelName() + + serviceVersionText + " not found in MSO Catalog DB"; + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + VfModuleNotFoundException vfModuleException = new VfModuleNotFoundException.Builder(errorMessage, + HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build(); requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, vfModuleException.getMessage()); throw vfModuleException; - } - } - - - serviceInstanceId = requestHandlerUtils.setServiceInstanceId(requestScope, sir); - String vnfId = ""; - String vfModuleId = ""; - String volumeGroupId = ""; - String networkId = ""; - String pnfCorrelationId = ""; - String instanceGroupId = null; - - if(sir.getVnfInstanceId () != null){ - vnfId = sir.getVnfInstanceId (); - } - - if(sir.getVfModuleInstanceId () != null){ - vfModuleId = sir.getVfModuleInstanceId (); - } - - if(sir.getVolumeGroupInstanceId () != null){ - volumeGroupId = sir.getVolumeGroupInstanceId (); - } - - if(sir.getNetworkInstanceId () != null){ - networkId = sir.getNetworkInstanceId (); - } - if(sir.getInstanceGroupId() != null){ - instanceGroupId = sir.getInstanceGroupId(); - } + } + } + + + serviceInstanceId = requestHandlerUtils.setServiceInstanceId(requestScope, sir); + String vnfId = ""; + String vfModuleId = ""; + String volumeGroupId = ""; + String networkId = ""; + String pnfCorrelationId = ""; + String instanceGroupId = null; + + if (sir.getVnfInstanceId() != null) { + vnfId = sir.getVnfInstanceId(); + } + + if (sir.getVfModuleInstanceId() != null) { + vfModuleId = sir.getVfModuleInstanceId(); + } + + if (sir.getVolumeGroupInstanceId() != null) { + volumeGroupId = sir.getVolumeGroupInstanceId(); + } + + if (sir.getNetworkInstanceId() != null) { + networkId = sir.getNetworkInstanceId(); + } + if (sir.getInstanceGroupId() != null) { + instanceGroupId = sir.getInstanceGroupId(); + } pnfCorrelationId = getPnfCorrelationId(sir); - try{ + try { infraActiveRequestsClient.save(currentActiveReq); - }catch(Exception e){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) - .errorInfo(errorLoggerInfo).build(); + } catch (Exception e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build(); } - - if(!requestScope.equalsIgnoreCase(ModelType.service.name()) && action != Action.recreateInstance){ - aLaCarte = true; - }else if(aLaCarte == null){ - aLaCarte = false; - } - - RequestClientParameter requestClientParameter = null; - try { - requestClientParameter = new RequestClientParameter.Builder() - .setRequestId(requestId) - .setBaseVfModule(isBaseVfModule) - .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) - .setRequestAction(action.toString()) - .setServiceInstanceId(serviceInstanceId) - .setPnfCorrelationId(pnfCorrelationId) - .setVnfId(vnfId) - .setVfModuleId(vfModuleId) - .setVolumeGroupId(volumeGroupId) - .setNetworkId(networkId) - .setServiceType(serviceInstanceType) - .setVnfType(vnfType) - .setVfModuleType(vfModuleType) - .setNetworkType(networkType) - .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action)) - .setApiVersion(apiVersion) - .setALaCarte(aLaCarte) - .setRequestUri(requestUri) - .setInstanceGroupId(instanceGroupId).build(); - } catch (IOException e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER) - .errorInfo(errorLoggerInfo).build(); - } - return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope); - } - public Response deleteInstanceGroups(Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri, ContainerRequestContext requestContext) throws ApiException { - String instanceGroupId = instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID); - Boolean aLaCarte = true; - long startTime = System.currentTimeMillis (); - String apiVersion = version.substring(1); - ServiceInstancesRequest sir = new ServiceInstancesRequest(); - sir.setInstanceGroupId(instanceGroupId); - - String requestScope = ModelType.instanceGroup.toString(); - InfraActiveRequests currentActiveReq = msoRequest.createRequestObject (sir, action, requestId, Status.IN_PROGRESS, null, requestScope); - requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap); - try { - requestHandlerUtils.validateHeaders(requestContext); - } catch (ValidationException e) { - logger.error("Exception occurred", e); - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) - .errorInfo(errorLoggerInfo).build(); + + if (!requestScope.equalsIgnoreCase(ModelType.service.name()) && action != Action.recreateInstance) { + aLaCarte = true; + } else if (aLaCarte == null) { + aLaCarte = false; + } + + RequestClientParameter requestClientParameter = null; + try { + requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId) + .setBaseVfModule(isBaseVfModule).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) + .setRequestAction(action.toString()).setServiceInstanceId(serviceInstanceId) + .setPnfCorrelationId(pnfCorrelationId).setVnfId(vnfId).setVfModuleId(vfModuleId) + .setVolumeGroupId(volumeGroupId).setNetworkId(networkId).setServiceType(serviceInstanceType) + .setVnfType(vnfType).setVfModuleType(vfModuleType).setNetworkType(networkType) + .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action)) + .setApiVersion(apiVersion).setALaCarte(aLaCarte).setRequestUri(requestUri) + .setInstanceGroupId(instanceGroupId).build(); + } catch (IOException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo) + .build(); + } + return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, + recipeLookupResult.getOrchestrationURI(), requestScope); + } + + public Response deleteInstanceGroups(Actions action, HashMap<String, String> instanceIdMap, String version, + String requestId, String requestUri, ContainerRequestContext requestContext) throws ApiException { + String instanceGroupId = instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID); + Boolean aLaCarte = true; + long startTime = System.currentTimeMillis(); + String apiVersion = version.substring(1); + ServiceInstancesRequest sir = new ServiceInstancesRequest(); + sir.setInstanceGroupId(instanceGroupId); + + String requestScope = ModelType.instanceGroup.toString(); + InfraActiveRequests currentActiveReq = + msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, null, requestScope); + requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap); + try { + requestHandlerUtils.validateHeaders(requestContext); + } catch (ValidationException e) { + logger.error("Exception occurred", e); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + ValidateException validateException = + new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); throw validateException; - } - - InfraActiveRequests dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, startTime, msoRequest, null, requestScope, currentActiveReq); - boolean inProgress = false; - - if(dup != null){ - inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq); - } - - if (dup != null && inProgress) { - requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, null, requestScope, dup); - } - - ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse(); - - RequestReferences referencesResponse = new RequestReferences(); - - referencesResponse.setRequestId(requestId); - - serviceResponse.setRequestReferences(referencesResponse); - Boolean isBaseVfModule = false; + } + + InfraActiveRequests dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, startTime, msoRequest, null, + requestScope, currentActiveReq); + boolean inProgress = false; + + if (dup != null) { + inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq); + } + + if (dup != null && inProgress) { + requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, + msoRequest, null, requestScope, dup); + } + + ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse(); + + RequestReferences referencesResponse = new RequestReferences(); + + referencesResponse.setRequestId(requestId); + + serviceResponse.setRequestReferences(referencesResponse); + Boolean isBaseVfModule = false; RecipeLookupResult recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180); - - try{ + + try { infraActiveRequestsClient.save(currentActiveReq); - }catch(Exception e){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) - .errorInfo(errorLoggerInfo).build(); + } catch (Exception e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build(); } - - RequestClientParameter requestClientParameter = new RequestClientParameter.Builder() - .setRequestId(requestId) - .setBaseVfModule(isBaseVfModule) - .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) - .setRequestAction(action.toString()) - .setApiVersion(apiVersion) - .setALaCarte(aLaCarte) - .setRequestUri(requestUri) - .setInstanceGroupId(instanceGroupId).build(); - - return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope); - } - - private String getPnfCorrelationId(ServiceInstancesRequest sir) { - return Optional.of(sir) - .map(ServiceInstancesRequest::getRequestDetails) - .map(RequestDetails::getRequestParameters) - .map(parameters -> parameters.getUserParamValue("pnfId")) - .orElse(""); - } - - private RecipeLookupResult getServiceInstanceOrchestrationURI(ServiceInstancesRequest sir, Actions action, boolean alaCarteFlag, - InfraActiveRequests currentActiveReq) throws ApiException { - RecipeLookupResult recipeLookupResult = null; - //if the aLaCarte flag is set to TRUE, the API-H should choose the VID_DEFAULT recipe for the requested action - ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); - // Query MSO Catalog DB - - if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) { - recipeLookupResult = getDefaultVnfUri(sir, action); - }else if(action == Action.addMembers || action == Action.removeMembers){ - recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180); - }else if (modelInfo.getModelType().equals(ModelType.service)) { - try { - recipeLookupResult = getServiceURI(sir, action,alaCarteFlag); - } catch (IOException e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - - - ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) - .errorInfo(errorLoggerInfo).build(); + + RequestClientParameter requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId) + .setBaseVfModule(isBaseVfModule).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) + .setRequestAction(action.toString()).setApiVersion(apiVersion).setALaCarte(aLaCarte) + .setRequestUri(requestUri).setInstanceGroupId(instanceGroupId).build(); + + return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, + recipeLookupResult.getOrchestrationURI(), requestScope); + } + + private String getPnfCorrelationId(ServiceInstancesRequest sir) { + return Optional.of(sir).map(ServiceInstancesRequest::getRequestDetails) + .map(RequestDetails::getRequestParameters).map(parameters -> parameters.getUserParamValue("pnfId")) + .orElse(""); + } + + private RecipeLookupResult getServiceInstanceOrchestrationURI(ServiceInstancesRequest sir, Actions action, + boolean alaCarteFlag, InfraActiveRequests currentActiveReq) throws ApiException { + RecipeLookupResult recipeLookupResult = null; + // if the aLaCarte flag is set to TRUE, the API-H should choose the VID_DEFAULT recipe for the requested action + ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); + // Query MSO Catalog DB + + if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) { + recipeLookupResult = getDefaultVnfUri(sir, action); + } else if (action == Action.addMembers || action == Action.removeMembers) { + recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180); + } else if (modelInfo.getModelType().equals(ModelType.service)) { + try { + recipeLookupResult = getServiceURI(sir, action, alaCarteFlag); + } catch (IOException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + + + ValidateException validateException = + new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); throw validateException; - } - } else if (modelInfo.getModelType().equals(ModelType.vfModule) || - modelInfo.getModelType().equals(ModelType.volumeGroup) || modelInfo.getModelType().equals(ModelType.vnf)) { + } + } else if (modelInfo.getModelType().equals(ModelType.vfModule) + || modelInfo.getModelType().equals(ModelType.volumeGroup) + || modelInfo.getModelType().equals(ModelType.vnf)) { try { - recipeLookupResult = getVnfOrVfModuleUri( sir, action); + recipeLookupResult = getVnfOrVfModuleUri(sir, action); } catch (ValidationException e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) - .errorInfo(errorLoggerInfo).build(); + ValidateException validateException = + new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); throw validateException; } - }else if (modelInfo.getModelType().equals(ModelType.network)) { + } else if (modelInfo.getModelType().equals(ModelType.network)) { try { - recipeLookupResult = getNetworkUri( sir, action); + recipeLookupResult = getNetworkUri(sir, action); } catch (ValidationException e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) - .errorInfo(errorLoggerInfo).build(); + ValidateException validateException = + new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); throw validateException; } - }else if(modelInfo.getModelType().equals(ModelType.instanceGroup)){ - recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180); + } else if (modelInfo.getModelType().equals(ModelType.instanceGroup)) { + recipeLookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 180); } if (recipeLookupResult == null) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - RecipeNotFoundException recipeNotFoundExceptionException = new RecipeNotFoundException.Builder("Recipe could not be retrieved from catalog DB.", HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR) - .errorInfo(errorLoggerInfo).build(); + RecipeNotFoundException recipeNotFoundExceptionException = + new RecipeNotFoundException.Builder("Recipe could not be retrieved from catalog DB.", + HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).errorInfo(errorLoggerInfo) + .build(); - requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, recipeNotFoundExceptionException.getMessage()); + requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, + recipeNotFoundExceptionException.getMessage()); throw recipeNotFoundExceptionException; - } - return recipeLookupResult; - } - - private RecipeLookupResult getServiceURI(ServiceInstancesRequest servInstReq, Actions action, boolean alaCarteFlag) throws IOException { - // SERVICE REQUEST - // Construct the default service name - // TODO need to make this a configurable property - String defaultServiceModelName = requestHandlerUtils.getDefaultModel(servInstReq); - RequestDetails requestDetails = servInstReq.getRequestDetails(); - ModelInfo modelInfo = requestDetails.getModelInfo(); - org.onap.so.db.catalog.beans.Service serviceRecord; - List<org.onap.so.db.catalog.beans.Service> serviceRecordList; - ServiceRecipe recipe = null; - - if(alaCarteFlag){ - serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); - if(serviceRecord !=null){ - recipe =catalogDbClient.getFirstByServiceModelUUIDAndAction(serviceRecord.getModelUUID(),action.toString()); - } - }else{ - serviceRecord = catalogDbClient.getServiceByID(modelInfo.getModelVersionId()); - recipe = catalogDbClient.getFirstByServiceModelUUIDAndAction(modelInfo.getModelVersionId(), action.toString()); - if (recipe == null){ - serviceRecordList = catalogDbClient.getServiceByModelInvariantUUIDOrderByModelVersionDesc(modelInfo.getModelInvariantId()); - if(!serviceRecordList.isEmpty()){ - for(org.onap.so.db.catalog.beans.Service record : serviceRecordList){ - recipe = catalogDbClient.getFirstByServiceModelUUIDAndAction(record.getModelUUID(),action.toString()); - if(recipe != null){ - break; - } - } - } - } - } - - //if an aLaCarte flag was sent in the request, throw an error if the recipe was not found - RequestParameters reqParam = requestDetails.getRequestParameters(); - if(reqParam!=null && alaCarteFlag && recipe==null){ - return null; - } else if(!alaCarteFlag && recipe != null && Action.createInstance.equals(action)) { - mapToLegacyRequest(requestDetails); - }else if (recipe == null) { //aLaCarte wasn't sent, so we'll try the default - serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); - recipe = catalogDbClient.getFirstByServiceModelUUIDAndAction(serviceRecord.getModelUUID(),action.toString()); - } - if(modelInfo.getModelVersionId() == null) { - modelInfo.setModelVersionId(serviceRecord.getModelUUID()); - } - if(recipe==null){ - return null; - } - return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ()); - } - - protected void mapToLegacyRequest(RequestDetails requestDetails) throws IOException { - RequestParameters reqParam; - if (requestDetails.getRequestParameters() == null) { - reqParam = new RequestParameters(); - } else { - reqParam = requestDetails.getRequestParameters(); - } - if(requestDetails.getCloudConfiguration() == null) { - CloudConfiguration cloudConfig = configureCloudConfig(reqParam); - if(cloudConfig != null) { - requestDetails.setCloudConfiguration(cloudConfig); - } - } - - List<Map<String, Object>> userParams = configureUserParams(reqParam); - if(!userParams.isEmpty()) { - if (reqParam == null) { - requestDetails.setRequestParameters(new RequestParameters()); - } - requestDetails.getRequestParameters().setUserParams(userParams); - } - } - - protected CloudConfiguration configureCloudConfig(RequestParameters reqParams) throws IOException { - - for(Map<String, Object> params : reqParams.getUserParams()){ - if(params.containsKey("service")){ - Service service = serviceMapper(params); - - Optional<CloudConfiguration> targetConfiguration = addCloudConfig(service.getCloudConfiguration()); - - if (targetConfiguration.isPresent()) { - return targetConfiguration.get(); - } else { - for(Networks network : service.getResources().getNetworks()) { - targetConfiguration = addCloudConfig(network.getCloudConfiguration()); - if(targetConfiguration.isPresent()) { - return targetConfiguration.get(); - } - } - - for(Vnfs vnf : service.getResources().getVnfs()) { - targetConfiguration = addCloudConfig(vnf.getCloudConfiguration()); - - if(targetConfiguration.isPresent()) { - return targetConfiguration.get(); - } - - for(VfModules vfModule : vnf.getVfModules()) { - targetConfiguration = addCloudConfig(vfModule.getCloudConfiguration()); - - if(targetConfiguration.isPresent()) { - return targetConfiguration.get(); - } - } - } - } - } - } - - return null; - } - - private Optional<CloudConfiguration> addCloudConfig(CloudConfiguration sourceCloudConfiguration) { - CloudConfiguration targetConfiguration = new CloudConfiguration(); - if(sourceCloudConfiguration != null) { - targetConfiguration.setAicNodeClli(sourceCloudConfiguration.getAicNodeClli()); - targetConfiguration.setTenantId(sourceCloudConfiguration.getTenantId()); - targetConfiguration.setLcpCloudRegionId(sourceCloudConfiguration.getLcpCloudRegionId()); - targetConfiguration.setCloudOwner(sourceCloudConfiguration.getCloudOwner()); - return Optional.of(targetConfiguration); - } - return Optional.empty(); - } - - protected List<Map<String, Object>> configureUserParams(RequestParameters reqParams) throws IOException { - logger.debug("Configuring UserParams for Macro Request"); - Map<String, Object> userParams = new HashMap<>(); - - for(Map<String, Object> params : reqParams.getUserParams()){ - if(params.containsKey("service")){ - Service service = serviceMapper(params); - - addUserParams(userParams, service.getInstanceParams()); - - for(Networks network : service.getResources().getNetworks()) { - addUserParams(userParams, network.getInstanceParams()); - } - - for(Vnfs vnf: service.getResources().getVnfs()) { - addUserParams(userParams, vnf.getInstanceParams()); - - for(VfModules vfModule: vnf.getVfModules()) { - addUserParams(userParams, vfModule.getInstanceParams()); - } - } - } - } - - return mapFlatMapToNameValue(userParams); + } + return recipeLookupResult; + } + + private RecipeLookupResult getServiceURI(ServiceInstancesRequest servInstReq, Actions action, boolean alaCarteFlag) + throws IOException { + // SERVICE REQUEST + // Construct the default service name + // TODO need to make this a configurable property + String defaultServiceModelName = requestHandlerUtils.getDefaultModel(servInstReq); + RequestDetails requestDetails = servInstReq.getRequestDetails(); + ModelInfo modelInfo = requestDetails.getModelInfo(); + org.onap.so.db.catalog.beans.Service serviceRecord; + List<org.onap.so.db.catalog.beans.Service> serviceRecordList; + ServiceRecipe recipe = null; + + if (alaCarteFlag) { + serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); + if (serviceRecord != null) { + recipe = catalogDbClient.getFirstByServiceModelUUIDAndAction(serviceRecord.getModelUUID(), + action.toString()); + } + } else { + serviceRecord = catalogDbClient.getServiceByID(modelInfo.getModelVersionId()); + recipe = catalogDbClient.getFirstByServiceModelUUIDAndAction(modelInfo.getModelVersionId(), + action.toString()); + if (recipe == null) { + serviceRecordList = catalogDbClient + .getServiceByModelInvariantUUIDOrderByModelVersionDesc(modelInfo.getModelInvariantId()); + if (!serviceRecordList.isEmpty()) { + for (org.onap.so.db.catalog.beans.Service record : serviceRecordList) { + recipe = catalogDbClient.getFirstByServiceModelUUIDAndAction(record.getModelUUID(), + action.toString()); + if (recipe != null) { + break; + } + } + } + } + } + + // if an aLaCarte flag was sent in the request, throw an error if the recipe was not found + RequestParameters reqParam = requestDetails.getRequestParameters(); + if (reqParam != null && alaCarteFlag && recipe == null) { + return null; + } else if (!alaCarteFlag && recipe != null && Action.createInstance.equals(action)) { + mapToLegacyRequest(requestDetails); + } else if (recipe == null) { // aLaCarte wasn't sent, so we'll try the default + serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName); + recipe = catalogDbClient.getFirstByServiceModelUUIDAndAction(serviceRecord.getModelUUID(), + action.toString()); + } + if (modelInfo.getModelVersionId() == null) { + modelInfo.setModelVersionId(serviceRecord.getModelUUID()); + } + if (recipe == null) { + return null; + } + return new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout()); + } + + protected void mapToLegacyRequest(RequestDetails requestDetails) throws IOException { + RequestParameters reqParam; + if (requestDetails.getRequestParameters() == null) { + reqParam = new RequestParameters(); + } else { + reqParam = requestDetails.getRequestParameters(); + } + if (requestDetails.getCloudConfiguration() == null) { + CloudConfiguration cloudConfig = configureCloudConfig(reqParam); + if (cloudConfig != null) { + requestDetails.setCloudConfiguration(cloudConfig); + } + } + + List<Map<String, Object>> userParams = configureUserParams(reqParam); + if (!userParams.isEmpty()) { + if (reqParam == null) { + requestDetails.setRequestParameters(new RequestParameters()); + } + requestDetails.getRequestParameters().setUserParams(userParams); + } + } + + protected CloudConfiguration configureCloudConfig(RequestParameters reqParams) throws IOException { + + for (Map<String, Object> params : reqParams.getUserParams()) { + if (params.containsKey("service")) { + Service service = serviceMapper(params); + + Optional<CloudConfiguration> targetConfiguration = addCloudConfig(service.getCloudConfiguration()); + + if (targetConfiguration.isPresent()) { + return targetConfiguration.get(); + } else { + for (Networks network : service.getResources().getNetworks()) { + targetConfiguration = addCloudConfig(network.getCloudConfiguration()); + if (targetConfiguration.isPresent()) { + return targetConfiguration.get(); + } + } + + for (Vnfs vnf : service.getResources().getVnfs()) { + targetConfiguration = addCloudConfig(vnf.getCloudConfiguration()); + + if (targetConfiguration.isPresent()) { + return targetConfiguration.get(); + } + + for (VfModules vfModule : vnf.getVfModules()) { + targetConfiguration = addCloudConfig(vfModule.getCloudConfiguration()); + + if (targetConfiguration.isPresent()) { + return targetConfiguration.get(); + } + } + } + } + } + } + + return null; + } + + private Optional<CloudConfiguration> addCloudConfig(CloudConfiguration sourceCloudConfiguration) { + CloudConfiguration targetConfiguration = new CloudConfiguration(); + if (sourceCloudConfiguration != null) { + targetConfiguration.setAicNodeClli(sourceCloudConfiguration.getAicNodeClli()); + targetConfiguration.setTenantId(sourceCloudConfiguration.getTenantId()); + targetConfiguration.setLcpCloudRegionId(sourceCloudConfiguration.getLcpCloudRegionId()); + targetConfiguration.setCloudOwner(sourceCloudConfiguration.getCloudOwner()); + return Optional.of(targetConfiguration); + } + return Optional.empty(); + } + + protected List<Map<String, Object>> configureUserParams(RequestParameters reqParams) throws IOException { + logger.debug("Configuring UserParams for Macro Request"); + Map<String, Object> userParams = new HashMap<>(); + + for (Map<String, Object> params : reqParams.getUserParams()) { + if (params.containsKey("service")) { + Service service = serviceMapper(params); + + addUserParams(userParams, service.getInstanceParams()); + + for (Networks network : service.getResources().getNetworks()) { + addUserParams(userParams, network.getInstanceParams()); + } + + for (Vnfs vnf : service.getResources().getVnfs()) { + addUserParams(userParams, vnf.getInstanceParams()); + + for (VfModules vfModule : vnf.getVfModules()) { + addUserParams(userParams, vfModule.getInstanceParams()); + } + } + } + } + + return mapFlatMapToNameValue(userParams); } - private Service serviceMapper(Map<String, Object> params) - throws JsonProcessingException, IOException, JsonParseException, JsonMappingException { - ObjectMapper obj = new ObjectMapper(); - String input = obj.writeValueAsString(params.get("service")); - return obj.readValue(input, Service.class); - } - - private void addUserParams(Map<String, Object> targetUserParams, List<Map<String, String>> sourceUserParams) { - for(Map<String, String> map : sourceUserParams) { - for (Map.Entry<String, String> entry : map.entrySet()) { - targetUserParams.put(entry.getKey(), entry.getValue()); - } - } - } - - protected List<Map<String, Object>> mapFlatMapToNameValue(Map<String, Object> flatMap) { - List<Map<String, Object>> targetUserParams = new ArrayList<>(); - - for(Map.Entry<String, Object> map : flatMap.entrySet()) { - Map<String, Object> targetMap = new HashMap<>(); - targetMap.put(NAME, map.getKey()); - targetMap.put(VALUE, map.getValue()); - targetUserParams.add(targetMap); - } - return targetUserParams; - } - - private RecipeLookupResult getVnfOrVfModuleUri(ServiceInstancesRequest servInstReq, Actions action) throws ValidationException { - - ModelInfo modelInfo = servInstReq.getRequestDetails().getModelInfo(); - String vnfComponentType = modelInfo.getModelType().name(); - - RelatedInstanceList[] instanceList = null; - if (servInstReq.getRequestDetails() != null) { - instanceList = servInstReq.getRequestDetails().getRelatedInstanceList(); - } - - Recipe recipe = null; - String defaultSource = requestHandlerUtils.getDefaultModel(servInstReq); - String modelCustomizationId = modelInfo.getModelCustomizationId(); - String modelCustomizationName = modelInfo.getModelCustomizationName(); - String relatedInstanceModelVersionId = null; - String relatedInstanceModelInvariantId = null; - String relatedInstanceVersion = null; - String relatedInstanceModelCustomizationName = null; - - if (instanceList != null) { - - for(RelatedInstanceList relatedInstanceList : instanceList){ - - RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); - ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo(); - if(relatedInstanceModelInfo.getModelType().equals(ModelType.service)){ - relatedInstanceModelVersionId = relatedInstanceModelInfo.getModelVersionId(); - relatedInstanceVersion = relatedInstanceModelInfo.getModelVersion(); - } - - if(relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)){ - relatedInstanceModelVersionId = relatedInstanceModelInfo.getModelVersionId(); - relatedInstanceModelInvariantId = relatedInstanceModelInfo.getModelInvariantId(); - relatedInstanceVersion = relatedInstanceModelInfo.getModelVersion(); - relatedInstanceModelCustomizationName = relatedInstanceModelInfo.getModelCustomizationName(); - } - } - - if(modelInfo.getModelType().equals(ModelType.vnf)) { - // a. For a vnf request (only create, no update currently): - // i. (v3-v4) If modelInfo.modelCustomizationId is provided, use it to validate catalog DB has record in vnf_resource_customization.model_customization_uuid. - // ii. (v2-v4) If modelInfo.modelCustomizationId is NOT provided (because it is a pre-1702 ASDC model or pre-v3), then modelInfo.modelCustomizationName must have - // been provided (else create request should be rejected). APIH should use the relatedInstance.modelInfo[service].modelVersionId** + modelInfo[vnf].modelCustomizationName - // to “join�? service_to_resource_customizations with vnf_resource_customization to confirm a vnf_resource_customization.model_customization_uuid record exists. - // **If relatedInstance.modelInfo[service].modelVersionId was not provided, use relatedInstance.modelInfo[service].modelInvariantId + modelVersion instead to lookup modelVersionId - // (MODEL_UUID) in SERVICE table. - // iii. Regardless of how the value was provided/obtained above, APIH must always populate vnfModelCustomizationId in bpmnRequest. It would be assumed it was MSO generated - // during 1707 data migration if VID did not provide it originally on request. - // iv. Note: continue to construct the “vnf-type�? value and pass to BPMN (must still be populated in A&AI). - // 1. If modelCustomizationName is NOT provided on a vnf/vfModule request, use modelCustomizationId to look it up in our catalog to construct vnf-type value to pass to BPMN. - - VnfResource vnfResource = null; - VnfResourceCustomization vrc=null; - // Validation for vnfResource - - if(modelCustomizationId!=null) { + private Service serviceMapper(Map<String, Object> params) + throws JsonProcessingException, IOException, JsonParseException, JsonMappingException { + ObjectMapper obj = new ObjectMapper(); + String input = obj.writeValueAsString(params.get("service")); + return obj.readValue(input, Service.class); + } + + private void addUserParams(Map<String, Object> targetUserParams, List<Map<String, String>> sourceUserParams) { + for (Map<String, String> map : sourceUserParams) { + for (Map.Entry<String, String> entry : map.entrySet()) { + targetUserParams.put(entry.getKey(), entry.getValue()); + } + } + } + + protected List<Map<String, Object>> mapFlatMapToNameValue(Map<String, Object> flatMap) { + List<Map<String, Object>> targetUserParams = new ArrayList<>(); + + for (Map.Entry<String, Object> map : flatMap.entrySet()) { + Map<String, Object> targetMap = new HashMap<>(); + targetMap.put(NAME, map.getKey()); + targetMap.put(VALUE, map.getValue()); + targetUserParams.add(targetMap); + } + return targetUserParams; + } + + private RecipeLookupResult getVnfOrVfModuleUri(ServiceInstancesRequest servInstReq, Actions action) + throws ValidationException { + + ModelInfo modelInfo = servInstReq.getRequestDetails().getModelInfo(); + String vnfComponentType = modelInfo.getModelType().name(); + + RelatedInstanceList[] instanceList = null; + if (servInstReq.getRequestDetails() != null) { + instanceList = servInstReq.getRequestDetails().getRelatedInstanceList(); + } + + Recipe recipe = null; + String defaultSource = requestHandlerUtils.getDefaultModel(servInstReq); + String modelCustomizationId = modelInfo.getModelCustomizationId(); + String modelCustomizationName = modelInfo.getModelCustomizationName(); + String relatedInstanceModelVersionId = null; + String relatedInstanceModelInvariantId = null; + String relatedInstanceVersion = null; + String relatedInstanceModelCustomizationName = null; + + if (instanceList != null) { + + for (RelatedInstanceList relatedInstanceList : instanceList) { + + RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo(); + if (relatedInstanceModelInfo.getModelType().equals(ModelType.service)) { + relatedInstanceModelVersionId = relatedInstanceModelInfo.getModelVersionId(); + relatedInstanceVersion = relatedInstanceModelInfo.getModelVersion(); + } + + if (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) { + relatedInstanceModelVersionId = relatedInstanceModelInfo.getModelVersionId(); + relatedInstanceModelInvariantId = relatedInstanceModelInfo.getModelInvariantId(); + relatedInstanceVersion = relatedInstanceModelInfo.getModelVersion(); + relatedInstanceModelCustomizationName = relatedInstanceModelInfo.getModelCustomizationName(); + } + } + + if (modelInfo.getModelType().equals(ModelType.vnf)) { + // a. For a vnf request (only create, no update currently): + // i. (v3-v4) If modelInfo.modelCustomizationId is provided, use it to validate catalog DB has record in + // vnf_resource_customization.model_customization_uuid. + // ii. (v2-v4) If modelInfo.modelCustomizationId is NOT provided (because it is a pre-1702 ASDC model or + // pre-v3), then modelInfo.modelCustomizationName must have + // been provided (else create request should be rejected). APIH should use the + // relatedInstance.modelInfo[service].modelVersionId** + modelInfo[vnf].modelCustomizationName + // to “join�? service_to_resource_customizations with vnf_resource_customization to confirm a + // vnf_resource_customization.model_customization_uuid record exists. + // **If relatedInstance.modelInfo[service].modelVersionId was not provided, use + // relatedInstance.modelInfo[service].modelInvariantId + modelVersion instead to lookup modelVersionId + // (MODEL_UUID) in SERVICE table. + // iii. Regardless of how the value was provided/obtained above, APIH must always populate + // vnfModelCustomizationId in bpmnRequest. It would be assumed it was MSO generated + // during 1707 data migration if VID did not provide it originally on request. + // iv. Note: continue to construct the “vnf-type�? value and pass to BPMN (must still be populated + // in A&AI). + // 1. If modelCustomizationName is NOT provided on a vnf/vfModule request, use modelCustomizationId to + // look it up in our catalog to construct vnf-type value to pass to BPMN. + + VnfResource vnfResource = null; + VnfResourceCustomization vrc = null; + // Validation for vnfResource + + if (modelCustomizationId != null) { vrc = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(modelCustomizationId); - if(vrc != null){ - vnfResource = vrc.getVnfResources(); + if (vrc != null) { + vnfResource = vrc.getVnfResources(); + } + } else { + org.onap.so.db.catalog.beans.Service service = + catalogDbClient.getServiceByID(relatedInstanceModelVersionId); + if (service == null) { + service = catalogDbClient.getServiceByModelVersionAndModelInvariantUUID(relatedInstanceVersion, + relatedInstanceModelInvariantId); + } + + if (service == null) { + throw new ValidationException("service in relatedInstance"); } - } else { - org.onap.so.db.catalog.beans.Service service = catalogDbClient.getServiceByID(relatedInstanceModelVersionId); - if(service == null) { - service = catalogDbClient.getServiceByModelVersionAndModelInvariantUUID(relatedInstanceVersion, relatedInstanceModelInvariantId); - } - - if(service == null) { - throw new ValidationException("service in relatedInstance"); - } for (VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()) { if (vnfResourceCustom.getModelInstanceName().equals(modelCustomizationName)) { - vrc=vnfResourceCustom; + vrc = vnfResourceCustom; } } - - if(vrc != null) { - vnfResource = vrc.getVnfResources(); + + if (vrc != null) { + vnfResource = vrc.getVnfResources(); modelInfo.setModelCustomizationId(vrc.getModelCustomizationUUID()); modelInfo.setModelCustomizationUuid(vrc.getModelCustomizationUUID()); - } - } + } + } - if(vnfResource==null){ - throw new ValidationException("vnfResource"); - } else { - if(modelInfo.getModelVersionId() == null) { + if (vnfResource == null) { + throw new ValidationException("vnfResource"); + } else { + if (modelInfo.getModelVersionId() == null) { modelInfo.setModelVersionId(vnfResource.getModelUUID()); - } - } - - VnfRecipe vnfRecipe = null; - - if(vrc != null) { - String nfRole = vrc.getNfRole(); - if(nfRole != null) { - vnfRecipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(vrc.getNfRole(), action.toString()); - } - } - - if(vnfRecipe == null) { - vnfRecipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); - } - - if (vnfRecipe == null) { - return null; - } - - return new RecipeLookupResult (vnfRecipe.getOrchestrationUri(), vnfRecipe.getRecipeTimeout()); - } else { - /* (v5-v7) If modelInfo.modelCustomizationId is NOT provided (because it is a pre-1702 ASDC model or pre-v3), then modelInfo.modelCustomizationName must have - // been provided (else create request should be rejected). APIH should use the relatedInstance.modelInfo[vnf].modelVersionId + modelInfo[vnf].modelCustomizationName - // to join vnf_to_resource_customizations with vf_resource_customization to confirm a vf_resource_customization.model_customization_uuid record exists. - // Once the vnfs model_customization_uuid has been obtained, use it to find all vfModule customizations for that vnf customization in the vnf_res_custom_to_vf_module_custom join table. - // For each vf_module_cust_model_customization_uuid value returned, use that UUID to query vf_module_customization table along with modelInfo[vfModule|volumeGroup].modelVersionId to - // confirm record matches request data (and to identify the modelCustomizationId associated with the vfModule in the request). This means taking each record found - // in vf_module_customization and looking up in vf_module (using vf_module_customization’s FK into vf_module) to find a match on MODEL_INVARIANT_UUID (modelInvariantId) - // and MODEL_VERSION (modelVersion). - */ - VfModuleCustomization vfmc = null; - VnfResource vnfr; - VnfResourceCustomization vnfrc; - VfModule vfModule = null; - - if(modelInfo.getModelCustomizationId() != null) { - vfmc = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(modelInfo.getModelCustomizationId()); - } else { - vnfr = catalogDbClient.getVnfResourceByModelUUID(relatedInstanceModelVersionId); - if(vnfr == null){ - vnfr = catalogDbClient.getFirstVnfResourceByModelInvariantUUIDAndModelVersion(relatedInstanceModelInvariantId, relatedInstanceVersion); - } - vnfrc = catalogDbClient.getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources(relatedInstanceModelCustomizationName, vnfr); - - List<VfModuleCustomization> list = vnfrc.getVfModuleCustomizations(); - - String vfModuleModelUUID = modelInfo.getModelVersionId(); - for(VfModuleCustomization vf : list) { - VfModuleCustomization vfmCustom; - if(vfModuleModelUUID != null){ - vfmCustom = catalogDbClient.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(vf.getModelCustomizationUUID(), vfModuleModelUUID); - if(vfmCustom != null){ - vfModule = vfmCustom.getVfModule(); - } - }else{ - vfmCustom = catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(vf.getModelCustomizationUUID()); - if(vfmCustom != null){ - vfModule = vfmCustom.getVfModule(); - }else{ - vfModule = catalogDbClient.getVfModuleByModelInvariantUUIDAndModelVersion(relatedInstanceModelInvariantId, relatedInstanceVersion); - } - } - - if(vfModule != null) { - modelInfo.setModelCustomizationId(vf.getModelCustomizationUUID()); - modelInfo.setModelCustomizationUuid(vf.getModelCustomizationUUID()); - break; - } - } - } - - if(vfmc == null && vfModule == null) { - throw new ValidationException("vfModuleCustomization"); - } else if (vfModule == null && vfmc != null) { - vfModule = vfmc.getVfModule(); // can't be null as vfModuleModelUUID is not-null property in VfModuleCustomization table - } - - if(modelInfo.getModelVersionId() == null) { - modelInfo.setModelVersionId(vfModule.getModelUUID()); - } - - - recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(vfModule.getModelUUID(), vnfComponentType, action.toString()); - if(recipe == null){ - List<VfModule> vfModuleRecords= catalogDbClient.getVfModuleByModelInvariantUUIDOrderByModelVersionDesc(vfModule.getModelInvariantUUID()); - if(!vfModuleRecords.isEmpty()){ - for(VfModule record : vfModuleRecords){ - recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(record.getModelUUID(), vnfComponentType, action.toString()); - if(recipe != null){ - break; - } - } - } - } - if(recipe == null) { - recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(defaultSource, vnfComponentType, action.toString()); - if (recipe == null) { - recipe = catalogDbClient.getFirstVnfComponentsRecipeByVnfComponentTypeAndAction(vnfComponentType, action.toString()); - } - - if(recipe == null) { - return null; - } - } - } - } else { - - if(modelInfo.getModelType().equals(ModelType.vnf)) { - recipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); - if (recipe == null) { - return null; - } - } else { - recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(defaultSource, vnfComponentType, action.toString()); - - if (recipe == null) { - return null; - } - } - } - - return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ()); - } - + } + } + + VnfRecipe vnfRecipe = null; + + if (vrc != null) { + String nfRole = vrc.getNfRole(); + if (nfRole != null) { + vnfRecipe = + catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(vrc.getNfRole(), action.toString()); + } + } + + if (vnfRecipe == null) { + vnfRecipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); + } + + if (vnfRecipe == null) { + return null; + } + + return new RecipeLookupResult(vnfRecipe.getOrchestrationUri(), vnfRecipe.getRecipeTimeout()); + } else { + /* + * (v5-v7) If modelInfo.modelCustomizationId is NOT provided (because it is a pre-1702 ASDC model or + * pre-v3), then modelInfo.modelCustomizationName must have // been provided (else create request should + * be rejected). APIH should use the relatedInstance.modelInfo[vnf].modelVersionId + + * modelInfo[vnf].modelCustomizationName // to join vnf_to_resource_customizations with + * vf_resource_customization to confirm a vf_resource_customization.model_customization_uuid record + * exists. // Once the vnfs model_customization_uuid has been obtained, use it to find all vfModule + * customizations for that vnf customization in the vnf_res_custom_to_vf_module_custom join table. // + * For each vf_module_cust_model_customization_uuid value returned, use that UUID to query + * vf_module_customization table along with modelInfo[vfModule|volumeGroup].modelVersionId to // confirm + * record matches request data (and to identify the modelCustomizationId associated with the vfModule in + * the request). This means taking each record found // in vf_module_customization and looking up in + * vf_module (using vf_module_customization’s FK into vf_module) to find a match on + * MODEL_INVARIANT_UUID (modelInvariantId) // and MODEL_VERSION (modelVersion). + */ + VfModuleCustomization vfmc = null; + VnfResource vnfr; + VnfResourceCustomization vnfrc; + VfModule vfModule = null; + + if (modelInfo.getModelCustomizationId() != null) { + vfmc = catalogDbClient + .getVfModuleCustomizationByModelCuztomizationUUID(modelInfo.getModelCustomizationId()); + } else { + vnfr = catalogDbClient.getVnfResourceByModelUUID(relatedInstanceModelVersionId); + if (vnfr == null) { + vnfr = catalogDbClient.getFirstVnfResourceByModelInvariantUUIDAndModelVersion( + relatedInstanceModelInvariantId, relatedInstanceVersion); + } + vnfrc = catalogDbClient.getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources( + relatedInstanceModelCustomizationName, vnfr); + + List<VfModuleCustomization> list = vnfrc.getVfModuleCustomizations(); + + String vfModuleModelUUID = modelInfo.getModelVersionId(); + for (VfModuleCustomization vf : list) { + VfModuleCustomization vfmCustom; + if (vfModuleModelUUID != null) { + vfmCustom = catalogDbClient + .getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID( + vf.getModelCustomizationUUID(), vfModuleModelUUID); + if (vfmCustom != null) { + vfModule = vfmCustom.getVfModule(); + } + } else { + vfmCustom = catalogDbClient + .getVfModuleCustomizationByModelCuztomizationUUID(vf.getModelCustomizationUUID()); + if (vfmCustom != null) { + vfModule = vfmCustom.getVfModule(); + } else { + vfModule = catalogDbClient.getVfModuleByModelInvariantUUIDAndModelVersion( + relatedInstanceModelInvariantId, relatedInstanceVersion); + } + } + + if (vfModule != null) { + modelInfo.setModelCustomizationId(vf.getModelCustomizationUUID()); + modelInfo.setModelCustomizationUuid(vf.getModelCustomizationUUID()); + break; + } + } + } + + if (vfmc == null && vfModule == null) { + throw new ValidationException("vfModuleCustomization"); + } else if (vfModule == null && vfmc != null) { + vfModule = vfmc.getVfModule(); // can't be null as vfModuleModelUUID is not-null property in + // VfModuleCustomization table + } + + if (modelInfo.getModelVersionId() == null) { + modelInfo.setModelVersionId(vfModule.getModelUUID()); + } + + + recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction( + vfModule.getModelUUID(), vnfComponentType, action.toString()); + if (recipe == null) { + List<VfModule> vfModuleRecords = catalogDbClient + .getVfModuleByModelInvariantUUIDOrderByModelVersionDesc(vfModule.getModelInvariantUUID()); + if (!vfModuleRecords.isEmpty()) { + for (VfModule record : vfModuleRecords) { + recipe = catalogDbClient + .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction( + record.getModelUUID(), vnfComponentType, action.toString()); + if (recipe != null) { + break; + } + } + } + } + if (recipe == null) { + recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction( + defaultSource, vnfComponentType, action.toString()); + if (recipe == null) { + recipe = catalogDbClient.getFirstVnfComponentsRecipeByVnfComponentTypeAndAction( + vnfComponentType, action.toString()); + } + + if (recipe == null) { + return null; + } + } + } + } else { + + if (modelInfo.getModelType().equals(ModelType.vnf)) { + recipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); + if (recipe == null) { + return null; + } + } else { + recipe = catalogDbClient.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction( + defaultSource, vnfComponentType, action.toString()); + + if (recipe == null) { + return null; + } + } + } + + return new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout()); + } + private RecipeLookupResult getDefaultVnfUri(ServiceInstancesRequest sir, Actions action) { - - String defaultSource = requestHandlerUtils.getDefaultModel(sir); - VnfRecipe vnfRecipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); + String defaultSource = requestHandlerUtils.getDefaultModel(sir); + + VnfRecipe vnfRecipe = catalogDbClient.getFirstVnfRecipeByNfRoleAndAction(defaultSource, action.toString()); - if (vnfRecipe == null) { - return null; - } + if (vnfRecipe == null) { + return null; + } - return new RecipeLookupResult (vnfRecipe.getOrchestrationUri(), vnfRecipe.getRecipeTimeout()); - } + return new RecipeLookupResult(vnfRecipe.getOrchestrationUri(), vnfRecipe.getRecipeTimeout()); + } private RecipeLookupResult getNetworkUri(ServiceInstancesRequest sir, Actions action) throws ValidationException { - String defaultNetworkType = requestHandlerUtils.getDefaultModel(sir); - - ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); - String modelName = modelInfo.getModelName(); - Recipe recipe = null; - - if(modelInfo.getModelCustomizationId()!=null){ - NetworkResourceCustomization networkResourceCustomization = catalogDbClient.getNetworkResourceCustomizationByModelCustomizationUUID(modelInfo.getModelCustomizationId()); - if(networkResourceCustomization != null){ - NetworkResource networkResource = networkResourceCustomization.getNetworkResource(); - if(networkResource!=null){ - if(modelInfo.getModelVersionId() == null) { - modelInfo.setModelVersionId(networkResource.getModelUUID()); - } - recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(networkResource.getModelName(), action.toString()); - }else{ - throw new ValidationException("no catalog entry found"); - } - }else if(action != Action.deleteInstance){ - throw new ValidationException("modelCustomizationId for networkResourceCustomization lookup", true); - } - }else{ - //ok for version < 3 and action delete - if(modelName != null){ - recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(modelName, action.toString()); - } - } - - if(recipe == null){ - recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(defaultNetworkType, action.toString()); - } - - return recipe !=null ? new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout()) : null; - } - - - private Response configurationRecipeLookup(String requestJSON, Action action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException { - String serviceInstanceId = (instanceIdMap ==null)? null:instanceIdMap.get("serviceInstanceId"); - Boolean aLaCarte = null; - String apiVersion = version.substring(1); - boolean inProgress = false; - - long startTime = System.currentTimeMillis (); - ServiceInstancesRequest sir = null; - - sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, requestId, requestUri); - String requestScope = requestHandlerUtils.deriveRequestScope(action,sir, requestUri); - InfraActiveRequests currentActiveReq = msoRequest.createRequestObject ( sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope); - if(sir.getRequestDetails().getRequestParameters() != null){ - aLaCarte = sir.getRequestDetails().getRequestParameters().getALaCarte(); - } - requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, currentActiveReq); - requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap); - String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName(); - - InfraActiveRequests dup = null; - - dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName,requestScope, currentActiveReq); - - if(dup != null){ - inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq); - } - - if (instanceIdMap != null && dup != null && inProgress) { - requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, msoRequest, instanceName, requestScope, dup); - } - - ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse(); - RequestReferences referencesResponse = new RequestReferences(); - referencesResponse.setRequestId(requestId); - serviceResponse.setRequestReferences(referencesResponse); - - - String orchestrationUri = env.getProperty(CommonConstants.ALACARTE_ORCHESTRATION); - String timeOut = env.getProperty(CommonConstants.ALACARTE_RECIPE_TIMEOUT); - - if (StringUtils.isBlank(orchestrationUri) || StringUtils.isBlank(timeOut)) { - String error = StringUtils.isBlank(orchestrationUri) ? "ALaCarte Orchestration URI not found in properties" : "ALaCarte Recipe Timeout not found in properties"; - - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - - - ValidateException validateException = new ValidateException.Builder(error, HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR) - .errorInfo(errorLoggerInfo).build(); + String defaultNetworkType = requestHandlerUtils.getDefaultModel(sir); + + ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); + String modelName = modelInfo.getModelName(); + Recipe recipe = null; + + if (modelInfo.getModelCustomizationId() != null) { + NetworkResourceCustomization networkResourceCustomization = catalogDbClient + .getNetworkResourceCustomizationByModelCustomizationUUID(modelInfo.getModelCustomizationId()); + if (networkResourceCustomization != null) { + NetworkResource networkResource = networkResourceCustomization.getNetworkResource(); + if (networkResource != null) { + if (modelInfo.getModelVersionId() == null) { + modelInfo.setModelVersionId(networkResource.getModelUUID()); + } + recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(networkResource.getModelName(), + action.toString()); + } else { + throw new ValidationException("no catalog entry found"); + } + } else if (action != Action.deleteInstance) { + throw new ValidationException("modelCustomizationId for networkResourceCustomization lookup", true); + } + } else { + // ok for version < 3 and action delete + if (modelName != null) { + recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(modelName, action.toString()); + } + } + + if (recipe == null) { + recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(defaultNetworkType, action.toString()); + } + + return recipe != null ? new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout()) : null; + } + + + private Response configurationRecipeLookup(String requestJSON, Action action, HashMap<String, String> instanceIdMap, + String version, String requestId, String requestUri) throws ApiException { + String serviceInstanceId = (instanceIdMap == null) ? null : instanceIdMap.get("serviceInstanceId"); + Boolean aLaCarte = null; + String apiVersion = version.substring(1); + boolean inProgress = false; + + long startTime = System.currentTimeMillis(); + ServiceInstancesRequest sir = null; + + sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, startTime, sir, msoRequest, + requestId, requestUri); + String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri); + InfraActiveRequests currentActiveReq = + msoRequest.createRequestObject(sir, action, requestId, Status.IN_PROGRESS, requestJSON, requestScope); + if (sir.getRequestDetails().getRequestParameters() != null) { + aLaCarte = sir.getRequestDetails().getRequestParameters().getALaCarte(); + } + requestHandlerUtils.parseRequest(sir, instanceIdMap, action, version, requestJSON, aLaCarte, requestId, + currentActiveReq); + requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap); + String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName(); + + InfraActiveRequests dup = null; + + dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, startTime, msoRequest, instanceName, + requestScope, currentActiveReq); + + if (dup != null) { + inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq); + } + + if (instanceIdMap != null && dup != null && inProgress) { + requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, startTime, + msoRequest, instanceName, requestScope, dup); + } + + ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse(); + RequestReferences referencesResponse = new RequestReferences(); + referencesResponse.setRequestId(requestId); + serviceResponse.setRequestReferences(referencesResponse); + + + String orchestrationUri = env.getProperty(CommonConstants.ALACARTE_ORCHESTRATION); + String timeOut = env.getProperty(CommonConstants.ALACARTE_RECIPE_TIMEOUT); + + if (StringUtils.isBlank(orchestrationUri) || StringUtils.isBlank(timeOut)) { + String error = StringUtils.isBlank(orchestrationUri) ? "ALaCarte Orchestration URI not found in properties" + : "ALaCarte Recipe Timeout not found in properties"; + + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + + + ValidateException validateException = new ValidateException.Builder(error, HttpStatus.SC_NOT_FOUND, + ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage()); throw validateException; - - } - - serviceInstanceId = ""; - String configurationId = ""; - String pnfCorrelationId = ""; - - if(sir.getServiceInstanceId () != null){ - serviceInstanceId = sir.getServiceInstanceId (); - } - - if(sir.getConfigurationId() != null){ + + } + + serviceInstanceId = ""; + String configurationId = ""; + String pnfCorrelationId = ""; + + if (sir.getServiceInstanceId() != null) { + serviceInstanceId = sir.getServiceInstanceId(); + } + + if (sir.getConfigurationId() != null) { configurationId = sir.getConfigurationId(); } pnfCorrelationId = getPnfCorrelationId(sir); - try{ - infraActiveRequestsClient.save(currentActiveReq); - }catch(Exception e){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) - .errorInfo(errorLoggerInfo).build(); - } - - if(!requestScope.equalsIgnoreCase(ModelType.service.name())){ - aLaCarte = true; - }else if(aLaCarte == null){ - aLaCarte = false; - } - RequestClientParameter requestClientParameter = null; - try { - requestClientParameter = new RequestClientParameter.Builder() - .setRequestId(requestId) - .setBaseVfModule(false) - .setRecipeTimeout(Integer.parseInt(timeOut)) - .setRequestAction(action.toString()) - .setServiceInstanceId(serviceInstanceId) - .setPnfCorrelationId(pnfCorrelationId) - .setConfigurationId(configurationId) - .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action)) - .setApiVersion(apiVersion) - .setALaCarte(aLaCarte) - .setRequestUri(requestUri).build(); - } catch (IOException e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER) - .errorInfo(errorLoggerInfo).build(); - } - - return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, orchestrationUri, requestScope); - } - + try { + infraActiveRequestsClient.save(currentActiveReq); + } catch (Exception e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build(); + } + + if (!requestScope.equalsIgnoreCase(ModelType.service.name())) { + aLaCarte = true; + } else if (aLaCarte == null) { + aLaCarte = false; + } + RequestClientParameter requestClientParameter = null; + try { + requestClientParameter = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(false) + .setRecipeTimeout(Integer.parseInt(timeOut)).setRequestAction(action.toString()) + .setServiceInstanceId(serviceInstanceId).setPnfCorrelationId(pnfCorrelationId) + .setConfigurationId(configurationId) + .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(requestJSON, sir, aLaCarte, action)) + .setApiVersion(apiVersion).setALaCarte(aLaCarte).setRequestUri(requestUri).build(); + } catch (IOException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + throw new ValidateException.Builder("Unable to generate RequestClientParamter object" + e.getMessage(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo) + .build(); + } + + return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, orchestrationUri, + requestScope); + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SubsystemHealthcheckResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SubsystemHealthcheckResponse.java index 625df66d2a..8b25018ee7 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SubsystemHealthcheckResponse.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SubsystemHealthcheckResponse.java @@ -22,15 +22,15 @@ package org.onap.so.apihandlerinfra; import java.io.Serializable; public class SubsystemHealthcheckResponse implements Serializable { - private static final long serialVersionUID = 1L; - private String status; + private static final long serialVersionUID = 1L; + private String status; - public String getStatus() { - return status; - } + public String getStatus() { + return status; + } - public void setStatus(String status) { - this.status = status; - } + public void setStatus(String status) { + this.status = status; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java index b7bd28f45f..7bd7f95286 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java @@ -26,7 +26,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; - import javax.transaction.Transactional; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -34,7 +33,6 @@ import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; - import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.json.JSONArray; @@ -48,7 +46,6 @@ import org.onap.so.apihandler.common.ResponseHandler; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; - import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.apihandlerinfra.tasksbeans.TaskList; import org.onap.so.apihandlerinfra.tasksbeans.TaskVariableValue; @@ -56,264 +53,279 @@ import org.onap.so.apihandlerinfra.tasksbeans.TaskVariables; import org.onap.so.apihandlerinfra.tasksbeans.TasksGetResponse; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @Path("onap/so/infra/tasks") -@Api(value="onap/so/infra/tasks",description="Queries of Manual Tasks") +@Api(value = "onap/so/infra/tasks", description = "Queries of Manual Tasks") @Component public class TasksHandler { private static Logger logger = LoggerFactory.getLogger(TasksHandler.class); - + @Value("${mso.camunda.rest.task.uri}") private String requestUrl; - - @Autowired - private RequestClientFactory reqClientFactory; - @Autowired - private ResponseBuilder builder; - + @Autowired + private RequestClientFactory reqClientFactory; + + @Autowired + private ResponseBuilder builder; + @Path("/{version:[vV]1}") @GET - @ApiOperation(value="Finds Manual Tasks",response=Response.class) + @ApiOperation(value = "Finds Manual Tasks", response = Response.class) @Transactional - public Response queryFilters (@QueryParam("taskId") String taskId, - @QueryParam("originalRequestId") String originalRequestId, - @QueryParam("subscriptionServiceType") String subscriptionServiceType, - @QueryParam("nfRole") String nfRole, - @QueryParam("buildingBlockName") String buildingBlockName, - @QueryParam("originalRequestDate") String originalRequestDate, - @QueryParam("originalRequestorId") String originalRequestorId, - @PathParam("version") String version) throws ApiException { - Response responseBack = null; - String apiVersion = version.substring(1); + public Response queryFilters(@QueryParam("taskId") String taskId, + @QueryParam("originalRequestId") String originalRequestId, + @QueryParam("subscriptionServiceType") String subscriptionServiceType, @QueryParam("nfRole") String nfRole, + @QueryParam("buildingBlockName") String buildingBlockName, + @QueryParam("originalRequestDate") String originalRequestDate, + @QueryParam("originalRequestorId") String originalRequestorId, @PathParam("version") String version) + throws ApiException { + Response responseBack = null; + String apiVersion = version.substring(1); // Prepare the query string to /task interface TaskVariables tv = new TaskVariables(); - + List<TaskVariableValue> tvvList = new ArrayList<>(); - + if (originalRequestId != null) { - TaskVariableValue tvv = new TaskVariableValue(); - tvv.setName("originalRequestId"); - tvv.setValue(originalRequestId); - tvv.setOperator("eq"); - tvvList.add(tvv); + TaskVariableValue tvv = new TaskVariableValue(); + tvv.setName("originalRequestId"); + tvv.setValue(originalRequestId); + tvv.setOperator("eq"); + tvvList.add(tvv); } if (subscriptionServiceType != null) { - TaskVariableValue tvv = new TaskVariableValue(); - tvv.setName("subscriptionServiceType"); - tvv.setValue(subscriptionServiceType); - tvv.setOperator("eq"); - tvvList.add(tvv); + TaskVariableValue tvv = new TaskVariableValue(); + tvv.setName("subscriptionServiceType"); + tvv.setValue(subscriptionServiceType); + tvv.setOperator("eq"); + tvvList.add(tvv); } if (nfRole != null) { - TaskVariableValue tvv = new TaskVariableValue(); - tvv.setName("nfRole"); - tvv.setValue(nfRole); - tvv.setOperator("eq"); - tvvList.add(tvv); + TaskVariableValue tvv = new TaskVariableValue(); + tvv.setName("nfRole"); + tvv.setValue(nfRole); + tvv.setOperator("eq"); + tvvList.add(tvv); } if (buildingBlockName != null) { - TaskVariableValue tvv = new TaskVariableValue(); - tvv.setName("buildingBlockName"); - tvv.setValue(buildingBlockName); - tvv.setOperator("eq"); - tvvList.add(tvv); + TaskVariableValue tvv = new TaskVariableValue(); + tvv.setName("buildingBlockName"); + tvv.setValue(buildingBlockName); + tvv.setOperator("eq"); + tvvList.add(tvv); } if (originalRequestDate != null) { - TaskVariableValue tvv = new TaskVariableValue(); - tvv.setName("originalRequestDate"); - tvv.setValue(originalRequestDate); - tvv.setOperator("eq"); - tvvList.add(tvv); + TaskVariableValue tvv = new TaskVariableValue(); + tvv.setName("originalRequestDate"); + tvv.setValue(originalRequestDate); + tvv.setOperator("eq"); + tvvList.add(tvv); } if (originalRequestorId != null) { - TaskVariableValue tvv = new TaskVariableValue(); - tvv.setName("originalRequestorId"); - tvv.setValue(originalRequestorId); - tvv.setOperator("eq"); - tvvList.add(tvv); - } - + TaskVariableValue tvv = new TaskVariableValue(); + tvv.setName("originalRequestorId"); + tvv.setValue(originalRequestorId); + tvv.setOperator("eq"); + tvvList.add(tvv); + } + tv.setTaskVariables(tvvList); - + RequestClient requestClient = null; - - HttpResponse response = null; - - try { - requestClient = reqClientFactory.getRequestClient(requestUrl); - // Capture audit event - ObjectMapper mapper = new ObjectMapper(); - String camundaJsonReq = mapper.writeValueAsString(tv); - response = requestClient.post(camundaJsonReq); - - } catch(JsonProcessingException e){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).build(); - - - ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(), - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); - - throw validateException; - } catch(IOException e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError).build(); - BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY),HttpStatus.SC_BAD_GATEWAY,ErrorNumbers.SVC_NO_SERVER_RESOURCES).build(); - throw bpmnFailureException; - } - TasksGetResponse trr = new TasksGetResponse(); - List<TaskList> taskList = new ArrayList<>(); - - ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ()); - int bpelStatus = respHandler.getStatus (); - if (bpelStatus == HttpStatus.SC_NO_CONTENT || bpelStatus == HttpStatus.SC_ACCEPTED) { - String respBody = respHandler.getResponseBody(); - if (respBody != null) { - JSONArray data = new JSONArray(respBody); - - for (int i=0; i<data.length();i++) { - JSONObject taskEntry = data.getJSONObject(i); - String id = taskEntry.getString("id"); - if (taskId != null && !taskId.equals(id)) { - continue; - } - // Get variables info for each task ID - TaskList taskListEntry = null; - taskListEntry = getTaskInfo(id); - - taskList.add(taskListEntry); - - } - trr.setTaskList(taskList); - } - - } else { - - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError).build(); - - - BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(bpelStatus), bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR) - .errorInfo(errorLoggerInfo).build(); - - throw bpmnFailureException; - } - - String jsonResponse = null; - try { - ObjectMapper mapper = new ObjectMapper(); - jsonResponse = mapper.writeValueAsString(trr); - } - catch (JsonProcessingException e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).build(); - - - ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(), - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); - - throw validateException; - } - - return builder.buildResponse(HttpStatus.SC_ACCEPTED, "", jsonResponse, apiVersion); - } + + HttpResponse response = null; + + try { + requestClient = reqClientFactory.getRequestClient(requestUrl); + // Capture audit event + ObjectMapper mapper = new ObjectMapper(); + String camundaJsonReq = mapper.writeValueAsString(tv); + response = requestClient.post(camundaJsonReq); + + } catch (JsonProcessingException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .build(); + + + ValidateException validateException = + new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(), + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); + + throw validateException; + } catch (IOException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError) + .build(); + BPMNFailureException bpmnFailureException = + new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY), + HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).build(); + throw bpmnFailureException; + } + TasksGetResponse trr = new TasksGetResponse(); + List<TaskList> taskList = new ArrayList<>(); + + ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType()); + int bpelStatus = respHandler.getStatus(); + if (bpelStatus == HttpStatus.SC_NO_CONTENT || bpelStatus == HttpStatus.SC_ACCEPTED) { + String respBody = respHandler.getResponseBody(); + if (respBody != null) { + JSONArray data = new JSONArray(respBody); + + for (int i = 0; i < data.length(); i++) { + JSONObject taskEntry = data.getJSONObject(i); + String id = taskEntry.getString("id"); + if (taskId != null && !taskId.equals(id)) { + continue; + } + // Get variables info for each task ID + TaskList taskListEntry = null; + taskListEntry = getTaskInfo(id); + + taskList.add(taskListEntry); + + } + trr.setTaskList(taskList); + } + + } else { + + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcesssError) + .build(); + + + BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(bpelStatus), + bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); + + throw bpmnFailureException; + } + + String jsonResponse = null; + try { + ObjectMapper mapper = new ObjectMapper(); + jsonResponse = mapper.writeValueAsString(trr); + } catch (JsonProcessingException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .build(); + + + ValidateException validateException = + new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(), + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); + + throw validateException; + } + + return builder.buildResponse(HttpStatus.SC_ACCEPTED, "", jsonResponse, apiVersion); + } // Makes a GET call to Camunda to get variables for this task - private TaskList getTaskInfo(String taskId) throws ApiException{ - TaskList taskList; - String getRequestUrl = UriBuilder.fromUri(requestUrl).path(taskId).path("variables").build().toString(); - HttpResponse getResponse; - - RequestClient requestClient = reqClientFactory.getRequestClient (getRequestUrl); - // Capture audit event - try { - getResponse = requestClient.get(); - }catch(IOException e){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError).build(); - BPMNFailureException validateException = new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY), HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).build(); - throw validateException; - } - ResponseHandler respHandler = new ResponseHandler (getResponse, requestClient.getType ()); - int bpelStatus = respHandler.getStatus (); - if (bpelStatus == HttpStatus.SC_ACCEPTED) { - String respBody = respHandler.getResponseBody(); - if (respBody != null) { - taskList = buildTaskList(taskId, respBody); - } - else { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError).build(); + private TaskList getTaskInfo(String taskId) throws ApiException { + TaskList taskList; + String getRequestUrl = UriBuilder.fromUri(requestUrl).path(taskId).path("variables").build().toString(); + HttpResponse getResponse; + + RequestClient requestClient = reqClientFactory.getRequestClient(getRequestUrl); + // Capture audit event + try { + getResponse = requestClient.get(); + } catch (IOException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError) + .build(); + BPMNFailureException validateException = + new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY), + HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).build(); + throw validateException; + } + ResponseHandler respHandler = new ResponseHandler(getResponse, requestClient.getType()); + int bpelStatus = respHandler.getStatus(); + if (bpelStatus == HttpStatus.SC_ACCEPTED) { + String respBody = respHandler.getResponseBody(); + if (respBody != null) { + taskList = buildTaskList(taskId, respBody); + } else { + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, + ErrorCode.AvailabilityError).build(); + BPMNFailureException bpmnFailureException = + new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY), + HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).build(); - BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY), HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).build(); + throw bpmnFailureException; + } - throw bpmnFailureException; - } - - } - else { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError).build(); + } else { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError) + .build(); + BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(bpelStatus), + bpelStatus, ErrorNumbers.SVC_NO_SERVER_RESOURCES).build(); - BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(bpelStatus), bpelStatus, ErrorNumbers.SVC_NO_SERVER_RESOURCES).build(); + throw bpmnFailureException; + } + + return taskList; - throw bpmnFailureException; - } - - return taskList; - } - + private TaskList buildTaskList(String taskId, String respBody) throws JSONException { - TaskList taskList = new TaskList(); - JSONObject variables = new JSONObject(respBody); - - taskList.setTaskId(taskId); - taskList.setType(getOptVariableValue(variables, "type")); - taskList.setNfRole(getOptVariableValue(variables, "nfRole")); - taskList.setSubscriptionServiceType(getOptVariableValue(variables, "subscriptionServiceType")); - taskList.setOriginalRequestId(getOptVariableValue(variables, "originalRequestId")); - taskList.setOriginalRequestorId(getOptVariableValue(variables, "originalRequestorId")); - taskList.setErrorSource(getOptVariableValue(variables, "errorSource")); - taskList.setErrorCode(getOptVariableValue(variables, "errorCode")); - taskList.setErrorMessage(getOptVariableValue(variables, "errorMessage")); - taskList.setBuildingBlockName(getOptVariableValue(variables, "buildingBlockName")); - taskList.setBuildingBlockStep(getOptVariableValue(variables, "buildingBlockStep")); - taskList.setDescription(getOptVariableValue(variables, "description")); - taskList.setTimeout(getOptVariableValue(variables, "timeout")); - - String validResponses = getOptVariableValue(variables, "validResponses").toLowerCase(); - List<String> items = Arrays.asList(validResponses.split("\\s*,\\s*")); - taskList.setValidResponses(items); - - return taskList; + TaskList taskList = new TaskList(); + JSONObject variables = new JSONObject(respBody); + + taskList.setTaskId(taskId); + taskList.setType(getOptVariableValue(variables, "type")); + taskList.setNfRole(getOptVariableValue(variables, "nfRole")); + taskList.setSubscriptionServiceType(getOptVariableValue(variables, "subscriptionServiceType")); + taskList.setOriginalRequestId(getOptVariableValue(variables, "originalRequestId")); + taskList.setOriginalRequestorId(getOptVariableValue(variables, "originalRequestorId")); + taskList.setErrorSource(getOptVariableValue(variables, "errorSource")); + taskList.setErrorCode(getOptVariableValue(variables, "errorCode")); + taskList.setErrorMessage(getOptVariableValue(variables, "errorMessage")); + taskList.setBuildingBlockName(getOptVariableValue(variables, "buildingBlockName")); + taskList.setBuildingBlockStep(getOptVariableValue(variables, "buildingBlockStep")); + taskList.setDescription(getOptVariableValue(variables, "description")); + taskList.setTimeout(getOptVariableValue(variables, "timeout")); + + String validResponses = getOptVariableValue(variables, "validResponses").toLowerCase(); + List<String> items = Arrays.asList(validResponses.split("\\s*,\\s*")); + taskList.setValidResponses(items); + + return taskList; } - + private String getOptVariableValue(JSONObject variables, String name) throws JSONException { - String variableEntry = variables.optString(name); - String value = ""; - if (!variableEntry.isEmpty()) { - JSONObject variableEntryJson = new JSONObject(variableEntry); - value = variableEntryJson.optString("value"); - } - return value; + String variableEntry = variables.optString(name); + String value = ""; + if (!variableEntry.isEmpty()) { + JSONObject variableEntryJson = new JSONObject(variableEntry); + value = variableEntryJson.optString("value"); + } + return value; } - - + + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TestApi.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TestApi.java index d2e96562ea..7497617e4d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TestApi.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TestApi.java @@ -21,17 +21,16 @@ package org.onap.so.apihandlerinfra; public enum TestApi { - GR_API("GR-API-DEFAULT"), - VNF_API("VNF-API-DEFAULT"); - - private final String modelName; - - private TestApi(String modelName) { - this.modelName = modelName; - } - - public String getModelName() { - return modelName; - } + GR_API("GR-API-DEFAULT"), VNF_API("VNF-API-DEFAULT"); + + private final String modelName; + + private TestApi(String modelName) { + this.modelName = modelName; + } + + public String getModelName() { + return modelName; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WebSecurityConfigImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WebSecurityConfigImpl.java index aca0fa511e..97b80098e6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WebSecurityConfigImpl.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WebSecurityConfigImpl.java @@ -34,24 +34,21 @@ import org.springframework.util.StringUtils; @Configuration("att-security-config") @Order(2) public class WebSecurityConfigImpl extends WebSecurityConfig { - - - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable() - .authorizeRequests() - .antMatchers("/manage/health","/manage/info").permitAll() - .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(),",").toString()) - .and() - .httpBasic(); - - } - - @Override - public void configure(WebSecurity web) throws Exception { - super.configure(web); - StrictHttpFirewall firewall = new MSOSpringFirewall(); - web.httpFirewall(firewall); - } + + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() + .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",").toString()) + .and().httpBasic(); + + } + + @Override + public void configure(WebSecurity web) throws Exception { + super.configure(web); + StrictHttpFirewall firewall = new MSOSpringFirewall(); + web.httpFirewall(firewall); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java index dba393dcd6..bc4f389469 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java @@ -21,70 +21,68 @@ package org.onap.so.apihandlerinfra; import java.nio.file.Files; import java.nio.file.Paths; - import javax.transaction.Transactional; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; - import org.apache.http.HttpStatus; - import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandler.common.ResponseBuilder; import org.onap.so.apihandlerinfra.exceptions.ValidateException; - import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowSpecifications; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @Path("onap/so/infra/workflowSpecifications") -@Api(value="onap/so/infra/workflowSpecifications",description="Queries of Workflow Specifications") +@Api(value = "onap/so/infra/workflowSpecifications", description = "Queries of Workflow Specifications") @Component public class WorkflowSpecificationsHandler { @Autowired - private ResponseBuilder builder; - + private ResponseBuilder builder; + @Path("/{version:[vV]1}/workflows") @GET - @ApiOperation(value="Finds Workflow Specifications",response=Response.class) + @ApiOperation(value = "Finds Workflow Specifications", response = Response.class) @Transactional - public Response queryFilters (@QueryParam("vnfModelVersionId") String vnfModelVersionId, - @PathParam("version") String version) throws Exception { - - String apiVersion = version.substring(1); - - ObjectMapper mapper1 = new ObjectMapper(); - mapper1.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - - //Replace with Catalog DB Query - WorkflowSpecifications workflowSpecifications = mapper1.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/__files/WorkflowSpecifications.json"))), WorkflowSpecifications.class); - - String jsonResponse = null; - try { - ObjectMapper mapper = new ObjectMapper(); - jsonResponse = mapper.writeValueAsString(workflowSpecifications); - } - catch (JsonProcessingException e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).build(); - ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(), - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); - throw validateException; - } - - return builder.buildResponse(HttpStatus.SC_OK, "", jsonResponse, apiVersion); - } + public Response queryFilters(@QueryParam("vnfModelVersionId") String vnfModelVersionId, + @PathParam("version") String version) throws Exception { + + String apiVersion = version.substring(1); + + ObjectMapper mapper1 = new ObjectMapper(); + mapper1.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + // Replace with Catalog DB Query + WorkflowSpecifications workflowSpecifications = mapper1.readValue( + new String(Files.readAllBytes(Paths.get("src/test/resources/__files/WorkflowSpecifications.json"))), + WorkflowSpecifications.class); + + String jsonResponse = null; + try { + ObjectMapper mapper = new ObjectMapper(); + jsonResponse = mapper.writeValueAsString(workflowSpecifications); + } catch (JsonProcessingException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .build(); + ValidateException validateException = + new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(), + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); + throw validateException; + } + + return builder.buildResponse(HttpStatus.SC_OK, "", jsonResponse, apiVersion); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/CatalogDBConfig.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/CatalogDBConfig.java index 3aa54bdfb3..4d81695e55 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/CatalogDBConfig.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/CatalogDBConfig.java @@ -23,7 +23,6 @@ package org.onap.so.apihandlerinfra.configuration; import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; - import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -40,41 +39,31 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @Configuration @EnableTransactionManagement -@EnableJpaRepositories( - entityManagerFactoryRef = "entityManagerFactory", - basePackages = {"org.onap.so.db.catalog.data.repository"} - ) +@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory", + basePackages = {"org.onap.so.db.catalog.data.repository"}) @Profile({"!test"}) public class CatalogDBConfig { - - @Primary - @Bean(name = "dataSource") - @ConfigurationProperties(prefix = "spring.datasource") - public DataSource dataSource() { - return DataSourceBuilder.create().build(); - } - @Primary - @Bean(name = "entityManagerFactory") - public LocalContainerEntityManagerFactoryBean - entityManagerFactory( - EntityManagerFactoryBuilder builder, - @Qualifier("dataSource") DataSource dataSource - ) { - return builder - .dataSource(dataSource) - .packages("org.onap.so.db.catalog.beans") - .persistenceUnit("catalogDB") - .build(); - } + @Primary + @Bean(name = "dataSource") + @ConfigurationProperties(prefix = "spring.datasource") + public DataSource dataSource() { + return DataSourceBuilder.create().build(); + } + + @Primary + @Bean(name = "entityManagerFactory") + public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder, + @Qualifier("dataSource") DataSource dataSource) { + return builder.dataSource(dataSource).packages("org.onap.so.db.catalog.beans").persistenceUnit("catalogDB") + .build(); + } - @Primary - @Bean(name = "transactionManager") - public PlatformTransactionManager transactionManager( - @Qualifier("entityManagerFactory") EntityManagerFactory - entityManagerFactory - ) { - return new JpaTransactionManager(entityManagerFactory); - } + @Primary + @Bean(name = "transactionManager") + public PlatformTransactionManager transactionManager( + @Qualifier("entityManagerFactory") EntityManagerFactory entityManagerFactory) { + return new JpaTransactionManager(entityManagerFactory); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/RequestDBConfig.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/RequestDBConfig.java index 908b864536..1bc54ffe7b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/RequestDBConfig.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/configuration/RequestDBConfig.java @@ -23,7 +23,6 @@ package org.onap.so.apihandlerinfra.configuration; import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; - import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -39,40 +38,30 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @Configuration @EnableTransactionManagement -@EnableJpaRepositories( - entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager", - basePackages = { "org.onap.so.db.request.data.repository"} - ) +@EnableJpaRepositories(entityManagerFactoryRef = "requestEntityManagerFactory", + transactionManagerRef = "requestTransactionManager", basePackages = {"org.onap.so.db.request.data.repository"}) @Profile({"!test"}) public class RequestDBConfig { - @Bean(name = "requestDataSource") - @ConfigurationProperties(prefix = "request.datasource") - public DataSource dataSource() { - return DataSourceBuilder.create().build(); - } + @Bean(name = "requestDataSource") + @ConfigurationProperties(prefix = "request.datasource") + public DataSource dataSource() { + return DataSourceBuilder.create().build(); + } - @Bean(name = "requestEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean - entityManagerFactory( - EntityManagerFactoryBuilder builder, - @Qualifier("requestDataSource") DataSource dataSource - ) { - return builder - .dataSource(dataSource) - .packages("org.onap.so.db.request.beans") - .persistenceUnit("requestDB") - .build(); - } + @Bean(name = "requestEntityManagerFactory") + public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder, + @Qualifier("requestDataSource") DataSource dataSource) { + return builder.dataSource(dataSource).packages("org.onap.so.db.request.beans").persistenceUnit("requestDB") + .build(); + } - @Bean(name = "requestTransactionManager") - public PlatformTransactionManager transactionManager( - @Qualifier("requestEntityManagerFactory") EntityManagerFactory - entityManagerFactory - ) { - return new JpaTransactionManager(entityManagerFactory); - } + @Bean(name = "requestTransactionManager") + public PlatformTransactionManager transactionManager( + @Qualifier("requestEntityManagerFactory") EntityManagerFactory entityManagerFactory) { + return new JpaTransactionManager(entityManagerFactory); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/CompareModelsRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/CompareModelsRequest.java index 89482f7879..2bca89f980 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/CompareModelsRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/CompareModelsRequest.java @@ -25,44 +25,44 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) public class CompareModelsRequest { - private String globalSubscriberId; - - private String serviceType; + private String globalSubscriberId; - private String modelInvariantIdTarget; - - private String modelVersionIdTarget; + private String serviceType; + private String modelInvariantIdTarget; - public String getGlobalSubscriberId() { - return globalSubscriberId; - } + private String modelVersionIdTarget; - public void setGlobalSubscriberId(String globalSubscriberId) { - this.globalSubscriberId = globalSubscriberId; - } - public String getServiceType() { - return serviceType; - } + public String getGlobalSubscriberId() { + return globalSubscriberId; + } - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } - public String getModelInvariantIdTarget() { - return modelInvariantIdTarget; - } + public String getServiceType() { + return serviceType; + } - public void setModelInvariantIdTarget(String modelInvariantIdTarget) { - this.modelInvariantIdTarget = modelInvariantIdTarget; - } + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } - public String getModelVersionIdTarget() { - return modelVersionIdTarget; - } + public String getModelInvariantIdTarget() { + return modelInvariantIdTarget; + } - public void setModelVersionIdTarget(String modelVersionIdTarget) { - this.modelVersionIdTarget = modelVersionIdTarget; - } + public void setModelInvariantIdTarget(String modelInvariantIdTarget) { + this.modelInvariantIdTarget = modelInvariantIdTarget; + } + + public String getModelVersionIdTarget() { + return modelVersionIdTarget; + } + + public void setModelVersionIdTarget(String modelVersionIdTarget) { + this.modelVersionIdTarget = modelVersionIdTarget; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcResp.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcResp.java index a2b410f57f..c620c379ec 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcResp.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcResp.java @@ -25,13 +25,13 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) public class DelE2ESvcResp { - private String operationId; + private String operationId; - public String getOperationId() { - return operationId; - } + public String getOperationId() { + return operationId; + } - public void setOperationId(String operationId) { - this.operationId = operationId; - } + public void setOperationId(String operationId) { + this.operationId = operationId; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EParameters.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EParameters.java index 6dfa4b6587..6c8ac55523 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EParameters.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EParameters.java @@ -23,41 +23,40 @@ package org.onap.so.apihandlerinfra.e2eserviceinstancebeans; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; - import java.util.HashMap; import java.util.List; import java.util.Map; -@JsonIgnoreProperties({ "additionalProperties" }) +@JsonIgnoreProperties({"additionalProperties"}) public class E2EParameters { - @JsonProperty("locationConstraints") - List<LocationConstraint> locationConstraints; + @JsonProperty("locationConstraints") + List<LocationConstraint> locationConstraints; + + @JsonProperty("resources") + private List<ResourceRequest> resources; - @JsonProperty("resources") - private List<ResourceRequest> resources; + @JsonProperty("requestInputs") + private HashMap<String, ?> requestInputs; - @JsonProperty("requestInputs") - private HashMap<String, ?> requestInputs; + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<>(); - @JsonIgnore - private Map<String, Object> additionalProperties = new HashMap<>(); + public Map<String, Object> getAdditionalProperties() { + return additionalProperties; + } - public Map<String, Object> getAdditionalProperties() { - return additionalProperties; - } + public void setAdditionalProperties(Map<String, Object> additionalProperties) { + this.additionalProperties = additionalProperties; + } - public void setAdditionalProperties(Map<String, Object> additionalProperties) { - this.additionalProperties = additionalProperties; - } - /** * @return Returns the resources. */ public List<ResourceRequest> getResources() { return resources; } - + /** * @param resources The resources to set. */ @@ -73,11 +72,11 @@ public class E2EParameters { this.locationConstraints = locationConstraints; } - public HashMap<String, ?> getRequestInputs() { - return requestInputs; - } + public HashMap<String, ?> getRequestInputs() { + return requestInputs; + } - public void setRequestInputs(HashMap<String, ?> requestInputs) { - this.requestInputs = requestInputs; - } + public void setRequestInputs(HashMap<String, ?> requestInputs) { + this.requestInputs = requestInputs; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2ERequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2ERequest.java index dfe94dd2f0..77abbbfa9a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2ERequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2ERequest.java @@ -22,92 +22,91 @@ package org.onap.so.apihandlerinfra.e2eserviceinstancebeans; import java.sql.Timestamp; - import com.fasterxml.jackson.databind.annotation.JsonSerialize; @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) public class E2ERequest { - protected String operationId; - protected String operation; - protected String result; - protected String reason; - protected String userId; - protected String operationContent; - protected long progress; - protected String operateAt; - protected String finishedAt; - - public String getOperationId() { - return operationId; - } - - public void setOperationId(String operationId) { - this.operationId = operationId; - } - - public String getOperation() { - return operation; - } - - public void setOperation(String operation) { - this.operation = operation; - } - - public String getResult() { - return result; - } - - public void setResult(String result) { - this.result = result; - } - - public String getReason() { - return reason; - } - - public void setReason(String reason) { - this.reason = reason; - } - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public String getOperationContent() { - return operationContent; - } - - public void setOperationContent(String operationContent) { - this.operationContent = operationContent; - } - - public long getProgress() { - return progress; - } - - public void setProgress(long progress) { - this.progress = progress; - } - - public String getOperateAt() { - return operateAt; - } - - public void setOperateAt(String operateAt) { - this.operateAt = operateAt; - } - - public String getFinishedAt() { - return finishedAt; - } - - public void setFinishedAt(String finishedAt) { - this.finishedAt = finishedAt; - } + protected String operationId; + protected String operation; + protected String result; + protected String reason; + protected String userId; + protected String operationContent; + protected long progress; + protected String operateAt; + protected String finishedAt; + + public String getOperationId() { + return operationId; + } + + public void setOperationId(String operationId) { + this.operationId = operationId; + } + + public String getOperation() { + return operation; + } + + public void setOperation(String operation) { + this.operation = operation; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getOperationContent() { + return operationContent; + } + + public void setOperationContent(String operationContent) { + this.operationContent = operationContent; + } + + public long getProgress() { + return progress; + } + + public void setProgress(long progress) { + this.progress = progress; + } + + public String getOperateAt() { + return operateAt; + } + + public void setOperateAt(String operateAt) { + this.operateAt = operateAt; + } + + public String getFinishedAt() { + return finishedAt; + } + + public void setFinishedAt(String finishedAt) { + this.finishedAt = finishedAt; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EService.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EService.java index 9f6a9b438c..f969674ed1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EService.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EService.java @@ -22,99 +22,98 @@ package org.onap.so.apihandlerinfra.e2eserviceinstancebeans; import java.util.HashMap; import java.util.Map; - import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -@JsonIgnoreProperties({ "additionalProperties" }) +@JsonIgnoreProperties({"additionalProperties"}) public class E2EService { - @JsonProperty("name") - private String name; + @JsonProperty("name") + private String name; - @JsonProperty("description") - private String description; + @JsonProperty("description") + private String description; - @JsonProperty("serviceInvariantUuid") - private String serviceInvariantUuid; + @JsonProperty("serviceInvariantUuid") + private String serviceInvariantUuid; - @JsonProperty("serviceUuid") - private String serviceUuid; + @JsonProperty("serviceUuid") + private String serviceUuid; - @JsonProperty("globalSubscriberId") - private String globalSubscriberId; + @JsonProperty("globalSubscriberId") + private String globalSubscriberId; - @JsonProperty("serviceType") - private String serviceType; + @JsonProperty("serviceType") + private String serviceType; - @JsonProperty("parameters") - private E2EParameters parameters; + @JsonProperty("parameters") + private E2EParameters parameters; - @JsonIgnore - private Map<String, Object> additionalProperties = new HashMap<>(); + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<>(); - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public E2EParameters getParameters() { - return parameters; - } + public E2EParameters getParameters() { + return parameters; + } - public void setParameters(E2EParameters parameters) { - this.parameters = parameters; - } + public void setParameters(E2EParameters parameters) { + this.parameters = parameters; + } - public Map<String, Object> getAdditionalProperties() { - return additionalProperties; - } + public Map<String, Object> getAdditionalProperties() { + return additionalProperties; + } - public void setAdditionalProperties(Map<String, Object> additionalProperties) { - this.additionalProperties = additionalProperties; - } + public void setAdditionalProperties(Map<String, Object> additionalProperties) { + this.additionalProperties = additionalProperties; + } - public String getServiceInvariantUuid() { - return serviceInvariantUuid; - } + public String getServiceInvariantUuid() { + return serviceInvariantUuid; + } - public void setServiceInvariantUuid(String serviceInvariantUuid) { - this.serviceInvariantUuid = serviceInvariantUuid; - } + public void setServiceInvariantUuid(String serviceInvariantUuid) { + this.serviceInvariantUuid = serviceInvariantUuid; + } - public String getGlobalSubscriberId() { - return globalSubscriberId; - } + public String getGlobalSubscriberId() { + return globalSubscriberId; + } - public void setGlobalSubscriberId(String globalSubscriberId) { - this.globalSubscriberId = globalSubscriberId; - } + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } - public String getServiceType() { - return serviceType; - } + public String getServiceType() { + return serviceType; + } - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } - public String getServiceUuid() { - return serviceUuid; - } + public String getServiceUuid() { + return serviceUuid; + } - public void setServiceUuid(String serviceUuid) { - this.serviceUuid = serviceUuid; - } + public void setServiceUuid(String serviceUuid) { + this.serviceUuid = serviceUuid; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequest.java index a920bdfdc8..3335410658 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceDeleteRequest.java @@ -23,24 +23,24 @@ package org.onap.so.apihandlerinfra.e2eserviceinstancebeans; public class E2EServiceInstanceDeleteRequest { - private String globalSubscriberId; - - private String serviceType; - - public String getGlobalSubscriberId() { - return globalSubscriberId; - } - - public void setGlobalSubscriberId(String globalSubscriberId) { - this.globalSubscriberId = globalSubscriberId; - } - - public String getServiceType() { - return serviceType; - } - - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } - + private String globalSubscriberId; + + private String serviceType; + + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceRequest.java index e3edf3b742..9f354f02b4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EServiceInstanceRequest.java @@ -22,40 +22,39 @@ package org.onap.so.apihandlerinfra.e2eserviceinstancebeans; import java.util.HashMap; import java.util.Map; - import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -@JsonIgnoreProperties({ "additionalProperties" }) +@JsonIgnoreProperties({"additionalProperties"}) public class E2EServiceInstanceRequest { - @JsonProperty("service") - private E2EService service; + @JsonProperty("service") + private E2EService service; + + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<>(); + + public E2EService getService() { + return service; + } - @JsonIgnore - private Map<String, Object> additionalProperties = new HashMap<>(); + public void setService(E2EService service) { + this.service = service; + } - public E2EService getService() { - return service; - } + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } - public void setService(E2EService service) { - this.service = service; - } - public Map<String, Object> getAdditionalProperties() { - return this.additionalProperties; - } - - - public void setAdditionalProperties(Map<String, Object> additionalProperties) { - this.additionalProperties = additionalProperties; - } + public void setAdditionalProperties(Map<String, Object> additionalProperties) { + this.additionalProperties = additionalProperties; + } - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EUserParam.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EUserParam.java index 531824e379..dbfe023684 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EUserParam.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/E2EUserParam.java @@ -22,48 +22,47 @@ package org.onap.so.apihandlerinfra.e2eserviceinstancebeans; import java.util.HashMap; import java.util.Map; - import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; public class E2EUserParam { - @JsonProperty("name") - private String name; + @JsonProperty("name") + private String name; + + @JsonProperty("value") + private String value; + + @JsonIgnore + private Map<String, Object> additionalProperties = new HashMap<>(); - @JsonProperty("value") - private String value; + public String getName() { + return name; + } - @JsonIgnore - private Map<String, Object> additionalProperties = new HashMap<>(); + public void setName(String name) { + this.name = name; + } - public String getName() { - return name; - } + public String getValue() { + return value; + } - public void setName(String name) { - this.name = name; - } + public void setValue(String value) { + this.value = value; + } - public String getValue() { - return value; - } + public Map<String, Object> getAdditionalProperties() { + return this.additionalProperties; + } - public void setValue(String value) { - this.value = value; - } + public void setAdditionalProperty(String name, Object value) { + this.additionalProperties.put(name, value); + } - public Map<String, Object> getAdditionalProperties() { - return this.additionalProperties; - } + public void setAdditionalProperties(Map<String, Object> additionalProperties) { + this.additionalProperties = additionalProperties; + } - public void setAdditionalProperty(String name, Object value) { - this.additionalProperties.put(name, value); - } - public void setAdditionalProperties(Map<String, Object> additionalProperties) { - this.additionalProperties = additionalProperties; - } - - } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java index 5c958ad2a3..f7fa01aeb0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java @@ -22,28 +22,27 @@ package org.onap.so.apihandlerinfra.e2eserviceinstancebeans; import org.onap.so.db.request.beans.OperationStatus; - import com.fasterxml.jackson.databind.annotation.JsonSerialize; -@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +@JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) public class GetE2EServiceInstanceResponse { - protected OperationStatus operation; + protected OperationStatus operation; -// public OperationStatus getOperationStatus() { -// return operation; -// } -// -// public void setOperationStatus(OperationStatus requestDB) { -// this.operation = requestDB; -// } + // public OperationStatus getOperationStatus() { + // return operation; + // } + // + // public void setOperationStatus(OperationStatus requestDB) { + // this.operation = requestDB; + // } - public OperationStatus getOperation() { - return operation; - } + public OperationStatus getOperation() { + return operation; + } - public void setOperation(OperationStatus operation) { - this.operation = operation; - } + public void setOperation(OperationStatus operation) { + this.operation = operation; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/LocationConstraint.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/LocationConstraint.java index b1256a236b..dc5b69e2f2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/LocationConstraint.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/LocationConstraint.java @@ -57,7 +57,7 @@ public class LocationConstraint { this.vnfProfileId = vnfProfileId; } - + /** * @return Returns the locationConstraints. */ @@ -65,7 +65,7 @@ public class LocationConstraint { return locationConstraints; } - + /** * @param locationConstraints The locationConstraints to set. */ diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/NsParameters.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/NsParameters.java index e7baf98411..02885c7bbb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/NsParameters.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/NsParameters.java @@ -36,6 +36,7 @@ public class NsParameters { private List<LocationConstraint> locationConstraints; private Map<String, Object> additionalParamForNs = new HashMap<>(); + /** * @return Returns the locationConstraints. */ @@ -50,7 +51,7 @@ public class NsParameters { this.locationConstraints = locationConstraints; } - + /** * @return Returns the additionalParamForNs. */ @@ -58,7 +59,7 @@ public class NsParameters { return additionalParamForNs; } - + /** * @param additionalParamForNs The additionalParamForNs to set. */ diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ResourceRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ResourceRequest.java index 6518523256..44592ce2e4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ResourceRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/ResourceRequest.java @@ -22,7 +22,6 @@ package org.onap.so.apihandlerinfra.e2eserviceinstancebeans; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; - import java.util.HashMap; import java.util.Map; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/VimLocation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/VimLocation.java index 72d370425f..5a4b55c048 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/VimLocation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/e2eserviceinstancebeans/VimLocation.java @@ -26,7 +26,7 @@ public class VimLocation { @JsonProperty("vimId") private String vimId; - + /** * @return Returns the vimId. */ @@ -34,12 +34,12 @@ public class VimLocation { return vimId; } - + /** * @param vimId The vimId to set. */ public void setVimId(String vimId) { this.vimId = vimId; } - + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/package-info.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/package-info.java index 2312678460..8b85ce7e34 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/package-info.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/package-info.java @@ -19,12 +19,13 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.01.08 at 03:50:12 PM EST +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.01.08 at 03:50:12 PM EST // -@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.onap/so/request/types/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.onap/so/request/types/v1", + elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) package org.onap.so.apihandlerinfra; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestDetails.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestDetails.java index 957450fab0..ebb1912503 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestDetails.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestDetails.java @@ -24,16 +24,15 @@ import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @JsonRootName(value = "requestDetails") -@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +@JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) public class RequestDetails { - protected RequestInfo requestInfo; - /** + protected RequestInfo requestInfo; + + /** * Gets the value of the requestInfo property. * - * @return - * possible object is - * {@link RequestInfo } + * @return possible object is {@link RequestInfo } * */ public RequestInfo getRequestInfo() { @@ -43,9 +42,7 @@ public class RequestDetails { /** * Sets the value of the requestInfo property. * - * @param value - * allowed object is - * {@link RequestInfo } + * @param value allowed object is {@link RequestInfo } * */ public void setRequestInfo(RequestInfo value) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfo.java index aae8786bb0..61d31b3a55 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfo.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/RequestInfo.java @@ -22,19 +22,17 @@ package org.onap.so.apihandlerinfra.tasksbeans; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +@JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) public class RequestInfo { - protected String source; - protected ValidResponses responseValue; + protected String source; + protected ValidResponses responseValue; protected String requestorId; - + /** * Gets the value of the source property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public String getSource() { @@ -44,30 +42,28 @@ public class RequestInfo { /** * Sets the value of the source property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setSource(String value) { this.source = value; } - public ValidResponses getResponseValue() { - return responseValue; - } + public ValidResponses getResponseValue() { + return responseValue; + } + + public void setResponseValue(ValidResponses responseValue) { + this.responseValue = responseValue; + } - public void setResponseValue(ValidResponses responseValue) { - this.responseValue = responseValue; - } - - public String getRequestorId() { - return requestorId; - } + public String getRequestorId() { + return requestorId; + } - public void setRequestorId(String requestorId) { - this.requestorId = requestorId; - } + public void setRequestorId(String requestorId) { + this.requestorId = requestorId; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskList.java index ceba65fa97..f690aa5f01 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskList.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskList.java @@ -21,21 +21,20 @@ package org.onap.so.apihandlerinfra.tasksbeans; import java.util.List; - import com.fasterxml.jackson.databind.annotation.JsonSerialize; -@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) -public class TaskList { - protected String taskId; - protected String type; - protected String nfRole; - protected String subscriptionServiceType; - protected String originalRequestId; - protected String originalRequestorId; - protected String errorSource; - protected String errorCode; - protected String errorMessage; - protected String buildingBlockName; +@JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) +public class TaskList { + protected String taskId; + protected String type; + protected String nfRole; + protected String subscriptionServiceType; + protected String originalRequestId; + protected String originalRequestorId; + protected String errorSource; + protected String errorCode; + protected String errorMessage; + protected String buildingBlockName; protected String buildingBlockStep; protected String description; protected String timeout; @@ -44,10 +43,8 @@ public class TaskList { /** * Gets the value of the taskId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getTaskId() { return taskId; @@ -56,10 +53,8 @@ public class TaskList { /** * Sets the value of the taskId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setTaskId(String value) { this.taskId = value; @@ -68,10 +63,8 @@ public class TaskList { /** * Gets the value of the type property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getType() { return type; @@ -80,10 +73,8 @@ public class TaskList { /** * Sets the value of the type property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setType(String value) { this.type = value; @@ -92,10 +83,8 @@ public class TaskList { /** * Gets the value of the nfRole property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getNfRole() { return nfRole; @@ -104,10 +93,8 @@ public class TaskList { /** * Sets the value of the nfRole property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setNfRole(String value) { this.nfRole = value; @@ -116,10 +103,8 @@ public class TaskList { /** * Gets the value of the subscriptionServiceType property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getSubscriptionServiceType() { return subscriptionServiceType; @@ -128,10 +113,8 @@ public class TaskList { /** * Sets the value of the subscriptionServiceType property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setSubscriptionServiceType(String value) { this.subscriptionServiceType = value; @@ -140,10 +123,8 @@ public class TaskList { /** * Gets the value of the originalRequestId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getOriginalRequestId() { return originalRequestId; @@ -152,10 +133,8 @@ public class TaskList { /** * Sets the value of the originalRequestId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setOriginalRequestId(String value) { this.originalRequestId = value; @@ -164,10 +143,8 @@ public class TaskList { /** * Gets the value of the originalRequestorId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getOriginalRequestorId() { return originalRequestorId; @@ -176,10 +153,8 @@ public class TaskList { /** * Sets the value of the originalRequestorId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setOriginalRequestorId(String value) { this.originalRequestorId = value; @@ -188,10 +163,8 @@ public class TaskList { /** * Gets the value of the errorSource property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getErrorSource() { return errorSource; @@ -200,10 +173,8 @@ public class TaskList { /** * Sets the value of the errorSource property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setErrorSource(String value) { this.errorSource = value; @@ -212,10 +183,8 @@ public class TaskList { /** * Gets the value of the errorCode property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getErrorCode() { return errorCode; @@ -224,10 +193,8 @@ public class TaskList { /** * Sets the value of the errorCode property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setErrorCode(String value) { this.errorCode = value; @@ -236,10 +203,8 @@ public class TaskList { /** * Gets the value of the errorMessage property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getErrorMessage() { return errorMessage; @@ -248,10 +213,8 @@ public class TaskList { /** * Sets the value of the errorMessage property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setErrorMessage(String value) { this.errorMessage = value; @@ -260,10 +223,8 @@ public class TaskList { /** * Gets the value of the buildingBlockName property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getBuildingBlockName() { return buildingBlockName; @@ -272,10 +233,8 @@ public class TaskList { /** * Sets the value of the buildingBlockName property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setBuildingBlockName(String value) { this.buildingBlockName = value; @@ -284,10 +243,8 @@ public class TaskList { /** * Gets the value of the buildingBlockStep property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getBuildingBlockStep() { return buildingBlockStep; @@ -296,22 +253,18 @@ public class TaskList { /** * Sets the value of the buildingBlockStep property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setBuildingBlockStep(String value) { this.buildingBlockStep = value; } - + /** * Gets the value of the description property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getDescription() { return description; @@ -320,22 +273,18 @@ public class TaskList { /** * Sets the value of the description property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setDescription(String value) { this.description = value; } - + /** * Gets the value of the timeout property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getTimeout() { return timeout; @@ -344,10 +293,8 @@ public class TaskList { /** * Sets the value of the timeout property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setTimeout(String value) { this.timeout = value; @@ -356,10 +303,8 @@ public class TaskList { /** * Gets the value of the validResponses property. * - * @return - * possible object is - * {@link ValidResponses } - * + * @return possible object is {@link ValidResponses } + * */ public List<String> getValidResponses() { return validResponses; @@ -368,16 +313,13 @@ public class TaskList { /** * Sets the value of the validResponses property. * - * @param value - * allowed object is - * {@link ValidResponses } - * + * @param value allowed object is {@link ValidResponses } + * */ public void setValidResponses(List<String> value) { this.validResponses = value; } - } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskRequestReference.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskRequestReference.java index 860fe6bddb..18c9005f40 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskRequestReference.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskRequestReference.java @@ -1,19 +1,15 @@ -/* ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at +/* + * ============LICENSE_START======================================================= ONAP - SO + * ================================================================================ Copyright (C) 2017 AT&T Intellectual + * Property. All rights reserved. ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. * ============LICENSE_END========================================================= */ @@ -21,18 +17,17 @@ package org.onap.so.apihandlerinfra.tasksbeans; import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.databind.annotation.JsonSerialize; + @JsonRootName(value = "taskRequestReference") -@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +@JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) public class TaskRequestReference { - protected String taskId; - + protected String taskId; + /** * Gets the value of the taskId property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public String getTaskId() { @@ -42,15 +37,13 @@ public class TaskRequestReference { /** * Sets the value of the taskId property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setTaskId(String value) { this.taskId = value; } - + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValue.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValue.java index 441d4f315a..fab42515d5 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValue.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariableValue.java @@ -22,19 +22,17 @@ package org.onap.so.apihandlerinfra.tasksbeans; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +@JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) public class TaskVariableValue { - protected String name; - protected String value; - protected String operator; - - /** + protected String name; + protected String value; + protected String operator; + + /** * Gets the value of the name property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public String getName() { @@ -44,22 +42,18 @@ public class TaskVariableValue { /** * Sets the value of the name property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setName(String value) { this.name = value; } - - + + /** * Gets the value of the value property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public String getValue() { @@ -69,21 +63,17 @@ public class TaskVariableValue { /** * Sets the value of the value property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setValue(String value) { this.value = value; } - + /** * Gets the value of the operator property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public String getOperator() { @@ -93,15 +83,13 @@ public class TaskVariableValue { /** * Sets the value of the operator property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setOperator(String value) { this.operator = value; } - - + + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariables.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariables.java index 7d5b465891..e759b4f87a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariables.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TaskVariables.java @@ -21,19 +21,18 @@ package org.onap.so.apihandlerinfra.tasksbeans; import java.util.List; - import com.fasterxml.jackson.databind.annotation.JsonSerialize; -@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +@JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) public class TaskVariables { - private List<TaskVariableValue> taskVariables; + private List<TaskVariableValue> taskVariables; - public List<TaskVariableValue> getTaskVariables() { - return taskVariables; - } + public List<TaskVariableValue> getTaskVariables() { + return taskVariables; + } - public void setTaskVariables(List<TaskVariableValue> taskVariables) { - this.taskVariables = taskVariables; - } + public void setTaskVariables(List<TaskVariableValue> taskVariables) { + this.taskVariables = taskVariables; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TasksGetResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TasksGetResponse.java index 5ee01aeaf6..b0b6f43e03 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TasksGetResponse.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TasksGetResponse.java @@ -24,13 +24,13 @@ import java.util.List; public class TasksGetResponse { - private List<TaskList> taskList; + private List<TaskList> taskList; - public List<TaskList> getTaskList() { - return taskList; - } + public List<TaskList> getTaskList() { + return taskList; + } - public void setTaskList(List<TaskList> taskList) { - this.taskList = taskList; - } + public void setTaskList(List<TaskList> taskList) { + this.taskList = taskList; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TasksRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TasksRequest.java index 0544f536a2..bd37ecd10a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TasksRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/TasksRequest.java @@ -22,13 +22,13 @@ package org.onap.so.apihandlerinfra.tasksbeans; public class TasksRequest { - private RequestDetails requestDetails; + private RequestDetails requestDetails; - public RequestDetails getRequestDetails() { - return requestDetails; - } + public RequestDetails getRequestDetails() { + return requestDetails; + } - public void setRequestDetails(RequestDetails requestDetails) { - this.requestDetails = requestDetails; - } + public void setRequestDetails(RequestDetails requestDetails) { + this.requestDetails = requestDetails; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/ValidResponses.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/ValidResponses.java index 18fc7f9739..e25e40ced4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/ValidResponses.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/ValidResponses.java @@ -19,10 +19,10 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // @@ -30,17 +30,11 @@ package org.onap.so.apihandlerinfra.tasksbeans; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +@JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) public enum ValidResponses { - rollback, - abort, - skip, - retry, - manual, - resume - ; + rollback, abort, skip, retry, manual, resume; public String value() { return name(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/Value.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/Value.java index 98ed5b653f..be113010b4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/Value.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/Value.java @@ -22,17 +22,15 @@ package org.onap.so.apihandlerinfra.tasksbeans; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +@JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) public class Value { - protected String value; - + protected String value; + /** * Gets the value of the value property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public String getValue() { @@ -42,14 +40,12 @@ public class Value { /** * Sets the value of the value property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setValue(String value) { this.value = value; } - + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/Variables.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/Variables.java index 1ed011db91..7338f19d28 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/Variables.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tasksbeans/Variables.java @@ -22,20 +22,19 @@ package org.onap.so.apihandlerinfra.tasksbeans; import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.databind.annotation.JsonSerialize; + @JsonRootName(value = "variables") -@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT) +@JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) public class Variables { - protected Value source; - protected Value responseValue; + protected Value source; + protected Value responseValue; protected Value requestorId; - + /** * Gets the value of the source property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public Value getSource() { @@ -45,30 +44,28 @@ public class Variables { /** * Sets the value of the source property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setSource(Value value) { this.source = value; } - public Value getResponseValue() { - return responseValue; - } + public Value getResponseValue() { + return responseValue; + } - public void setResponseValue(Value responseValue) { - this.responseValue = responseValue; - } + public void setResponseValue(Value responseValue) { + this.responseValue = responseValue; + } - - public Value getRequestorId() { - return requestorId; - } - public void setRequestorId(Value requestorId) { - this.requestorId = requestorId; - } + public Value getRequestorId() { + return requestorId; + } + + public void setRequestorId(Value requestorId) { + this.requestorId = requestorId; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java index 1ea77acf95..db2b5b6b4e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java @@ -22,7 +22,6 @@ package org.onap.so.apihandlerinfra.tenantisolation; import java.net.MalformedURLException; import java.net.URL; - import org.onap.so.client.aai.AAIProperties; import org.onap.so.client.aai.AAIVersion; import org.onap.so.spring.SpringContextHelper; @@ -30,39 +29,40 @@ import org.springframework.context.ApplicationContext; public class AaiClientPropertiesImpl implements AAIProperties { - private String aaiEndpoint; - private String auth; - private String key; - public AaiClientPropertiesImpl() { - - ApplicationContext context = SpringContextHelper.getAppContext(); - aaiEndpoint = context.getEnvironment().getProperty("mso.aai.endpoint"); - this.auth = context.getEnvironment().getProperty("aai.auth"); - this.key = context.getEnvironment().getProperty("mso.msoKey"); - } + private String aaiEndpoint; + private String auth; + private String key; + + public AaiClientPropertiesImpl() { + + ApplicationContext context = SpringContextHelper.getAppContext(); + aaiEndpoint = context.getEnvironment().getProperty("mso.aai.endpoint"); + this.auth = context.getEnvironment().getProperty("aai.auth"); + this.key = context.getEnvironment().getProperty("mso.msoKey"); + } + + @Override + public URL getEndpoint() throws MalformedURLException { + return new URL(aaiEndpoint); + } - @Override - public URL getEndpoint() throws MalformedURLException { - return new URL(aaiEndpoint); - } + @Override + public String getSystemName() { + return "MSO"; + } - @Override - public String getSystemName() { - return "MSO"; - } - - @Override - public AAIVersion getDefaultVersion() { - return AAIVersion.LATEST; - } + @Override + public AAIVersion getDefaultVersion() { + return AAIVersion.LATEST; + } - @Override - public String getAuth() { - return this.auth; - } + @Override + public String getAuth() { + return this.auth; + } - @Override - public String getKey() { - return this.key; - } + @Override + public String getKey() { + return this.key; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java index be8f603a28..d79d73c036 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java @@ -27,7 +27,6 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.UUID; - import javax.inject.Provider; import javax.transaction.Transactional; import javax.ws.rs.Consumes; @@ -39,7 +38,6 @@ import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - import org.apache.http.HttpStatus; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.Constants; @@ -61,186 +59,199 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import com.fasterxml.jackson.databind.ObjectMapper; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @Component @Path("/onap/so/infra/cloudResources") -@Api(value="/onap/so/infra/cloudResources",description="API Requests for cloud resources - Tenant Isolation") +@Api(value = "/onap/so/infra/cloudResources", description = "API Requests for cloud resources - Tenant Isolation") public class CloudOrchestration { - private static Logger logger = LoggerFactory.getLogger(CloudOrchestration.class); - private static final String ENVIRONMENT_ID_KEY = "operationalEnvironmentId"; - - @Autowired - private TenantIsolationRequest tenantIsolationRequest ; - - @Autowired - private RequestsDbClient requestsDbClient; - - @Autowired - private Provider<TenantIsolationRunnable> tenantIsolationRunnable; - - @POST - @Path("/{version:[vV][1]}/operationalEnvironments") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Create an Operational Environment",response=Response.class) - @Transactional - public Response createOperationEnvironment(String request, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException{ - logger.debug("Received request to Create Operational Environment"); - return cloudOrchestration(request, Action.create, null, version, getRequestId(requestContext)); - } - - @POST - @Path("/{version:[vV][1]}/operationalEnvironments/{operationalEnvironmentId}/activate") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Activate an Operational Environment",response=Response.class) - @Transactional - public Response activateOperationEnvironment(String request, @PathParam("version") String version, @PathParam("operationalEnvironmentId") String operationalEnvironmentId, - @Context ContainerRequestContext requestContext) throws ApiException{ - logger.debug("Received request to Activate an Operational Environment"); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put(ENVIRONMENT_ID_KEY, operationalEnvironmentId); - return cloudOrchestration(request, Action.activate, instanceIdMap, version, getRequestId(requestContext)); - } - - @POST - @Path("/{version:[vV][1]}/operationalEnvironments/{operationalEnvironmentId}/deactivate") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Deactivate an Operational Environment",response=Response.class) - @Transactional - public Response deactivateOperationEnvironment(String request, @PathParam("version") String version, @PathParam("operationalEnvironmentId") String operationalEnvironmentId, @Context ContainerRequestContext requestContext) throws ApiException{ - logger.debug("Received request to Deactivate an Operational Environment"); - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put(ENVIRONMENT_ID_KEY, operationalEnvironmentId); - return cloudOrchestration(request, Action.deactivate, instanceIdMap, version, getRequestId(requestContext)); - } - - - private Response cloudOrchestration(String requestJSON, Action action, HashMap<String, String> instanceIdMap, String version, String requestId) throws ApiException{ - logger.info("{} {}", MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); - long startTime = System.currentTimeMillis (); - CloudOrchestrationRequest cor = null; - tenantIsolationRequest.setRequestId(requestId); - - cor = convertJsonToCloudOrchestrationRequest(requestJSON, action, startTime, cor); - - try { - tenantIsolationRequest.parse(cor, instanceIdMap, action); - }catch(ValidationException e){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, - ErrorCode.SchemaError).build(); - - - throw new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER) - .cause(e).errorInfo(errorLoggerInfo).build(); - } - - String instanceName = cor.getRequestDetails().getRequestInfo().getInstanceName(); - String resourceType = cor.getRequestDetails().getRequestInfo().getResourceType().name(); - InfraActiveRequests dup = null; - - dup = duplicateCheck(action, instanceIdMap, startTime, instanceName, resourceType); - - if(dup == null && (Action.activate.equals(action) || Action.deactivate.equals(action))) { - dup = requestsDbClient.checkVnfIdStatus(cor.getOperationalEnvironmentId()); - } - - if(dup != null) { - String instance = null; - if(instanceName != null){ - instance = instanceName; - }else if (instanceIdMap != null){ - instance = instanceIdMap.get(resourceType + "InstanceId"); - } - - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_FOUND, ErrorCode.SchemaError).build(); - - - throw new DuplicateRequestException.Builder(resourceType,instance,dup.getRequestStatus(),dup.getRequestId(), HttpStatus.SC_CONFLICT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR) - .errorInfo(errorLoggerInfo).build(); - } - - String instanceId = null; - - if(instanceIdMap != null && instanceIdMap.get(ENVIRONMENT_ID_KEY) != null) { - instanceId = instanceIdMap.get(ENVIRONMENT_ID_KEY); - } else { - instanceId = UUID.randomUUID().toString(); - tenantIsolationRequest.setOperationalEnvironmentId(instanceId); - cor.setOperationalEnvironmentId(instanceId); - } - - tenantIsolationRequest.createRequestRecord(Status.IN_PROGRESS, action); - - OperationalEnvironment opEnv = cor.getRequestDetails().getRequestParameters().getOperationalEnvironmentType(); - String operationalEnvType = opEnv != null ? opEnv.name() : null; - - TenantIsolationRunnable runnable = tenantIsolationRunnable.get(); - runnable.run(action, operationalEnvType, cor, requestId); - - String encodedValue; - try { - encodedValue = new String(instanceId.getBytes("UTF-8")); - } catch(UnsupportedEncodingException ex) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, - ErrorCode.DataError).build(); - - - throw new ValidateException.Builder("Could not encode instanceID" + ex.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER) - .cause(ex).errorInfo(errorLoggerInfo).build(); - } - - TenantSyncResponse tenantResponse = new TenantSyncResponse(); - RequestReferences reqReference = new RequestReferences(); - reqReference.setInstanceId(encodedValue); - reqReference.setRequestId(requestId); - tenantResponse.setRequestReferences(reqReference); - - return Response.ok(tenantResponse).build(); - } - - private InfraActiveRequests duplicateCheck(Action action, HashMap<String, String> instanceIdMap, long startTime, - String instanceName, String requestScope) throws ApiException { - try { - return requestsDbClient.checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope); - } catch (Exception e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - - - throw new ValidateException.Builder("Duplicate Check Request", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) - .errorInfo(errorLoggerInfo).build(); - } - } - - private CloudOrchestrationRequest convertJsonToCloudOrchestrationRequest(String requestJSON, Action action, long startTime, - CloudOrchestrationRequest cor) throws ApiException { - try{ - logger.debug("Converting incoming JSON request to Object"); - ObjectMapper mapper = new ObjectMapper(); - return mapper.readValue(requestJSON, CloudOrchestrationRequest.class); - } catch(IOException e){ - - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, - ErrorCode.SchemaError).build(); - - - ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_BAD_PARAMETER) - .cause(e).errorInfo(errorLoggerInfo).build(); - if (tenantIsolationRequest.getRequestId () != null) { - tenantIsolationRequest.createRequestRecord (Status.FAILED, action); - } - throw validateException; - } - } - - private String getRequestId(ContainerRequestContext requestContext) { - return requestContext.getProperty("requestId").toString(); - } + private static Logger logger = LoggerFactory.getLogger(CloudOrchestration.class); + private static final String ENVIRONMENT_ID_KEY = "operationalEnvironmentId"; + + @Autowired + private TenantIsolationRequest tenantIsolationRequest; + + @Autowired + private RequestsDbClient requestsDbClient; + + @Autowired + private Provider<TenantIsolationRunnable> tenantIsolationRunnable; + + @POST + @Path("/{version:[vV][1]}/operationalEnvironments") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Create an Operational Environment", response = Response.class) + @Transactional + public Response createOperationEnvironment(String request, @PathParam("version") String version, + @Context ContainerRequestContext requestContext) throws ApiException { + logger.debug("Received request to Create Operational Environment"); + return cloudOrchestration(request, Action.create, null, version, getRequestId(requestContext)); + } + + @POST + @Path("/{version:[vV][1]}/operationalEnvironments/{operationalEnvironmentId}/activate") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Activate an Operational Environment", response = Response.class) + @Transactional + public Response activateOperationEnvironment(String request, @PathParam("version") String version, + @PathParam("operationalEnvironmentId") String operationalEnvironmentId, + @Context ContainerRequestContext requestContext) throws ApiException { + logger.debug("Received request to Activate an Operational Environment"); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put(ENVIRONMENT_ID_KEY, operationalEnvironmentId); + return cloudOrchestration(request, Action.activate, instanceIdMap, version, getRequestId(requestContext)); + } + + @POST + @Path("/{version:[vV][1]}/operationalEnvironments/{operationalEnvironmentId}/deactivate") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Deactivate an Operational Environment", response = Response.class) + @Transactional + public Response deactivateOperationEnvironment(String request, @PathParam("version") String version, + @PathParam("operationalEnvironmentId") String operationalEnvironmentId, + @Context ContainerRequestContext requestContext) throws ApiException { + logger.debug("Received request to Deactivate an Operational Environment"); + HashMap<String, String> instanceIdMap = new HashMap<>(); + instanceIdMap.put(ENVIRONMENT_ID_KEY, operationalEnvironmentId); + return cloudOrchestration(request, Action.deactivate, instanceIdMap, version, getRequestId(requestContext)); + } + + + private Response cloudOrchestration(String requestJSON, Action action, HashMap<String, String> instanceIdMap, + String version, String requestId) throws ApiException { + logger.info("{} {}", MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); + long startTime = System.currentTimeMillis(); + CloudOrchestrationRequest cor = null; + tenantIsolationRequest.setRequestId(requestId); + + cor = convertJsonToCloudOrchestrationRequest(requestJSON, action, startTime, cor); + + try { + tenantIsolationRequest.parse(cor, instanceIdMap, action); + } catch (ValidationException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .build(); + + + throw new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo) + .build(); + } + + String instanceName = cor.getRequestDetails().getRequestInfo().getInstanceName(); + String resourceType = cor.getRequestDetails().getRequestInfo().getResourceType().name(); + InfraActiveRequests dup = null; + + dup = duplicateCheck(action, instanceIdMap, startTime, instanceName, resourceType); + + if (dup == null && (Action.activate.equals(action) || Action.deactivate.equals(action))) { + dup = requestsDbClient.checkVnfIdStatus(cor.getOperationalEnvironmentId()); + } + + if (dup != null) { + String instance = null; + if (instanceName != null) { + instance = instanceName; + } else if (instanceIdMap != null) { + instance = instanceIdMap.get(resourceType + "InstanceId"); + } + + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_FOUND, ErrorCode.SchemaError).build(); + + + throw new DuplicateRequestException.Builder(resourceType, instance, dup.getRequestStatus(), + dup.getRequestId(), HttpStatus.SC_CONFLICT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR) + .errorInfo(errorLoggerInfo).build(); + } + + String instanceId = null; + + if (instanceIdMap != null && instanceIdMap.get(ENVIRONMENT_ID_KEY) != null) { + instanceId = instanceIdMap.get(ENVIRONMENT_ID_KEY); + } else { + instanceId = UUID.randomUUID().toString(); + tenantIsolationRequest.setOperationalEnvironmentId(instanceId); + cor.setOperationalEnvironmentId(instanceId); + } + + tenantIsolationRequest.createRequestRecord(Status.IN_PROGRESS, action); + + OperationalEnvironment opEnv = cor.getRequestDetails().getRequestParameters().getOperationalEnvironmentType(); + String operationalEnvType = opEnv != null ? opEnv.name() : null; + + TenantIsolationRunnable runnable = tenantIsolationRunnable.get(); + runnable.run(action, operationalEnvType, cor, requestId); + + String encodedValue; + try { + encodedValue = new String(instanceId.getBytes("UTF-8")); + } catch (UnsupportedEncodingException ex) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.DataError).build(); + + + throw new ValidateException.Builder("Could not encode instanceID" + ex.getMessage(), + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(ex).errorInfo(errorLoggerInfo) + .build(); + } + + TenantSyncResponse tenantResponse = new TenantSyncResponse(); + RequestReferences reqReference = new RequestReferences(); + reqReference.setInstanceId(encodedValue); + reqReference.setRequestId(requestId); + tenantResponse.setRequestReferences(reqReference); + + return Response.ok(tenantResponse).build(); + } + + private InfraActiveRequests duplicateCheck(Action action, HashMap<String, String> instanceIdMap, long startTime, + String instanceName, String requestScope) throws ApiException { + try { + return requestsDbClient.checkInstanceNameDuplicate(instanceIdMap, instanceName, requestScope); + } catch (Exception e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DUPLICATE_CHECK_EXC, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + + + throw new ValidateException.Builder("Duplicate Check Request", HttpStatus.SC_INTERNAL_SERVER_ERROR, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build(); + } + } + + private CloudOrchestrationRequest convertJsonToCloudOrchestrationRequest(String requestJSON, Action action, + long startTime, CloudOrchestrationRequest cor) throws ApiException { + try { + logger.debug("Converting incoming JSON request to Object"); + ObjectMapper mapper = new ObjectMapper(); + return mapper.readValue(requestJSON, CloudOrchestrationRequest.class); + } catch (IOException e) { + + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .build(); + + + ValidateException validateException = + new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); + if (tenantIsolationRequest.getRequestId() != null) { + tenantIsolationRequest.createRequestRecord(Status.FAILED, action); + } + throw validateException; + } + } + + private String getRequestId(ContainerRequestContext requestContext) { + return requestContext.getProperty("requestId").toString(); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationRequest.java index d387928e22..6660cc653c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationRequest.java @@ -21,61 +21,58 @@ package org.onap.so.apihandlerinfra.tenantisolation; import java.io.Serializable; - import org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution; import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestDetails; - import com.fasterxml.jackson.annotation.JsonProperty; public class CloudOrchestrationRequest implements Serializable { - private static final long serialVersionUID = -4959169541182257787L; - @JsonProperty("requestDetails") - private RequestDetails requestDetails; - @JsonProperty("operationalEnvironmentId") - private String operationalEnvironmentId; - @JsonProperty("distribution") - private Distribution distribution; - @JsonProperty("distributionId") - private String distributionId; - - public String getOperationalEnvironmentId() { - return operationalEnvironmentId; - } + private static final long serialVersionUID = -4959169541182257787L; + @JsonProperty("requestDetails") + private RequestDetails requestDetails; + @JsonProperty("operationalEnvironmentId") + private String operationalEnvironmentId; + @JsonProperty("distribution") + private Distribution distribution; + @JsonProperty("distributionId") + private String distributionId; + + public String getOperationalEnvironmentId() { + return operationalEnvironmentId; + } + + public void setOperationalEnvironmentId(String operationalEnvironmentId) { + this.operationalEnvironmentId = operationalEnvironmentId; + } + + public RequestDetails getRequestDetails() { + return requestDetails; + } - public void setOperationalEnvironmentId(String operationalEnvironmentId) { - this.operationalEnvironmentId = operationalEnvironmentId; - } + public void setRequestDetails(RequestDetails requestDetails) { + this.requestDetails = requestDetails; + } - public RequestDetails getRequestDetails() { - return requestDetails; - } - - public void setRequestDetails(RequestDetails requestDetails){ - this.requestDetails = requestDetails; - } + public Distribution getDistribution() { + return distribution; + } - public Distribution getDistribution() { - return distribution; - } + public void setDistribution(Distribution distribution) { + this.distribution = distribution; + } - public void setDistribution(Distribution distribution) { - this.distribution = distribution; - } + public String getDistributionId() { + return distributionId; + } - public String getDistributionId() { - return distributionId; - } + public void setDistributionId(String distributionId) { + this.distributionId = distributionId; + } - public void setDistributionId(String distributionId) { - this.distributionId = distributionId; - } - - @Override - public String toString() { - return "ServiceInstancesRequest [requestDetails=" + requestDetails - + ", operationalEnvironmentId=" + operationalEnvironmentId - + ", distribution=" + distribution - + ", distributionId=" + distributionId + "]"; - } + @Override + public String toString() { + return "ServiceInstancesRequest [requestDetails=" + requestDetails + ", operationalEnvironmentId=" + + operationalEnvironmentId + ", distribution=" + distribution + ", distributionId=" + distributionId + + "]"; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java index fe74b108ba..be6d5b06ca 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java @@ -27,7 +27,6 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.Map; - import javax.transaction.Transactional; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -40,14 +39,12 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; - import org.apache.http.HttpStatus; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandler.common.ResponseBuilder; import org.onap.so.apihandlerinfra.Constants; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; - import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; import org.onap.so.apihandlerinfra.tenantisolationbeans.CloudOrchestrationRequestList; import org.onap.so.apihandlerinfra.tenantisolationbeans.CloudOrchestrationResponse; @@ -60,231 +57,257 @@ import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import com.fasterxml.jackson.databind.ObjectMapper; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @Component @Path("onap/so/infra/cloudResourcesRequests") -@Api(value="onap/so/infra/cloudResourcesRequests",description="API GET Requests for cloud resources - Tenant Isolation") +@Api(value = "onap/so/infra/cloudResourcesRequests", + description = "API GET Requests for cloud resources - Tenant Isolation") public class CloudResourcesOrchestration { - private static Logger logger = LoggerFactory.getLogger(CloudResourcesOrchestration.class); - - @Autowired - RequestsDbClient requestDbClient; - - @Autowired - private ResponseBuilder builder; - - @POST - @Path("/{version: [vV][1]}/{requestId}/unlock") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Unlock CloudOrchestration requests for a specified requestId") - @Transactional - public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId, @PathParam("version") String version) throws ApiException{ - TenantIsolationRequest msoRequest = new TenantIsolationRequest(requestId); - InfraActiveRequests infraActiveRequest = null; - - CloudOrchestrationRequest cor = null; - - logger.debug ("requestId is: " + requestId); - - try{ - ObjectMapper mapper = new ObjectMapper(); - cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class); - } catch(IOException e){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, - ErrorCode.SchemaError).build(); - - ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_BAD_PARAMETER) - .cause(e).errorInfo(errorLoggerInfo).build(); - throw validateException; - } - - try{ - msoRequest.parseOrchestration(cor); - } catch (ValidationException e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, - ErrorCode.SchemaError).build(); - ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_BAD_PARAMETER) - .cause(e).errorInfo(errorLoggerInfo).build(); - throw validateException; - } - try { - infraActiveRequest = requestDbClient.getInfraActiveRequestbyRequestId(requestId); - }catch(Exception e){ - ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).build(); - throw validateException; - } - if(infraActiveRequest == null) { - - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.BusinessProcesssError).build(); - ValidateException validateException = new ValidateException.Builder("Orchestration RequestId " + requestId + " is not found in DB", HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_DETAILED_SERVICE_ERROR) - .errorInfo(errorLoggerInfo).build(); - - throw validateException; - - }else{ - String status = infraActiveRequest.getRequestStatus(); - if(status.equalsIgnoreCase("IN_PROGRESS") || status.equalsIgnoreCase("PENDING") || status.equalsIgnoreCase("PENDING_MANUAL_TASK")){ - infraActiveRequest.setRequestStatus("UNLOCKED"); - infraActiveRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); - infraActiveRequest.setRequestId(requestId); - requestDbClient.save(infraActiveRequest); - }else{ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, - ErrorCode.DataError).build(); - ValidateException validateException = new ValidateException.Builder("Orchestration RequestId " + requestId + " has a status of " + status + " and can not be unlocked", - HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); - - throw validateException; - } - } - - return Response.status (HttpStatus.SC_NO_CONTENT).entity ("").build (); - } - - @GET - @Path("/{version:[vV][1]}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Get status of an Operational Environment based on filter criteria",response=Response.class) - @Transactional - public Response getOperationEnvironmentStatusFilter(@Context UriInfo ui, @PathParam("version") String version ) throws ApiException{ - - MultivaluedMap<String, String> queryParams = ui.getQueryParameters(); - List<String> requestIdKey = queryParams.get("requestId"); - String apiVersion = version.substring(1); - - if(queryParams.size() == 1 && requestIdKey != null) { - String requestId = requestIdKey.get(0); - - CloudOrchestrationResponse cloudOrchestrationGetResponse = new CloudOrchestrationResponse(); - TenantIsolationRequest tenantIsolationRequest = new TenantIsolationRequest (requestId); - InfraActiveRequests requestDB = null; - - try { - requestDB = requestDbClient.getInfraActiveRequestbyRequestId(requestId); - } catch (Exception e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.AvailabilityError).build(); - ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) - .errorInfo(errorLoggerInfo).build(); - throw validateException; - } - - if(requestDB == null) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.BusinessProcesssError).build(); - ValidateException validateException = new ValidateException.Builder("Orchestration RequestId " + requestId + " is not found in DB", - HttpStatus.SC_NO_CONTENT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR) - .errorInfo(errorLoggerInfo).build(); - - throw validateException; - } - - Request request = mapInfraActiveRequestToRequest(requestDB); - cloudOrchestrationGetResponse.setRequest(request); - return builder.buildResponse(HttpStatus.SC_OK, requestId, cloudOrchestrationGetResponse, apiVersion); - - } else { - TenantIsolationRequest tenantIsolationRequest = new TenantIsolationRequest (); - List<InfraActiveRequests> activeRequests = null; - CloudOrchestrationRequestList orchestrationList = null; - - - Map<String, String> orchestrationMap; - try{ - orchestrationMap = tenantIsolationRequest.getOrchestrationFilters(queryParams); - }catch(ValidationException ex){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcesssError).build(); - ValidateException validateException = new ValidateException.Builder(ex.getMessage(), - HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).cause(ex) - .errorInfo(errorLoggerInfo).build(); - - throw validateException; - - } - activeRequests = requestDbClient.getCloudOrchestrationFiltersFromInfraActive(orchestrationMap); - orchestrationList = new CloudOrchestrationRequestList(); - List<CloudOrchestrationResponse> requestLists = new ArrayList<CloudOrchestrationResponse>(); - - for(InfraActiveRequests infraActive : activeRequests){ - - Request request = mapInfraActiveRequestToRequest(infraActive); - CloudOrchestrationResponse requestList = new CloudOrchestrationResponse(); - requestList.setRequest(request); - requestLists.add(requestList); - } - orchestrationList.setRequestList(requestLists); - - return builder.buildResponse(HttpStatus.SC_OK, null, orchestrationList, apiVersion); - } - } - - private Request mapInfraActiveRequestToRequest(InfraActiveRequests iar) throws ApiException { - Request request = new Request(); - request.setRequestId(iar.getRequestId()); - request.setRequestScope(iar.getRequestScope()); - request.setRequestType(iar.getRequestAction()); - - InstanceReferences ir = new InstanceReferences(); - - if(iar.getOperationalEnvId() != null) - ir.setOperationalEnvironmentId(iar.getOperationalEnvId()); - if(iar.getOperationalEnvName() != null) - ir.setOperationalEnvName(iar.getOperationalEnvName()); - if(iar.getRequestorId() != null) - ir.setRequestorId(iar.getRequestorId()); - - request.setInstanceReferences(ir); - String requestBody = iar.getRequestBody(); - RequestDetails requestDetails = null; - - if (requestBody != null) { - try { - ObjectMapper mapper = new ObjectMapper(); - requestDetails = mapper.readValue(requestBody, RequestDetails.class); - } catch (IOException e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).build(); - ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER) - .cause(e).errorInfo(errorLoggerInfo).build(); - throw validateException; - } - } - - request.setRequestDetails(requestDetails); - String startTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getStartTime()) + " GMT"; - request.setStartTime(startTimeStamp); - - RequestStatus status = new RequestStatus(); - if(iar.getStatusMessage() != null){ - status.setStatusMessage(iar.getStatusMessage()); - } - - if(iar.getEndTime() != null){ - String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getEndTime()) + " GMT"; - status.setTimeStamp(endTimeStamp); - } - - if(iar.getRequestStatus() != null){ - status.setRequestState(iar.getRequestStatus()); - } - - if(iar.getProgress() != null){ - status.setPercentProgress(iar.getProgress().toString()); - } - - request.setRequestStatus(status); - - return request; - } + private static Logger logger = LoggerFactory.getLogger(CloudResourcesOrchestration.class); + + @Autowired + RequestsDbClient requestDbClient; + + @Autowired + private ResponseBuilder builder; + + @POST + @Path("/{version: [vV][1]}/{requestId}/unlock") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Unlock CloudOrchestration requests for a specified requestId") + @Transactional + public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId, + @PathParam("version") String version) throws ApiException { + TenantIsolationRequest msoRequest = new TenantIsolationRequest(requestId); + InfraActiveRequests infraActiveRequest = null; + + CloudOrchestrationRequest cor = null; + + logger.debug("requestId is: " + requestId); + + try { + ObjectMapper mapper = new ObjectMapper(); + cor = mapper.readValue(requestJSON, CloudOrchestrationRequest.class); + } catch (IOException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .build(); + + ValidateException validateException = + new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); + throw validateException; + } + + try { + msoRequest.parseOrchestration(cor); + } catch (ValidationException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .build(); + ValidateException validateException = + new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); + throw validateException; + } + try { + infraActiveRequest = requestDbClient.getInfraActiveRequestbyRequestId(requestId); + } catch (Exception e) { + ValidateException validateException = new ValidateException.Builder(e.getMessage(), + HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).build(); + throw validateException; + } + if (infraActiveRequest == null) { + + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, + ErrorCode.BusinessProcesssError).build(); + ValidateException validateException = + new ValidateException.Builder("Orchestration RequestId " + requestId + " is not found in DB", + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR) + .errorInfo(errorLoggerInfo).build(); + + throw validateException; + + } else { + String status = infraActiveRequest.getRequestStatus(); + if (status.equalsIgnoreCase("IN_PROGRESS") || status.equalsIgnoreCase("PENDING") + || status.equalsIgnoreCase("PENDING_MANUAL_TASK")) { + infraActiveRequest.setRequestStatus("UNLOCKED"); + infraActiveRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); + infraActiveRequest.setRequestId(requestId); + requestDbClient.save(infraActiveRequest); + } else { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.DataError) + .build(); + ValidateException validateException = new ValidateException.Builder( + "Orchestration RequestId " + requestId + " has a status of " + status + + " and can not be unlocked", + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo) + .build(); + + throw validateException; + } + } + + return Response.status(HttpStatus.SC_NO_CONTENT).entity("").build(); + } + + @GET + @Path("/{version:[vV][1]}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Get status of an Operational Environment based on filter criteria", + response = Response.class) + @Transactional + public Response getOperationEnvironmentStatusFilter(@Context UriInfo ui, @PathParam("version") String version) + throws ApiException { + + MultivaluedMap<String, String> queryParams = ui.getQueryParameters(); + List<String> requestIdKey = queryParams.get("requestId"); + String apiVersion = version.substring(1); + + if (queryParams.size() == 1 && requestIdKey != null) { + String requestId = requestIdKey.get(0); + + CloudOrchestrationResponse cloudOrchestrationGetResponse = new CloudOrchestrationResponse(); + TenantIsolationRequest tenantIsolationRequest = new TenantIsolationRequest(requestId); + InfraActiveRequests requestDB = null; + + try { + requestDB = requestDbClient.getInfraActiveRequestbyRequestId(requestId); + } catch (Exception e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.AvailabilityError) + .build(); + ValidateException validateException = + new ValidateException.Builder(e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build(); + throw validateException; + } + + if (requestDB == null) { + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, + ErrorCode.BusinessProcesssError).build(); + ValidateException validateException = + new ValidateException.Builder("Orchestration RequestId " + requestId + " is not found in DB", + HttpStatus.SC_NO_CONTENT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR) + .errorInfo(errorLoggerInfo).build(); + + throw validateException; + } + + Request request = mapInfraActiveRequestToRequest(requestDB); + cloudOrchestrationGetResponse.setRequest(request); + return builder.buildResponse(HttpStatus.SC_OK, requestId, cloudOrchestrationGetResponse, apiVersion); + + } else { + TenantIsolationRequest tenantIsolationRequest = new TenantIsolationRequest(); + List<InfraActiveRequests> activeRequests = null; + CloudOrchestrationRequestList orchestrationList = null; + + + Map<String, String> orchestrationMap; + try { + orchestrationMap = tenantIsolationRequest.getOrchestrationFilters(queryParams); + } catch (ValidationException ex) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcesssError) + .build(); + ValidateException validateException = + new ValidateException.Builder(ex.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, + ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).cause(ex).errorInfo(errorLoggerInfo).build(); + + throw validateException; + + } + activeRequests = requestDbClient.getCloudOrchestrationFiltersFromInfraActive(orchestrationMap); + orchestrationList = new CloudOrchestrationRequestList(); + List<CloudOrchestrationResponse> requestLists = new ArrayList<CloudOrchestrationResponse>(); + + for (InfraActiveRequests infraActive : activeRequests) { + + Request request = mapInfraActiveRequestToRequest(infraActive); + CloudOrchestrationResponse requestList = new CloudOrchestrationResponse(); + requestList.setRequest(request); + requestLists.add(requestList); + } + orchestrationList.setRequestList(requestLists); + + return builder.buildResponse(HttpStatus.SC_OK, null, orchestrationList, apiVersion); + } + } + + private Request mapInfraActiveRequestToRequest(InfraActiveRequests iar) throws ApiException { + Request request = new Request(); + request.setRequestId(iar.getRequestId()); + request.setRequestScope(iar.getRequestScope()); + request.setRequestType(iar.getRequestAction()); + + InstanceReferences ir = new InstanceReferences(); + + if (iar.getOperationalEnvId() != null) + ir.setOperationalEnvironmentId(iar.getOperationalEnvId()); + if (iar.getOperationalEnvName() != null) + ir.setOperationalEnvName(iar.getOperationalEnvName()); + if (iar.getRequestorId() != null) + ir.setRequestorId(iar.getRequestorId()); + + request.setInstanceReferences(ir); + String requestBody = iar.getRequestBody(); + RequestDetails requestDetails = null; + + if (requestBody != null) { + try { + ObjectMapper mapper = new ObjectMapper(); + requestDetails = mapper.readValue(requestBody, RequestDetails.class); + } catch (IOException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .build(); + ValidateException validateException = + new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); + throw validateException; + } + } + + request.setRequestDetails(requestDetails); + String startTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getStartTime()) + " GMT"; + request.setStartTime(startTimeStamp); + + RequestStatus status = new RequestStatus(); + if (iar.getStatusMessage() != null) { + status.setStatusMessage(iar.getStatusMessage()); + } + + if (iar.getEndTime() != null) { + String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getEndTime()) + " GMT"; + status.setTimeStamp(endTimeStamp); + } + + if (iar.getRequestStatus() != null) { + status.setRequestState(iar.getRequestStatus()); + } + + if (iar.getProgress() != null) { + status.setPercentProgress(iar.getProgress().toString()); + } + + request.setRequestStatus(status); + + return request; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java index 60a05d74e5..f7b3811bce 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/GrmClientPropertiesImpl.java @@ -22,54 +22,52 @@ package org.onap.so.apihandlerinfra.tenantisolation; import java.net.MalformedURLException; import java.net.URL; - import javax.ws.rs.core.MediaType; - import org.onap.so.client.grm.GRMProperties; import org.onap.so.spring.SpringContextHelper; import org.springframework.context.ApplicationContext; public class GrmClientPropertiesImpl implements GRMProperties { - private String grmEndpoint; - private String grmAuth; - private String grmKey; - - public GrmClientPropertiesImpl() { - ApplicationContext context = SpringContextHelper.getAppContext(); - grmEndpoint = context.getEnvironment().getProperty("mso.grm.endpoint"); - grmAuth = context.getEnvironment().getProperty("mso.grm.auth"); - grmKey = context.getEnvironment().getProperty("mso.msoKey"); - } - - @Override - public URL getEndpoint() throws MalformedURLException { - return new URL(grmEndpoint); - } + private String grmEndpoint; + private String grmAuth; + private String grmKey; + + public GrmClientPropertiesImpl() { + ApplicationContext context = SpringContextHelper.getAppContext(); + grmEndpoint = context.getEnvironment().getProperty("mso.grm.endpoint"); + grmAuth = context.getEnvironment().getProperty("mso.grm.auth"); + grmKey = context.getEnvironment().getProperty("mso.msoKey"); + } + + @Override + public URL getEndpoint() throws MalformedURLException { + return new URL(grmEndpoint); + } - @Override - public String getSystemName() { - return "MSO"; - } + @Override + public String getSystemName() { + return "MSO"; + } - @Override - public String getDefaultVersion() { - return "v1"; - } + @Override + public String getDefaultVersion() { + return "v1"; + } - @Override - public String getAuth() { - return grmAuth; - } + @Override + public String getAuth() { + return grmAuth; + } - @Override - public String getKey() { - return grmKey; - } + @Override + public String getKey() { + return grmKey; + } - @Override - public String getContentType() { - return MediaType.APPLICATION_JSON; - } + @Override + public String getContentType() { + return MediaType.APPLICATION_JSON; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java index 4be1ec9187..b2933df030 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java @@ -24,7 +24,6 @@ package org.onap.so.apihandlerinfra.tenantisolation; import java.io.IOException; import java.util.List; - import javax.inject.Provider; import javax.transaction.Transactional; import javax.ws.rs.Consumes; @@ -34,7 +33,6 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpStatus; import org.onap.so.apihandler.common.ErrorNumbers; @@ -54,110 +52,118 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @Component @Path("/onap/so/infra/modelDistributions") -@Api(value="/onap/so/infra/modelDistributions",description="API Requests for Model Distributions") +@Api(value = "/onap/so/infra/modelDistributions", description = "API Requests for Model Distributions") public class ModelDistributionRequest { - - private static Logger logger = LoggerFactory.getLogger(ModelDistributionRequest.class); - @Autowired - private Provider<TenantIsolationRunnable> tenantIsolationRunnable; - - @PATCH - @Path("/{version:[vV][1]}/distributions/{distributionId}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ApiOperation(value="Update model distribution status",response=Response.class) - @Transactional - public Response updateModelDistributionStatus(String requestJSON, @PathParam("version") String version, @PathParam("distributionId") String distributionId) throws ApiException{ - long startTime = System.currentTimeMillis (); - Distribution distributionRequest = null; - - try { - ObjectMapper mapper = new ObjectMapper(); - distributionRequest = mapper.readValue(requestJSON, Distribution.class); - } catch(IOException e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, - ErrorCode.SchemaError).build(); - - - ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_BAD_PARAMETER) - .cause(e).errorInfo(errorLoggerInfo).build(); - throw validateException; - - } - - try { - parse(distributionRequest); - } catch(ValidationException e) { - - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, - ErrorCode.SchemaError).build(); - - - ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_BAD_PARAMETER) - .cause(e).errorInfo(errorLoggerInfo).build(); - throw validateException; - } - - CloudOrchestrationRequest cor = new CloudOrchestrationRequest(); - cor.setDistribution(distributionRequest); - cor.setDistributionId(distributionId); - - TenantIsolationRunnable runnable = tenantIsolationRunnable.get(); - runnable.run(Action.distributionStatus, null, cor, null); - - return Response.ok().build(); - } - - private void parse(Distribution distributionRequest) throws ValidationException { - if(distributionRequest.getStatus() == null) { - throw new ValidationException("status"); - } - - if(StringUtils.isBlank(distributionRequest.getErrorReason()) && Status.DISTRIBUTION_COMPLETE_ERROR.equals(distributionRequest.getStatus())) { - throw new ValidationException("errorReason"); - } - } - - private Response buildServiceErrorResponse (int httpResponseCode, MsoException exceptionType, String text, - String messageId, List<String> variables) throws ApiException{ - RequestError re = new RequestError(); - ServiceException se = new ServiceException(); - se.setMessageId(messageId); - se.setText(text); - if(variables != null){ - if(variables != null){ - for(String variable: variables){ - se.getVariables().add(variable); - } - } - } - re.setServiceException(se); + + private static Logger logger = LoggerFactory.getLogger(ModelDistributionRequest.class); + @Autowired + private Provider<TenantIsolationRunnable> tenantIsolationRunnable; + + @PATCH + @Path("/{version:[vV][1]}/distributions/{distributionId}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Update model distribution status", response = Response.class) + @Transactional + public Response updateModelDistributionStatus(String requestJSON, @PathParam("version") String version, + @PathParam("distributionId") String distributionId) throws ApiException { + long startTime = System.currentTimeMillis(); + Distribution distributionRequest = null; + + try { + ObjectMapper mapper = new ObjectMapper(); + distributionRequest = mapper.readValue(requestJSON, Distribution.class); + } catch (IOException e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .build(); + + + ValidateException validateException = + new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); + throw validateException; + + } + + try { + parse(distributionRequest); + } catch (ValidationException e) { + + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .build(); + + + ValidateException validateException = + new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); + throw validateException; + } + + CloudOrchestrationRequest cor = new CloudOrchestrationRequest(); + cor.setDistribution(distributionRequest); + cor.setDistributionId(distributionId); + + TenantIsolationRunnable runnable = tenantIsolationRunnable.get(); + runnable.run(Action.distributionStatus, null, cor, null); + + return Response.ok().build(); + } + + private void parse(Distribution distributionRequest) throws ValidationException { + if (distributionRequest.getStatus() == null) { + throw new ValidationException("status"); + } + + if (StringUtils.isBlank(distributionRequest.getErrorReason()) + && Status.DISTRIBUTION_COMPLETE_ERROR.equals(distributionRequest.getStatus())) { + throw new ValidationException("errorReason"); + } + } + + private Response buildServiceErrorResponse(int httpResponseCode, MsoException exceptionType, String text, + String messageId, List<String> variables) throws ApiException { + RequestError re = new RequestError(); + ServiceException se = new ServiceException(); + se.setMessageId(messageId); + se.setText(text); + if (variables != null) { + if (variables != null) { + for (String variable : variables) { + se.getVariables().add(variable); + } + } + } + re.setServiceException(se); String requestErrorStr = null; - try{ - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_DEFAULT); - requestErrorStr = mapper.writeValueAsString(re); - }catch(JsonProcessingException e){ + try { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_DEFAULT); + requestErrorStr = mapper.writeValueAsString(re); + } catch (JsonProcessingException e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.DataError).build(); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, ErrorCode.DataError).build(); - ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), HttpStatus.SC_BAD_REQUEST,ErrorNumbers.SVC_BAD_PARAMETER) - .cause(e).errorInfo(errorLoggerInfo).build(); - throw validateException; + ValidateException validateException = + new ValidateException.Builder("Mapping of request to JSON object failed. " + e.getMessage(), + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) + .errorInfo(errorLoggerInfo).build(); + throw validateException; } - return Response.status (httpResponseCode).entity(requestErrorStr).build (); + return Response.status(httpResponseCode).entity(requestErrorStr).build(); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java index 82a5d1ebbf..696616099f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java @@ -27,9 +27,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; - import javax.ws.rs.core.MultivaluedMap; - import org.apache.commons.lang3.StringUtils; import org.onap.so.apihandlerinfra.Constants; import org.onap.so.apihandlerinfra.Status; @@ -49,14 +47,12 @@ import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; - import org.onap.so.utils.UUIDChecker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -75,316 +71,323 @@ public class TenantIsolationRequest { private long progress = Constants.PROGRESS_REQUEST_RECEIVED; private String requestScope; private CloudOrchestrationRequest cor; - + @Autowired - private RequestsDbClient requestsDbClient; - + private RequestsDbClient requestsDbClient; + private static Logger logger = LoggerFactory.getLogger(TenantIsolationRequest.class); - TenantIsolationRequest (String requestId) { + TenantIsolationRequest(String requestId) { this.requestId = requestId; } - TenantIsolationRequest () { + TenantIsolationRequest() {} + + void parse(CloudOrchestrationRequest request, HashMap<String, String> instanceIdMap, Action action) + throws ValidationException { + this.cor = request; + this.requestInfo = request.getRequestDetails().getRequestInfo(); + + try { + ObjectMapper mapper = new ObjectMapper(); + requestJSON = mapper.writeValueAsString(request.getRequestDetails()); + + } catch (JsonProcessingException e) { + throw new ValidationException("Parse ServiceInstanceRequest to JSON string", true); + } + + String envId = null; + if (instanceIdMap != null) { + envId = instanceIdMap.get("operationalEnvironmentId"); + if (envId != null && !UUIDChecker.isValidUUID(envId)) { + throw new ValidationException("operationalEnvironmentId", true); + } + cor.setOperationalEnvironmentId(envId); + } + + this.operationalEnvironmentId = envId; + + RequestDetails requestDetails = request.getRequestDetails(); + RequestParameters requestParameters = requestDetails.getRequestParameters(); + + requestInfoValidation(action, requestInfo); + + requestParamsValidation(action, requestParameters); + + relatedInstanceValidation(action, requestDetails, requestParameters); + + } + + private void relatedInstanceValidation(Action action, RequestDetails requestDetails, + RequestParameters requestParameters) throws ValidationException { + RelatedInstanceList[] instanceList = requestDetails.getRelatedInstanceList(); + + if (requestParameters == null) { + throw new ValidationException("requestParameters", true); + } + if ((Action.activate.equals(action) || Action.deactivate.equals(action)) + && OperationalEnvironment.ECOMP.equals(requestParameters.getOperationalEnvironmentType())) { + throw new ValidationException("operationalEnvironmentType in requestParameters", true); + } + + if (!Action.deactivate.equals(action) + && OperationalEnvironment.VNF.equals(requestParameters.getOperationalEnvironmentType())) { + if (instanceList != null && instanceList.length > 0) { + for (RelatedInstanceList relatedInstanceList : instanceList) { + RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + + if (relatedInstance.getResourceType() == null) { + throw new ValidationException("ResourceType in relatedInstance", true); + } + + if (!empty(relatedInstance.getInstanceName()) + && !relatedInstance.getInstanceName().matches(Constants.VALID_INSTANCE_NAME_FORMAT)) { + throw new ValidationException("instanceName format", true); + } + + if (empty(relatedInstance.getInstanceId())) { + throw new ValidationException("instanceId in relatedInstance", true); + } + + if (!UUIDChecker.isValidUUID(relatedInstance.getInstanceId())) { + throw new ValidationException("instanceId format in relatedInstance", true); + } + } + } else { + throw new ValidationException("relatedInstanceList", true); + } + } } - - void parse(CloudOrchestrationRequest request, HashMap<String,String> instanceIdMap, Action action) throws ValidationException { - this.cor = request; - this.requestInfo = request.getRequestDetails().getRequestInfo(); - - try{ - ObjectMapper mapper = new ObjectMapper(); - requestJSON = mapper.writeValueAsString(request.getRequestDetails()); - - } catch(JsonProcessingException e){ - throw new ValidationException ("Parse ServiceInstanceRequest to JSON string", true); + + private void requestParamsValidation(Action action, RequestParameters requestParameters) + throws ValidationException { + + if (requestParameters != null) { + if (!Action.deactivate.equals(action) && requestParameters.getOperationalEnvironmentType() == null) { + throw new ValidationException("OperationalEnvironmentType", true); + } + + if (Action.create.equals(action) && empty(requestParameters.getTenantContext())) { + throw new ValidationException("Tenant Context", true); + } + if (!Action.deactivate.equals(action) && empty(requestParameters.getWorkloadContext())) { + throw new ValidationException("Workload Context", true); + } + + Manifest manifest = requestParameters.getManifest(); + + if (Action.activate.equals(action)) { + if (manifest == null) { + throw new ValidationException("Manifest on Activate", true); + } else { + List<ServiceModelList> serviceModelList = manifest.getServiceModelList(); + + if (serviceModelList.isEmpty()) { + throw new ValidationException(" empty ServiceModelList", true); + } + + for (ServiceModelList list : serviceModelList) { + if (empty(list.getServiceModelVersionId())) { + throw new ValidationException("ServiceModelVersionId", true); + } + + if (!UUIDChecker.isValidUUID(list.getServiceModelVersionId())) { + throw new ValidationException("ServiceModelVersionId format", true); + } + + if (list.getRecoveryAction() == null) { + throw new ValidationException("RecoveryAction", true); + } + } + } + } + } else if (!Action.deactivate.equals(action)) { + throw new ValidationException("request Parameters", true); + } + } + + private void requestInfoValidation(Action action, RequestInfo requestInfo) throws ValidationException { + + if (Action.create.equals(action) && empty(requestInfo.getInstanceName())) { + throw new ValidationException("instanceName", true); + } + + if (!empty(requestInfo.getInstanceName()) + && !requestInfo.getInstanceName().matches(Constants.VALID_INSTANCE_NAME_FORMAT)) { + throw new ValidationException("instanceName format", true); + } + + if (empty(requestInfo.getSource())) { + throw new ValidationException("source", true); } - - String envId = null; - if(instanceIdMap != null) { - envId = instanceIdMap.get("operationalEnvironmentId"); - if(envId != null && !UUIDChecker.isValidUUID (envId)){ - throw new ValidationException ("operationalEnvironmentId", true); - } - cor.setOperationalEnvironmentId(envId); - } - - this.operationalEnvironmentId = envId; - - RequestDetails requestDetails = request.getRequestDetails(); - RequestParameters requestParameters = requestDetails.getRequestParameters(); - - requestInfoValidation(action, requestInfo); - - requestParamsValidation(action, requestParameters); - - relatedInstanceValidation(action, requestDetails, requestParameters); - - } - - private void relatedInstanceValidation(Action action, RequestDetails requestDetails, RequestParameters requestParameters) throws ValidationException { - RelatedInstanceList[] instanceList = requestDetails.getRelatedInstanceList(); - - if (requestParameters == null) { - throw new ValidationException("requestParameters", true); - } - if((Action.activate.equals(action) || Action.deactivate.equals(action)) && OperationalEnvironment.ECOMP.equals(requestParameters.getOperationalEnvironmentType())) { - throw new ValidationException("operationalEnvironmentType in requestParameters", true); - } - - if(!Action.deactivate.equals(action) && OperationalEnvironment.VNF.equals(requestParameters.getOperationalEnvironmentType())) { - if(instanceList != null && instanceList.length > 0) { - for(RelatedInstanceList relatedInstanceList : instanceList){ - RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); - - if(relatedInstance.getResourceType() == null) { - throw new ValidationException("ResourceType in relatedInstance", true); - } - - if(!empty(relatedInstance.getInstanceName()) && !relatedInstance.getInstanceName().matches(Constants.VALID_INSTANCE_NAME_FORMAT)) { - throw new ValidationException ("instanceName format", true); - } - - if (empty (relatedInstance.getInstanceId ())) { - throw new ValidationException ("instanceId in relatedInstance", true); - } - - if (!UUIDChecker.isValidUUID (relatedInstance.getInstanceId ())) { - throw new ValidationException ("instanceId format in relatedInstance", true); - } - } - } else { - throw new ValidationException ("relatedInstanceList", true); - } - } - } - - private void requestParamsValidation(Action action, RequestParameters requestParameters) throws ValidationException { - - if(requestParameters != null) { - if(!Action.deactivate.equals(action) && requestParameters.getOperationalEnvironmentType() == null) { - throw new ValidationException ("OperationalEnvironmentType", true); - } - - if (Action.create.equals(action) && empty(requestParameters.getTenantContext())) { - throw new ValidationException ("Tenant Context", true); - } - if (!Action.deactivate.equals(action) && empty(requestParameters.getWorkloadContext())) { - throw new ValidationException ("Workload Context", true); - } - - Manifest manifest = requestParameters.getManifest(); - - if(Action.activate.equals(action)) { - if(manifest == null) { - throw new ValidationException ("Manifest on Activate", true); - } else { - List<ServiceModelList> serviceModelList = manifest.getServiceModelList(); - - if(serviceModelList.isEmpty()) { - throw new ValidationException (" empty ServiceModelList", true); - } - - for(ServiceModelList list : serviceModelList) { - if(empty(list.getServiceModelVersionId())) { - throw new ValidationException ("ServiceModelVersionId", true); - } - - if (!UUIDChecker.isValidUUID (list.getServiceModelVersionId())) { - throw new ValidationException ("ServiceModelVersionId format", true); - } - - if(list.getRecoveryAction() == null) { - throw new ValidationException ("RecoveryAction", true); - } - } - } - } - } else if(!Action.deactivate.equals(action)) { - throw new ValidationException("request Parameters", true); - } - } - - private void requestInfoValidation(Action action, RequestInfo requestInfo) throws ValidationException { - - if(Action.create.equals(action) && empty(requestInfo.getInstanceName())) { - throw new ValidationException ("instanceName", true); - } - - if(!empty(requestInfo.getInstanceName()) && !requestInfo.getInstanceName().matches(Constants.VALID_INSTANCE_NAME_FORMAT)) { - throw new ValidationException ("instanceName format", true); - } - - if (empty(requestInfo.getSource())) { - throw new ValidationException ("source", true); + + if (empty(requestInfo.getRequestorId())) { + throw new ValidationException("requestorId", true); } - - if(empty(requestInfo.getRequestorId())) { - throw new ValidationException ("requestorId", true); + + ResourceType resourceType = requestInfo.getResourceType(); + if (resourceType == null) { + throw new ValidationException("resourceType", true); } - - ResourceType resourceType = requestInfo.getResourceType(); - if(resourceType == null) { - throw new ValidationException ("resourceType", true); - } - - this.requestScope = resourceType.name(); - } - - void parseOrchestration (CloudOrchestrationRequest cor) throws ValidationException { + + this.requestScope = resourceType.name(); + } + + void parseOrchestration(CloudOrchestrationRequest cor) throws ValidationException { this.cor = cor; - try{ - ObjectMapper mapper = new ObjectMapper(); - requestJSON = mapper.writeValueAsString(cor.getRequestDetails()); + try { + ObjectMapper mapper = new ObjectMapper(); + requestJSON = mapper.writeValueAsString(cor.getRequestDetails()); - } catch(JsonProcessingException e){ - throw new ValidationException ("Parse CloudOrchestrationRequest to JSON string", e); + } catch (JsonProcessingException e) { + throw new ValidationException("Parse CloudOrchestrationRequest to JSON string", e); } - if(cor.getRequestDetails() == null){ + if (cor.getRequestDetails() == null) { throw new ValidationException("requestDetails", true); } this.requestInfo = cor.getRequestDetails().getRequestInfo(); if (this.requestInfo == null) { - throw new ValidationException ("requestInfo", true); + throw new ValidationException("requestInfo", true); } - if (empty (requestInfo.getSource ())) { - throw new ValidationException ("source", true); + if (empty(requestInfo.getSource())) { + throw new ValidationException("source", true); } - if (empty (requestInfo.getRequestorId ())) { - throw new ValidationException ("requestorId", true); + if (empty(requestInfo.getRequestorId())) { + throw new ValidationException("requestorId", true); } } - - public void createRequestRecord (Status status, Action action){ - - InfraActiveRequests aq = new InfraActiveRequests (); - aq.setRequestId (requestId); - - aq.setRequestAction(action.name()); - aq.setAction(action.name()); - - Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis()); - - aq.setStartTime (startTimeStamp); - - if (requestInfo != null) { - - if(requestInfo.getSource() != null){ - aq.setSource(requestInfo.getSource()); - } - if(requestInfo.getRequestorId() != null) { - aq.setRequestorId(requestInfo.getRequestorId()); - } - if(requestInfo.getResourceType() != null) { - aq.setRequestScope(requestInfo.getResourceType().name()); - } - } - - if(ResourceType.operationalEnvironment.name().equalsIgnoreCase(requestScope) && requestInfo != null) { - aq.setOperationalEnvId(operationalEnvironmentId); - aq.setOperationalEnvName(requestInfo.getInstanceName()); - } - - aq.setRequestBody (this.requestJSON); - - aq.setRequestStatus (status.toString ()); - aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER); - - if ((status == Status.FAILED) || (status == Status.COMPLETE)) { - aq.setStatusMessage (this.errorMessage); - aq.setResponseBody (this.responseBody); - aq.setProgress(Long.valueOf(100)); - - Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis()); - aq.setEndTime (endTimeStamp); - } else if(status == Status.IN_PROGRESS) { - aq.setProgress(Constants.PROGRESS_REQUEST_IN_PROGRESS); - } - requestsDbClient.save(aq); + + public void createRequestRecord(Status status, Action action) { + + InfraActiveRequests aq = new InfraActiveRequests(); + aq.setRequestId(requestId); + + aq.setRequestAction(action.name()); + aq.setAction(action.name()); + + Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis()); + + aq.setStartTime(startTimeStamp); + + if (requestInfo != null) { + + if (requestInfo.getSource() != null) { + aq.setSource(requestInfo.getSource()); + } + if (requestInfo.getRequestorId() != null) { + aq.setRequestorId(requestInfo.getRequestorId()); + } + if (requestInfo.getResourceType() != null) { + aq.setRequestScope(requestInfo.getResourceType().name()); + } + } + + if (ResourceType.operationalEnvironment.name().equalsIgnoreCase(requestScope) && requestInfo != null) { + aq.setOperationalEnvId(operationalEnvironmentId); + aq.setOperationalEnvName(requestInfo.getInstanceName()); + } + + aq.setRequestBody(this.requestJSON); + + aq.setRequestStatus(status.toString()); + aq.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); + + if ((status == Status.FAILED) || (status == Status.COMPLETE)) { + aq.setStatusMessage(this.errorMessage); + aq.setResponseBody(this.responseBody); + aq.setProgress(Long.valueOf(100)); + + Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis()); + aq.setEndTime(endTimeStamp); + } else if (status == Status.IN_PROGRESS) { + aq.setProgress(Constants.PROGRESS_REQUEST_IN_PROGRESS); + } + requestsDbClient.save(aq); } - - - public Map<String, String> getOrchestrationFilters (MultivaluedMap<String, String> queryParams) throws ValidationException { + + + public Map<String, String> getOrchestrationFilters(MultivaluedMap<String, String> queryParams) + throws ValidationException { String queryParam = null; Map<String, String> orchestrationFilterParams = new HashMap<>(); - for (Entry<String,List<String>> entry : queryParams.entrySet()) { + for (Entry<String, List<String>> entry : queryParams.entrySet()) { queryParam = entry.getKey(); - try{ - for(String value : entry.getValue()) { - if(StringUtils.isBlank(value)) { - throw (new Exception(queryParam + " value")); - } - orchestrationFilterParams.put(queryParam, value); - } - }catch(Exception e){ - throw new ValidationException (e.getMessage(), true); - } + try { + for (String value : entry.getValue()) { + if (StringUtils.isBlank(value)) { + throw (new Exception(queryParam + " value")); + } + orchestrationFilterParams.put(queryParam, value); + } + } catch (Exception e) { + throw new ValidationException(e.getMessage(), true); + } } return orchestrationFilterParams; - } + } + + private static boolean empty(String s) { + return (s == null || s.trim().isEmpty()); + } - private static boolean empty(String s) { - return (s == null || s.trim().isEmpty()); - } - - public String getRequestId () { + public String getRequestId() { return requestId; } - + public void setRequestId(String requestId) { - this.requestId = requestId; + this.requestId = requestId; + } + + public void updateFinalStatus() { + try { + InfraActiveRequests request = new InfraActiveRequests(requestId); + request.setRequestStatus(status.toString()); + request.setStatusMessage(this.errorMessage); + request.setProgress(this.progress); + request.setResponseBody(this.responseBody); + request.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); + requestsDbClient.save(request); + } catch (Exception e) { + logger.error("{} {} {} {}", MessageEnum.APIH_DB_UPDATE_EXC.toString(), e.getMessage(), + ErrorCode.DataError.getValue(), "Exception when updating record in DB"); + logger.debug("Exception: ", e); + } } - public void updateFinalStatus() { - try { - InfraActiveRequests request = new InfraActiveRequests(requestId); - request.setRequestStatus(status.toString()); - request.setStatusMessage(this.errorMessage); - request.setProgress(this.progress); - request.setResponseBody(this.responseBody); - request.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); - requestsDbClient.save(request); - } catch (Exception e) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_UPDATE_EXC.toString(), e.getMessage(), - ErrorCode.DataError.getValue(), "Exception when updating record in DB"); - logger.debug("Exception: ", e); - } - } - - public void setStatus (RequestStatusType status) { + public void setStatus(RequestStatusType status) { this.status = status; switch (status) { - case FAILED: - case COMPLETE: - this.progress = Constants.PROGRESS_REQUEST_COMPLETED; - break; - case IN_PROGRESS: - this.progress = Constants.PROGRESS_REQUEST_IN_PROGRESS; - break; - case PENDING: - break; - case TIMEOUT: - break; - case UNLOCKED: - break; - default: - break; + case FAILED: + case COMPLETE: + this.progress = Constants.PROGRESS_REQUEST_COMPLETED; + break; + case IN_PROGRESS: + this.progress = Constants.PROGRESS_REQUEST_IN_PROGRESS; + break; + case PENDING: + break; + case TIMEOUT: + break; + case UNLOCKED: + break; + default: + break; } } - public String getOperationalEnvironmentId() { - return operationalEnvironmentId; - } + public String getOperationalEnvironmentId() { + return operationalEnvironmentId; + } - public void setOperationalEnvironmentId(String operationalEnvironmentId) { - this.operationalEnvironmentId = operationalEnvironmentId; - } + public void setOperationalEnvironmentId(String operationalEnvironmentId) { + this.operationalEnvironmentId = operationalEnvironmentId; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java index 98104e9073..b2596f9013 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java @@ -48,57 +48,63 @@ import org.springframework.stereotype.Component; @Scope("prototype") public class TenantIsolationRunnable { - private static final Logger logger = LoggerFactory.getLogger(TenantIsolationRunnable.class); - - @Autowired - private RequestsDBHelper requestDb; - @Autowired - private CreateEcompOperationalEnvironment createEcompOpEnv; - @Autowired - private CreateVnfOperationalEnvironment createVnfOpEnv; - @Autowired - private ActivateVnfOperationalEnvironment activateVnfOpEnv; - @Autowired - private DeactivateVnfOperationalEnvironment deactivateVnfOpEnv; - @Autowired - private ActivateVnfStatusOperationalEnvironment activateVnfStatusOpEnv; - - @Async - public void run(Action action, String operationalEnvType, CloudOrchestrationRequest cor, String requestId) throws ApiException { + private static final Logger logger = LoggerFactory.getLogger(TenantIsolationRunnable.class); - logger.debug("Starting threadExecution in TenantIsolationRunnable for Action {} and OperationalEnvType: {}", - action.name(), operationalEnvType); - try { - - if(Action.create.equals(action)) { - if(OperationalEnvironment.ECOMP.name().equalsIgnoreCase(operationalEnvType)) { - createEcompOpEnv.execute(requestId, cor); - } else if(OperationalEnvironment.VNF.name().equalsIgnoreCase(operationalEnvType)) { - createVnfOpEnv.execute(requestId, cor); - } else { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError).build(); - ValidateException validateException = new ValidateException.Builder("Invalid OperationalEnvironment Type specified for Create Action", + @Autowired + private RequestsDBHelper requestDb; + @Autowired + private CreateEcompOperationalEnvironment createEcompOpEnv; + @Autowired + private CreateVnfOperationalEnvironment createVnfOpEnv; + @Autowired + private ActivateVnfOperationalEnvironment activateVnfOpEnv; + @Autowired + private DeactivateVnfOperationalEnvironment deactivateVnfOpEnv; + @Autowired + private ActivateVnfStatusOperationalEnvironment activateVnfStatusOpEnv; + + @Async + public void run(Action action, String operationalEnvType, CloudOrchestrationRequest cor, String requestId) + throws ApiException { + + logger.debug("Starting threadExecution in TenantIsolationRunnable for Action {} and OperationalEnvType: {}", + action.name(), operationalEnvType); + try { + + if (Action.create.equals(action)) { + if (OperationalEnvironment.ECOMP.name().equalsIgnoreCase(operationalEnvType)) { + createEcompOpEnv.execute(requestId, cor); + } else if (OperationalEnvironment.VNF.name().equalsIgnoreCase(operationalEnvType)) { + createVnfOpEnv.execute(requestId, cor); + } else { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError) + .build(); + ValidateException validateException = new ValidateException.Builder( + "Invalid OperationalEnvironment Type specified for Create Action", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo) - .build(); + .build(); throw validateException; - } - } else if(Action.activate.equals(action)) { - activateVnfOpEnv.execute(requestId, cor); - } else if(Action.deactivate.equals(action)) { - deactivateVnfOpEnv.execute(requestId, cor); - } else if(Action.distributionStatus.equals(action)) { - activateVnfStatusOpEnv.execute(requestId, cor); - } else { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError).build(); - ValidateException validateException = new ValidateException.Builder("Invalid Action specified: " + action, - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build(); + } + } else if (Action.activate.equals(action)) { + activateVnfOpEnv.execute(requestId, cor); + } else if (Action.deactivate.equals(action)) { + deactivateVnfOpEnv.execute(requestId, cor); + } else if (Action.distributionStatus.equals(action)) { + activateVnfStatusOpEnv.execute(requestId, cor); + } else { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError).build(); + ValidateException validateException = + new ValidateException.Builder("Invalid Action specified: " + action, HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build(); throw validateException; - } - }catch(ApiException e) { + } + } catch (ApiException e) { requestDb.updateInfraFailureCompletion(e.getMessage(), requestId, cor.getOperationalEnvironmentId()); throw e; } - } + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/CreateEcompOperationEnvironmentBean.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/CreateEcompOperationEnvironmentBean.java index 44198d727d..d79e5311c7 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/CreateEcompOperationEnvironmentBean.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/CreateEcompOperationEnvironmentBean.java @@ -26,137 +26,132 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "operationalEnvironmentId", - "operationalEnvironmentName", - "operationalEnvironmentType", - "tenantContext", - "workloadContext" -}) +@JsonPropertyOrder({"operationalEnvironmentId", "operationalEnvironmentName", "operationalEnvironmentType", + "tenantContext", "workloadContext"}) public class CreateEcompOperationEnvironmentBean { - @JsonProperty("operationalEnvironmentId") - private String operationalEnvironmentId; - @JsonProperty("operationalEnvironmentName") - private String operationalEnvironmentName; - @JsonProperty("operationalEnvironmentType") - private String operationalEnvironmentType; - @JsonProperty("tenantContext") - private String tenantContext; - @JsonProperty("workloadContext") - private String workloadContext; - @JsonProperty("action") - private String action; - - public CreateEcompOperationEnvironmentBean() {} - - /** - * - * @param operationalEnvironmentId - * @param operationalEnvironmentName - * @param operationalEnvironmentType - * @param tenantContext - * @param workloadContext - */ - public CreateEcompOperationEnvironmentBean(String operationalEnvironmentId, String operationalEnvironmentName, String operationalEnvironmentType, - String tenantContext, String workloadContext, String action) { - this.operationalEnvironmentId = operationalEnvironmentId; - this.operationalEnvironmentName = operationalEnvironmentName; - this.operationalEnvironmentType = operationalEnvironmentType; - this.tenantContext = tenantContext; - this.workloadContext = workloadContext; - this.action = action; - } - - @JsonProperty("operationalEnvironmentId") - public String getOperationalEnvironmentId() { - return operationalEnvironmentId; - } - - @JsonProperty("operationalEnvironmentId") - public void setOperationalEnvironmentId(String operationalEnvironmentId) { - this.operationalEnvironmentId = operationalEnvironmentId; - } - - public CreateEcompOperationEnvironmentBean withOperationalEnvironmentId(String operationalEnvironmentId) { - this.operationalEnvironmentId = operationalEnvironmentId; - return this; - } - - - @JsonProperty("operationalEnvironmentName") - public String getoperationalEnvironmentName() { - return operationalEnvironmentName; - } - - @JsonProperty("operationalEnvironmentName") - public void setoperationalEnvironmentName(String operationalEnvironmentName) { - this.operationalEnvironmentName = operationalEnvironmentName; - } - - public CreateEcompOperationEnvironmentBean withOperationalEnvironmentName(String operationalEnvironmentName) { - this.operationalEnvironmentName = operationalEnvironmentName; - return this; - } - - @JsonProperty("operationalEnvironmentType") - public String getoperationalEnvironmentType() { - return operationalEnvironmentType; - } - - @JsonProperty("operationalEnvironmentType") - public void setoperationalEnvironmentType(String operationalEnvironmentType) { - this.operationalEnvironmentType = operationalEnvironmentType; - } - - public CreateEcompOperationEnvironmentBean withOperationalEnvironmentType(String operationalEnvironmentType) { - this.operationalEnvironmentType = operationalEnvironmentType; - return this; - } - - @JsonProperty("tenantContext") - public String gettenantContext() { - return tenantContext; - } - - @JsonProperty("tenantContext") - public void settenantContext(String tenantContext) { - this.tenantContext = tenantContext; - } - - public CreateEcompOperationEnvironmentBean withTenantContext(String tenantContext) { - this.tenantContext = tenantContext; - return this; - } - - @JsonProperty("workloadContext") - public String getworkloadContext() { - return workloadContext; - } - - @JsonProperty("workloadContext") - public void setworkloadContext(String workloadContext) { - this.workloadContext = workloadContext; - } - - public CreateEcompOperationEnvironmentBean withWorkloadContext(String workloadContext) { - this.workloadContext = workloadContext; - return this; - } - - @JsonProperty("action") - public String getaction() { - return action; - } - - @JsonProperty("action") - public void setaction(String action) { - this.action = action; - } - - public CreateEcompOperationEnvironmentBean withaction(String action) { - this.action = action; - return this; - } + @JsonProperty("operationalEnvironmentId") + private String operationalEnvironmentId; + @JsonProperty("operationalEnvironmentName") + private String operationalEnvironmentName; + @JsonProperty("operationalEnvironmentType") + private String operationalEnvironmentType; + @JsonProperty("tenantContext") + private String tenantContext; + @JsonProperty("workloadContext") + private String workloadContext; + @JsonProperty("action") + private String action; + + public CreateEcompOperationEnvironmentBean() {} + + /** + * + * @param operationalEnvironmentId + * @param operationalEnvironmentName + * @param operationalEnvironmentType + * @param tenantContext + * @param workloadContext + */ + public CreateEcompOperationEnvironmentBean(String operationalEnvironmentId, String operationalEnvironmentName, + String operationalEnvironmentType, String tenantContext, String workloadContext, String action) { + this.operationalEnvironmentId = operationalEnvironmentId; + this.operationalEnvironmentName = operationalEnvironmentName; + this.operationalEnvironmentType = operationalEnvironmentType; + this.tenantContext = tenantContext; + this.workloadContext = workloadContext; + this.action = action; + } + + @JsonProperty("operationalEnvironmentId") + public String getOperationalEnvironmentId() { + return operationalEnvironmentId; + } + + @JsonProperty("operationalEnvironmentId") + public void setOperationalEnvironmentId(String operationalEnvironmentId) { + this.operationalEnvironmentId = operationalEnvironmentId; + } + + public CreateEcompOperationEnvironmentBean withOperationalEnvironmentId(String operationalEnvironmentId) { + this.operationalEnvironmentId = operationalEnvironmentId; + return this; + } + + + @JsonProperty("operationalEnvironmentName") + public String getoperationalEnvironmentName() { + return operationalEnvironmentName; + } + + @JsonProperty("operationalEnvironmentName") + public void setoperationalEnvironmentName(String operationalEnvironmentName) { + this.operationalEnvironmentName = operationalEnvironmentName; + } + + public CreateEcompOperationEnvironmentBean withOperationalEnvironmentName(String operationalEnvironmentName) { + this.operationalEnvironmentName = operationalEnvironmentName; + return this; + } + + @JsonProperty("operationalEnvironmentType") + public String getoperationalEnvironmentType() { + return operationalEnvironmentType; + } + + @JsonProperty("operationalEnvironmentType") + public void setoperationalEnvironmentType(String operationalEnvironmentType) { + this.operationalEnvironmentType = operationalEnvironmentType; + } + + public CreateEcompOperationEnvironmentBean withOperationalEnvironmentType(String operationalEnvironmentType) { + this.operationalEnvironmentType = operationalEnvironmentType; + return this; + } + + @JsonProperty("tenantContext") + public String gettenantContext() { + return tenantContext; + } + + @JsonProperty("tenantContext") + public void settenantContext(String tenantContext) { + this.tenantContext = tenantContext; + } + + public CreateEcompOperationEnvironmentBean withTenantContext(String tenantContext) { + this.tenantContext = tenantContext; + return this; + } + + @JsonProperty("workloadContext") + public String getworkloadContext() { + return workloadContext; + } + + @JsonProperty("workloadContext") + public void setworkloadContext(String workloadContext) { + this.workloadContext = workloadContext; + } + + public CreateEcompOperationEnvironmentBean withWorkloadContext(String workloadContext) { + this.workloadContext = workloadContext; + return this; + } + + @JsonProperty("action") + public String getaction() { + return action; + } + + @JsonProperty("action") + public void setaction(String action) { + this.action = action; + } + + public CreateEcompOperationEnvironmentBean withaction(String action) { + this.action = action; + return this; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java index 55b1ea6198..340d143b42 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapOperationalEnvClient.java @@ -21,9 +21,7 @@ package org.onap.so.apihandlerinfra.tenantisolation.dmaap; import java.io.IOException; - import javax.inject.Provider; - import org.apache.http.HttpStatus; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.exceptions.ApiException; @@ -33,49 +31,53 @@ import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @Component public class DmaapOperationalEnvClient { - @Autowired - private Provider<OperationalEnvironmentPublisher> dmaapPublisher; - - protected String buildRequest(String operationalEnvironmentId, String operationalEnvironmentName, String operationalEnvironmentType, String tenantContext, String workloadContext, String action ) - throws ApiException { - final CreateEcompOperationEnvironmentBean operationalEnv = new CreateEcompOperationEnvironmentBean(); - operationalEnv.withOperationalEnvironmentId(operationalEnvironmentId) - .withOperationalEnvironmentName(operationalEnvironmentName) - .withOperationalEnvironmentType(operationalEnvironmentType) - .withTenantContext(tenantContext) - .withWorkloadContext(workloadContext) - .withaction(action); - try { - return this.getJson(operationalEnv); - }catch(JsonProcessingException ex){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).build(); - ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : " + ex.getMessage(), - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(ex).errorInfo(errorLoggerInfo).build(); + @Autowired + private Provider<OperationalEnvironmentPublisher> dmaapPublisher; + + protected String buildRequest(String operationalEnvironmentId, String operationalEnvironmentName, + String operationalEnvironmentType, String tenantContext, String workloadContext, String action) + throws ApiException { + final CreateEcompOperationEnvironmentBean operationalEnv = new CreateEcompOperationEnvironmentBean(); + operationalEnv.withOperationalEnvironmentId(operationalEnvironmentId) + .withOperationalEnvironmentName(operationalEnvironmentName) + .withOperationalEnvironmentType(operationalEnvironmentType).withTenantContext(tenantContext) + .withWorkloadContext(workloadContext).withaction(action); + try { + return this.getJson(operationalEnv); + } catch (JsonProcessingException ex) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) + .build(); + ValidateException validateException = + new ValidateException.Builder("Mapping of request to JSON object failed : " + ex.getMessage(), + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(ex) + .errorInfo(errorLoggerInfo).build(); + + throw validateException; + } + } + + protected String getJson(CreateEcompOperationEnvironmentBean obj) throws JsonProcessingException { + + final ObjectMapper mapper = new ObjectMapper(); + return mapper.writeValueAsString(obj); - throw validateException; - } - } + } - protected String getJson(CreateEcompOperationEnvironmentBean obj) throws JsonProcessingException { - - final ObjectMapper mapper = new ObjectMapper(); - return mapper.writeValueAsString(obj); - - } - - public void dmaapPublishOperationalEnvRequest(String operationalEnvironmentId, String operationalEnvironmentName, String operationalEnvironmentType, - String tenantContext, String workloadContext, String action ) throws ApiException, IOException, InterruptedException { + public void dmaapPublishOperationalEnvRequest(String operationalEnvironmentId, String operationalEnvironmentName, + String operationalEnvironmentType, String tenantContext, String workloadContext, String action) + throws ApiException, IOException, InterruptedException { - String request = this.buildRequest(operationalEnvironmentId, operationalEnvironmentName, operationalEnvironmentType, tenantContext, workloadContext, action); - dmaapPublisher.get().send(request); + String request = this.buildRequest(operationalEnvironmentId, operationalEnvironmentName, + operationalEnvironmentType, tenantContext, workloadContext, action); + dmaapPublisher.get().send(request); - } + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java index 8409d9c300..4ba69f55e9 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/DmaapPropertiesImpl.java @@ -22,34 +22,30 @@ package org.onap.so.apihandlerinfra.tenantisolation.dmaap; import java.util.HashMap; import java.util.Map; - import org.onap.so.client.dmaap.DmaapProperties; import org.onap.so.spring.SpringContextHelper; import org.springframework.context.ApplicationContext; public class DmaapPropertiesImpl implements DmaapProperties { - private final Map<String, String> props = new HashMap<>(); - private static final String[] propertyNames = { - "mso.so.operational-environment.dmaap.auth", - "mso.msoKey", - "mso.so.operational-environment.publisher.topic", - "mso.so.operational-environment.dmaap.host" - }; - public DmaapPropertiesImpl () { - ApplicationContext context = SpringContextHelper.getAppContext(); - - for (String name : propertyNames) { - this.props.put(name, context.getEnvironment().getProperty(name)); - - } - - } - - @Override - public Map<String, String> getProperties() { - - return this.props; - } + private final Map<String, String> props = new HashMap<>(); + private static final String[] propertyNames = {"mso.so.operational-environment.dmaap.auth", "mso.msoKey", + "mso.so.operational-environment.publisher.topic", "mso.so.operational-environment.dmaap.host"}; + + public DmaapPropertiesImpl() { + ApplicationContext context = SpringContextHelper.getAppContext(); + + for (String name : propertyNames) { + this.props.put(name, context.getEnvironment().getProperty(name)); + + } + + } + + @Override + public Map<String, String> getProperties() { + + return this.props; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisher.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisher.java index 31bc6fcb4f..350a091d97 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisher.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/dmaap/OperationalEnvironmentPublisher.java @@ -22,7 +22,6 @@ package org.onap.so.apihandlerinfra.tenantisolation.dmaap; import java.io.IOException; import java.util.Optional; - import org.onap.so.client.dmaap.DmaapPublisher; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -31,31 +30,31 @@ import org.springframework.stereotype.Component; @Scope("prototype") public class OperationalEnvironmentPublisher extends DmaapPublisher { - - public OperationalEnvironmentPublisher() throws IOException { - super(); - } - - @Override - public String getAuth() { - - return this.msoProperties.get("mso.so.operational-environment.dmaap.auth"); - } - - @Override - public String getKey() { - - return this.msoProperties.get("mso.msoKey"); - } - - @Override - public String getTopic() { - - return this.msoProperties.get("mso.so.operational-environment.publisher.topic"); - } - - @Override - public Optional<String> getHost() { - return Optional.ofNullable(this.msoProperties.get("mso.so.operational-environment.dmaap.host")); - } + + public OperationalEnvironmentPublisher() throws IOException { + super(); + } + + @Override + public String getAuth() { + + return this.msoProperties.get("mso.so.operational-environment.dmaap.auth"); + } + + @Override + public String getKey() { + + return this.msoProperties.get("mso.msoKey"); + } + + @Override + public String getTopic() { + + return this.msoProperties.get("mso.so.operational-environment.publisher.topic"); + } + + @Override + public Optional<String> getHost() { + return Optional.ofNullable(this.msoProperties.get("mso.so.operational-environment.dmaap.host")); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/AAIClientCallFailed.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/AAIClientCallFailed.java index 4f4fa1ae35..3ceb8e7897 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/AAIClientCallFailed.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/AAIClientCallFailed.java @@ -22,8 +22,8 @@ package org.onap.so.apihandlerinfra.tenantisolation.exceptions; public class AAIClientCallFailed extends Exception { - public AAIClientCallFailed(String message, Throwable cause) { - super(message, cause); - } + public AAIClientCallFailed(String message, Throwable cause) { + super(message, cause); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/SDCClientCallFailed.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/SDCClientCallFailed.java index 9cdef3c9d1..cacbb557b2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/SDCClientCallFailed.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/SDCClientCallFailed.java @@ -22,15 +22,15 @@ package org.onap.so.apihandlerinfra.tenantisolation.exceptions; public class SDCClientCallFailed extends Exception { - private static final long serialVersionUID = 3066575499816576134L; + private static final long serialVersionUID = 3066575499816576134L; + + public SDCClientCallFailed(String message, Throwable cause) { + super(message, cause); + } + + public SDCClientCallFailed(String message) { + super(message); + } - public SDCClientCallFailed(String message, Throwable cause) { - super(message, cause); - } - public SDCClientCallFailed(String message) { - super(message); - } - - } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/TenantIsolationException.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/TenantIsolationException.java index af3e7937af..14e6464960 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/TenantIsolationException.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/exceptions/TenantIsolationException.java @@ -22,15 +22,15 @@ package org.onap.so.apihandlerinfra.tenantisolation.exceptions; public class TenantIsolationException extends Exception { - private static final long serialVersionUID = 6948152225371031774L; - - public TenantIsolationException() { - super(); - - } - - public TenantIsolationException(String msg) { - super ("Tenant Isolation error: " + msg); - - } -}
\ No newline at end of file + private static final long serialVersionUID = 6948152225371031774L; + + public TenantIsolationException() { + super(); + + } + + public TenantIsolationException(String msg) { + super("Tenant Isolation error: " + msg); + + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java index 870fa11b5c..8b3b91ae1a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java @@ -25,9 +25,7 @@ package org.onap.so.apihandlerinfra.tenantisolation.helpers; import java.io.PrintWriter; import java.io.StringWriter; import java.util.Map; - import javax.ws.rs.NotFoundException; - import org.onap.aai.domain.yang.OperationalEnvironment; import org.onap.so.apihandlerinfra.tenantisolation.exceptions.AAIClientCallFailed; import org.onap.so.client.aai.AAIObjectType; @@ -43,81 +41,89 @@ import org.springframework.stereotype.Component; @Component public class AAIClientHelper { - - private static Logger logger = LoggerFactory.getLogger(AAIClientHelper.class); - - /** - * Get managing ECOMP Environment Info from A&AI - * @param id = operationalEnvironmentId - * @return AAIResultWrapper object - */ - public AAIResultWrapper getAaiOperationalEnvironment(String id){ - - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id); - uri.depth(Depth.ZERO); - AAIResourcesClient client = this.getClient(); - return client.get(uri, NotFoundException.class); - } - - - /** - * Update managing ECOMP Environment Info from A&AI - * @param id = operationalEnvironmentId - * @param AAIOperationalEnvironment object - */ - public void updateAaiOperationalEnvironment(String id, OperationalEnvironment aaiRequest){ - - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id); - AAIResourcesClient client = this.getClient(); - client.update(uri, aaiRequest); - - } - - - public void updateAaiOperationalEnvironment(String operationalEnvironmentId, Map<String, String> payload) throws Exception { - try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, operationalEnvironmentId); - AAIResourcesClient aaiClient = this.getClient(); - aaiClient.update(uri, payload); - } - catch(Exception ex) { - logStackTrace(ex); - throw new AAIClientCallFailed("Call to A&AI failed!", ex); - } - } - - /** - * Create an Operational Environment object in A&AI - * @param AAIOperationalEnvironment object - */ - public void createOperationalEnvironment(OperationalEnvironment operationalEnvironment){ - - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, operationalEnvironment.getOperationalEnvironmentId()); - AAIResourcesClient client = this.getClient(); - client.create(uri, operationalEnvironment); - } - - /** - * Create a relationship between ECOMP managing and VNF Operational Environments - * @param managingEcompOperationalEnvironmentId - * @param vnfOperationalEnvironmentId - * @throws Exception - */ - public void createRelationship(String managingEcompOperationalEnvironmentId, String vnfOperationalEnvironmentId) { - - AAIResourceUri ecompEnvUri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, managingEcompOperationalEnvironmentId); - AAIResourceUri vnfEnvUri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, vnfOperationalEnvironmentId); - AAIResourcesClient client = this.getClient(); - client.connect(vnfEnvUri, ecompEnvUri); - - } - - private void logStackTrace(Exception e) { - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); - } - - protected AAIResourcesClient getClient() { - return new AAIResourcesClient(); - } + + private static Logger logger = LoggerFactory.getLogger(AAIClientHelper.class); + + /** + * Get managing ECOMP Environment Info from A&AI + * + * @param id = operationalEnvironmentId + * @return AAIResultWrapper object + */ + public AAIResultWrapper getAaiOperationalEnvironment(String id) { + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id); + uri.depth(Depth.ZERO); + AAIResourcesClient client = this.getClient(); + return client.get(uri, NotFoundException.class); + } + + + /** + * Update managing ECOMP Environment Info from A&AI + * + * @param id = operationalEnvironmentId + * @param AAIOperationalEnvironment object + */ + public void updateAaiOperationalEnvironment(String id, OperationalEnvironment aaiRequest) { + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, id); + AAIResourcesClient client = this.getClient(); + client.update(uri, aaiRequest); + + } + + + public void updateAaiOperationalEnvironment(String operationalEnvironmentId, Map<String, String> payload) + throws Exception { + try { + AAIResourceUri uri = + AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, operationalEnvironmentId); + AAIResourcesClient aaiClient = this.getClient(); + aaiClient.update(uri, payload); + } catch (Exception ex) { + logStackTrace(ex); + throw new AAIClientCallFailed("Call to A&AI failed!", ex); + } + } + + /** + * Create an Operational Environment object in A&AI + * + * @param AAIOperationalEnvironment object + */ + public void createOperationalEnvironment(OperationalEnvironment operationalEnvironment) { + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, + operationalEnvironment.getOperationalEnvironmentId()); + AAIResourcesClient client = this.getClient(); + client.create(uri, operationalEnvironment); + } + + /** + * Create a relationship between ECOMP managing and VNF Operational Environments + * + * @param managingEcompOperationalEnvironmentId + * @param vnfOperationalEnvironmentId + * @throws Exception + */ + public void createRelationship(String managingEcompOperationalEnvironmentId, String vnfOperationalEnvironmentId) { + + AAIResourceUri ecompEnvUri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, + managingEcompOperationalEnvironmentId); + AAIResourceUri vnfEnvUri = + AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, vnfOperationalEnvironmentId); + AAIResourcesClient client = this.getClient(); + client.connect(vnfEnvUri, ecompEnvUri); + + } + + private void logStackTrace(Exception e) { + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw)); + } + + protected AAIResourcesClient getClient() { + return new AAIResourcesClient(); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java index dc6019c9cb..b5294cd8b8 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientObjectBuilder.java @@ -26,17 +26,21 @@ import org.springframework.stereotype.Component; @Component public class AAIClientObjectBuilder { - - public OperationalEnvironment buildAAIOperationalEnvironment(String status, CloudOrchestrationRequest cloudOrchestrationRequest) { - OperationalEnvironment env = new OperationalEnvironment(); - env.setOperationalEnvironmentId(cloudOrchestrationRequest.getOperationalEnvironmentId()); - env.setOperationalEnvironmentName(cloudOrchestrationRequest.getRequestDetails().getRequestInfo().getInstanceName()); - env.setOperationalEnvironmentType(cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getOperationalEnvironmentType().toString()); - env.setOperationalEnvironmentStatus(status); - env.setTenantContext(cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getTenantContext()); - env.setWorkloadContext(cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getWorkloadContext()); - return env; - } + + public OperationalEnvironment buildAAIOperationalEnvironment(String status, + CloudOrchestrationRequest cloudOrchestrationRequest) { + OperationalEnvironment env = new OperationalEnvironment(); + env.setOperationalEnvironmentId(cloudOrchestrationRequest.getOperationalEnvironmentId()); + env.setOperationalEnvironmentName( + cloudOrchestrationRequest.getRequestDetails().getRequestInfo().getInstanceName()); + env.setOperationalEnvironmentType(cloudOrchestrationRequest.getRequestDetails().getRequestParameters() + .getOperationalEnvironmentType().toString()); + env.setOperationalEnvironmentStatus(status); + env.setTenantContext(cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getTenantContext()); + env.setWorkloadContext( + cloudOrchestrationRequest.getRequestDetails().getRequestParameters().getWorkloadContext()); + return env; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java index de1d9e9cfb..98b49d39d7 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java @@ -30,94 +30,89 @@ import org.springframework.stereotype.Component; @Component public class ActivateVnfDBHelper { - - private static Logger logger = LoggerFactory.getLogger(ActivateVnfDBHelper.class); - - /** - * Insert record to OperationalEnvServiceModelStatus table - * @param requestId - String - * @param operationalEnvironmentId - String - * @param serviceModelVersionId - String - * @param status - String - * @param recoveryAction - String - * @param retryCount - int - * @param workloadContext - String - * @return serviceModelStatus - OperationalEnvServiceModelStatus object - */ - public OperationalEnvServiceModelStatus insertRecordToOperationalEnvServiceModelStatus( String requestId, - String operationalEnvironmentId, - String serviceModelVersionId, - String status, - String recoveryAction, - int retryCount, - String workloadContext, - String vnfOperationalEnvironmentId) { - OperationalEnvServiceModelStatus serviceModelStatus = new OperationalEnvServiceModelStatus(); - serviceModelStatus.setRequestId(requestId); - serviceModelStatus.setOperationalEnvId(operationalEnvironmentId); - serviceModelStatus.setServiceModelVersionId(serviceModelVersionId); - serviceModelStatus.setServiceModelVersionDistrStatus(status); - serviceModelStatus.setRecoveryAction(recoveryAction); - serviceModelStatus.setRetryCount(new Integer(retryCount)); - serviceModelStatus.setWorkloadContext(workloadContext); - serviceModelStatus.setVnfOperationalEnvId(vnfOperationalEnvironmentId); - return serviceModelStatus; - } - /** - * Update RetryCount & Status in OperationalEnvServiceModelStatus table - * @param serviceModelStatusResponse - OperationalEnvServiceModelStatus object - * @param status - String - * @param retryCount - int - * @return serviceModelStatusResponse - OperationalEnvServiceModelStatus object - */ - public OperationalEnvServiceModelStatus updateRetryCountAndStatusInOperationalEnvServiceModelStatus(OperationalEnvServiceModelStatus serviceModelStatusResponse, - String status, - int retryCount) { - serviceModelStatusResponse.setServiceModelVersionDistrStatus(status); - serviceModelStatusResponse.setRetryCount(new Integer(retryCount)); - return serviceModelStatusResponse; - } - - /** - * Insert record to OperationalEnvDistributionStatus table - * @param distributionId - String - * @param operationalEnvironmentId - String - * @param serviceModelVersionId - String - * @param requestId - String - * @param status - String - * @param distributionIdErrorReason - String - * @return distStatus - OperationalEnvDistributionStatus object - */ - public OperationalEnvDistributionStatus insertRecordToOperationalEnvDistributionStatus( String distributionId, - String operationalEnvironmentId, - String serviceModelVersionId, - String requestId, - String status, - String distributionIdErrorReason) { - OperationalEnvDistributionStatus distStatus = new OperationalEnvDistributionStatus(); - distStatus.setDistributionId(distributionId); - distStatus.setOperationalEnvId(operationalEnvironmentId); - distStatus.setServiceModelVersionId(serviceModelVersionId); - distStatus.setRequestId(requestId); - distStatus.setDistributionIdStatus(status); - distStatus.setDistributionIdErrorReason(distributionIdErrorReason); - return distStatus; - } - - /** - * Update Status in OperationalEnvDistributionStatus table - * @param distributionStatusResponse - OperationalEnvDistributionStatus object - * @param status - String - * @param distributionIdErrorReason - String - * @return distributionStatusResponse - OperationalEnvDistributionStatus object - */ - public OperationalEnvDistributionStatus updateStatusInOperationalEnvDistributionStatus(OperationalEnvDistributionStatus distributionStatusResponse, - String status, - String distributionIdErrorReason) { - distributionStatusResponse.setDistributionIdStatus(status); - distributionStatusResponse.setDistributionIdErrorReason(distributionIdErrorReason); - return distributionStatusResponse; - } - + private static Logger logger = LoggerFactory.getLogger(ActivateVnfDBHelper.class); + + /** + * Insert record to OperationalEnvServiceModelStatus table + * + * @param requestId - String + * @param operationalEnvironmentId - String + * @param serviceModelVersionId - String + * @param status - String + * @param recoveryAction - String + * @param retryCount - int + * @param workloadContext - String + * @return serviceModelStatus - OperationalEnvServiceModelStatus object + */ + public OperationalEnvServiceModelStatus insertRecordToOperationalEnvServiceModelStatus(String requestId, + String operationalEnvironmentId, String serviceModelVersionId, String status, String recoveryAction, + int retryCount, String workloadContext, String vnfOperationalEnvironmentId) { + OperationalEnvServiceModelStatus serviceModelStatus = new OperationalEnvServiceModelStatus(); + serviceModelStatus.setRequestId(requestId); + serviceModelStatus.setOperationalEnvId(operationalEnvironmentId); + serviceModelStatus.setServiceModelVersionId(serviceModelVersionId); + serviceModelStatus.setServiceModelVersionDistrStatus(status); + serviceModelStatus.setRecoveryAction(recoveryAction); + serviceModelStatus.setRetryCount(new Integer(retryCount)); + serviceModelStatus.setWorkloadContext(workloadContext); + serviceModelStatus.setVnfOperationalEnvId(vnfOperationalEnvironmentId); + return serviceModelStatus; + } + + /** + * Update RetryCount & Status in OperationalEnvServiceModelStatus table + * + * @param serviceModelStatusResponse - OperationalEnvServiceModelStatus object + * @param status - String + * @param retryCount - int + * @return serviceModelStatusResponse - OperationalEnvServiceModelStatus object + */ + public OperationalEnvServiceModelStatus updateRetryCountAndStatusInOperationalEnvServiceModelStatus( + OperationalEnvServiceModelStatus serviceModelStatusResponse, String status, int retryCount) { + serviceModelStatusResponse.setServiceModelVersionDistrStatus(status); + serviceModelStatusResponse.setRetryCount(new Integer(retryCount)); + return serviceModelStatusResponse; + } + + /** + * Insert record to OperationalEnvDistributionStatus table + * + * @param distributionId - String + * @param operationalEnvironmentId - String + * @param serviceModelVersionId - String + * @param requestId - String + * @param status - String + * @param distributionIdErrorReason - String + * @return distStatus - OperationalEnvDistributionStatus object + */ + public OperationalEnvDistributionStatus insertRecordToOperationalEnvDistributionStatus(String distributionId, + String operationalEnvironmentId, String serviceModelVersionId, String requestId, String status, + String distributionIdErrorReason) { + OperationalEnvDistributionStatus distStatus = new OperationalEnvDistributionStatus(); + distStatus.setDistributionId(distributionId); + distStatus.setOperationalEnvId(operationalEnvironmentId); + distStatus.setServiceModelVersionId(serviceModelVersionId); + distStatus.setRequestId(requestId); + distStatus.setDistributionIdStatus(status); + distStatus.setDistributionIdErrorReason(distributionIdErrorReason); + return distStatus; + } + + /** + * Update Status in OperationalEnvDistributionStatus table + * + * @param distributionStatusResponse - OperationalEnvDistributionStatus object + * @param status - String + * @param distributionIdErrorReason - String + * @return distributionStatusResponse - OperationalEnvDistributionStatus object + */ + public OperationalEnvDistributionStatus updateStatusInOperationalEnvDistributionStatus( + OperationalEnvDistributionStatus distributionStatusResponse, String status, + String distributionIdErrorReason) { + distributionStatusResponse.setDistributionIdStatus(status); + distributionStatusResponse.setDistributionIdErrorReason(distributionIdErrorReason); + return distributionStatusResponse; + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java index bf5623a9da..b5ba9281a6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java @@ -24,10 +24,8 @@ package org.onap.so.apihandlerinfra.tenantisolation.helpers; import java.net.URL; import java.util.UUID; - import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; - import org.apache.http.HttpStatus; import org.json.JSONException; import org.json.JSONObject; @@ -49,185 +47,198 @@ import org.springframework.stereotype.Component; @Component public class SDCClientHelper { - private static Logger logger = LoggerFactory.getLogger(SDCClientHelper.class); - private static final String SDC_CONTENT_TYPE = "application/json"; - private static final String SDC_ACCEPT_TYPE = "application/json"; - private static String PARTIAL_SDC_URI = "/sdc/v1/catalog/services/"; - - private static String MESSAGE_UNDEFINED_ERROR = "Undefined Error Message!"; - private static String MESSAGE_UNEXPECTED_FORMAT = "Unexpected response format from SDC."; - private final HttpClientFactory httpClientFactory = new HttpClientFactory(); - - @Value("${mso.sdc.endpoint}") - private String sdcEndpoint; - @Value("${mso.sdc.activate.userid}") - private String sdcActivateUserId; - @Value("${mso.sdc.activate.instanceid}") - private String sdcActivateInstanceId; - @Value("${mso.sdc.client.auth}") - private String sdcClientAuth; - @Value("${mso.msoKey}") - private String msoKey; - - /** - * Send POST request to SDC for operational activation - * @param serviceModelVersionI - String - * @param operationalEnvironmentId - String - * @param workloadContext - String - * @return sdcResponseJsonObj - JSONObject object - * @throws JSONException - */ - public JSONObject postActivateOperationalEnvironment(String serviceModelVersionId, String operationalEnvironmentId, String workloadContext) throws ApiException { - JSONObject sdcResponseJsonObj = new JSONObject(); - - try { - String urlString = this.buildUriBuilder(serviceModelVersionId, operationalEnvironmentId); - String jsonPayload = this.buildJsonWorkloadContext(workloadContext); - String basicAuthCred = getBasicAuth(); - - if ( basicAuthCred == null || "".equals(basicAuthCred) ) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcesssError).build(); - ValidateException validateException = new ValidateException.Builder(" SDC credentials 'mso.sdc.client.auth' not setup in properties file!", - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); + private static Logger logger = LoggerFactory.getLogger(SDCClientHelper.class); + private static final String SDC_CONTENT_TYPE = "application/json"; + private static final String SDC_ACCEPT_TYPE = "application/json"; + private static String PARTIAL_SDC_URI = "/sdc/v1/catalog/services/"; + + private static String MESSAGE_UNDEFINED_ERROR = "Undefined Error Message!"; + private static String MESSAGE_UNEXPECTED_FORMAT = "Unexpected response format from SDC."; + private final HttpClientFactory httpClientFactory = new HttpClientFactory(); + + @Value("${mso.sdc.endpoint}") + private String sdcEndpoint; + @Value("${mso.sdc.activate.userid}") + private String sdcActivateUserId; + @Value("${mso.sdc.activate.instanceid}") + private String sdcActivateInstanceId; + @Value("${mso.sdc.client.auth}") + private String sdcClientAuth; + @Value("${mso.msoKey}") + private String msoKey; + + /** + * Send POST request to SDC for operational activation + * + * @param serviceModelVersionI - String + * @param operationalEnvironmentId - String + * @param workloadContext - String + * @return sdcResponseJsonObj - JSONObject object + * @throws JSONException + */ + public JSONObject postActivateOperationalEnvironment(String serviceModelVersionId, String operationalEnvironmentId, + String workloadContext) throws ApiException { + JSONObject sdcResponseJsonObj = new JSONObject(); + + try { + String urlString = this.buildUriBuilder(serviceModelVersionId, operationalEnvironmentId); + String jsonPayload = this.buildJsonWorkloadContext(workloadContext); + String basicAuthCred = getBasicAuth(); + + if (basicAuthCred == null || "".equals(basicAuthCred)) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcesssError) + .build(); + ValidateException validateException = new ValidateException.Builder( + " SDC credentials 'mso.sdc.client.auth' not setup in properties file!", + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo) + .build(); throw validateException; - } - - URL url = new URL(urlString); - - HttpClient httpClient = httpClientFactory.newJsonClient(url, TargetEntity.SDC); - httpClient.addBasicAuthHeader(sdcClientAuth, msoKey); - httpClient.addAdditionalHeader("X-ECOMP-InstanceID", sdcActivateInstanceId); - httpClient.addAdditionalHeader("X-ECOMP-RequestID", UUID.randomUUID().toString()); - httpClient.addAdditionalHeader("Content-Type", SDCClientHelper.SDC_CONTENT_TYPE); - httpClient.addAdditionalHeader("Accept", SDCClientHelper.SDC_ACCEPT_TYPE); - httpClient.addAdditionalHeader("USER_ID", sdcActivateUserId); - - Response apiResponse = setHttpPostResponse(httpClient, jsonPayload); - int statusCode = apiResponse.getStatus();; - - String responseData = apiResponse.readEntity(String.class); - sdcResponseJsonObj = enhanceJsonResponse(new JSONObject(responseData), statusCode); - - } catch (Exception ex) { - logger.debug("calling SDC Exception message: {}", ex.getMessage()); - String errorMessage = " Encountered Error while calling SDC POST Activate. " + ex.getMessage(); - logger.debug(errorMessage); - sdcResponseJsonObj.put("statusCode", String.valueOf(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode())); - sdcResponseJsonObj.put("messageId", ""); - sdcResponseJsonObj.put("message", errorMessage); - - } - return sdcResponseJsonObj; - } - - /** - * set HttpPostResponse - * @param config - RESTConfig object - * @param jsonPayload - String - * @return client - RestClient object - */ - public Response setHttpPostResponse(HttpClient client, String jsonPayload) throws ApiException { - try { + } + + URL url = new URL(urlString); + + HttpClient httpClient = httpClientFactory.newJsonClient(url, TargetEntity.SDC); + httpClient.addBasicAuthHeader(sdcClientAuth, msoKey); + httpClient.addAdditionalHeader("X-ECOMP-InstanceID", sdcActivateInstanceId); + httpClient.addAdditionalHeader("X-ECOMP-RequestID", UUID.randomUUID().toString()); + httpClient.addAdditionalHeader("Content-Type", SDCClientHelper.SDC_CONTENT_TYPE); + httpClient.addAdditionalHeader("Accept", SDCClientHelper.SDC_ACCEPT_TYPE); + httpClient.addAdditionalHeader("USER_ID", sdcActivateUserId); + + Response apiResponse = setHttpPostResponse(httpClient, jsonPayload); + int statusCode = apiResponse.getStatus();; + + String responseData = apiResponse.readEntity(String.class); + sdcResponseJsonObj = enhanceJsonResponse(new JSONObject(responseData), statusCode); + + } catch (Exception ex) { + logger.debug("calling SDC Exception message: {}", ex.getMessage()); + String errorMessage = " Encountered Error while calling SDC POST Activate. " + ex.getMessage(); + logger.debug(errorMessage); + sdcResponseJsonObj.put("statusCode", String.valueOf(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode())); + sdcResponseJsonObj.put("messageId", ""); + sdcResponseJsonObj.put("message", errorMessage); + + } + return sdcResponseJsonObj; + } + + /** + * set HttpPostResponse + * + * @param config - RESTConfig object + * @param jsonPayload - String + * @return client - RestClient object + */ + public Response setHttpPostResponse(HttpClient client, String jsonPayload) throws ApiException { + try { return client.post(jsonPayload); - }catch(Exception ex){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcesssError).build(); - ValidateException validateException = new ValidateException.Builder("Bad request could not post payload", - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(ex).errorInfo(errorLoggerInfo).build(); + } catch (Exception ex) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcesssError) + .build(); + ValidateException validateException = + new ValidateException.Builder("Bad request could not post payload", HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(ex).errorInfo(errorLoggerInfo).build(); throw validateException; } - } - - /** - * enhance Response - * @param sdcResponseJsonObj - JSONObject object - * @param statusCode - int - * @return enhancedAsdcResponseJsonObj - JSONObject object - */ - public JSONObject enhanceJsonResponse(JSONObject sdcResponseJsonObj, int statusCode) throws JSONException { - - JSONObject enhancedAsdcResponseJsonObj = new JSONObject(); - - String message = ""; - String messageId = ""; - - if (statusCode == Response.Status.ACCEPTED.getStatusCode()) { // Accepted - enhancedAsdcResponseJsonObj.put("distributionId", sdcResponseJsonObj.get("distributionId")); - enhancedAsdcResponseJsonObj.put("statusCode", Integer.toString(statusCode)); - enhancedAsdcResponseJsonObj.put("messageId", ""); - enhancedAsdcResponseJsonObj.put("message", "Success"); - - } else { // error - if (sdcResponseJsonObj.has("requestError") ) { - JSONObject requestErrorObj = sdcResponseJsonObj.getJSONObject("requestError"); - if (sdcResponseJsonObj.getJSONObject("requestError").has("serviceException") ) { - message = requestErrorObj.getJSONObject("serviceException").getString("text"); - messageId = requestErrorObj.getJSONObject("serviceException").getString("messageId"); - } - if (sdcResponseJsonObj.getJSONObject("requestError").has("policyException") ) { - message = requestErrorObj.getJSONObject("policyException").getString("text"); - messageId = requestErrorObj.getJSONObject("policyException").getString("messageId"); - } - enhancedAsdcResponseJsonObj.put("statusCode", Integer.toString(statusCode)); - enhancedAsdcResponseJsonObj.put("messageId", messageId); - enhancedAsdcResponseJsonObj.put("message", message); - - } else { - // unexpected format - enhancedAsdcResponseJsonObj.put("statusCode", String.valueOf(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode())); - enhancedAsdcResponseJsonObj.put("messageId", MESSAGE_UNDEFINED_ERROR); - enhancedAsdcResponseJsonObj.put("message", MESSAGE_UNEXPECTED_FORMAT); - } - } - return enhancedAsdcResponseJsonObj; - - } - - /** - * Build Uri - * @param serviceModelVersionId - String - * @param operationalEnvironmentId - String - * @return uriBuilder - String - */ - public String buildUriBuilder(String serviceModelVersionId, String operationalEnvironmentId) { - String path = serviceModelVersionId + "/distribution/" + operationalEnvironmentId +"/activate"; - UriBuilder uriBuilder = UriBuilder.fromPath(sdcEndpoint + SDCClientHelper.PARTIAL_SDC_URI) - .path(path); - return uriBuilder.build().toString(); - } - - /** - * Build JSON context - * @param workloadContext - String - * @return String json - * @throws JSONException - */ - public String buildJsonWorkloadContext(String workloadContext) throws JSONException { - return new JSONObject().put("workloadContext", workloadContext).toString(); - - } - - /** - * decrypt value - * @param toDecrypt - String - * @param msokey - String - * @return result - String - */ - public synchronized String decrypt(String toDecrypt, String msokey){ - String result = null; - try { - result = CryptoUtils.decrypt(toDecrypt, msokey); - - } - catch (Exception e) { - logger.debug("Failed to decrypt credentials: {}", toDecrypt, e); - } - return result; - } - - private String getBasicAuth() { - return decrypt(sdcClientAuth, msoKey); - } + } + + /** + * enhance Response + * + * @param sdcResponseJsonObj - JSONObject object + * @param statusCode - int + * @return enhancedAsdcResponseJsonObj - JSONObject object + */ + public JSONObject enhanceJsonResponse(JSONObject sdcResponseJsonObj, int statusCode) throws JSONException { + + JSONObject enhancedAsdcResponseJsonObj = new JSONObject(); + + String message = ""; + String messageId = ""; + + if (statusCode == Response.Status.ACCEPTED.getStatusCode()) { // Accepted + enhancedAsdcResponseJsonObj.put("distributionId", sdcResponseJsonObj.get("distributionId")); + enhancedAsdcResponseJsonObj.put("statusCode", Integer.toString(statusCode)); + enhancedAsdcResponseJsonObj.put("messageId", ""); + enhancedAsdcResponseJsonObj.put("message", "Success"); + + } else { // error + if (sdcResponseJsonObj.has("requestError")) { + JSONObject requestErrorObj = sdcResponseJsonObj.getJSONObject("requestError"); + if (sdcResponseJsonObj.getJSONObject("requestError").has("serviceException")) { + message = requestErrorObj.getJSONObject("serviceException").getString("text"); + messageId = requestErrorObj.getJSONObject("serviceException").getString("messageId"); + } + if (sdcResponseJsonObj.getJSONObject("requestError").has("policyException")) { + message = requestErrorObj.getJSONObject("policyException").getString("text"); + messageId = requestErrorObj.getJSONObject("policyException").getString("messageId"); + } + enhancedAsdcResponseJsonObj.put("statusCode", Integer.toString(statusCode)); + enhancedAsdcResponseJsonObj.put("messageId", messageId); + enhancedAsdcResponseJsonObj.put("message", message); + + } else { + // unexpected format + enhancedAsdcResponseJsonObj.put("statusCode", + String.valueOf(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode())); + enhancedAsdcResponseJsonObj.put("messageId", MESSAGE_UNDEFINED_ERROR); + enhancedAsdcResponseJsonObj.put("message", MESSAGE_UNEXPECTED_FORMAT); + } + } + return enhancedAsdcResponseJsonObj; + + } + + /** + * Build Uri + * + * @param serviceModelVersionId - String + * @param operationalEnvironmentId - String + * @return uriBuilder - String + */ + public String buildUriBuilder(String serviceModelVersionId, String operationalEnvironmentId) { + String path = serviceModelVersionId + "/distribution/" + operationalEnvironmentId + "/activate"; + UriBuilder uriBuilder = UriBuilder.fromPath(sdcEndpoint + SDCClientHelper.PARTIAL_SDC_URI).path(path); + return uriBuilder.build().toString(); + } + + /** + * Build JSON context + * + * @param workloadContext - String + * @return String json + * @throws JSONException + */ + public String buildJsonWorkloadContext(String workloadContext) throws JSONException { + return new JSONObject().put("workloadContext", workloadContext).toString(); + + } + + /** + * decrypt value + * + * @param toDecrypt - String + * @param msokey - String + * @return result - String + */ + public synchronized String decrypt(String toDecrypt, String msokey) { + String result = null; + try { + result = CryptoUtils.decrypt(toDecrypt, msokey); + + } catch (Exception e) { + logger.debug("Failed to decrypt credentials: {}", toDecrypt, e); + } + return result; + } + + private String getBasicAuth() { + return decrypt(sdcClientAuth, msoKey); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java index dde45a81c9..3957f86bab 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java @@ -22,9 +22,7 @@ package org.onap.so.apihandlerinfra.tenantisolation.process; import java.util.List; import java.util.Optional; - import javax.ws.rs.core.Response; - import org.apache.http.HttpStatus; import org.json.JSONObject; import org.onap.aai.domain.yang.OperationalEnvironment; @@ -57,145 +55,155 @@ import org.springframework.stereotype.Component; @Component public class ActivateVnfOperationalEnvironment { - private static final Logger logger = LoggerFactory.getLogger(ActivateVnfOperationalEnvironment.class); - private static final int DEFAULT_ACTIVATE_RETRY_COUNT = 3; - private static final String DISTRIBUTION_STATUS_SENT = "SENT"; - private static final String OPER_ENVIRONMENT_ID_KEY = "operational-environment-id"; - - @Autowired - private ActivateVnfDBHelper dbHelper; - @Autowired - private AAIClientHelper aaiHelper; - @Autowired - private RequestsDBHelper requestDb; - @Autowired - private SDCClientHelper sdcClientHelper; - - @Value("${mso.tenant.isolation.retry.count}") - private String sdcRetryCount; - - @Autowired - RequestsDbClient client; - - /** - * The Point-Of-Entry from APIH with VID request to send activate request - * @param requestId - String - * @param request - CloudOrchestrationRequest object - * @return void - nothing - */ - public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException{ - String vnfOperationalEnvironmentId = request.getOperationalEnvironmentId(); - - String vidWorkloadContext = request.getRequestDetails().getRequestParameters().getWorkloadContext(); - List<ServiceModelList> serviceModelVersionIdList = request.getRequestDetails().getRequestParameters().getManifest().getServiceModelList(); - - String ecompOperationalEnvironmentId = null; - AAIResultWrapper wrapper = getAAIOperationalEnvironment(vnfOperationalEnvironmentId); - Optional<Relationships> optRelationships = wrapper.getRelationships(); - if (optRelationships.isPresent()) { - Relationships relationships = optRelationships.get(); - List<AAIResourceUri> operationalEnvironments = relationships.getRelatedAAIUris(AAIObjectType.OPERATIONAL_ENVIRONMENT); - if (!operationalEnvironments.isEmpty()) { - ecompOperationalEnvironmentId = operationalEnvironments.get(0).getURIKeys().get(OPER_ENVIRONMENT_ID_KEY); - } - } - logger.debug(" vnfOperationalEnvironmentId : {}", vnfOperationalEnvironmentId); - logger.debug(" ecompOperationalEnvironmentId : {}", ecompOperationalEnvironmentId); - - OperationalEnvironment operationalEnv = wrapper.asBean(OperationalEnvironment.class).get(); - String workloadContext = operationalEnv.getWorkloadContext(); - logger.debug(" aai workloadContext: {}", workloadContext); - if (!vidWorkloadContext.equals(workloadContext)) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcesssError).build(); - throw new ValidateException.Builder(" The vid workloadContext did not match from aai record. " + " vid workloadContext:" + vidWorkloadContext + " aai workloadContext:" + workloadContext, - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); - } - if (ecompOperationalEnvironmentId==null) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcesssError).build(); - throw new ValidateException.Builder(" The ECOMP OE was not in aai record; the value of relationship.relationship-data key: " + OPER_ENVIRONMENT_ID_KEY, - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); - } - - processActivateSDCRequest(requestId, ecompOperationalEnvironmentId, serviceModelVersionIdList, workloadContext, vnfOperationalEnvironmentId); - - } - - - /** - * The Method to send the Activation Requests to SDC - * @param requestId - String - * @param operationalEnvironmentId - String - * @param serviceModelVersionIdList - List<ServiceModelList> list - * @param workloadContext - String - * @return jsonResponse - JSONObject object - */ - public void processActivateSDCRequest(String requestId, String operationalEnvironmentId, - List<ServiceModelList> serviceModelVersionIdList, - String workloadContext, String vnfOperationalEnvironmentId) throws ApiException { - - JSONObject jsonResponse = null; - int retryCount = 0; - try { - retryCount = Integer.parseInt(sdcRetryCount); - } catch (NumberFormatException e) { - retryCount = DEFAULT_ACTIVATE_RETRY_COUNT; - } - - // loop through the serviceModelVersionId, and send request SDC - for(ServiceModelList serviceModelList : serviceModelVersionIdList){ - String serviceModelVersionId = serviceModelList.getServiceModelVersionId(); - String recoveryAction = serviceModelList.getRecoveryAction().toString().toUpperCase(); - - // should insert 1 row - OperationalEnvServiceModelStatus serviceModelStatus = - dbHelper.insertRecordToOperationalEnvServiceModelStatus(requestId, - operationalEnvironmentId, - serviceModelVersionId, - DISTRIBUTION_STATUS_SENT, - recoveryAction, - retryCount, - workloadContext, - vnfOperationalEnvironmentId); - client.save(serviceModelStatus); - - String distributionId = ""; - - jsonResponse = sdcClientHelper.postActivateOperationalEnvironment(serviceModelVersionId, operationalEnvironmentId, workloadContext); - - String statusCode = jsonResponse.get("statusCode").toString(); - if (statusCode.equals(String.valueOf(Response.Status.ACCEPTED.getStatusCode()))) { - distributionId = jsonResponse.get("distributionId").toString(); - // should insert 1 row - OperationalEnvDistributionStatus distStatus = - dbHelper.insertRecordToOperationalEnvDistributionStatus(distributionId, - operationalEnvironmentId, - serviceModelVersionId, - requestId, - DISTRIBUTION_STATUS_SENT, - ""); - client.save(distStatus); - - } else { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcesssError).build(); - String dbErrorMessage = " Failure calling SDC: statusCode: " + statusCode + - "; messageId: " + jsonResponse.get("messageId") + - "; message: " + jsonResponse.get("message"); + private static final Logger logger = LoggerFactory.getLogger(ActivateVnfOperationalEnvironment.class); + private static final int DEFAULT_ACTIVATE_RETRY_COUNT = 3; + private static final String DISTRIBUTION_STATUS_SENT = "SENT"; + private static final String OPER_ENVIRONMENT_ID_KEY = "operational-environment-id"; + + @Autowired + private ActivateVnfDBHelper dbHelper; + @Autowired + private AAIClientHelper aaiHelper; + @Autowired + private RequestsDBHelper requestDb; + @Autowired + private SDCClientHelper sdcClientHelper; + + @Value("${mso.tenant.isolation.retry.count}") + private String sdcRetryCount; + + @Autowired + RequestsDbClient client; + + /** + * The Point-Of-Entry from APIH with VID request to send activate request + * + * @param requestId - String + * @param request - CloudOrchestrationRequest object + * @return void - nothing + */ + public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException { + String vnfOperationalEnvironmentId = request.getOperationalEnvironmentId(); + + String vidWorkloadContext = request.getRequestDetails().getRequestParameters().getWorkloadContext(); + List<ServiceModelList> serviceModelVersionIdList = + request.getRequestDetails().getRequestParameters().getManifest().getServiceModelList(); + + String ecompOperationalEnvironmentId = null; + AAIResultWrapper wrapper = getAAIOperationalEnvironment(vnfOperationalEnvironmentId); + Optional<Relationships> optRelationships = wrapper.getRelationships(); + if (optRelationships.isPresent()) { + Relationships relationships = optRelationships.get(); + List<AAIResourceUri> operationalEnvironments = + relationships.getRelatedAAIUris(AAIObjectType.OPERATIONAL_ENVIRONMENT); + if (!operationalEnvironments.isEmpty()) { + ecompOperationalEnvironmentId = + operationalEnvironments.get(0).getURIKeys().get(OPER_ENVIRONMENT_ID_KEY); + } + } + logger.debug(" vnfOperationalEnvironmentId : {}", vnfOperationalEnvironmentId); + logger.debug(" ecompOperationalEnvironmentId : {}", ecompOperationalEnvironmentId); + + OperationalEnvironment operationalEnv = wrapper.asBean(OperationalEnvironment.class).get(); + String workloadContext = operationalEnv.getWorkloadContext(); + logger.debug(" aai workloadContext: {}", workloadContext); + if (!vidWorkloadContext.equals(workloadContext)) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcesssError) + .build(); + throw new ValidateException.Builder( + " The vid workloadContext did not match from aai record. " + " vid workloadContext:" + + vidWorkloadContext + " aai workloadContext:" + workloadContext, + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo) + .build(); + } + if (ecompOperationalEnvironmentId == null) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcesssError) + .build(); + throw new ValidateException.Builder( + " The ECOMP OE was not in aai record; the value of relationship.relationship-data key: " + + OPER_ENVIRONMENT_ID_KEY, + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo) + .build(); + } + + processActivateSDCRequest(requestId, ecompOperationalEnvironmentId, serviceModelVersionIdList, workloadContext, + vnfOperationalEnvironmentId); + + } + + + /** + * The Method to send the Activation Requests to SDC + * + * @param requestId - String + * @param operationalEnvironmentId - String + * @param serviceModelVersionIdList - List<ServiceModelList> list + * @param workloadContext - String + * @return jsonResponse - JSONObject object + */ + public void processActivateSDCRequest(String requestId, String operationalEnvironmentId, + List<ServiceModelList> serviceModelVersionIdList, String workloadContext, + String vnfOperationalEnvironmentId) throws ApiException { + + JSONObject jsonResponse = null; + int retryCount = 0; + try { + retryCount = Integer.parseInt(sdcRetryCount); + } catch (NumberFormatException e) { + retryCount = DEFAULT_ACTIVATE_RETRY_COUNT; + } + + // loop through the serviceModelVersionId, and send request SDC + for (ServiceModelList serviceModelList : serviceModelVersionIdList) { + String serviceModelVersionId = serviceModelList.getServiceModelVersionId(); + String recoveryAction = serviceModelList.getRecoveryAction().toString().toUpperCase(); + + // should insert 1 row + OperationalEnvServiceModelStatus serviceModelStatus = + dbHelper.insertRecordToOperationalEnvServiceModelStatus(requestId, operationalEnvironmentId, + serviceModelVersionId, DISTRIBUTION_STATUS_SENT, recoveryAction, retryCount, + workloadContext, vnfOperationalEnvironmentId); + client.save(serviceModelStatus); + + String distributionId = ""; + + jsonResponse = sdcClientHelper.postActivateOperationalEnvironment(serviceModelVersionId, + operationalEnvironmentId, workloadContext); + + String statusCode = jsonResponse.get("statusCode").toString(); + if (statusCode.equals(String.valueOf(Response.Status.ACCEPTED.getStatusCode()))) { + distributionId = jsonResponse.get("distributionId").toString(); + // should insert 1 row + OperationalEnvDistributionStatus distStatus = dbHelper.insertRecordToOperationalEnvDistributionStatus( + distributionId, operationalEnvironmentId, serviceModelVersionId, requestId, + DISTRIBUTION_STATUS_SENT, ""); + client.save(distStatus); + + } else { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcesssError) + .build(); + String dbErrorMessage = " Failure calling SDC: statusCode: " + statusCode + "; messageId: " + + jsonResponse.get("messageId") + "; message: " + jsonResponse.get("message"); requestDb.updateInfraFailureCompletion(dbErrorMessage, requestId, operationalEnvironmentId); - throw new ValidateException.Builder(dbErrorMessage, - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); - } - } - - } - - /** - * Get AAIOperationalEnvironment object - * @param operationalEnvironmentId - String - * @return operationalEnv - AAIOperationalEnvironment object - */ - public AAIResultWrapper getAAIOperationalEnvironment(String operationalEnvironmentId) { - return aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId); - } + throw new ValidateException.Builder(dbErrorMessage, HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); + } + } + + } + + /** + * Get AAIOperationalEnvironment object + * + * @param operationalEnvironmentId - String + * @return operationalEnv - AAIOperationalEnvironment object + */ + public AAIResultWrapper getAAIOperationalEnvironment(String operationalEnvironmentId) { + return aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java index cd05aa558e..3005abaf9b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java @@ -25,9 +25,7 @@ package org.onap.so.apihandlerinfra.tenantisolation.process; import java.util.List; import java.util.Optional; - import javax.ws.rs.core.Response; - import org.apache.http.HttpStatus; import org.json.JSONObject; import org.onap.aai.domain.yang.OperationalEnvironment; @@ -56,272 +54,278 @@ import org.springframework.stereotype.Component; @Component public class ActivateVnfStatusOperationalEnvironment { - private static Logger logger = LoggerFactory.getLogger(ActivateVnfStatusOperationalEnvironment.class); - private String origRequestId = ""; - private String errorMessage = ""; - private OperationalEnvDistributionStatus queryDistributionDbResponse = null; - private OperationalEnvServiceModelStatus queryServiceModelResponse = null; - private boolean isOverallSuccess = false; - - private final int RETRY_COUNT_ZERO = 0; - private final String ERROR_REASON_ABORTED = "ABORTED"; - private final String RECOVERY_ACTION_RETRY = "RETRY"; - private final String RECOVERY_ACTION_ABORT = "ABORT"; - private final String RECOVERY_ACTION_SKIP = "SKIP"; - private final String DISTRIBUTION_STATUS_OK = DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString(); - private final String DISTRIBUTION_STATUS_ERROR = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString(); - private final String DISTRIBUTION_STATUS_SENT = "SENT"; - - private final String MESSAGE_UNDEFINED_ID = "Undefined Error Message!"; - - @Autowired - private ActivateVnfDBHelper dbHelper; - @Autowired - private RequestsDBHelper requestDb; - @Autowired - private SDCClientHelper sdcClientHelper; - @Autowired - private RequestsDbClient client; - @Autowired - private AAIClientHelper aaiHelper; - - /** - * The Point-Of-Entry from APIH with activate status from SDC - * @param requestId - String - * @param request - CloudOrchestrationRequest - object - * @return void - nothing - */ - public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException { - - try { - - String operationalEnvironmentId = ""; - - String sdcDistributionId = request.getDistributionId(); - Distribution sdcStatus = request.getDistribution(); - - // Distribution, Query for operationalEnvironmentId, serviceModelVersionId, origRequestId - this.queryDistributionDbResponse = client.getDistributionStatusById(sdcDistributionId); - operationalEnvironmentId = this.queryDistributionDbResponse.getOperationalEnvId(); - this.origRequestId = this.queryDistributionDbResponse.getRequestId(); - - // ServiceModel, Query for recoveryAction, retryCountString - this.queryServiceModelResponse = client.findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId(operationalEnvironmentId, queryDistributionDbResponse.getServiceModelVersionId(), this.origRequestId); - - processActivateSDCStatus(sdcDistributionId, sdcStatus, this.queryDistributionDbResponse, this.queryServiceModelResponse); - - // After EVERY status processed, need to query the status of all service modelId - // to determine the OVERALL status if "COMPLETE" or "FAILURE": - checkOrUpdateOverallStatus(operationalEnvironmentId, this.origRequestId); - - // Update AAI to ACTIVE if Overall success - if (isOverallSuccess) { - String vnfOperationalEnvironmentId = this.queryServiceModelResponse.getVnfOperationalEnvId(); - OperationalEnvironment aaiOpEnv = getAAIOperationalEnvironment(vnfOperationalEnvironmentId); - if (aaiOpEnv != null) { - aaiOpEnv.setOperationalEnvironmentStatus("ACTIVE"); - aaiHelper.updateAaiOperationalEnvironment(vnfOperationalEnvironmentId, aaiOpEnv); - }else { - requestDb.updateInfraFailureCompletion("Unable to update ACTIVATE status in AAI. ", this.origRequestId, this.queryServiceModelResponse.getVnfOperationalEnvId()); - } - } - - } catch(Exception e) { - requestDb.updateInfraFailureCompletion(e.getMessage(), this.origRequestId, this.queryServiceModelResponse.getVnfOperationalEnvId()); + private static Logger logger = LoggerFactory.getLogger(ActivateVnfStatusOperationalEnvironment.class); + private String origRequestId = ""; + private String errorMessage = ""; + private OperationalEnvDistributionStatus queryDistributionDbResponse = null; + private OperationalEnvServiceModelStatus queryServiceModelResponse = null; + private boolean isOverallSuccess = false; + + private final int RETRY_COUNT_ZERO = 0; + private final String ERROR_REASON_ABORTED = "ABORTED"; + private final String RECOVERY_ACTION_RETRY = "RETRY"; + private final String RECOVERY_ACTION_ABORT = "ABORT"; + private final String RECOVERY_ACTION_SKIP = "SKIP"; + private final String DISTRIBUTION_STATUS_OK = DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString(); + private final String DISTRIBUTION_STATUS_ERROR = DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString(); + private final String DISTRIBUTION_STATUS_SENT = "SENT"; + + private final String MESSAGE_UNDEFINED_ID = "Undefined Error Message!"; + + @Autowired + private ActivateVnfDBHelper dbHelper; + @Autowired + private RequestsDBHelper requestDb; + @Autowired + private SDCClientHelper sdcClientHelper; + @Autowired + private RequestsDbClient client; + @Autowired + private AAIClientHelper aaiHelper; + + /** + * The Point-Of-Entry from APIH with activate status from SDC + * + * @param requestId - String + * @param request - CloudOrchestrationRequest - object + * @return void - nothing + */ + public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException { + + try { + + String operationalEnvironmentId = ""; + + String sdcDistributionId = request.getDistributionId(); + Distribution sdcStatus = request.getDistribution(); + + // Distribution, Query for operationalEnvironmentId, serviceModelVersionId, origRequestId + this.queryDistributionDbResponse = client.getDistributionStatusById(sdcDistributionId); + operationalEnvironmentId = this.queryDistributionDbResponse.getOperationalEnvId(); + this.origRequestId = this.queryDistributionDbResponse.getRequestId(); + + // ServiceModel, Query for recoveryAction, retryCountString + this.queryServiceModelResponse = + client.findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId(operationalEnvironmentId, + queryDistributionDbResponse.getServiceModelVersionId(), this.origRequestId); + + processActivateSDCStatus(sdcDistributionId, sdcStatus, this.queryDistributionDbResponse, + this.queryServiceModelResponse); + + // After EVERY status processed, need to query the status of all service modelId + // to determine the OVERALL status if "COMPLETE" or "FAILURE": + checkOrUpdateOverallStatus(operationalEnvironmentId, this.origRequestId); + + // Update AAI to ACTIVE if Overall success + if (isOverallSuccess) { + String vnfOperationalEnvironmentId = this.queryServiceModelResponse.getVnfOperationalEnvId(); + OperationalEnvironment aaiOpEnv = getAAIOperationalEnvironment(vnfOperationalEnvironmentId); + if (aaiOpEnv != null) { + aaiOpEnv.setOperationalEnvironmentStatus("ACTIVE"); + aaiHelper.updateAaiOperationalEnvironment(vnfOperationalEnvironmentId, aaiOpEnv); + } else { + requestDb.updateInfraFailureCompletion("Unable to update ACTIVATE status in AAI. ", + this.origRequestId, this.queryServiceModelResponse.getVnfOperationalEnvId()); + } + } + + } catch (Exception e) { + requestDb.updateInfraFailureCompletion(e.getMessage(), this.origRequestId, + this.queryServiceModelResponse.getVnfOperationalEnvId()); } - - } - - /** - * The Method to process the Activation Status from SDC - * @param sdcDistributionId - string - * @param sdcStatus - Distribution object - * @param queryDistributionDbResponse - OperationalEnvDistributionStatus object - * @param queryServiceModelResponse - OperationalEnvServiceModelStatus object - * @return void - nothing - */ - public void processActivateSDCStatus(String sdcDistributionId, Distribution sdcStatus, OperationalEnvDistributionStatus queryDistributionDbResponse, - OperationalEnvServiceModelStatus queryServiceModelResponse) throws ApiException { - - String sdcStatusValue = sdcStatus.getStatus().toString(); - String recoveryAction = queryServiceModelResponse.getRecoveryAction(); - int retryCount = queryServiceModelResponse.getRetryCount(); - - // Validate/process status - if (sdcStatus.getStatus().toString().equals(DISTRIBUTION_STATUS_OK)) { - // should update 1 row, update status to "DISTRIBUTION_COMPLETE_OK" - OperationalEnvDistributionStatus updateDistStatusOk = - dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse, - sdcStatusValue, - ""); - client.save(updateDistStatusOk); - // should update 1 row, update status and retryCount = 0 (ie, serviceModelVersionId is DONE!) - OperationalEnvServiceModelStatus updateRetryCountZeroAndStatusOk = - dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse, - sdcStatusValue, - RETRY_COUNT_ZERO); - client.save(updateRetryCountZeroAndStatusOk); - } else { - - // "DISTRIBUTION_COMPLETE_ERROR", Check if recoveryAction is "RETRY" - if (recoveryAction.equals(RECOVERY_ACTION_RETRY) && retryCount > RETRY_COUNT_ZERO) { - - // RESEND / RETRY serviceModelVersionId to SDC - - JSONObject jsonResponse = callSDClientForRetry(queryDistributionDbResponse, queryServiceModelResponse, sdcStatus); - - } else { // either RETRY & Count = 0, or 'ABORT', or 'SKIP' - - if (recoveryAction.equals(RECOVERY_ACTION_SKIP) || recoveryAction.equals(RECOVERY_ACTION_ABORT)) { - String modifiedStatus = ""; - String errorReason = ""; - if (recoveryAction.equals(RECOVERY_ACTION_SKIP)) { // considered SUCCESS - modifiedStatus = DISTRIBUTION_STATUS_OK; - } else { - if (recoveryAction.equals(RECOVERY_ACTION_ABORT)) { - modifiedStatus = DISTRIBUTION_STATUS_ERROR; // ABORT, error - errorReason = ERROR_REASON_ABORTED; - } - } - - sdcStatusValue = modifiedStatus; - OperationalEnvServiceModelStatus updateRetryCountZeroAndStatus = - dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse, - modifiedStatus, - RETRY_COUNT_ZERO); - client.save(updateRetryCountZeroAndStatus); - OperationalEnvDistributionStatus updateDistStatus = - dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse, - modifiedStatus, - errorReason); - client.save(updateDistStatus); - } else { - // RETRY & Count = 0 (do nothing!) - } - } - } - } - - /** - * The Method to call SDC for recoveryActioin RETRY - * @param queryDistributionDbResponse - OperationalEnvDistributionStatus object - * @param queryServiceModelResponse - OperationalEnvServiceModelStatus object - * @param sdcStatus - Distribution object - * @return JSONObject object - */ - public JSONObject callSDClientForRetry(OperationalEnvDistributionStatus queryDistributionDbResponse, - OperationalEnvServiceModelStatus queryServiceModelResponse, - Distribution sdcStatus) throws ApiException { - - JSONObject jsonResponse = null; - - String operEnvironmentId = queryDistributionDbResponse.getOperationalEnvId(); - String serviceModelVersionId = queryDistributionDbResponse.getServiceModelVersionId(); - String originalRequestId = queryServiceModelResponse.getRequestId(); - int retryCount = queryServiceModelResponse.getRetryCount(); - String workloadContext = queryServiceModelResponse.getWorkloadContext(); - - - jsonResponse = sdcClientHelper.postActivateOperationalEnvironment(serviceModelVersionId, operEnvironmentId, workloadContext); - String statusCode = jsonResponse.get("statusCode").toString(); - if (statusCode.equals(String.valueOf(Response.Status.ACCEPTED.getStatusCode()))) { - String newDistributionId = jsonResponse.get("distributionId").toString(); - // should insert 1 row, NEW distributionId for replacement of the serviceModelServiceId record - OperationalEnvDistributionStatus insertNewDistributionId = - dbHelper.insertRecordToOperationalEnvDistributionStatus(newDistributionId, - operEnvironmentId, - serviceModelVersionId, - originalRequestId, - DISTRIBUTION_STATUS_SENT, - ""); - client.save(insertNewDistributionId); - - // update retryCount (less 1) for the serviceModelServiceId - retryCount = retryCount - 1; - // should update 1 row, original insert - OperationalEnvServiceModelStatus updateRetryCountAndStatus = - dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse, - DISTRIBUTION_STATUS_SENT, - retryCount); - client.save(updateRetryCountAndStatus); - - // should update 1 row, OLD distributionId set to status error (ie, old distributionId is DONE!). - OperationalEnvDistributionStatus updateStatus = - dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse, - DISTRIBUTION_STATUS_ERROR, - sdcStatus.getErrorReason()); - client.save(updateStatus); - } else { - String dbErrorMessage = "Failure calling SDC: statusCode: " + statusCode + - "; messageId: " + jsonResponse.get("messageId") + - "; message: " + jsonResponse.get("message"); - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcesssError).build(); - ValidateException validateException = new ValidateException.Builder(dbErrorMessage, - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); - requestDb.updateInfraFailureCompletion(dbErrorMessage, this.origRequestId, operEnvironmentId); - throw validateException; - } - - return jsonResponse; - - } - - - /** - * The Method to check the overall status of the Activation for an operationalEnvironmentId - * @param operationalEnvironmentId - string - * @param origRequestId - string - * @return void - nothing - */ - public void checkOrUpdateOverallStatus(String operationalEnvironmentId, String origRequestId) throws ApiException{ - - List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = client.getAllByOperationalEnvIdAndRequestId(operationalEnvironmentId, origRequestId); - - String status = "Waiting"; - int count = 0; - // loop through the statuses of the service model - for (OperationalEnvServiceModelStatus querySrvModelResponse : queryServiceModelResponseList) { - status = querySrvModelResponse.getServiceModelVersionDistrStatus(); - // all should be OK to be completed. - if ((status.equals(DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString()) && - (querySrvModelResponse.getRetryCount() == 0))) { - status = "Completed"; - count ++; - } - // one error with zero retry, means all are failures. - if ((status.equals(DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString()) && - (querySrvModelResponse.getRetryCount() == 0))) { - status = "Failure"; - count = queryServiceModelResponseList.size(); - break; - } - } - - if (status.equals("Completed") && queryServiceModelResponseList.size() == count) { - String messageStatus = "Overall Activation process is complete. " + status; - isOverallSuccess = true; - requestDb.updateInfraSuccessCompletion(messageStatus, origRequestId, operationalEnvironmentId); - } else { - if (status.equals("Failure") && queryServiceModelResponseList.size() == count) { - this.errorMessage = "Overall Activation process is a Failure. " + status; - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcesssError).build(); - ValidateException validateException = new ValidateException.Builder(this.errorMessage, - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); + + } + + /** + * The Method to process the Activation Status from SDC + * + * @param sdcDistributionId - string + * @param sdcStatus - Distribution object + * @param queryDistributionDbResponse - OperationalEnvDistributionStatus object + * @param queryServiceModelResponse - OperationalEnvServiceModelStatus object + * @return void - nothing + */ + public void processActivateSDCStatus(String sdcDistributionId, Distribution sdcStatus, + OperationalEnvDistributionStatus queryDistributionDbResponse, + OperationalEnvServiceModelStatus queryServiceModelResponse) throws ApiException { + + String sdcStatusValue = sdcStatus.getStatus().toString(); + String recoveryAction = queryServiceModelResponse.getRecoveryAction(); + int retryCount = queryServiceModelResponse.getRetryCount(); + + // Validate/process status + if (sdcStatus.getStatus().toString().equals(DISTRIBUTION_STATUS_OK)) { + // should update 1 row, update status to "DISTRIBUTION_COMPLETE_OK" + OperationalEnvDistributionStatus updateDistStatusOk = dbHelper + .updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse, sdcStatusValue, ""); + client.save(updateDistStatusOk); + // should update 1 row, update status and retryCount = 0 (ie, serviceModelVersionId is DONE!) + OperationalEnvServiceModelStatus updateRetryCountZeroAndStatusOk = + dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse, + sdcStatusValue, RETRY_COUNT_ZERO); + client.save(updateRetryCountZeroAndStatusOk); + } else { + + // "DISTRIBUTION_COMPLETE_ERROR", Check if recoveryAction is "RETRY" + if (recoveryAction.equals(RECOVERY_ACTION_RETRY) && retryCount > RETRY_COUNT_ZERO) { + + // RESEND / RETRY serviceModelVersionId to SDC + + JSONObject jsonResponse = + callSDClientForRetry(queryDistributionDbResponse, queryServiceModelResponse, sdcStatus); + + } else { // either RETRY & Count = 0, or 'ABORT', or 'SKIP' + + if (recoveryAction.equals(RECOVERY_ACTION_SKIP) || recoveryAction.equals(RECOVERY_ACTION_ABORT)) { + String modifiedStatus = ""; + String errorReason = ""; + if (recoveryAction.equals(RECOVERY_ACTION_SKIP)) { // considered SUCCESS + modifiedStatus = DISTRIBUTION_STATUS_OK; + } else { + if (recoveryAction.equals(RECOVERY_ACTION_ABORT)) { + modifiedStatus = DISTRIBUTION_STATUS_ERROR; // ABORT, error + errorReason = ERROR_REASON_ABORTED; + } + } + + sdcStatusValue = modifiedStatus; + OperationalEnvServiceModelStatus updateRetryCountZeroAndStatus = + dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus( + queryServiceModelResponse, modifiedStatus, RETRY_COUNT_ZERO); + client.save(updateRetryCountZeroAndStatus); + OperationalEnvDistributionStatus updateDistStatus = + dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse, + modifiedStatus, errorReason); + client.save(updateDistStatus); + } else { + // RETRY & Count = 0 (do nothing!) + } + } + } + } + + /** + * The Method to call SDC for recoveryActioin RETRY + * + * @param queryDistributionDbResponse - OperationalEnvDistributionStatus object + * @param queryServiceModelResponse - OperationalEnvServiceModelStatus object + * @param sdcStatus - Distribution object + * @return JSONObject object + */ + public JSONObject callSDClientForRetry(OperationalEnvDistributionStatus queryDistributionDbResponse, + OperationalEnvServiceModelStatus queryServiceModelResponse, Distribution sdcStatus) throws ApiException { + + JSONObject jsonResponse = null; + + String operEnvironmentId = queryDistributionDbResponse.getOperationalEnvId(); + String serviceModelVersionId = queryDistributionDbResponse.getServiceModelVersionId(); + String originalRequestId = queryServiceModelResponse.getRequestId(); + int retryCount = queryServiceModelResponse.getRetryCount(); + String workloadContext = queryServiceModelResponse.getWorkloadContext(); + + + jsonResponse = sdcClientHelper.postActivateOperationalEnvironment(serviceModelVersionId, operEnvironmentId, + workloadContext); + String statusCode = jsonResponse.get("statusCode").toString(); + if (statusCode.equals(String.valueOf(Response.Status.ACCEPTED.getStatusCode()))) { + String newDistributionId = jsonResponse.get("distributionId").toString(); + // should insert 1 row, NEW distributionId for replacement of the serviceModelServiceId record + OperationalEnvDistributionStatus insertNewDistributionId = + dbHelper.insertRecordToOperationalEnvDistributionStatus(newDistributionId, operEnvironmentId, + serviceModelVersionId, originalRequestId, DISTRIBUTION_STATUS_SENT, ""); + client.save(insertNewDistributionId); + + // update retryCount (less 1) for the serviceModelServiceId + retryCount = retryCount - 1; + // should update 1 row, original insert + OperationalEnvServiceModelStatus updateRetryCountAndStatus = + dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse, + DISTRIBUTION_STATUS_SENT, retryCount); + client.save(updateRetryCountAndStatus); + + // should update 1 row, OLD distributionId set to status error (ie, old distributionId is DONE!). + OperationalEnvDistributionStatus updateStatus = dbHelper.updateStatusInOperationalEnvDistributionStatus( + queryDistributionDbResponse, DISTRIBUTION_STATUS_ERROR, sdcStatus.getErrorReason()); + client.save(updateStatus); + } else { + String dbErrorMessage = "Failure calling SDC: statusCode: " + statusCode + "; messageId: " + + jsonResponse.get("messageId") + "; message: " + jsonResponse.get("message"); + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcesssError) + .build(); + ValidateException validateException = + new ValidateException.Builder(dbErrorMessage, HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); + requestDb.updateInfraFailureCompletion(dbErrorMessage, this.origRequestId, operEnvironmentId); + throw validateException; + } + + return jsonResponse; + + } + + + /** + * The Method to check the overall status of the Activation for an operationalEnvironmentId + * + * @param operationalEnvironmentId - string + * @param origRequestId - string + * @return void - nothing + */ + public void checkOrUpdateOverallStatus(String operationalEnvironmentId, String origRequestId) throws ApiException { + + List<OperationalEnvServiceModelStatus> queryServiceModelResponseList = + client.getAllByOperationalEnvIdAndRequestId(operationalEnvironmentId, origRequestId); + + String status = "Waiting"; + int count = 0; + // loop through the statuses of the service model + for (OperationalEnvServiceModelStatus querySrvModelResponse : queryServiceModelResponseList) { + status = querySrvModelResponse.getServiceModelVersionDistrStatus(); + // all should be OK to be completed. + if ((status.equals(DistributionStatus.DISTRIBUTION_COMPLETE_OK.toString()) + && (querySrvModelResponse.getRetryCount() == 0))) { + status = "Completed"; + count++; + } + // one error with zero retry, means all are failures. + if ((status.equals(DistributionStatus.DISTRIBUTION_COMPLETE_ERROR.toString()) + && (querySrvModelResponse.getRetryCount() == 0))) { + status = "Failure"; + count = queryServiceModelResponseList.size(); + break; + } + } + + if (status.equals("Completed") && queryServiceModelResponseList.size() == count) { + String messageStatus = "Overall Activation process is complete. " + status; + isOverallSuccess = true; + requestDb.updateInfraSuccessCompletion(messageStatus, origRequestId, operationalEnvironmentId); + } else { + if (status.equals("Failure") && queryServiceModelResponseList.size() == count) { + this.errorMessage = "Overall Activation process is a Failure. " + status; + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.BusinessProcesssError) + .build(); + ValidateException validateException = + new ValidateException.Builder(this.errorMessage, HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); requestDb.updateInfraFailureCompletion(this.errorMessage, origRequestId, operationalEnvironmentId); - throw validateException; - } - - } - } - - /** - * Get OperationalEnvironment object - * @param operationalEnvironmentId - String - * @return operationalEnv - OperationalEnvironment object - */ - private OperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) { - AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId); - Optional<OperationalEnvironment> operationalEnvironmentOpt = aaiResult.asBean(OperationalEnvironment.class); - return operationalEnvironmentOpt.isPresent() ? operationalEnvironmentOpt.get() : null; - } + throw validateException; + } + + } + } + + /** + * Get OperationalEnvironment object + * + * @param operationalEnvironmentId - String + * @return operationalEnv - OperationalEnvironment object + */ + private OperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) { + AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId); + Optional<OperationalEnvironment> operationalEnvironmentOpt = aaiResult.asBean(OperationalEnvironment.class); + return operationalEnvironmentOpt.isPresent() ? operationalEnvironmentOpt.get() : null; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java index e9c9be9dd4..3812aa9edf 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java @@ -41,48 +41,51 @@ import org.springframework.stereotype.Component; @Component public class CreateEcompOperationalEnvironment { - - private static Logger logger = LoggerFactory.getLogger(CreateEcompOperationalEnvironment.class); - - @Autowired - private AAIClientObjectBuilder aaiClientObjectBuilder; - @Autowired - private AAIClientHelper aaiHelper; - @Autowired - private RequestsDBHelper requestDb; - @Autowired - private DmaapOperationalEnvClient dmaapClient; - public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException{ + private static Logger logger = LoggerFactory.getLogger(CreateEcompOperationalEnvironment.class); - //Create ECOMP Managing Environment object in A&AI - aaiHelper.createOperationalEnvironment(aaiClientObjectBuilder.buildAAIOperationalEnvironment("ACTIVE", request)); + @Autowired + private AAIClientObjectBuilder aaiClientObjectBuilder; + @Autowired + private AAIClientHelper aaiHelper; + @Autowired + private RequestsDBHelper requestDb; + @Autowired + private DmaapOperationalEnvClient dmaapClient; - // Call client to publish to DMaap + public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException { + + // Create ECOMP Managing Environment object in A&AI + aaiHelper + .createOperationalEnvironment(aaiClientObjectBuilder.buildAAIOperationalEnvironment("ACTIVE", request)); + + // Call client to publish to DMaap try { - logger.debug("1 {}", request.getOperationalEnvironmentId()); - logger.debug("2 {}", request.getRequestDetails().getRequestInfo().getInstanceName()); - logger.debug("3 {}", request.getRequestDetails().getRequestParameters().getOperationalEnvironmentType() - .toString()); - logger.debug("4 {}", request.getRequestDetails().getRequestParameters().getTenantContext()); - logger.debug("5 {}", request.getRequestDetails().getRequestParameters().getWorkloadContext()); + logger.debug("1 {}", request.getOperationalEnvironmentId()); + logger.debug("2 {}", request.getRequestDetails().getRequestInfo().getInstanceName()); + logger.debug("3 {}", + request.getRequestDetails().getRequestParameters().getOperationalEnvironmentType().toString()); + logger.debug("4 {}", request.getRequestDetails().getRequestParameters().getTenantContext()); + logger.debug("5 {}", request.getRequestDetails().getRequestParameters().getWorkloadContext()); dmaapClient.dmaapPublishOperationalEnvRequest(request.getOperationalEnvironmentId(), request.getRequestDetails().getRequestInfo().getInstanceName(), request.getRequestDetails().getRequestParameters().getOperationalEnvironmentType().toString(), request.getRequestDetails().getRequestParameters().getTenantContext(), - request.getRequestDetails().getRequestParameters().getWorkloadContext(), - "Create"); - }catch(Exception e){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError).build(); - ValidateException validateException = new ValidateException.Builder("Could not publish DMaap", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) - .errorInfo(errorLoggerInfo).build(); + request.getRequestDetails().getRequestParameters().getWorkloadContext(), "Create"); + } catch (Exception e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError).build(); + ValidateException validateException = + new ValidateException.Builder("Could not publish DMaap", HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); requestDb.updateInfraFailureCompletion(e.getMessage(), requestId, request.getOperationalEnvironmentId()); throw validateException; } - //Update request database - requestDb.updateInfraSuccessCompletion("SUCCESSFULLY Created ECOMP OperationalEnvironment.", requestId, request.getOperationalEnvironmentId()); + // Update request database + requestDb.updateInfraSuccessCompletion("SUCCESSFULLY Created ECOMP OperationalEnvironment.", requestId, + request.getOperationalEnvironmentId()); - } + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java index cc3e3aeb16..fe81a07212 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java @@ -24,9 +24,7 @@ package org.onap.so.apihandlerinfra.tenantisolation.process; import java.util.ArrayList; import java.util.List; - import javax.ws.rs.NotFoundException; - import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpStatus; import org.onap.aai.domain.yang.OperationalEnvironment; @@ -54,178 +52,184 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import com.fasterxml.jackson.databind.ObjectMapper; @Component public class CreateVnfOperationalEnvironment { - - private static Logger logger = LoggerFactory.getLogger(CreateVnfOperationalEnvironment.class); - protected CloudOrchestrationRequest request; - - @Autowired - private AAIClientObjectBuilder aaiClientObjectBuilder; - @Autowired - private AAIClientHelper aaiHelper; - @Autowired - private RequestsDBHelper requestDb; - private GRMClient grmClient; - - public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException{ - try { - setRequest(request); - ObjectMapper objectMapper = new ObjectMapper(); - AAIResultWrapper aaiResultWrapper = aaiHelper.getAaiOperationalEnvironment(getEcompManagingEnvironmentId()); - if (aaiResultWrapper.isEmpty()) { - throw new NotFoundException(getEcompManagingEnvironmentId() + " not found in A&AI"); - } - OperationalEnvironment aaiEnv = aaiResultWrapper.asBean(OperationalEnvironment.class).get(); - - //Find ECOMP environments in GRM - logger.debug(" Start of GRM findRunningServicesAsString"); - String searchKey = getSearchKey(aaiEnv); - String tenantContext = getTenantContext().toUpperCase(); - String jsonResponse = getGrmClient().findRunningServicesAsString(searchKey, 1, tenantContext); - ServiceEndPointList sel = objectMapper.readValue(jsonResponse, ServiceEndPointList.class); - if(sel.getServiceEndPointList().size() == 0) { - throw new TenantIsolationException("GRM did not find any matches for " + searchKey + " in " + tenantContext); - } - - //Replicate end-point for VNF Operating environment in GRM - List<ServiceEndPointRequest> serviceEndpointRequestList = buildEndPointRequestList(sel); - int ctr = 0; - int total = serviceEndpointRequestList.size(); - for (ServiceEndPointRequest requestList : serviceEndpointRequestList) { - logger.debug("Creating endpoint " + ++ctr + " of " + total + ": " + requestList.getServiceEndPoint().getName()); - getGrmClient().addServiceEndPoint(requestList); - } - - //Create VNF operating in A&AI - aaiHelper.createOperationalEnvironment(aaiClientObjectBuilder.buildAAIOperationalEnvironment("INACTIVE", request)); - aaiHelper.createRelationship(request.getOperationalEnvironmentId(), getEcompManagingEnvironmentId()); - - //Update request database - requestDb.updateInfraSuccessCompletion("SUCCESSFULLY created VNF operational environment", requestId, request.getOperationalEnvironmentId()); - - }catch(Exception e) { - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError).build(); - - - ValidateException validateException = new ValidateException.Builder(e.getMessage(), - HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build(); - - throw validateException; - } - } - - - protected String getEcompManagingEnvironmentId() throws TenantIsolationException { - RelatedInstanceList[] relatedInstances = request.getRequestDetails().getRelatedInstanceList(); - if (relatedInstances.length > 0 && relatedInstances[0].getRelatedInstance() != null) { - return relatedInstances[0].getRelatedInstance().getInstanceId(); - } else { - return null; - } - } - - - protected String getTenantContext() throws TenantIsolationException { - if(!StringUtils.isEmpty(request.getRequestDetails().getRequestParameters().getTenantContext())) { - return request.getRequestDetails().getRequestParameters().getTenantContext(); - } - else { - throw new TenantIsolationException("Tenant Context is missing from request!"); - } - } - - - private List<ServiceEndPointRequest> buildEndPointRequestList(ServiceEndPointList serviceEndPointList) throws TenantIsolationException { - List<ServiceEndPoint> endpointList = serviceEndPointList.getServiceEndPointList(); - logger.debug("Number of service endpoints from GRM: {}", endpointList.size()); - List<ServiceEndPointRequest> serviceEndPointRequestList = new ArrayList<ServiceEndPointRequest>(); - for(ServiceEndPoint serviceEndpoint : endpointList) { - serviceEndPointRequestList.add(buildServiceEndpoint(serviceEndpoint)); - } - return serviceEndPointRequestList; - } - - - private ServiceEndPointRequest buildServiceEndpoint(ServiceEndPoint serviceEndpoint) throws TenantIsolationException { - - //@TODO: handle nulls? Put in a ServiceEndpointWrapper class which will check for nulls and flatten access to fields - Version ver = new Version(); - ver.setMajor(serviceEndpoint.getVersion().getMajor()); - ver.setMinor(serviceEndpoint.getVersion().getMinor()); - ver.setPatch(serviceEndpoint.getVersion().getPatch()); - - ServiceEndPoint endpoint = new ServiceEndPoint(); - endpoint.setName(buildServiceNameForVnf(serviceEndpoint.getName())); - - endpoint.setVersion(ver); - endpoint.setHostAddress(serviceEndpoint.getHostAddress()); - endpoint.setListenPort(serviceEndpoint.getListenPort()); - endpoint.setLatitude(serviceEndpoint.getLatitude()); - endpoint.setLongitude(serviceEndpoint.getLongitude()); - endpoint.setContextPath(serviceEndpoint.getContextPath()); - endpoint.setRouteOffer(serviceEndpoint.getRouteOffer()); - - OperationalInfo operInfo = new OperationalInfo(); - operInfo.setCreatedBy(serviceEndpoint.getOperationalInfo().getCreatedBy()); - operInfo.setUpdatedBy(serviceEndpoint.getOperationalInfo().getUpdatedBy()); - - endpoint.setOperationalInfo(operInfo); - endpoint.setProperties(serviceEndpoint.getProperties()); - - String env = getEnvironmentName(serviceEndpoint.getProperties()); - - ServiceEndPointRequest serviceEndPontRequest = new ServiceEndPointRequest(); - serviceEndPontRequest.setEnv(env); - serviceEndPontRequest.setServiceEndPoint(endpoint); - - return serviceEndPontRequest; - } - - - protected String getEnvironmentName(List<Property> props) { - String env = ""; - for(Property prop : props) { - if(prop.getName().equalsIgnoreCase("Environment")) { - env = prop.getValue(); - } - } - return env; - } - - - protected String buildServiceNameForVnf(String fqName) throws TenantIsolationException { - // Service name format is: {tenantContext}.{workloadContext}.{serviceName} e.g. TEST.ECOMP_PSL.Inventory - // We need to extract the serviceName, in the above example: "Inventory" - String[] tokens = fqName.split("[.]"); - String serviceName; - if(tokens.length > 0) { - serviceName = tokens[tokens.length-1]; - } - else { - throw new TenantIsolationException("Fully qualified service name is null."); - } - String tenantContext = request.getRequestDetails().getRequestParameters().getTenantContext(); - String workloadContext = request.getRequestDetails().getRequestParameters().getWorkloadContext(); - return tenantContext + "." + workloadContext + "." + serviceName; - } - - protected String getSearchKey(OperationalEnvironment aaiEnv) { - return aaiEnv.getTenantContext() + "." + aaiEnv.getWorkloadContext() + ".*"; - } - - public void setRequest(CloudOrchestrationRequest request) { - this.request = request; - } - - private GRMClient getGrmClient() { - if(grmClient == null) { - this.grmClient = new GRMClient(); - } - - return grmClient; - } + + private static Logger logger = LoggerFactory.getLogger(CreateVnfOperationalEnvironment.class); + protected CloudOrchestrationRequest request; + + @Autowired + private AAIClientObjectBuilder aaiClientObjectBuilder; + @Autowired + private AAIClientHelper aaiHelper; + @Autowired + private RequestsDBHelper requestDb; + private GRMClient grmClient; + + public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException { + try { + setRequest(request); + ObjectMapper objectMapper = new ObjectMapper(); + AAIResultWrapper aaiResultWrapper = aaiHelper.getAaiOperationalEnvironment(getEcompManagingEnvironmentId()); + if (aaiResultWrapper.isEmpty()) { + throw new NotFoundException(getEcompManagingEnvironmentId() + " not found in A&AI"); + } + OperationalEnvironment aaiEnv = aaiResultWrapper.asBean(OperationalEnvironment.class).get(); + + // Find ECOMP environments in GRM + logger.debug(" Start of GRM findRunningServicesAsString"); + String searchKey = getSearchKey(aaiEnv); + String tenantContext = getTenantContext().toUpperCase(); + String jsonResponse = getGrmClient().findRunningServicesAsString(searchKey, 1, tenantContext); + ServiceEndPointList sel = objectMapper.readValue(jsonResponse, ServiceEndPointList.class); + if (sel.getServiceEndPointList().size() == 0) { + throw new TenantIsolationException( + "GRM did not find any matches for " + searchKey + " in " + tenantContext); + } + + // Replicate end-point for VNF Operating environment in GRM + List<ServiceEndPointRequest> serviceEndpointRequestList = buildEndPointRequestList(sel); + int ctr = 0; + int total = serviceEndpointRequestList.size(); + for (ServiceEndPointRequest requestList : serviceEndpointRequestList) { + logger.debug("Creating endpoint " + ++ctr + " of " + total + ": " + + requestList.getServiceEndPoint().getName()); + getGrmClient().addServiceEndPoint(requestList); + } + + // Create VNF operating in A&AI + aaiHelper.createOperationalEnvironment( + aaiClientObjectBuilder.buildAAIOperationalEnvironment("INACTIVE", request)); + aaiHelper.createRelationship(request.getOperationalEnvironmentId(), getEcompManagingEnvironmentId()); + + // Update request database + requestDb.updateInfraSuccessCompletion("SUCCESSFULLY created VNF operational environment", requestId, + request.getOperationalEnvironmentId()); + + } catch (Exception e) { + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError).build(); + + + ValidateException validateException = + new ValidateException.Builder(e.getMessage(), HttpStatus.SC_INTERNAL_SERVER_ERROR, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e).errorInfo(errorLoggerInfo).build(); + + throw validateException; + } + } + + + protected String getEcompManagingEnvironmentId() throws TenantIsolationException { + RelatedInstanceList[] relatedInstances = request.getRequestDetails().getRelatedInstanceList(); + if (relatedInstances.length > 0 && relatedInstances[0].getRelatedInstance() != null) { + return relatedInstances[0].getRelatedInstance().getInstanceId(); + } else { + return null; + } + } + + + protected String getTenantContext() throws TenantIsolationException { + if (!StringUtils.isEmpty(request.getRequestDetails().getRequestParameters().getTenantContext())) { + return request.getRequestDetails().getRequestParameters().getTenantContext(); + } else { + throw new TenantIsolationException("Tenant Context is missing from request!"); + } + } + + + private List<ServiceEndPointRequest> buildEndPointRequestList(ServiceEndPointList serviceEndPointList) + throws TenantIsolationException { + List<ServiceEndPoint> endpointList = serviceEndPointList.getServiceEndPointList(); + logger.debug("Number of service endpoints from GRM: {}", endpointList.size()); + List<ServiceEndPointRequest> serviceEndPointRequestList = new ArrayList<ServiceEndPointRequest>(); + for (ServiceEndPoint serviceEndpoint : endpointList) { + serviceEndPointRequestList.add(buildServiceEndpoint(serviceEndpoint)); + } + return serviceEndPointRequestList; + } + + + private ServiceEndPointRequest buildServiceEndpoint(ServiceEndPoint serviceEndpoint) + throws TenantIsolationException { + + // @TODO: handle nulls? Put in a ServiceEndpointWrapper class which will check for nulls and flatten access to + // fields + Version ver = new Version(); + ver.setMajor(serviceEndpoint.getVersion().getMajor()); + ver.setMinor(serviceEndpoint.getVersion().getMinor()); + ver.setPatch(serviceEndpoint.getVersion().getPatch()); + + ServiceEndPoint endpoint = new ServiceEndPoint(); + endpoint.setName(buildServiceNameForVnf(serviceEndpoint.getName())); + + endpoint.setVersion(ver); + endpoint.setHostAddress(serviceEndpoint.getHostAddress()); + endpoint.setListenPort(serviceEndpoint.getListenPort()); + endpoint.setLatitude(serviceEndpoint.getLatitude()); + endpoint.setLongitude(serviceEndpoint.getLongitude()); + endpoint.setContextPath(serviceEndpoint.getContextPath()); + endpoint.setRouteOffer(serviceEndpoint.getRouteOffer()); + + OperationalInfo operInfo = new OperationalInfo(); + operInfo.setCreatedBy(serviceEndpoint.getOperationalInfo().getCreatedBy()); + operInfo.setUpdatedBy(serviceEndpoint.getOperationalInfo().getUpdatedBy()); + + endpoint.setOperationalInfo(operInfo); + endpoint.setProperties(serviceEndpoint.getProperties()); + + String env = getEnvironmentName(serviceEndpoint.getProperties()); + + ServiceEndPointRequest serviceEndPontRequest = new ServiceEndPointRequest(); + serviceEndPontRequest.setEnv(env); + serviceEndPontRequest.setServiceEndPoint(endpoint); + + return serviceEndPontRequest; + } + + + protected String getEnvironmentName(List<Property> props) { + String env = ""; + for (Property prop : props) { + if (prop.getName().equalsIgnoreCase("Environment")) { + env = prop.getValue(); + } + } + return env; + } + + + protected String buildServiceNameForVnf(String fqName) throws TenantIsolationException { + // Service name format is: {tenantContext}.{workloadContext}.{serviceName} e.g. TEST.ECOMP_PSL.Inventory + // We need to extract the serviceName, in the above example: "Inventory" + String[] tokens = fqName.split("[.]"); + String serviceName; + if (tokens.length > 0) { + serviceName = tokens[tokens.length - 1]; + } else { + throw new TenantIsolationException("Fully qualified service name is null."); + } + String tenantContext = request.getRequestDetails().getRequestParameters().getTenantContext(); + String workloadContext = request.getRequestDetails().getRequestParameters().getWorkloadContext(); + return tenantContext + "." + workloadContext + "." + serviceName; + } + + protected String getSearchKey(OperationalEnvironment aaiEnv) { + return aaiEnv.getTenantContext() + "." + aaiEnv.getWorkloadContext() + ".*"; + } + + public void setRequest(CloudOrchestrationRequest request) { + this.request = request; + } + + private GRMClient getGrmClient() { + if (grmClient == null) { + this.grmClient = new GRMClient(); + } + + return grmClient; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java index 7f8b330727..e8ea153a6a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java @@ -23,7 +23,6 @@ package org.onap.so.apihandlerinfra.tenantisolation.process; import java.util.Optional; - import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpStatus; import org.onap.aai.domain.yang.OperationalEnvironment; @@ -45,50 +44,53 @@ import org.springframework.stereotype.Component; @Component public class DeactivateVnfOperationalEnvironment { - private static Logger logger = LoggerFactory.getLogger(DeactivateVnfOperationalEnvironment - .class); - - @Autowired + private static Logger logger = LoggerFactory.getLogger(DeactivateVnfOperationalEnvironment.class); + + @Autowired private AAIClientHelper aaiHelper; - @Autowired + @Autowired private RequestsDBHelper requestDb; - - public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException { - String operationalEnvironmentId = request.getOperationalEnvironmentId(); - - OperationalEnvironment aaiOpEnv = getAAIOperationalEnvironment(operationalEnvironmentId); - if (aaiOpEnv != null) { - String operationalEnvironmentStatus = aaiOpEnv.getOperationalEnvironmentStatus(); - - if(StringUtils.isBlank(operationalEnvironmentStatus)) { - String error = "OperationalEnvironmentStatus is null on OperationalEnvironmentId: " + operationalEnvironmentId; - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError).build(); - throw new ValidateException.Builder(error, HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR) - .errorInfo(errorLoggerInfo) - .build(); - } - - if(operationalEnvironmentStatus.equalsIgnoreCase("ACTIVE")) { - - aaiOpEnv.setOperationalEnvironmentStatus("INACTIVE"); - aaiHelper.updateAaiOperationalEnvironment(operationalEnvironmentId, aaiOpEnv); - - } else if(!operationalEnvironmentStatus.equalsIgnoreCase("INACTIVE")) { - String error = "Invalid OperationalEnvironmentStatus on OperationalEnvironmentId: " + operationalEnvironmentId; - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError).build(); - ValidateException validateException = new ValidateException.Builder(error, - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); - requestDb.updateInfraFailureCompletion(error, requestId, operationalEnvironmentId); - throw validateException; - } - - requestDb.updateInfraSuccessCompletion("SUCCESSFULLY Deactivated OperationalEnvironment", requestId, operationalEnvironmentId); - } - } - - private OperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) { - AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId); - Optional<OperationalEnvironment> operationalEnvironmentOpt = aaiResult.asBean(OperationalEnvironment.class); - return operationalEnvironmentOpt.isPresent() ? operationalEnvironmentOpt.get() : null; - } + + public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException { + String operationalEnvironmentId = request.getOperationalEnvironmentId(); + + OperationalEnvironment aaiOpEnv = getAAIOperationalEnvironment(operationalEnvironmentId); + if (aaiOpEnv != null) { + String operationalEnvironmentStatus = aaiOpEnv.getOperationalEnvironmentStatus(); + + if (StringUtils.isBlank(operationalEnvironmentStatus)) { + String error = + "OperationalEnvironmentStatus is null on OperationalEnvironmentId: " + operationalEnvironmentId; + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError).build(); + throw new ValidateException.Builder(error, HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); + } + + if (operationalEnvironmentStatus.equalsIgnoreCase("ACTIVE")) { + + aaiOpEnv.setOperationalEnvironmentStatus("INACTIVE"); + aaiHelper.updateAaiOperationalEnvironment(operationalEnvironmentId, aaiOpEnv); + + } else if (!operationalEnvironmentStatus.equalsIgnoreCase("INACTIVE")) { + String error = + "Invalid OperationalEnvironmentStatus on OperationalEnvironmentId: " + operationalEnvironmentId; + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.DataError).build(); + ValidateException validateException = new ValidateException.Builder(error, HttpStatus.SC_BAD_REQUEST, + ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build(); + requestDb.updateInfraFailureCompletion(error, requestId, operationalEnvironmentId); + throw validateException; + } + + requestDb.updateInfraSuccessCompletion("SUCCESSFULLY Deactivated OperationalEnvironment", requestId, + operationalEnvironmentId); + } + } + + private OperationalEnvironment getAAIOperationalEnvironment(String operationalEnvironmentId) { + AAIResultWrapper aaiResult = aaiHelper.getAaiOperationalEnvironment(operationalEnvironmentId); + Optional<OperationalEnvironment> operationalEnvironmentOpt = aaiResult.asBean(OperationalEnvironment.class); + return operationalEnvironmentOpt.isPresent() ? operationalEnvironmentOpt.get() : null; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Action.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Action.java index 3f7a5536f3..3fc567e81e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Action.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Action.java @@ -21,8 +21,5 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; public enum Action { - create, - activate, - deactivate, - distributionStatus + create, activate, deactivate, distributionStatus } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/CloudOrchestrationRequestList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/CloudOrchestrationRequestList.java index 25c8538003..71eb6020b4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/CloudOrchestrationRequestList.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/CloudOrchestrationRequestList.java @@ -24,14 +24,14 @@ import java.util.List; public class CloudOrchestrationRequestList { - private List<CloudOrchestrationResponse> requestList; + private List<CloudOrchestrationResponse> requestList; - public List<CloudOrchestrationResponse> getRequestList() { - return requestList; - } + public List<CloudOrchestrationResponse> getRequestList() { + return requestList; + } - public void setRequestList(List<CloudOrchestrationResponse> requestList) { - this.requestList = requestList; - } + public void setRequestList(List<CloudOrchestrationResponse> requestList) { + this.requestList = requestList; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/CloudOrchestrationResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/CloudOrchestrationResponse.java index bd5167c395..7dc219407e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/CloudOrchestrationResponse.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/CloudOrchestrationResponse.java @@ -25,14 +25,14 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; @JsonInclude(Include.NON_DEFAULT) public class CloudOrchestrationResponse { - - protected Request request; - - public Request getRequest() { - return request; - } - public void setRequest(Request request) { - this.request = request; - } + protected Request request; + + public Request getRequest() { + return request; + } + + public void setRequest(Request request) { + this.request = request; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Distribution.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Distribution.java index b556178427..255d3a50f9 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Distribution.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Distribution.java @@ -22,29 +22,29 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; import java.io.Serializable; -public class Distribution implements Serializable{ - - /** - * - */ - private static final long serialVersionUID = -529289171571892371L; - private Status status; - private String errorReason; - - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - - public String getErrorReason() { - return errorReason; - } - - public void setErrorReason(String errorReason) { - this.errorReason = errorReason; - } +public class Distribution implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -529289171571892371L; + private Status status; + private String errorReason; + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } + + public String getErrorReason() { + return errorReason; + } + + public void setErrorReason(String errorReason) { + this.errorReason = errorReason; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/DistributionStatus.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/DistributionStatus.java index d54c6238ae..1b30b6fa14 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/DistributionStatus.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/DistributionStatus.java @@ -21,6 +21,5 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; public enum DistributionStatus { - DISTRIBUTION_COMPLETE_OK, - DISTRIBUTION_COMPLETE_ERROR + DISTRIBUTION_COMPLETE_OK, DISTRIBUTION_COMPLETE_ERROR } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/InstanceReferences.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/InstanceReferences.java index 097660d9f3..34e219415b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/InstanceReferences.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/InstanceReferences.java @@ -29,32 +29,32 @@ import com.fasterxml.jackson.annotation.JsonRootName; @JsonInclude(Include.NON_DEFAULT) public class InstanceReferences { - private String operationalEnvironmentId; - private String operationalEnvName; - private String requestorId; - - public String getOperationalEnvironmentId() { - return operationalEnvironmentId; - } - - public void setOperationalEnvironmentId(String operationalEnvironmentId) { - this.operationalEnvironmentId = operationalEnvironmentId; - } - - public String getOperationalEnvName() { - return operationalEnvName; - } - - public void setOperationalEnvName(String operationalEnvName) { - this.operationalEnvName = operationalEnvName; - } - - public String getRequestorId() { - return requestorId; - } - - public void setRequestorId(String requestorId) { - this.requestorId = requestorId; - } - + private String operationalEnvironmentId; + private String operationalEnvName; + private String requestorId; + + public String getOperationalEnvironmentId() { + return operationalEnvironmentId; + } + + public void setOperationalEnvironmentId(String operationalEnvironmentId) { + this.operationalEnvironmentId = operationalEnvironmentId; + } + + public String getOperationalEnvName() { + return operationalEnvName; + } + + public void setOperationalEnvName(String operationalEnvName) { + this.operationalEnvName = operationalEnvName; + } + + public String getRequestorId() { + return requestorId; + } + + public void setRequestorId(String requestorId) { + this.requestorId = requestorId; + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Manifest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Manifest.java index afb9ebdff3..4c66a3118e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Manifest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Manifest.java @@ -23,7 +23,6 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; import java.io.Serializable; import java.util.ArrayList; import java.util.List; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; @@ -33,21 +32,21 @@ import com.fasterxml.jackson.annotation.JsonRootName; @JsonInclude(Include.NON_DEFAULT) public class Manifest implements Serializable { - private static final long serialVersionUID = -3460949513229380541L; - @JsonProperty("serviceModelList") - private List<ServiceModelList> serviceModelList = new ArrayList<ServiceModelList>(); - - public List<ServiceModelList> getServiceModelList() { - return serviceModelList; - } - - public void setServiceModelList(List<ServiceModelList> serviceModelList) { - this.serviceModelList = serviceModelList; - } - - @Override - public String toString() { - return "Manifest [serviceModelList=" + serviceModelList.toString() + "]"; - } - + private static final long serialVersionUID = -3460949513229380541L; + @JsonProperty("serviceModelList") + private List<ServiceModelList> serviceModelList = new ArrayList<ServiceModelList>(); + + public List<ServiceModelList> getServiceModelList() { + return serviceModelList; + } + + public void setServiceModelList(List<ServiceModelList> serviceModelList) { + this.serviceModelList = serviceModelList; + } + + @Override + public String toString() { + return "Manifest [serviceModelList=" + serviceModelList.toString() + "]"; + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/OperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/OperationalEnvironment.java index 61acc9f94c..d16093de04 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/OperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/OperationalEnvironment.java @@ -22,6 +22,5 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; public enum OperationalEnvironment { - ECOMP, - VNF + ECOMP, VNF } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RecoveryAction.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RecoveryAction.java index f32c11f8a8..91d7aa2b89 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RecoveryAction.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RecoveryAction.java @@ -22,7 +22,5 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; public enum RecoveryAction { - retry, - abort, - skip + retry, abort, skip } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RelatedInstance.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RelatedInstance.java index 78faea7b8e..75f7e91742 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RelatedInstance.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RelatedInstance.java @@ -21,7 +21,6 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; @@ -30,39 +29,43 @@ import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName(value = "relatedInstance") @JsonInclude(Include.NON_DEFAULT) public class RelatedInstance implements Serializable { - - private static final long serialVersionUID = -6775477105573153067L; - @JsonProperty("instanceName") - protected String instanceName; - @JsonProperty("instanceId") - protected String instanceId; - @JsonProperty("resourceType") - protected ResourceType resourceType; - public String getInstanceName() { - return instanceName; - } - public void setInstanceName(String instanceName) { - this.instanceName = instanceName; - } - public String getInstanceId() { - return instanceId; - } - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } - public ResourceType getResourceType() { - return resourceType; - } - public void setResourceType(ResourceType resourceType) { - this.resourceType = resourceType; - } + private static final long serialVersionUID = -6775477105573153067L; + @JsonProperty("instanceName") + protected String instanceName; + @JsonProperty("instanceId") + protected String instanceId; + @JsonProperty("resourceType") + protected ResourceType resourceType; + + public String getInstanceName() { + return instanceName; + } + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + public String getInstanceId() { + return instanceId; + } + + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + public ResourceType getResourceType() { + return resourceType; + } + + public void setResourceType(ResourceType resourceType) { + this.resourceType = resourceType; + } + + @Override + public String toString() { + return "RelatedInstance [instanceName=" + instanceName + ", instanceId=" + instanceId + ", resourceType=" + + resourceType + "]"; + } - @Override - public String toString() { - return "RelatedInstance [instanceName=" + instanceName + - ", instanceId=" + instanceId + - ", resourceType=" + resourceType + "]"; - } - } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RelatedInstanceList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RelatedInstanceList.java index ee54392e9d..73fb20660a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RelatedInstanceList.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RelatedInstanceList.java @@ -21,7 +21,6 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; @@ -31,15 +30,15 @@ import com.fasterxml.jackson.annotation.JsonRootName; @JsonInclude(Include.NON_DEFAULT) public class RelatedInstanceList implements Serializable { - private static final long serialVersionUID = 1758713583807257102L; - @JsonProperty("relatedInstance") - protected RelatedInstance relatedInstance; + private static final long serialVersionUID = 1758713583807257102L; + @JsonProperty("relatedInstance") + protected RelatedInstance relatedInstance; - public RelatedInstance getRelatedInstance() { - return relatedInstance; - } + public RelatedInstance getRelatedInstance() { + return relatedInstance; + } - public void setRelatedInstance(RelatedInstance relatedInstance) { - this.relatedInstance = relatedInstance; - } + public void setRelatedInstance(RelatedInstance relatedInstance) { + this.relatedInstance = relatedInstance; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Request.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Request.java index 7d927512e6..eb4e9384f5 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Request.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Request.java @@ -36,55 +36,62 @@ public class Request { protected String requestType; protected RequestDetails requestDetails; protected RequestStatus requestStatus; - - - public String getRequestId() { - return requestId; - } - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getStartTime() { - return startTime; - } - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getRequestScope() { - return requestScope; - } - public void setRequestScope(String requestScope) { - this.requestScope = requestScope; - } - - public String getRequestType() { - return requestType; - } - public void setRequestType(String requestType) { - this.requestType = requestType; - } - - public RequestStatus getRequestStatus() { - return requestStatus; - } - public void setRequestStatus(RequestStatus requestStatus) { - this.requestStatus = requestStatus; - } - - public InstanceReferences getInstanceReferences() { - return instanceReferences; - } - public void setInstanceReferences(InstanceReferences instanceReferences) { - this.instanceReferences = instanceReferences; - } - - public RequestDetails getRequestDetails() { - return requestDetails; - } - public void setRequestDetails(RequestDetails requestDetails) { - this.requestDetails = requestDetails; - } - -}
\ No newline at end of file + + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getRequestScope() { + return requestScope; + } + + public void setRequestScope(String requestScope) { + this.requestScope = requestScope; + } + + public String getRequestType() { + return requestType; + } + + public void setRequestType(String requestType) { + this.requestType = requestType; + } + + public RequestStatus getRequestStatus() { + return requestStatus; + } + + public void setRequestStatus(RequestStatus requestStatus) { + this.requestStatus = requestStatus; + } + + public InstanceReferences getInstanceReferences() { + return instanceReferences; + } + + public void setInstanceReferences(InstanceReferences instanceReferences) { + this.instanceReferences = instanceReferences; + } + + public RequestDetails getRequestDetails() { + return requestDetails; + } + + public void setRequestDetails(RequestDetails requestDetails) { + this.requestDetails = requestDetails; + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestDetails.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestDetails.java index 36e3bf95e7..ff427c719f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestDetails.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestDetails.java @@ -22,7 +22,6 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; import java.io.Serializable; import java.util.Arrays; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; @@ -32,20 +31,18 @@ import com.fasterxml.jackson.annotation.JsonRootName; @JsonInclude(Include.NON_DEFAULT) public class RequestDetails implements Serializable { - private static final long serialVersionUID = -73080684945860609L; - @JsonProperty("requestInfo") + private static final long serialVersionUID = -73080684945860609L; + @JsonProperty("requestInfo") protected RequestInfo requestInfo; - @JsonProperty("relatedInstanceList") + @JsonProperty("relatedInstanceList") protected RelatedInstanceList[] relatedInstanceList; - @JsonProperty("requestParameters") + @JsonProperty("requestParameters") protected RequestParameters requestParameters; /** * Gets the value of the requestInfo property. * - * @return - * possible object is - * {@link RequestInfo } + * @return possible object is {@link RequestInfo } * */ public RequestInfo getRequestInfo() { @@ -55,9 +52,7 @@ public class RequestDetails implements Serializable { /** * Sets the value of the requestInfo property. * - * @param value - * allowed object is - * {@link RequestInfo } + * @param value allowed object is {@link RequestInfo } * */ public void setRequestInfo(RequestInfo value) { @@ -67,9 +62,7 @@ public class RequestDetails implements Serializable { /** * Gets the value of the requestParameters property. * - * @return - * possible object is - * {@link RequestParameters } + * @return possible object is {@link RequestParameters } * */ public RequestParameters getRequestParameters() { @@ -79,26 +72,24 @@ public class RequestDetails implements Serializable { /** * Sets the value of the requestParameters property. * - * @param value - * allowed object is - * {@link RequestParameters } + * @param value allowed object is {@link RequestParameters } * */ public void setRequestParameters(RequestParameters value) { this.requestParameters = value; } - public RelatedInstanceList[] getRelatedInstanceList() { - return relatedInstanceList; - } + public RelatedInstanceList[] getRelatedInstanceList() { + return relatedInstanceList; + } - public void setRelatedInstanceList(RelatedInstanceList[] relatedInstanceList) { - this.relatedInstanceList = relatedInstanceList; - } - @Override - public String toString() { - return "RequestDetails [requestInfo=" + requestInfo + - ", relatedInstanceList=" + Arrays.toString(relatedInstanceList) + - ", requestParameters=" + requestParameters + "]"; - } + public void setRelatedInstanceList(RelatedInstanceList[] relatedInstanceList) { + this.relatedInstanceList = relatedInstanceList; + } + + @Override + public String toString() { + return "RequestDetails [requestInfo=" + requestInfo + ", relatedInstanceList=" + + Arrays.toString(relatedInstanceList) + ", requestParameters=" + requestParameters + "]"; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestInfo.java index d57d4bf366..b40fc3f07d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestInfo.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestInfo.java @@ -21,7 +21,6 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; @@ -31,22 +30,20 @@ import com.fasterxml.jackson.annotation.JsonRootName; @JsonInclude(Include.NON_DEFAULT) public class RequestInfo implements Serializable { - private static final long serialVersionUID = 1346372792555344857L; - @JsonProperty("resourceType") + private static final long serialVersionUID = 1346372792555344857L; + @JsonProperty("resourceType") protected ResourceType resourceType; - @JsonProperty("source") + @JsonProperty("source") protected String source; - @JsonProperty("instanceName") + @JsonProperty("instanceName") protected String instanceName; - @JsonProperty("requestorId") + @JsonProperty("requestorId") protected String requestorId; - /** + /** * Gets the value of the resourceType property. * - * @return - * possible object is - * {@link ResourceType } + * @return possible object is {@link ResourceType } * */ public ResourceType getResourceType() { @@ -56,9 +53,7 @@ public class RequestInfo implements Serializable { /** * Sets the value of the source property. * - * @param value - * allowed object is - * {@link ResourceType } + * @param value allowed object is {@link ResourceType } * */ public void setResourceType(ResourceType value) { @@ -69,9 +64,7 @@ public class RequestInfo implements Serializable { /** * Gets the value of the source property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public String getSource() { @@ -81,38 +74,34 @@ public class RequestInfo implements Serializable { /** * Sets the value of the source property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setSource(String value) { this.source = value; } - public String getInstanceName() { - return instanceName; - } - - public void setInstanceName(String instanceName) { - this.instanceName = instanceName; - } - - public String getRequestorId() { - return requestorId; - } - - public void setRequestorId(String requestorId) { - this.requestorId = requestorId; - } - - @Override - public String toString() { - return "RequestInfo [source=" + source - + ", instanceName=" + instanceName - + ", requestorId=" + requestorId - + ", resourceType=" + resourceType + "]"; - } + public String getInstanceName() { + return instanceName; + } + + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + public String getRequestorId() { + return requestorId; + } + + public void setRequestorId(String requestorId) { + this.requestorId = requestorId; + } + + @Override + public String toString() { + return "RequestInfo [source=" + source + ", instanceName=" + instanceName + ", requestorId=" + requestorId + + ", resourceType=" + resourceType + "]"; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestList.java index 170b5e7609..20021888c0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestList.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestList.java @@ -30,17 +30,15 @@ import com.fasterxml.jackson.annotation.JsonRootName; public class RequestList { - @JsonProperty("request") + @JsonProperty("request") protected Request request; - @JsonProperty("requestStatus") + @JsonProperty("requestStatus") protected RequestStatus requestStatus; /** * Gets the value of the request property. * - * @return - * possible object is - * {@link Request } + * @return possible object is {@link Request } * */ public Request getRequest() { @@ -50,9 +48,7 @@ public class RequestList { /** * Sets the value of the requestInfo property. * - * @param value - * allowed object is - * {@link Request } + * @param value allowed object is {@link Request } * */ public void setRequest(Request value) { @@ -62,22 +58,18 @@ public class RequestList { /** * Gets the value of the requestStatus property. * - * @return - * possible object is - * {@link RequestStatus } + * @return possible object is {@link RequestStatus } * */ public RequestStatus getRequestStatus() { return requestStatus; } - + /** * Sets the value of the requestStatus property. * - * @param value - * allowed object is - * {@link RequestStatus } + * @param value allowed object is {@link RequestStatus } * */ public void setRequestStatus(RequestStatus value) { @@ -85,9 +77,8 @@ public class RequestList { } - @Override - public String toString() { - return "RequestList [request=" + request + - ", requestStatus=" + requestStatus + "]"; - } -}
\ No newline at end of file + @Override + public String toString() { + return "RequestList [request=" + request + ", requestStatus=" + requestStatus + "]"; + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestParameters.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestParameters.java index 1a12c47d7d..299d177099 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestParameters.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestParameters.java @@ -21,7 +21,6 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; @@ -31,54 +30,52 @@ import com.fasterxml.jackson.annotation.JsonRootName; @JsonInclude(Include.NON_DEFAULT) public class RequestParameters implements Serializable { - private static final long serialVersionUID = 8530327178156183693L; - @JsonProperty("operationalEnvironmentType") - private OperationalEnvironment operationalEnvironmentType; - @JsonProperty("tenantContext") - private String tenantContext; - @JsonProperty("workloadContext") - private String workloadContext; - @JsonProperty("manifest") - private Manifest manifest; - - public OperationalEnvironment getOperationalEnvironmentType() { - return operationalEnvironmentType; - } + private static final long serialVersionUID = 8530327178156183693L; + @JsonProperty("operationalEnvironmentType") + private OperationalEnvironment operationalEnvironmentType; + @JsonProperty("tenantContext") + private String tenantContext; + @JsonProperty("workloadContext") + private String workloadContext; + @JsonProperty("manifest") + private Manifest manifest; + + public OperationalEnvironment getOperationalEnvironmentType() { + return operationalEnvironmentType; + } + + public void setOperationalEnvironmentType(OperationalEnvironment operationalEnvironmentType) { + this.operationalEnvironmentType = operationalEnvironmentType; + } + + public String getTenantContext() { + return tenantContext; + } + + public void setTenantContext(String tenantContext) { + this.tenantContext = tenantContext; + } - public void setOperationalEnvironmentType(OperationalEnvironment operationalEnvironmentType) { - this.operationalEnvironmentType = operationalEnvironmentType; - } + public String getWorkloadContext() { + return workloadContext; + } - public String getTenantContext() { - return tenantContext; - } + public void setWorkloadContext(String workloadContext) { + this.workloadContext = workloadContext; + } - public void setTenantContext(String tenantContext) { - this.tenantContext = tenantContext; - } - - public String getWorkloadContext() { - return workloadContext; - } + public Manifest getManifest() { + return manifest; + } - public void setWorkloadContext(String workloadContext) { - this.workloadContext = workloadContext; - } - - public Manifest getManifest() { - return manifest; - } + public void setManifest(Manifest manifest) { + this.manifest = manifest; + } - public void setManifest(Manifest manifest) { - this.manifest = manifest; - } - - @Override - public String toString() { - return "RequestParameters [operationalEnvironmentType=" + operationalEnvironmentType - + ", tenantContext=" + tenantContext - + ", workloadContext=" + workloadContext - + ", manifes=" + manifest +"]"; - } + @Override + public String toString() { + return "RequestParameters [operationalEnvironmentType=" + operationalEnvironmentType + ", tenantContext=" + + tenantContext + ", workloadContext=" + workloadContext + ", manifes=" + manifest + "]"; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestReferences.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestReferences.java index 337de3c51d..d766bcf2dd 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestReferences.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestReferences.java @@ -21,7 +21,6 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; @@ -30,67 +29,58 @@ import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName(value = "requestReferences") @JsonInclude(Include.NON_DEFAULT) public class RequestReferences implements Serializable { - - private static final long serialVersionUID = 5873356773819905368L; - - @JsonProperty("requestId") - protected String requestId; - - @JsonProperty("instanceId") - String instanceId; + + private static final long serialVersionUID = 5873356773819905368L; + + @JsonProperty("requestId") + protected String requestId; + + @JsonProperty("instanceId") + String instanceId; /** * Gets the value of the requestId property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * - */ - public String getRequestId() { - return requestId; - } - + */ + public String getRequestId() { + return requestId; + } + /** * Sets the value of the requestId property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * - */ - public void setRequestId(String requestId) { - this.requestId = requestId; - } - + */ + public void setRequestId(String requestId) { + this.requestId = requestId; + } + /** * Gets the value of the instanceId property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * - */ - public String getInstanceId() { - return instanceId; - } - + */ + public String getInstanceId() { + return instanceId; + } + /** * Sets the value of the instanceId property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * - */ - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } + */ + public void setInstanceId(String instanceId) { + this.instanceId = instanceId; + } + + @Override + public String toString() { + return "RequestReferences [requestId=" + requestId + ", instanceId=" + instanceId + "]"; + } - @Override - public String toString() { - return "RequestReferences [requestId=" + requestId + - ", instanceId=" + instanceId + "]"; - } - } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestStatus.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestStatus.java index 6fd765b76f..f1f9417805 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestStatus.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestStatus.java @@ -21,7 +21,6 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; @@ -31,39 +30,46 @@ import com.fasterxml.jackson.annotation.JsonRootName; @JsonInclude(Include.NON_DEFAULT) public class RequestStatus implements Serializable { - private static final long serialVersionUID = -1835437975187313144L; - @JsonProperty("requestState") - protected String requestState; - @JsonProperty("statusMessage") + private static final long serialVersionUID = -1835437975187313144L; + @JsonProperty("requestState") + protected String requestState; + @JsonProperty("statusMessage") protected String statusMessage; - @JsonProperty("percentProgress") + @JsonProperty("percentProgress") protected String percentProgress; - @JsonProperty("timestamp") + @JsonProperty("timestamp") protected String timeStamp; - public String getRequestState() { - return requestState; - } - public void setRequestState(String requestState) { - this.requestState = requestState; - } - public String getStatusMessage() { - return statusMessage; - } - public void setStatusMessage(String statusMessage) { - this.statusMessage = statusMessage; - } - public String getPercentProgress() { - return percentProgress; - } - public void setPercentProgress(String percentProgress) { - this.percentProgress = percentProgress; - } - public String getTimeStamp() { - return timeStamp; - } - public void setTimeStamp(String timeStamp) { - this.timeStamp = timeStamp; - } -}
\ No newline at end of file + public String getRequestState() { + return requestState; + } + + public void setRequestState(String requestState) { + this.requestState = requestState; + } + + public String getStatusMessage() { + return statusMessage; + } + + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + + public String getPercentProgress() { + return percentProgress; + } + + public void setPercentProgress(String percentProgress) { + this.percentProgress = percentProgress; + } + + public String getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(String timeStamp) { + this.timeStamp = timeStamp; + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/ResourceType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/ResourceType.java index 835c2657d1..edeee56249 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/ResourceType.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/ResourceType.java @@ -22,5 +22,5 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; public enum ResourceType { - operationalEnvironment + operationalEnvironment } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/ServiceModelList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/ServiceModelList.java index 4dea3149ad..fbbd183380 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/ServiceModelList.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/ServiceModelList.java @@ -21,7 +21,6 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; @@ -31,29 +30,32 @@ import com.fasterxml.jackson.annotation.JsonRootName; @JsonInclude(Include.NON_DEFAULT) public class ServiceModelList implements Serializable { - private static final long serialVersionUID = 1758713583807257102L; - - @JsonProperty("serviceModelVersionId") - protected String serviceModelVersionId; - @JsonProperty("recoveryAction") - protected RecoveryAction recoveryAction; - - public String getServiceModelVersionId() { - return serviceModelVersionId; - } - public void setServiceModelVersionId(String serviceModelVersionId) { - this.serviceModelVersionId = serviceModelVersionId; - } - public RecoveryAction getRecoveryAction() { - return recoveryAction; - } - public void setRecoveryAction(RecoveryAction recoveryAction) { - this.recoveryAction = recoveryAction; - } - - @Override - public String toString() { - return "ServiceModelList [serviceModelVersionId=" + serviceModelVersionId + "," - + "recoveryAction=" + recoveryAction +"]"; - } + private static final long serialVersionUID = 1758713583807257102L; + + @JsonProperty("serviceModelVersionId") + protected String serviceModelVersionId; + @JsonProperty("recoveryAction") + protected RecoveryAction recoveryAction; + + public String getServiceModelVersionId() { + return serviceModelVersionId; + } + + public void setServiceModelVersionId(String serviceModelVersionId) { + this.serviceModelVersionId = serviceModelVersionId; + } + + public RecoveryAction getRecoveryAction() { + return recoveryAction; + } + + public void setRecoveryAction(RecoveryAction recoveryAction) { + this.recoveryAction = recoveryAction; + } + + @Override + public String toString() { + return "ServiceModelList [serviceModelVersionId=" + serviceModelVersionId + "," + "recoveryAction=" + + recoveryAction + "]"; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Status.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Status.java index a7c6c67395..5182f448fe 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Status.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/Status.java @@ -21,6 +21,5 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; public enum Status { - DISTRIBUTION_COMPLETE_OK, - DISTRIBUTION_COMPLETE_ERROR + DISTRIBUTION_COMPLETE_OK, DISTRIBUTION_COMPLETE_ERROR } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationRequest.java index 003cb0815a..6d4c17519b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationRequest.java @@ -21,7 +21,6 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; @@ -31,65 +30,72 @@ import com.fasterxml.jackson.annotation.JsonRootName; @JsonInclude(Include.NON_DEFAULT) public class TenantIsolationRequest implements Serializable { - private static final long serialVersionUID = -210322298981798607L; - @JsonProperty("requestId") + private static final long serialVersionUID = -210322298981798607L; + @JsonProperty("requestId") protected String requestId; - @JsonProperty("startTime") + @JsonProperty("startTime") protected String startTime; - @JsonProperty("requestScope") + @JsonProperty("requestScope") protected String requestScope; - @JsonProperty("requestType") + @JsonProperty("requestType") protected String requestType; - @JsonProperty("requestDetails") + @JsonProperty("requestDetails") protected RequestDetails requestDetails; - @JsonProperty("requestStatus") + @JsonProperty("requestStatus") protected RequestStatus requestStatus; - - public String getRequestId() { - return requestId; - } - public void setRequestId(String requestId) { - this.requestId = requestId; - } - public String getStartTime() { - return startTime; - } - public void setStartTime(String startTime) { - this.startTime = startTime; - } - public String getRequestScope() { - return requestScope; - } - public void setRequestScope(String requestScope) { - this.requestScope = requestScope; - } - public String getRequestType() { - return requestType; - } - public void setRequestType(String requestType) { - this.requestType = requestType; - } - public RequestStatus getRequestStatus() { - return requestStatus; - } - public void setRequestStatus(RequestStatus requestStatus) { - this.requestStatus = requestStatus; - } - - public RequestDetails getRequestDetails() { - return requestDetails; - } - public void setRequestDetails(RequestDetails requestDetails) { - this.requestDetails = requestDetails; - } - - @Override - public String toString() { - return "Request [requestId=" + requestId + - ", startTime=" + startTime + - ", requestType=" + requestType + - ", requestDetails=" + requestDetails.toString() + - ", requestStatus=" + requestStatus.toString() + "]"; - } - + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getRequestScope() { + return requestScope; + } + + public void setRequestScope(String requestScope) { + this.requestScope = requestScope; + } + + public String getRequestType() { + return requestType; + } + + public void setRequestType(String requestType) { + this.requestType = requestType; + } + + public RequestStatus getRequestStatus() { + return requestStatus; + } + + public void setRequestStatus(RequestStatus requestStatus) { + this.requestStatus = requestStatus; + } + + public RequestDetails getRequestDetails() { + return requestDetails; + } + + public void setRequestDetails(RequestDetails requestDetails) { + this.requestDetails = requestDetails; + } + + @Override + public String toString() { + return "Request [requestId=" + requestId + ", startTime=" + startTime + ", requestType=" + requestType + + ", requestDetails=" + requestDetails.toString() + ", requestStatus=" + requestStatus.toString() + "]"; + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationResponse.java index 15a0ab840c..b4ce83afca 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationResponse.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantIsolationResponse.java @@ -21,7 +21,6 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; import java.io.Serializable; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; @@ -30,86 +29,74 @@ import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName(value = "tenantIsolationResponse") @JsonInclude(Include.NON_DEFAULT) public class TenantIsolationResponse implements Serializable { - - private static final long serialVersionUID = 756749312745898666L; - @JsonProperty("requestId") - protected String requestId; - @JsonProperty("status") - String status; - @JsonProperty("message") - String message; + + private static final long serialVersionUID = 756749312745898666L; + @JsonProperty("requestId") + protected String requestId; + @JsonProperty("status") + String status; + @JsonProperty("message") + String message; /** * Gets the value of the requestId property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * - */ - public String getRequestId() { - return requestId; - } - + */ + public String getRequestId() { + return requestId; + } + /** * Sets the value of the requestId property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * - */ - public void setRequestId(String requestId) { - this.requestId = requestId; - } - + */ + public void setRequestId(String requestId) { + this.requestId = requestId; + } + /** * Gets the value of the status property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * - */ - public String getStatus() { - return status; - } - + */ + public String getStatus() { + return status; + } + /** * Sets the value of the status property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * - */ - public void setStatus(String status) { - this.status = status; - } - - /** + */ + public void setStatus(String status) { + this.status = status; + } + + /** * Gets the value of the message property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * - */ - public String getMessage() { - return message; - } - + */ + public String getMessage() { + return message; + } + /** * Sets the value of the message property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * - */ - public void setMessage(String message) { - this.message = message; - } + */ + public void setMessage(String message) { + this.message = message; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantSyncResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantSyncResponse.java index 7281e1c708..0327232b43 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantSyncResponse.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/TenantSyncResponse.java @@ -21,15 +21,15 @@ package org.onap.so.apihandlerinfra.tenantisolationbeans; public class TenantSyncResponse { - - private RequestReferences requestReferences; - public RequestReferences getRequestReferences() { - return requestReferences; - } + private RequestReferences requestReferences; - public void setRequestReferences(RequestReferences requestReferences) { - this.requestReferences = requestReferences; - } + public RequestReferences getRequestReferences() { + return requestReferences; + } + + public void setRequestReferences(RequestReferences requestReferences) { + this.requestReferences = requestReferences; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/package-info.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/package-info.java index 713a763321..45f85bf5d3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/package-info.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/package-info.java @@ -19,10 +19,10 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // package org.onap.so.apihandlerinfra.tenantisolationbeans; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ApplyUpdatedConfigValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ApplyUpdatedConfigValidation.java index 243bbf1474..07b2d4426f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ApplyUpdatedConfigValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ApplyUpdatedConfigValidation.java @@ -25,25 +25,26 @@ import org.onap.so.exceptions.ValidationException; import org.onap.so.serviceinstancebeans.RequestInfo; import org.onap.so.serviceinstancebeans.RequestParameters; -public class ApplyUpdatedConfigValidation implements ValidationRule{ +public class ApplyUpdatedConfigValidation implements ValidationRule { private static boolean empty(String s) { - return (s == null || s.trim().isEmpty()); + return (s == null || s.trim().isEmpty()); } - @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException{ - RequestParameters requestParameters = info.getSir().getRequestDetails().getRequestParameters(); - RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo(); - - if(requestInfo == null){ - throw new ValidationException("requestInfo"); - }else if(empty(requestInfo.getRequestorId())) { - throw new ValidationException ("requestorId"); - }else if (empty (requestInfo.getSource ())) { - throw new ValidationException ("source"); + + @Override + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + RequestParameters requestParameters = info.getSir().getRequestDetails().getRequestParameters(); + RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo(); + + if (requestInfo == null) { + throw new ValidationException("requestInfo"); + } else if (empty(requestInfo.getRequestorId())) { + throw new ValidationException("requestorId"); + } else if (empty(requestInfo.getSource())) { + throw new ValidationException("source"); + } + if (requestParameters == null) { + throw new ValidationException("requestParameters"); } - if(requestParameters == null){ - throw new ValidationException("requestParameters"); - } return info; - } -}
\ No newline at end of file + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java index 937ce19741..2207c52048 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CloudConfigurationValidation.java @@ -27,53 +27,61 @@ import org.onap.so.exceptions.ValidationException; import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.ModelType; -public class CloudConfigurationValidation implements ValidationRule{ - public boolean empty(String s) { - return (s == null || s.trim().isEmpty()); - } - @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException{ - CloudConfiguration cloudConfiguration = info.getSir().getRequestDetails().getCloudConfiguration(); - String requestScope = info.getRequestScope(); - int reqVersion = info.getReqVersion(); - Actions action = info.getAction(); - Boolean aLaCarteFlag = info.getALaCarteFlag(); - - if(!requestScope.equals(ModelType.instanceGroup.toString())){ - if(cloudConfiguration == null && reqVersion >= 5 && (aLaCarteFlag != null && aLaCarteFlag)){ - if((!requestScope.equalsIgnoreCase(ModelType.service.name()) && !requestScope.equalsIgnoreCase(ModelType.configuration.name())) && - (action == Action.createInstance || action == Action.deleteInstance || action == Action.updateInstance)){ - throw new ValidationException ("cloudConfiguration"); - } - if((requestScope.equalsIgnoreCase(ModelType.vnf.name()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name())) && - action == Action.replaceInstance){ - throw new ValidationException ("cloudConfiguration"); - } - if(requestScope.equalsIgnoreCase(ModelType.configuration.name()) && - (action == Action.enablePort || action == Action.disablePort || action == Action.activateInstance || action == Action.deactivateInstance)){ - throw new ValidationException ("cloudConfiguration"); - } - if(requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && (action == Action.deactivateAndCloudDelete || action == Action.scaleOut)){ - throw new ValidationException("cloudConfiguration"); - } - if(requestScope.equals(ModelType.vnf.name()) && action == Action.recreateInstance){ - throw new ValidationException("cloudConfiguration", true); - } - } - } - - if (cloudConfiguration == null && ((aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase (ModelType.service.name ()) && reqVersion < 5)) { - throw new ValidationException ("cloudConfiguration"); +public class CloudConfigurationValidation implements ValidationRule { + public boolean empty(String s) { + return (s == null || s.trim().isEmpty()); + } + + @Override + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + CloudConfiguration cloudConfiguration = info.getSir().getRequestDetails().getCloudConfiguration(); + String requestScope = info.getRequestScope(); + int reqVersion = info.getReqVersion(); + Actions action = info.getAction(); + Boolean aLaCarteFlag = info.getALaCarteFlag(); + + if (!requestScope.equals(ModelType.instanceGroup.toString())) { + if (cloudConfiguration == null && reqVersion >= 5 && (aLaCarteFlag != null && aLaCarteFlag)) { + if ((!requestScope.equalsIgnoreCase(ModelType.service.name()) + && !requestScope.equalsIgnoreCase(ModelType.configuration.name())) + && (action == Action.createInstance || action == Action.deleteInstance + || action == Action.updateInstance)) { + throw new ValidationException("cloudConfiguration"); + } + if ((requestScope.equalsIgnoreCase(ModelType.vnf.name()) + || requestScope.equalsIgnoreCase(ModelType.vfModule.name())) + && action == Action.replaceInstance) { + throw new ValidationException("cloudConfiguration"); + } + if (requestScope.equalsIgnoreCase(ModelType.configuration.name()) + && (action == Action.enablePort || action == Action.disablePort + || action == Action.activateInstance || action == Action.deactivateInstance)) { + throw new ValidationException("cloudConfiguration"); + } + if (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) + && (action == Action.deactivateAndCloudDelete || action == Action.scaleOut)) { + throw new ValidationException("cloudConfiguration"); + } + if (requestScope.equals(ModelType.vnf.name()) && action == Action.recreateInstance) { + throw new ValidationException("cloudConfiguration", true); + } + } + } + + if (cloudConfiguration == null && ((aLaCarteFlag != null && !aLaCarteFlag) + && requestScope.equalsIgnoreCase(ModelType.service.name()) && reqVersion < 5)) { + throw new ValidationException("cloudConfiguration"); } if (cloudConfiguration != null) { - if (empty (cloudConfiguration.getLcpCloudRegionId ())) { - throw new ValidationException ("lcpCloudRegionId"); - } - if (empty (cloudConfiguration.getTenantId ()) && !(requestScope.equalsIgnoreCase(ModelType.configuration.name()))) { - throw new ValidationException ("tenantId"); - } - } - return info; - } -}
\ No newline at end of file + if (empty(cloudConfiguration.getLcpCloudRegionId())) { + throw new ValidationException("lcpCloudRegionId"); + } + if (empty(cloudConfiguration.getTenantId()) + && !(requestScope.equalsIgnoreCase(ModelType.configuration.name()))) { + throw new ValidationException("tenantId"); + } + } + return info; + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java index 8fdb43f20c..158de70309 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ConfigurationParametersValidation.java @@ -23,27 +23,28 @@ package org.onap.so.apihandlerinfra.validation; import java.util.List; import java.util.Map; - import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.Actions; import org.onap.so.exceptions.ValidationException; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; -public class ConfigurationParametersValidation implements ValidationRule{ +public class ConfigurationParametersValidation implements ValidationRule { private static boolean empty(String s) { - return (s == null || s.trim().isEmpty()); + return (s == null || s.trim().isEmpty()); } - @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException{ - ServiceInstancesRequest sir = info.getSir(); - List<Map<String, String>> configParams = sir.getRequestDetails().getConfigurationParameters(); - String requestScope = info.getRequestScope(); - Actions action = info.getAction(); - - if(configParams.isEmpty() && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut){ - throw new ValidationException("configuration parameters"); - } + + @Override + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + ServiceInstancesRequest sir = info.getSir(); + List<Map<String, String>> configParams = sir.getRequestDetails().getConfigurationParameters(); + String requestScope = info.getRequestScope(); + Actions action = info.getAction(); + + if (configParams.isEmpty() && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) + && action == Action.scaleOut) { + throw new ValidationException("configuration parameters"); + } return info; - } -}
\ No newline at end of file + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java index 0602f09796..01e3de99ec 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java @@ -25,28 +25,27 @@ package org.onap.so.apihandlerinfra.validation; import org.onap.so.exceptions.ValidationException; import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.RequestParameters; - import com.google.common.base.Strings; public class CustomWorkflowValidation implements ValidationRule { - @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException { - RequestParameters requestParameters = info.getSir().getRequestDetails().getRequestParameters(); - CloudConfiguration cloudConfiguration = info.getSir().getRequestDetails().getCloudConfiguration(); + @Override + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + RequestParameters requestParameters = info.getSir().getRequestDetails().getRequestParameters(); + CloudConfiguration cloudConfiguration = info.getSir().getRequestDetails().getCloudConfiguration(); - if (cloudConfiguration == null) { - throw new ValidationException("cloudConfiguration"); - } else if (Strings.isNullOrEmpty((cloudConfiguration.getCloudOwner()))) { - throw new ValidationException("cloudOwner"); - } else if (Strings.isNullOrEmpty((cloudConfiguration.getLcpCloudRegionId()))) { - throw new ValidationException("lcpCloudRegionId"); - } else if (Strings.isNullOrEmpty((cloudConfiguration.getTenantId()))) { - throw new ValidationException("tenantId"); - } - if (requestParameters == null) { - throw new ValidationException("requestParameters"); - } - return info; - } + if (cloudConfiguration == null) { + throw new ValidationException("cloudConfiguration"); + } else if (Strings.isNullOrEmpty((cloudConfiguration.getCloudOwner()))) { + throw new ValidationException("cloudOwner"); + } else if (Strings.isNullOrEmpty((cloudConfiguration.getLcpCloudRegionId()))) { + throw new ValidationException("lcpCloudRegionId"); + } else if (Strings.isNullOrEmpty((cloudConfiguration.getTenantId()))) { + throw new ValidationException("tenantId"); + } + if (requestParameters == null) { + throw new ValidationException("requestParameters"); + } + return info; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InPlaceSoftwareUpdateValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InPlaceSoftwareUpdateValidation.java index afbacb465d..6ffd9dcef8 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InPlaceSoftwareUpdateValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InPlaceSoftwareUpdateValidation.java @@ -26,33 +26,34 @@ import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.RequestInfo; import org.onap.so.serviceinstancebeans.RequestParameters; -public class InPlaceSoftwareUpdateValidation implements ValidationRule{ +public class InPlaceSoftwareUpdateValidation implements ValidationRule { private static boolean empty(String s) { - return (s == null || s.trim().isEmpty()); + return (s == null || s.trim().isEmpty()); } - @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException{ - RequestParameters requestParameters = info.getSir().getRequestDetails().getRequestParameters(); - CloudConfiguration cloudConfiguration = info.getSir().getRequestDetails ().getCloudConfiguration(); - RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo(); - if (cloudConfiguration == null) { - throw new ValidationException ("cloudConfiguration"); - }else if (empty (cloudConfiguration.getLcpCloudRegionId ())) { - throw new ValidationException ("lcpCloudRegionId"); - }else if (empty (cloudConfiguration.getTenantId ())) { - throw new ValidationException ("tenantId"); - } - if(requestInfo == null){ - throw new ValidationException("requestInfo"); - }else if(empty(requestInfo.getRequestorId())) { - throw new ValidationException ("requestorId"); - }else if (empty (requestInfo.getSource ())) { - throw new ValidationException ("source"); + @Override + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + RequestParameters requestParameters = info.getSir().getRequestDetails().getRequestParameters(); + CloudConfiguration cloudConfiguration = info.getSir().getRequestDetails().getCloudConfiguration(); + RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo(); + + if (cloudConfiguration == null) { + throw new ValidationException("cloudConfiguration"); + } else if (empty(cloudConfiguration.getLcpCloudRegionId())) { + throw new ValidationException("lcpCloudRegionId"); + } else if (empty(cloudConfiguration.getTenantId())) { + throw new ValidationException("tenantId"); + } + if (requestInfo == null) { + throw new ValidationException("requestInfo"); + } else if (empty(requestInfo.getRequestorId())) { + throw new ValidationException("requestorId"); + } else if (empty(requestInfo.getSource())) { + throw new ValidationException("source"); + } + if (requestParameters == null) { + throw new ValidationException("requestParameters"); } - if(requestParameters == null){ - throw new ValidationException("requestParameters"); - } return info; - } -}
\ No newline at end of file + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java index fad11a5cc6..907bc942eb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/InstanceIdMapValidation.java @@ -22,68 +22,67 @@ package org.onap.so.apihandlerinfra.validation; import java.util.HashMap; - import org.onap.so.apihandler.common.CommonConstants; import org.onap.so.exceptions.ValidationException; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.utils.UUIDChecker; -public class InstanceIdMapValidation implements ValidationRule{ +public class InstanceIdMapValidation implements ValidationRule { + + @Override + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + HashMap<String, String> instanceIdMap = info.getInstanceIdMap(); + ServiceInstancesRequest sir = info.getSir(); + if (instanceIdMap != null) { + if (instanceIdMap.get("serviceInstanceId") != null) { + if (!UUIDChecker.isValidUUID(instanceIdMap.get("serviceInstanceId"))) { + throw new ValidationException("serviceInstanceId"); + } + sir.setServiceInstanceId(instanceIdMap.get("serviceInstanceId")); + } + + if (instanceIdMap.get("vnfInstanceId") != null) { + if (!UUIDChecker.isValidUUID(instanceIdMap.get("vnfInstanceId"))) { + throw new ValidationException("vnfInstanceId"); + } + sir.setVnfInstanceId(instanceIdMap.get("vnfInstanceId")); + } - @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException{ - HashMap<String, String> instanceIdMap = info.getInstanceIdMap(); - ServiceInstancesRequest sir = info.getSir(); - if(instanceIdMap != null){ - if(instanceIdMap.get("serviceInstanceId") != null){ - if (!UUIDChecker.isValidUUID (instanceIdMap.get ("serviceInstanceId"))) { - throw new ValidationException ("serviceInstanceId"); - } - sir.setServiceInstanceId(instanceIdMap.get("serviceInstanceId")); - } + if (instanceIdMap.get("vfModuleInstanceId") != null) { + if (!UUIDChecker.isValidUUID(instanceIdMap.get("vfModuleInstanceId"))) { + throw new ValidationException("vfModuleInstanceId"); + } + sir.setVfModuleInstanceId(instanceIdMap.get("vfModuleInstanceId")); + } - if(instanceIdMap.get("vnfInstanceId") != null){ - if (!UUIDChecker.isValidUUID (instanceIdMap.get ("vnfInstanceId"))) { - throw new ValidationException ("vnfInstanceId"); - } - sir.setVnfInstanceId(instanceIdMap.get("vnfInstanceId")); - } + if (instanceIdMap.get("volumeGroupInstanceId") != null) { + if (!UUIDChecker.isValidUUID(instanceIdMap.get("volumeGroupInstanceId"))) { + throw new ValidationException("volumeGroupInstanceId"); + } + sir.setVolumeGroupInstanceId(instanceIdMap.get("volumeGroupInstanceId")); + } - if(instanceIdMap.get("vfModuleInstanceId") != null){ - if (!UUIDChecker.isValidUUID (instanceIdMap.get ("vfModuleInstanceId"))) { - throw new ValidationException ("vfModuleInstanceId"); - } - sir.setVfModuleInstanceId(instanceIdMap.get("vfModuleInstanceId")); - } + if (instanceIdMap.get("networkInstanceId") != null) { + if (!UUIDChecker.isValidUUID(instanceIdMap.get("networkInstanceId"))) { + throw new ValidationException("networkInstanceId"); + } + sir.setNetworkInstanceId(instanceIdMap.get("networkInstanceId")); + } - if(instanceIdMap.get("volumeGroupInstanceId") != null){ - if (!UUIDChecker.isValidUUID (instanceIdMap.get ("volumeGroupInstanceId"))) { - throw new ValidationException ("volumeGroupInstanceId"); - } - sir.setVolumeGroupInstanceId(instanceIdMap.get("volumeGroupInstanceId")); - } + if (instanceIdMap.get("configurationInstanceId") != null) { + if (!UUIDChecker.isValidUUID(instanceIdMap.get("configurationInstanceId"))) { + throw new ValidationException("configurationInstanceId"); + } + sir.setConfigurationId(instanceIdMap.get("configurationInstanceId")); + } - if(instanceIdMap.get("networkInstanceId") != null){ - if (!UUIDChecker.isValidUUID (instanceIdMap.get ("networkInstanceId"))) { - throw new ValidationException ("networkInstanceId"); - } - sir.setNetworkInstanceId(instanceIdMap.get("networkInstanceId")); - } - - if(instanceIdMap.get("configurationInstanceId") != null){ - if (!UUIDChecker.isValidUUID (instanceIdMap.get ("configurationInstanceId"))) { - throw new ValidationException ("configurationInstanceId"); - } - sir.setConfigurationId(instanceIdMap.get("configurationInstanceId")); - } - - if(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID) != null){ - if (!UUIDChecker.isValidUUID (instanceIdMap.get (CommonConstants.INSTANCE_GROUP_INSTANCE_ID))) { - throw new ValidationException (CommonConstants.INSTANCE_GROUP_INSTANCE_ID, true); - } - sir.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID)); - } + if (instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID) != null) { + if (!UUIDChecker.isValidUUID(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID))) { + throw new ValidationException(CommonConstants.INSTANCE_GROUP_INSTANCE_ID, true); + } + sir.setInstanceGroupId(instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID)); + } } return info; - } -}
\ No newline at end of file + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/MembersValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/MembersValidation.java index 89bb15dcb1..5e38979b89 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/MembersValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/MembersValidation.java @@ -27,43 +27,44 @@ import org.onap.so.serviceinstancebeans.RelatedInstance; import org.onap.so.serviceinstancebeans.RelatedInstanceList; import org.onap.so.serviceinstancebeans.RequestInfo; -public class MembersValidation implements ValidationRule{ +public class MembersValidation implements ValidationRule { private static boolean empty(String s) { - return (s == null || s.trim().isEmpty()); + return (s == null || s.trim().isEmpty()); } - @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException{ - RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo(); - RelatedInstanceList[] relatedInstanceList = info.getSir().getRequestDetails().getRelatedInstanceList(); - boolean vnfRelatedInstance = false; - - if(requestInfo == null){ - throw new ValidationException("requestInfo", true); - }else if(empty(requestInfo.getRequestorId())) { - throw new ValidationException ("requestorId", true); - }else if (empty (requestInfo.getSource ())) { - throw new ValidationException ("source", true); + + @Override + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo(); + RelatedInstanceList[] relatedInstanceList = info.getSir().getRequestDetails().getRelatedInstanceList(); + boolean vnfRelatedInstance = false; + + if (requestInfo == null) { + throw new ValidationException("requestInfo", true); + } else if (empty(requestInfo.getRequestorId())) { + throw new ValidationException("requestorId", true); + } else if (empty(requestInfo.getSource())) { + throw new ValidationException("source", true); + } + if (relatedInstanceList == null) { + throw new ValidationException("related instances", true); + } else { + for (RelatedInstanceList instanceList : relatedInstanceList) { + RelatedInstance relatedInstance = instanceList.getRelatedInstance(); + ModelType modelType = relatedInstance.getModelInfo().getModelType(); + if (empty(relatedInstance.getInstanceId())) { + throw new ValidationException("instanceId in relatedInstances", true); + } + if (modelType == null) { + throw new ValidationException("modelType in relatedInstance", true); + } + if (modelType == ModelType.vnf) { + vnfRelatedInstance = true; + } + } + if (!vnfRelatedInstance) { + throw new ValidationException("vnf relatedInstance", true); + } } - if(relatedInstanceList == null){ - throw new ValidationException("related instances", true); - }else{ - for(RelatedInstanceList instanceList : relatedInstanceList){ - RelatedInstance relatedInstance = instanceList.getRelatedInstance(); - ModelType modelType = relatedInstance.getModelInfo().getModelType(); - if(empty(relatedInstance.getInstanceId())){ - throw new ValidationException("instanceId in relatedInstances", true); - } - if (modelType == null) { - throw new ValidationException("modelType in relatedInstance", true); - } - if(modelType == ModelType.vnf){ - vnfRelatedInstance = true; - } - } - if(!vnfRelatedInstance){ - throw new ValidationException("vnf relatedInstance", true); - } - } return info; - } -}
\ No newline at end of file + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java index e2a1bdc46a..ecc79c72e8 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ModelInfoValidation.java @@ -29,109 +29,141 @@ import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.RequestParameters; import org.onap.so.utils.UUIDChecker; -public class ModelInfoValidation implements ValidationRule{ - private static boolean empty(String s) { - return (s == null || s.trim().isEmpty()); - } - @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException{ - ModelInfo modelInfo = info.getSir().getRequestDetails().getModelInfo(); - RequestParameters requestParameters = info.getReqParameters(); - String requestScope = info.getRequestScope(); - Actions action = info.getAction(); - int reqVersion = info.getReqVersion(); - Boolean aLaCarteFlag = info.getALaCarteFlag(); - if(!requestScope.equals(ModelType.instanceGroup.toString())){ +public class ModelInfoValidation implements ValidationRule { + private static boolean empty(String s) { + return (s == null || s.trim().isEmpty()); + } - if(!empty(modelInfo.getModelNameVersionId())){ - modelInfo.setModelVersionId(modelInfo.getModelNameVersionId()); - } - // modelCustomizationId is required when usePreLoad is false for v4 and higher for VF Module Create - if(requestParameters != null && reqVersion >= 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.createInstance && !requestParameters.isUsePreload()) { - if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) { - throw new ValidationException("modelCustomizationId"); - } - } + @Override + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + ModelInfo modelInfo = info.getSir().getRequestDetails().getModelInfo(); + RequestParameters requestParameters = info.getReqParameters(); + String requestScope = info.getRequestScope(); + Actions action = info.getAction(); + int reqVersion = info.getReqVersion(); + Boolean aLaCarteFlag = info.getALaCarteFlag(); - // modelCustomizationId is required for v5 and higher for VF Module Replace - if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.replaceInstance) { - if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) { - throw new ValidationException("modelCustomizationId"); - } - } + if (!requestScope.equals(ModelType.instanceGroup.toString())) { - // modelCustomizationId or modelCustomizationName are required for VNF Replace - if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.replaceInstance || action == Action.recreateInstance) { - if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId()) && modelInfo.getModelCustomizationName() == null) { - throw new ValidationException("modelCustomizationId or modelCustomizationName"); - } - } + if (!empty(modelInfo.getModelNameVersionId())) { + modelInfo.setModelVersionId(modelInfo.getModelNameVersionId()); + } + // modelCustomizationId is required when usePreLoad is false for v4 and higher for VF Module Create + if (requestParameters != null && reqVersion >= 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) + && action == Action.createInstance && !requestParameters.isUsePreload()) { + if (!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) { + throw new ValidationException("modelCustomizationId"); + } + } - //is required for serviceInstance delete macro when aLaCarte=false (v3) - //create and updates except for network (except v4) - if (empty (modelInfo.getModelInvariantId ()) && ((reqVersion >2 && (aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) || - !(reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ())) && - (action == Action.createInstance || action == Action.updateInstance || action == Action.enablePort || action == Action.disablePort || action == Action.addRelationships || action == Action.removeRelationships || - (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) { - throw new ValidationException ("modelInvariantId"); - } - if(empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)){ - throw new ValidationException("modelInvariantId"); - } - if(empty(modelInfo.getModelInvariantId()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){ - throw new ValidationException("modelInvariantId", true); - } - if (!empty (modelInfo.getModelInvariantId ()) && !UUIDChecker.isValidUUID (modelInfo.getModelInvariantId ())) { - throw new ValidationException ("modelInvariantId format"); - } + // modelCustomizationId is required for v5 and higher for VF Module Replace + if (requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) + && action == Action.replaceInstance) { + if (!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) { + throw new ValidationException("modelCustomizationId"); + } + } - if(reqVersion >= 4 && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) && empty (modelInfo.getModelName ()) && (action == Action.createInstance || action == Action.updateInstance || - action == Action.addRelationships || action == Action.removeRelationships || action == Action.recreateInstance || ((action == Action.deleteInstance || action == Action.scaleOut) && (requestScope.equalsIgnoreCase (ModelType.vfModule.name ()))))){ - throw new ValidationException ("modelName", true); - } + // modelCustomizationId or modelCustomizationName are required for VNF Replace + if (requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) + && action == Action.replaceInstance || action == Action.recreateInstance) { + if (!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId()) + && modelInfo.getModelCustomizationName() == null) { + throw new ValidationException("modelCustomizationId or modelCustomizationName"); + } + } - if (empty (modelInfo.getModelVersion ()) && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) && - (!(reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ())) - && (action == Action.createInstance || action == Action.updateInstance || action == Action.addRelationships || action == Action.removeRelationships || action == Action.scaleOut))) { - throw new ValidationException ("modelVersion"); - } + // is required for serviceInstance delete macro when aLaCarte=false (v3) + // create and updates except for network (except v4) + if (empty(modelInfo.getModelInvariantId()) && ((reqVersion > 2 && (aLaCarteFlag != null && !aLaCarteFlag) + && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) + || !(reqVersion < 4 && requestScope.equalsIgnoreCase(ModelType.network.name())) + && (action == Action.createInstance || action == Action.updateInstance + || action == Action.enablePort || action == Action.disablePort + || action == Action.addRelationships || action == Action.removeRelationships + || (requestScope.equalsIgnoreCase(ModelType.configuration.name()) + && (action == Action.activateInstance + || action == Action.deactivateInstance))))) { + throw new ValidationException("modelInvariantId"); + } + if (empty(modelInfo.getModelInvariantId()) + && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)) { + throw new ValidationException("modelInvariantId"); + } + if (empty(modelInfo.getModelInvariantId()) + && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)) { + throw new ValidationException("modelInvariantId", true); + } + if (!empty(modelInfo.getModelInvariantId()) && !UUIDChecker.isValidUUID(modelInfo.getModelInvariantId())) { + throw new ValidationException("modelInvariantId format"); + } - if(empty(modelInfo.getModelVersion()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){ - throw new ValidationException("modelVersion", true); - } + if (reqVersion >= 4 && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) + && empty(modelInfo.getModelName()) + && (action == Action.createInstance || action == Action.updateInstance + || action == Action.addRelationships || action == Action.removeRelationships + || action == Action.recreateInstance + || ((action == Action.deleteInstance || action == Action.scaleOut) + && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()))))) { + throw new ValidationException("modelName", true); + } - // is required for serviceInstance delete macro when aLaCarte=false in v4 - if (reqVersion >= 4 && empty (modelInfo.getModelVersionId()) && (((aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) || - (action == Action.createInstance || action == Action.updateInstance || action == Action.enablePort || action == Action.disablePort || action == Action.addRelationships || action == Action.removeRelationships || - (requestScope.equalsIgnoreCase(ModelType.configuration.name()) && (action == Action.activateInstance || action == Action.deactivateInstance))))) { - throw new ValidationException ("modelVersionId"); - } - if(empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)){ - throw new ValidationException("modelVersionId", true); - } - if(empty(modelInfo.getModelVersionId()) && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)){ - throw new ValidationException("modelVersionId"); - } + if (empty(modelInfo.getModelVersion()) && !(requestScope.equalsIgnoreCase(ModelType.configuration.name())) + && (!(reqVersion < 4 && requestScope.equalsIgnoreCase(ModelType.network.name())) + && (action == Action.createInstance || action == Action.updateInstance + || action == Action.addRelationships || action == Action.removeRelationships + || action == Action.scaleOut))) { + throw new ValidationException("modelVersion"); + } - if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action != Action.deleteInstance && empty (modelInfo.getModelCustomizationName ())) { - if (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) { - throw new ValidationException ("modelCustomizationId or modelCustomizationName"); - } - } + if (empty(modelInfo.getModelVersion()) + && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)) { + throw new ValidationException("modelVersion", true); + } - if(reqVersion >= 4 && (!UUIDChecker.isValidUUID (modelInfo.getModelCustomizationId())) && (requestScope.equalsIgnoreCase (ModelType.network.name ()) || requestScope.equalsIgnoreCase(ModelType.configuration.name())) - && (action == Action.updateInstance || action == Action.createInstance)){ - throw new ValidationException ("modelCustomizationId"); - } - if(empty(modelInfo.getModelCustomizationId()) && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut && !(requestParameters.getTestApi() == TestApi.VNF_API.name() && requestParameters.isUsePreload() == true)){ - throw new ValidationException ("modelCustomizationId"); - } - }else{ - if(empty(modelInfo.getModelVersionId()) && action == Action.createInstance){ - throw new ValidationException("modelVersionId", true); - } - } - return info; - } + // is required for serviceInstance delete macro when aLaCarte=false in v4 + if (reqVersion >= 4 && empty(modelInfo.getModelVersionId()) && (((aLaCarteFlag != null && !aLaCarteFlag) + && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) + || (action == Action.createInstance || action == Action.updateInstance + || action == Action.enablePort || action == Action.disablePort + || action == Action.addRelationships || action == Action.removeRelationships + || (requestScope.equalsIgnoreCase(ModelType.configuration.name()) + && (action == Action.activateInstance || action == Action.deactivateInstance))))) { + throw new ValidationException("modelVersionId"); + } + if (empty(modelInfo.getModelVersionId()) + && (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.recreateInstance)) { + throw new ValidationException("modelVersionId", true); + } + if (empty(modelInfo.getModelVersionId()) + && (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)) { + throw new ValidationException("modelVersionId"); + } + + if (requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action != Action.deleteInstance + && empty(modelInfo.getModelCustomizationName())) { + if (!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) { + throw new ValidationException("modelCustomizationId or modelCustomizationName"); + } + } + + if (reqVersion >= 4 && (!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) + && (requestScope.equalsIgnoreCase(ModelType.network.name()) + || requestScope.equalsIgnoreCase(ModelType.configuration.name())) + && (action == Action.updateInstance || action == Action.createInstance)) { + throw new ValidationException("modelCustomizationId"); + } + if (empty(modelInfo.getModelCustomizationId()) && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) + && action == Action.scaleOut && !(requestParameters.getTestApi() == TestApi.VNF_API.name() + && requestParameters.isUsePreload() == true)) { + throw new ValidationException("modelCustomizationId"); + } + } else { + if (empty(modelInfo.getModelVersionId()) && action == Action.createInstance) { + throw new ValidationException("modelVersionId", true); + } + } + return info; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java index 7c51f3e5ce..c80e89e21d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/PlatformLOBValidation.java @@ -28,33 +28,34 @@ import org.onap.so.exceptions.ValidationException; import org.onap.so.serviceinstancebeans.LineOfBusiness; import org.onap.so.serviceinstancebeans.Platform; -public class PlatformLOBValidation implements ValidationRule{ +public class PlatformLOBValidation implements ValidationRule { private static boolean empty(String s) { - return (s == null || s.trim().isEmpty()); + return (s == null || s.trim().isEmpty()); } - @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException{ - int reqVersion = info.getReqVersion(); - Platform platform; - LineOfBusiness lineOfBusiness; - String requestScope = info.getRequestScope(); - Actions action = info.getAction(); - - platform = info.getSir().getRequestDetails().getPlatform(); - lineOfBusiness = info.getSir().getRequestDetails().getLineOfBusiness(); - if(reqVersion >= 5 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.createInstance){ - if(reqVersion > 5 && platform == null) { - throw new ValidationException("platform"); - } - if(platform != null && empty(platform.getPlatformName())){ - throw new ValidationException("platformName"); - } - if(lineOfBusiness != null && empty(lineOfBusiness.getLineOfBusinessName())){ - throw new ValidationException("lineOfBusinessName"); + + @Override + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + int reqVersion = info.getReqVersion(); + Platform platform; + LineOfBusiness lineOfBusiness; + String requestScope = info.getRequestScope(); + Actions action = info.getAction(); + + platform = info.getSir().getRequestDetails().getPlatform(); + lineOfBusiness = info.getSir().getRequestDetails().getLineOfBusiness(); + if (reqVersion >= 5 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.createInstance) { + if (reqVersion > 5 && platform == null) { + throw new ValidationException("platform"); + } + if (platform != null && empty(platform.getPlatformName())) { + throw new ValidationException("platformName"); } - } + if (lineOfBusiness != null && empty(lineOfBusiness.getLineOfBusinessName())) { + throw new ValidationException("lineOfBusinessName"); + } + } info.setPlatform(platform); info.setLOB(lineOfBusiness); return info; - } -}
\ No newline at end of file + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java index f6a3c03555..60e1274469 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ProjectOwningEntityValidation.java @@ -28,33 +28,35 @@ import org.onap.so.exceptions.ValidationException; import org.onap.so.serviceinstancebeans.OwningEntity; import org.onap.so.serviceinstancebeans.Project; -public class ProjectOwningEntityValidation implements ValidationRule{ +public class ProjectOwningEntityValidation implements ValidationRule { private static boolean empty(String s) { - return (s == null || s.trim().isEmpty()); + return (s == null || s.trim().isEmpty()); } - @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException{ - int reqVersion = info.getReqVersion(); - Project project; - OwningEntity owningEntity; - String requestScope = info.getRequestScope(); - Actions action = info.getAction(); - - project = info.getSir().getRequestDetails().getProject(); - owningEntity = info.getSir().getRequestDetails().getOwningEntity(); - if(reqVersion >= 5 && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.createInstance || action == Action.assignInstance){ - if(reqVersion > 5 && owningEntity == null) { - throw new ValidationException("owningEntity"); - } - if(owningEntity != null && empty(owningEntity.getOwningEntityId())){ - throw new ValidationException("owningEntityId"); - } - if(project != null && empty(project.getProjectName())){ - throw new ValidationException("projectName"); - } - } - info.setProject(project); - info.setOE(owningEntity); + + @Override + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + int reqVersion = info.getReqVersion(); + Project project; + OwningEntity owningEntity; + String requestScope = info.getRequestScope(); + Actions action = info.getAction(); + + project = info.getSir().getRequestDetails().getProject(); + owningEntity = info.getSir().getRequestDetails().getOwningEntity(); + if (reqVersion >= 5 && requestScope.equalsIgnoreCase(ModelType.service.name()) + && action == Action.createInstance || action == Action.assignInstance) { + if (reqVersion > 5 && owningEntity == null) { + throw new ValidationException("owningEntity"); + } + if (owningEntity != null && empty(owningEntity.getOwningEntityId())) { + throw new ValidationException("owningEntityId"); + } + if (project != null && empty(project.getProjectName())) { + throw new ValidationException("projectName"); + } + } + info.setProject(project); + info.setOE(owningEntity); return info; - } -}
\ No newline at end of file + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java index 5eb3083003..b02bd95d97 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java @@ -37,214 +37,238 @@ import org.onap.so.utils.UUIDChecker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class RelatedInstancesValidation implements ValidationRule{ - - private static Logger logger = LoggerFactory.getLogger(RelatedInstancesValidation.class); - - private static boolean empty(String s) { - return (s == null || s.trim().isEmpty()); - } - @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException{ - ServiceInstancesRequest sir = info.getSir(); - Actions action = info.getAction(); - int reqVersion = info.getReqVersion(); - String requestScope = info.getRequestScope(); - String serviceInstanceType = null; - String networkType = null; - String vnfType = null; - String vfModuleType = null; - String vfModuleModelName = null; - ModelInfo modelInfo = info.getSir().getRequestDetails().getModelInfo(); - RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList(); - String serviceModelName = null; +public class RelatedInstancesValidation implements ValidationRule { + + private static Logger logger = LoggerFactory.getLogger(RelatedInstancesValidation.class); + + private static boolean empty(String s) { + return (s == null || s.trim().isEmpty()); + } + + @Override + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + ServiceInstancesRequest sir = info.getSir(); + Actions action = info.getAction(); + int reqVersion = info.getReqVersion(); + String requestScope = info.getRequestScope(); + String serviceInstanceType = null; + String networkType = null; + String vnfType = null; + String vfModuleType = null; + String vfModuleModelName = null; + ModelInfo modelInfo = info.getSir().getRequestDetails().getModelInfo(); + RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList(); + String serviceModelName = null; String vnfModelName = null; String asdcServiceModelVersion = null; String volumeGroupId = null; boolean isRelatedServiceInstancePresent = false; boolean isRelatedVnfInstancePresent = false; - boolean isSourceVnfPresent = false; - boolean isDestinationVnfPresent = false; - boolean isConnectionPointPresent = false; - - if(requestScope.equalsIgnoreCase(ModelType.service.name())){ - serviceInstanceType = modelInfo.getModelName(); - info.setServiceInstanceType(serviceInstanceType); - } - if(requestScope.equalsIgnoreCase(ModelType.network.name())){ - networkType = modelInfo.getModelName(); - info.setNetworkType(networkType); - } - if (instanceList != null) { - for(RelatedInstanceList relatedInstanceList : instanceList){ - RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); - - ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo (); - if (relatedInstanceModelInfo == null) { - throw new ValidationException ("modelInfo in relatedInstance"); - } - - if (relatedInstanceModelInfo.getModelType () == null) { - throw new ValidationException ("modelType in relatedInstance"); - } - - if(empty(relatedInstance.getInstanceName ()) && ModelType.pnf.equals(relatedInstanceModelInfo.getModelType())) { - throw new ValidationException ("instanceName in relatedInstance for pnf modelType"); - } - - if (!empty (relatedInstance.getInstanceName ())) { - if (!relatedInstance.getInstanceName ().matches (Constants.VALID_INSTANCE_NAME_FORMAT)) { - throw new ValidationException ("instanceName format in relatedInstance"); - } - } - - if (empty (relatedInstance.getInstanceId ()) && !ModelType.pnf.equals(relatedInstanceModelInfo.getModelType())) { - throw new ValidationException ("instanceId in relatedInstance"); - } - - if (!empty(relatedInstance.getInstanceId ()) && !UUIDChecker.isValidUUID (relatedInstance.getInstanceId ())) { - throw new ValidationException ("instanceId format in relatedInstance"); - } - if(empty(relatedInstanceModelInfo.getModelVersionId()) && requestScope.equals(ModelType.instanceGroup.toString()) && relatedInstanceModelInfo.getModelType().equals(ModelType.service)){ - throw new ValidationException("modelVersionId in relatedInstance", true); - } - if(requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString()) && relatedInstanceModelInfo.getModelType().equals(ModelType.service)){ - isRelatedServiceInstancePresent = true; - } - - if (action != Action.deleteInstance && !requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())) { - if(!( relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup) || - relatedInstanceModelInfo.getModelType().equals(ModelType.connectionPoint) || - relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) || - relatedInstanceModelInfo.getModelType().equals(ModelType.networkInstanceGroup))) { - - if(empty (relatedInstanceModelInfo.getModelInvariantId ())) { - throw new ValidationException ("modelInvariantId in relatedInstance"); - } else if(reqVersion >= 4 && empty(relatedInstanceModelInfo.getModelVersionId ())) { - throw new ValidationException("modelVersionId in relatedInstance"); - } else if(empty(relatedInstanceModelInfo.getModelName ())) { - throw new ValidationException ("modelName in relatedInstance"); - } else if (empty (relatedInstanceModelInfo.getModelVersion ())) { - throw new ValidationException ("modelVersion in relatedInstance"); - } - } - - if (!empty (relatedInstanceModelInfo.getModelInvariantId ()) && - !UUIDChecker.isValidUUID (relatedInstanceModelInfo.getModelInvariantId ())) { - throw new ValidationException ("modelInvariantId format in relatedInstance"); - } - - if(ModelType.configuration.name().equalsIgnoreCase(requestScope)) { - if(InstanceDirection.source.equals(relatedInstance.getInstanceDirection()) && relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) { - isSourceVnfPresent = true; - } else if(InstanceDirection.destination.equals(relatedInstance.getInstanceDirection()) && - (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf)))) { - isDestinationVnfPresent = true; - } - } - - if(ModelType.connectionPoint.equals(relatedInstanceModelInfo.getModelType()) && ModelType.configuration.name().equalsIgnoreCase(requestScope)) { - isConnectionPointPresent = true; - } - } - - if (empty (relatedInstanceModelInfo.getModelCustomizationName ()) && relatedInstanceModelInfo.getModelType ().equals (ModelType.vnf) ) { - if(reqVersion >=4 && empty (relatedInstanceModelInfo.getModelCustomizationId()) && action != Action.deleteInstance) { - throw new ValidationException ("modelCustomizationName or modelCustomizationId in relatedInstance of vnf"); - } - } - - if(relatedInstanceModelInfo.getModelType().equals(ModelType.service) && !(requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString()) && action == Action.createInstance)) { - isRelatedServiceInstancePresent = true; - if (!relatedInstance.getInstanceId ().equals (sir.getServiceInstanceId ())) { - throw new ValidationException ("serviceInstanceId matching the serviceInstanceId in request URI"); - } - serviceModelName = relatedInstanceModelInfo.getModelName (); - asdcServiceModelVersion = relatedInstanceModelInfo.getModelVersion (); - } else if(relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) && !(ModelType.configuration.name().equalsIgnoreCase(requestScope))) { - isRelatedVnfInstancePresent = true; - if (!relatedInstance.getInstanceId ().equals (sir.getVnfInstanceId ())) { - throw new ValidationException ("vnfInstanceId matching the vnfInstanceId in request URI"); - } - vnfModelName = relatedInstanceModelInfo.getModelCustomizationName(); - } else if(relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup)) { - volumeGroupId = relatedInstance.getInstanceId (); - } - } - - if(action == Action.createInstance && ModelType.configuration.name().equalsIgnoreCase(requestScope)) { - if(!isSourceVnfPresent) { - throw new ValidationException ("source vnf relatedInstance for Port Configuration"); - } - - if(!isDestinationVnfPresent) { - throw new ValidationException ("destination vnf relatedInstance for Port Configuration"); - } - } - - if((action == Action.enablePort || action == Action.disablePort) && ModelType.configuration.name().equalsIgnoreCase(requestScope)) { - if(!isConnectionPointPresent) { - throw new ValidationException ("connectionPoint relatedInstance for Port Configuration"); - } - } - if(requestScope.equals(ModelType.instanceGroup.toString())){ - if(!isRelatedServiceInstancePresent){ - throw new ValidationException("related service instance for instanceGroup request", true); - } - } - if(requestScope.equalsIgnoreCase (ModelType.volumeGroup.name ())) { - if (!isRelatedServiceInstancePresent) { - throw new ValidationException ("related service instance for volumeGroup request"); - } - if (!isRelatedVnfInstancePresent) { - throw new ValidationException ("related vnf instance for volumeGroup request"); - } - serviceInstanceType = serviceModelName; - vnfType = serviceModelName + "/" + vnfModelName; - info.setServiceInstanceType(serviceInstanceType); - info.setVnfType(vnfType); - } - else if(requestScope.equalsIgnoreCase(ModelType.vfModule.name ())) { - if (!isRelatedServiceInstancePresent) { - throw new ValidationException ("related service instance for vfModule request"); - } - if (!isRelatedVnfInstancePresent) { - throw new ValidationException ("related vnf instance for vfModule request"); - } - vfModuleModelName = modelInfo.getModelName (); - serviceInstanceType = serviceModelName; - vnfType = serviceModelName + "/" + vnfModelName; - vfModuleType = vnfType + "::" + vfModuleModelName; - sir.setVolumeGroupInstanceId (volumeGroupId); - info.setVfModuleModelName(vfModuleModelName); - info.setVnfType(vnfType); - info.setServiceInstanceType(serviceInstanceType); - info.setVfModuleType(vfModuleType); - } - else if (requestScope.equalsIgnoreCase (ModelType.vnf.name ())) { - if (!isRelatedServiceInstancePresent) { - throw new ValidationException ("related service instance for vnf request"); - } - vnfType = serviceModelName + "/" + sir.getRequestDetails().getModelInfo().getModelCustomizationName(); - info.setVnfType(vnfType); - } + boolean isSourceVnfPresent = false; + boolean isDestinationVnfPresent = false; + boolean isConnectionPointPresent = false; + + if (requestScope.equalsIgnoreCase(ModelType.service.name())) { + serviceInstanceType = modelInfo.getModelName(); + info.setServiceInstanceType(serviceInstanceType); + } + if (requestScope.equalsIgnoreCase(ModelType.network.name())) { + networkType = modelInfo.getModelName(); + info.setNetworkType(networkType); + } + if (instanceList != null) { + for (RelatedInstanceList relatedInstanceList : instanceList) { + RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance(); + + ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo(); + if (relatedInstanceModelInfo == null) { + throw new ValidationException("modelInfo in relatedInstance"); + } + + if (relatedInstanceModelInfo.getModelType() == null) { + throw new ValidationException("modelType in relatedInstance"); + } + + if (empty(relatedInstance.getInstanceName()) + && ModelType.pnf.equals(relatedInstanceModelInfo.getModelType())) { + throw new ValidationException("instanceName in relatedInstance for pnf modelType"); + } + + if (!empty(relatedInstance.getInstanceName())) { + if (!relatedInstance.getInstanceName().matches(Constants.VALID_INSTANCE_NAME_FORMAT)) { + throw new ValidationException("instanceName format in relatedInstance"); + } + } + + if (empty(relatedInstance.getInstanceId()) + && !ModelType.pnf.equals(relatedInstanceModelInfo.getModelType())) { + throw new ValidationException("instanceId in relatedInstance"); + } + + if (!empty(relatedInstance.getInstanceId()) + && !UUIDChecker.isValidUUID(relatedInstance.getInstanceId())) { + throw new ValidationException("instanceId format in relatedInstance"); + } + if (empty(relatedInstanceModelInfo.getModelVersionId()) + && requestScope.equals(ModelType.instanceGroup.toString()) + && relatedInstanceModelInfo.getModelType().equals(ModelType.service)) { + throw new ValidationException("modelVersionId in relatedInstance", true); + } + if (requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString()) + && relatedInstanceModelInfo.getModelType().equals(ModelType.service)) { + isRelatedServiceInstancePresent = true; + } + + if (action != Action.deleteInstance + && !requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())) { + if (!(relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup) + || relatedInstanceModelInfo.getModelType().equals(ModelType.connectionPoint) + || relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) + || relatedInstanceModelInfo.getModelType().equals(ModelType.networkInstanceGroup))) { + + if (empty(relatedInstanceModelInfo.getModelInvariantId())) { + throw new ValidationException("modelInvariantId in relatedInstance"); + } else if (reqVersion >= 4 && empty(relatedInstanceModelInfo.getModelVersionId())) { + throw new ValidationException("modelVersionId in relatedInstance"); + } else if (empty(relatedInstanceModelInfo.getModelName())) { + throw new ValidationException("modelName in relatedInstance"); + } else if (empty(relatedInstanceModelInfo.getModelVersion())) { + throw new ValidationException("modelVersion in relatedInstance"); + } + } + + if (!empty(relatedInstanceModelInfo.getModelInvariantId()) + && !UUIDChecker.isValidUUID(relatedInstanceModelInfo.getModelInvariantId())) { + throw new ValidationException("modelInvariantId format in relatedInstance"); + } + + if (ModelType.configuration.name().equalsIgnoreCase(requestScope)) { + if (InstanceDirection.source.equals(relatedInstance.getInstanceDirection()) + && relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) { + isSourceVnfPresent = true; + } else if (InstanceDirection.destination.equals(relatedInstance.getInstanceDirection()) + && (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) + || (relatedInstanceModelInfo.getModelType().equals(ModelType.pnf)))) { + isDestinationVnfPresent = true; + } + } + + if (ModelType.connectionPoint.equals(relatedInstanceModelInfo.getModelType()) + && ModelType.configuration.name().equalsIgnoreCase(requestScope)) { + isConnectionPointPresent = true; + } + } + + if (empty(relatedInstanceModelInfo.getModelCustomizationName()) + && relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) { + if (reqVersion >= 4 && empty(relatedInstanceModelInfo.getModelCustomizationId()) + && action != Action.deleteInstance) { + throw new ValidationException( + "modelCustomizationName or modelCustomizationId in relatedInstance of vnf"); + } + } + + if (relatedInstanceModelInfo.getModelType().equals(ModelType.service) + && !(requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString()) + && action == Action.createInstance)) { + isRelatedServiceInstancePresent = true; + if (!relatedInstance.getInstanceId().equals(sir.getServiceInstanceId())) { + throw new ValidationException( + "serviceInstanceId matching the serviceInstanceId in request URI"); + } + serviceModelName = relatedInstanceModelInfo.getModelName(); + asdcServiceModelVersion = relatedInstanceModelInfo.getModelVersion(); + } else if (relatedInstanceModelInfo.getModelType().equals(ModelType.vnf) + && !(ModelType.configuration.name().equalsIgnoreCase(requestScope))) { + isRelatedVnfInstancePresent = true; + if (!relatedInstance.getInstanceId().equals(sir.getVnfInstanceId())) { + throw new ValidationException("vnfInstanceId matching the vnfInstanceId in request URI"); + } + vnfModelName = relatedInstanceModelInfo.getModelCustomizationName(); + } else if (relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup)) { + volumeGroupId = relatedInstance.getInstanceId(); + } + } + + if (action == Action.createInstance && ModelType.configuration.name().equalsIgnoreCase(requestScope)) { + if (!isSourceVnfPresent) { + throw new ValidationException("source vnf relatedInstance for Port Configuration"); + } + + if (!isDestinationVnfPresent) { + throw new ValidationException("destination vnf relatedInstance for Port Configuration"); + } + } + + if ((action == Action.enablePort || action == Action.disablePort) + && ModelType.configuration.name().equalsIgnoreCase(requestScope)) { + if (!isConnectionPointPresent) { + throw new ValidationException("connectionPoint relatedInstance for Port Configuration"); + } + } + if (requestScope.equals(ModelType.instanceGroup.toString())) { + if (!isRelatedServiceInstancePresent) { + throw new ValidationException("related service instance for instanceGroup request", true); + } + } + if (requestScope.equalsIgnoreCase(ModelType.volumeGroup.name())) { + if (!isRelatedServiceInstancePresent) { + throw new ValidationException("related service instance for volumeGroup request"); + } + if (!isRelatedVnfInstancePresent) { + throw new ValidationException("related vnf instance for volumeGroup request"); + } + serviceInstanceType = serviceModelName; + vnfType = serviceModelName + "/" + vnfModelName; + info.setServiceInstanceType(serviceInstanceType); + info.setVnfType(vnfType); + } else if (requestScope.equalsIgnoreCase(ModelType.vfModule.name())) { + if (!isRelatedServiceInstancePresent) { + throw new ValidationException("related service instance for vfModule request"); + } + if (!isRelatedVnfInstancePresent) { + throw new ValidationException("related vnf instance for vfModule request"); + } + vfModuleModelName = modelInfo.getModelName(); + serviceInstanceType = serviceModelName; + vnfType = serviceModelName + "/" + vnfModelName; + vfModuleType = vnfType + "::" + vfModuleModelName; + sir.setVolumeGroupInstanceId(volumeGroupId); + info.setVfModuleModelName(vfModuleModelName); + info.setVnfType(vnfType); + info.setServiceInstanceType(serviceInstanceType); + info.setVfModuleType(vfModuleType); + } else if (requestScope.equalsIgnoreCase(ModelType.vnf.name())) { + if (!isRelatedServiceInstancePresent) { + throw new ValidationException("related service instance for vnf request"); + } + vnfType = serviceModelName + "/" + sir.getRequestDetails().getModelInfo().getModelCustomizationName(); + info.setVnfType(vnfType); + } + } else if (((requestScope.equalsIgnoreCase(ModelType.vnf.name()) + || requestScope.equalsIgnoreCase(ModelType.volumeGroup.name()) + || requestScope.equalsIgnoreCase(ModelType.vfModule.name()) + || requestScope.equalsIgnoreCase(ModelType.configuration.name())) + && (action == Action.createInstance || action == Action.enablePort || action == Action.disablePort)) + || (reqVersion >= 4 + && (requestScope.equalsIgnoreCase(ModelType.volumeGroup.name()) + || requestScope.equalsIgnoreCase(ModelType.vfModule.name())) + && action == Action.updateInstance + || (requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.scaleOut)) + || (requestScope.equalsIgnoreCase(ModelType.service.name()) + && (action.equals(Action.addRelationships) || action.equals(Action.removeRelationships)))) { + logger.debug("related instance exception"); + throw new ValidationException("related instances"); } - else if ((( requestScope.equalsIgnoreCase(ModelType.vnf.name ()) || requestScope.equalsIgnoreCase(ModelType.volumeGroup.name ()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name ()) - || requestScope.equalsIgnoreCase(ModelType.configuration.name())) && (action == Action.createInstance || action == Action.enablePort || action == Action.disablePort)) || - (reqVersion >= 4 && (requestScope.equalsIgnoreCase(ModelType.volumeGroup.name ()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name ())) && action == Action.updateInstance || - (requestScope.equalsIgnoreCase(ModelType.vfModule.name ()) && action == Action.scaleOut)) || - (requestScope.equalsIgnoreCase(ModelType.service.name()) && (action.equals(Action.addRelationships) || action.equals(Action.removeRelationships)))){ - logger.debug("related instance exception"); - throw new ValidationException ("related instances"); + if (instanceList == null && requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString()) + && action == Action.createInstance) { + throw new ValidationException("relatedInstanceList", true); } - if(instanceList == null && requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString()) && action == Action.createInstance){ - throw new ValidationException("relatedInstanceList", true); - } - info.setVfModuleModelName(vfModuleModelName); - info.setServiceInstanceType(serviceInstanceType); - info.setVnfType(vnfType); - info.setAsdcServiceModelVersion(asdcServiceModelVersion); - info.setVfModuleType(vfModuleType); - return info; - } + info.setVfModuleModelName(vfModuleModelName); + info.setServiceInstanceType(serviceInstanceType); + info.setVnfType(vnfType); + info.setAsdcServiceModelVersion(asdcServiceModelVersion); + info.setVfModuleType(vfModuleType); + return info; + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestInfoValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestInfoValidation.java index bdc9649ecc..483c9db81b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestInfoValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestInfoValidation.java @@ -28,40 +28,44 @@ import org.onap.so.exceptions.ValidationException; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.RequestInfo; -public class RequestInfoValidation implements ValidationRule{ +public class RequestInfoValidation implements ValidationRule { private static boolean empty(String s) { - return (s == null || s.trim().isEmpty()); + return (s == null || s.trim().isEmpty()); } - @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException{ - RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo(); - int reqVersion = info.getReqVersion(); - String requestScope = info.getRequestScope(); - Actions action = info.getAction(); - Boolean aLaCarteFlag = info.getALaCarteFlag(); - - //required for all operations in V4 - if(empty(requestInfo.getRequestorId()) && reqVersion >= 4) { - throw new ValidationException ("requestorId"); + + @Override + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo(); + int reqVersion = info.getReqVersion(); + String requestScope = info.getRequestScope(); + Actions action = info.getAction(); + Boolean aLaCarteFlag = info.getALaCarteFlag(); + + // required for all operations in V4 + if (empty(requestInfo.getRequestorId()) && reqVersion >= 4) { + throw new ValidationException("requestorId"); } - if (empty (requestInfo.getSource ())) { - throw new ValidationException ("source"); + if (empty(requestInfo.getSource())) { + throw new ValidationException("source"); } - if (!empty (requestInfo.getInstanceName ())) { - if (!requestInfo.getInstanceName ().matches (Constants.VALID_INSTANCE_NAME_FORMAT)) { - throw new ValidationException ("instanceName format"); - } + if (!empty(requestInfo.getInstanceName())) { + if (!requestInfo.getInstanceName().matches(Constants.VALID_INSTANCE_NAME_FORMAT)) { + throw new ValidationException("instanceName format"); + } } - if (empty (requestInfo.getProductFamilyId ())) { - // Mandatory for vnf Create(aLaCarte=true), Network Create(aLaCarte=true) and network update - //Mandatory for macro request create service instance - if((requestScope.equalsIgnoreCase (ModelType.vnf.name ()) && action == Action.createInstance) || - (requestScope.equalsIgnoreCase (ModelType.network.name ()) && (action == Action.createInstance || action == Action.updateInstance)) || - (reqVersion > 3 && (aLaCarteFlag != null && !aLaCarteFlag) && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.createInstance)) { - throw new ValidationException ("productFamilyId"); - } + if (empty(requestInfo.getProductFamilyId())) { + // Mandatory for vnf Create(aLaCarte=true), Network Create(aLaCarte=true) and network update + // Mandatory for macro request create service instance + if ((requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.createInstance) + || (requestScope.equalsIgnoreCase(ModelType.network.name()) + && (action == Action.createInstance || action == Action.updateInstance)) + || (reqVersion > 3 && (aLaCarteFlag != null && !aLaCarteFlag) + && requestScope.equalsIgnoreCase(ModelType.service.name()) + && action == Action.createInstance)) { + throw new ValidationException("productFamilyId"); + } } return info; - } -}
\ No newline at end of file + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java index 8e1a6f5d35..edf48227f1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java @@ -27,99 +27,98 @@ import org.onap.so.exceptions.ValidationException; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.RequestParameters; -public class RequestParametersValidation implements ValidationRule{ - private static boolean empty(String s) { - return (s == null || s.trim().isEmpty()); +public class RequestParametersValidation implements ValidationRule { + private static boolean empty(String s) { + return (s == null || s.trim().isEmpty()); } - @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException{ - int reqVersion = info.getReqVersion(); - String requestScope = info.getRequestScope(); - Actions action = info.getAction(); - RequestParameters requestParameters = info.getReqParameters(); - - if (requestScope.equalsIgnoreCase(ModelType.service.name()) && (action == Action.createInstance || action == Action.assignInstance)) { - if (requestParameters == null) { - throw new ValidationException ("requestParameters"); - } - if (empty (requestParameters.getSubscriptionServiceType())) { - throw new ValidationException ("subscriptionServiceType"); - } + + @Override + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + int reqVersion = info.getReqVersion(); + String requestScope = info.getRequestScope(); + Actions action = info.getAction(); + RequestParameters requestParameters = info.getReqParameters(); + + if (requestScope.equalsIgnoreCase(ModelType.service.name()) + && (action == Action.createInstance || action == Action.assignInstance)) { + if (requestParameters == null) { + throw new ValidationException("requestParameters"); + } + if (empty(requestParameters.getSubscriptionServiceType())) { + throw new ValidationException("subscriptionServiceType"); + } } - if(reqVersion >= 4){ - if(Action.addRelationships.equals(action) || Action.removeRelationships.equals(action)) { - if(requestParameters == null || requestParameters.getALaCarte() == null) { - throw new ValidationException ("aLaCarte in requestParameters"); - } - } + if (reqVersion >= 4) { + if (Action.addRelationships.equals(action) || Action.removeRelationships.equals(action)) { + if (requestParameters == null || requestParameters.getALaCarte() == null) { + throw new ValidationException("aLaCarte in requestParameters"); + } + } } - if(requestParameters == null && !requestScope.equalsIgnoreCase(ModelType.service.name())){ - info.setALaCarteFlag(true); - } - if(requestParameters != null){ - if(requestScope.equalsIgnoreCase(ModelType.vnf.name())){ - if(action == Action.updateInstance){ - if(requestParameters.isUsePreload() == null){ - requestParameters.setUsePreload(true); - } - } - if(action == Action.replaceInstance){ - if(requestParameters.getRebuildVolumeGroups() == null){ - requestParameters.setRebuildVolumeGroups(false); - } - } - } - if(requestScope.equalsIgnoreCase(ModelType.vfModule.name())){ - if(action == Action.createInstance || action == Action.updateInstance){ - if(requestParameters.isUsePreload() == null){ - if(reqVersion >= 4){ - if (requestParameters.getALaCarte() == null || requestParameters.getALaCarte() == true) { - requestParameters.setUsePreload(true); - } - else { - requestParameters.setUsePreload(false); - } - } - else { - requestParameters.setUsePreload(true); - } - } - } - } - if(requestScope.equalsIgnoreCase(ModelType.service.name())){ - if(action == Action.createInstance){ - if(requestParameters.isUsePreload() == null){ - if(reqVersion >= 4){ - if (requestParameters.getALaCarte() == null || requestParameters.getALaCarte() == false) { - requestParameters.setUsePreload(false); - } - else { - requestParameters.setUsePreload(true); - } - } - else { - requestParameters.setUsePreload(true); - } - } - } - } - if(reqVersion >= 4){ - if(requestParameters.getALaCarte() != null){ - info.setALaCarteFlag(requestParameters.getALaCarte()); - }else if(requestScope.equalsIgnoreCase(ModelType.service.name())){ - if(action == Action.createInstance || action == Action.deleteInstance || action == Action.activateInstance || action == Action.deactivateInstance){ - if(requestParameters.getALaCarte() == null){ - requestParameters.setaLaCarte(false); - info.setALaCarteFlag(requestParameters.getALaCarte()); - } - } - }else{ - info.setALaCarteFlag(true); - } - }else{ - info.setALaCarteFlag(true); - } + if (requestParameters == null && !requestScope.equalsIgnoreCase(ModelType.service.name())) { + info.setALaCarteFlag(true); } - return info; - } -}
\ No newline at end of file + if (requestParameters != null) { + if (requestScope.equalsIgnoreCase(ModelType.vnf.name())) { + if (action == Action.updateInstance) { + if (requestParameters.isUsePreload() == null) { + requestParameters.setUsePreload(true); + } + } + if (action == Action.replaceInstance) { + if (requestParameters.getRebuildVolumeGroups() == null) { + requestParameters.setRebuildVolumeGroups(false); + } + } + } + if (requestScope.equalsIgnoreCase(ModelType.vfModule.name())) { + if (action == Action.createInstance || action == Action.updateInstance) { + if (requestParameters.isUsePreload() == null) { + if (reqVersion >= 4) { + if (requestParameters.getALaCarte() == null || requestParameters.getALaCarte() == true) { + requestParameters.setUsePreload(true); + } else { + requestParameters.setUsePreload(false); + } + } else { + requestParameters.setUsePreload(true); + } + } + } + } + if (requestScope.equalsIgnoreCase(ModelType.service.name())) { + if (action == Action.createInstance) { + if (requestParameters.isUsePreload() == null) { + if (reqVersion >= 4) { + if (requestParameters.getALaCarte() == null || requestParameters.getALaCarte() == false) { + requestParameters.setUsePreload(false); + } else { + requestParameters.setUsePreload(true); + } + } else { + requestParameters.setUsePreload(true); + } + } + } + } + if (reqVersion >= 4) { + if (requestParameters.getALaCarte() != null) { + info.setALaCarteFlag(requestParameters.getALaCarte()); + } else if (requestScope.equalsIgnoreCase(ModelType.service.name())) { + if (action == Action.createInstance || action == Action.deleteInstance + || action == Action.activateInstance || action == Action.deactivateInstance) { + if (requestParameters.getALaCarte() == null) { + requestParameters.setaLaCarte(false); + info.setALaCarteFlag(requestParameters.getALaCarte()); + } + } + } else { + info.setALaCarteFlag(true); + } + } else { + info.setALaCarteFlag(true); + } + } + return info; + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestScopeValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestScopeValidation.java index 51a9afe200..635a715558 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestScopeValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestScopeValidation.java @@ -25,25 +25,25 @@ import org.onap.so.exceptions.ValidationException; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.RequestInfo; -public class RequestScopeValidation implements ValidationRule{ - @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException{ - ModelInfo modelInfo = info.getSir().getRequestDetails().getModelInfo(); - RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo(); - String requestScope; - +public class RequestScopeValidation implements ValidationRule { + @Override + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + ModelInfo modelInfo = info.getSir().getRequestDetails().getModelInfo(); + RequestInfo requestInfo = info.getSir().getRequestDetails().getRequestInfo(); + String requestScope; + if (modelInfo == null) { - throw new ValidationException ("model-info"); + throw new ValidationException("model-info"); + } + if (requestInfo == null) { + throw new ValidationException("requestInfo"); } - if (requestInfo == null) { - throw new ValidationException ("requestInfo"); - } - info.setRequestInfo(requestInfo); - if (modelInfo.getModelType () == null) { - throw new ValidationException ("modelType"); + info.setRequestInfo(requestInfo); + if (modelInfo.getModelType() == null) { + throw new ValidationException("modelType"); } requestScope = info.getSir().getRequestDetails().getModelInfo().getModelType().name(); info.setRequestScope(requestScope); return info; - } -}
\ No newline at end of file + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/SubscriberInfoValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/SubscriberInfoValidation.java index d9298f5f4e..4f68ef319c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/SubscriberInfoValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/SubscriberInfoValidation.java @@ -27,25 +27,27 @@ import org.onap.so.exceptions.ValidationException; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.SubscriberInfo; -public class SubscriberInfoValidation implements ValidationRule{ +public class SubscriberInfoValidation implements ValidationRule { private static boolean empty(String s) { - return (s == null || s.trim().isEmpty()); + return (s == null || s.trim().isEmpty()); } - @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException{ - String requestScope = info.getRequestScope(); - int reqVersion = info.getReqVersion(); - Actions action = info.getAction(); - - if (reqVersion > 4 && requestScope.equalsIgnoreCase (ModelType.service.name ()) && action == Action.createInstance || action == Action.assignInstance) { - SubscriberInfo subscriberInfo = info.getSir().getRequestDetails ().getSubscriberInfo(); - if (subscriberInfo == null) { - throw new ValidationException ("subscriberInfo"); - } - if (empty (subscriberInfo.getGlobalSubscriberId ())) { - throw new ValidationException ("globalSubscriberId"); - } + + @Override + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + String requestScope = info.getRequestScope(); + int reqVersion = info.getReqVersion(); + Actions action = info.getAction(); + + if (reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.createInstance + || action == Action.assignInstance) { + SubscriberInfo subscriberInfo = info.getSir().getRequestDetails().getSubscriberInfo(); + if (subscriberInfo == null) { + throw new ValidationException("subscriberInfo"); + } + if (empty(subscriberInfo.getGlobalSubscriberId())) { + throw new ValidationException("globalSubscriberId"); + } } return info; - } -}
\ No newline at end of file + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java index 894e488e92..067e8611d0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java @@ -23,7 +23,6 @@ package org.onap.so.apihandlerinfra.validation; import java.util.ArrayList; import java.util.List; - import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.Actions; import org.onap.so.exceptions.ValidationException; @@ -33,103 +32,107 @@ import org.onap.so.serviceinstancebeans.Service; import org.onap.so.serviceinstancebeans.VfModules; import org.onap.so.serviceinstancebeans.Vnfs; -public class UserParamsValidation implements ValidationRule{ - @Override - public ValidationInformation validate(ValidationInformation info) throws ValidationException{ - Service validate = info.getUserParams(); - Actions action = info.getAction(); - - if(validate.getModelInfo() == null){ - throw new ValidationException ("modelInfo in userParams", true); - }else if(validate.getModelInfo().getModelType() == null){ - throw new ValidationException("modelType in userParams service modelInfo", true); - }else if(validate.getModelInfo().getModelVersionId() == null){ - throw new ValidationException("modelVersionId in userParams service modelInfo", true); - } - modelInfoValidation(info.getSir().getRequestDetails().getModelInfo(), validate.getModelInfo()); - if(validate.getInstanceName() != null && info.getRequestInfo().getInstanceName() != null){ - instanceNameValidation(info, validate); - } - for(Vnfs vnf : validate.getResources().getVnfs()){ - if(vnf.getModelInfo() == null){ - throw new ValidationException ("modelInfo in userParams vnf resources", true); - }else if(vnf.getModelInfo().getModelCustomizationId() == null){ - throw new ValidationException ("modelCustomizationId in userParams vnf resources", true); - }else if(vnf.getModelInfo().getModelVersionId() == null){ - throw new ValidationException("modelVersionId in userParams vnf resources", true); - } - if(vnf.getCloudConfiguration() == null){ - throw new ValidationException ("cloudConfiguration in userParams vnf resources", true); - } - if(action == Action.createInstance || action == Action.assignInstance){ - if(vnf.getPlatform() == null){ - throw new ValidationException ("platform in userParams vnf resources", true); - }if(vnf.getProductFamilyId() == null){ - throw new ValidationException ("productFamilyId in userParams vnf resources", true); - } - } - if (vnf.getPlatform() != null && vnf.getPlatform().getPlatformName() == null){ - throw new ValidationException ("platformName in userParams vnf resources", true); - } - if(vnf.getVfModules().isEmpty()){ - throw new ValidationException ("vfModules in userParams vnf resources", true); - } - for(VfModules vfModules : vnf.getVfModules()){ - if(vfModules.getModelInfo() == null){ - throw new ValidationException ("modelInfo in userParams vfModules resources", true); - }else if(vfModules.getModelInfo().getModelCustomizationId() == null){ - throw new ValidationException ("modelCustomizationId in userParams vfModule resources", true); - }else if(vfModules.getModelInfo().getModelVersionId() == null){ - throw new ValidationException("modelVersionId in userParams vfModule resources", true); - } - } - } - - List<Networks> validateNetworks = new ArrayList<>(); - validateNetworks = validate.getResources().getNetworks(); - if(validateNetworks != null){ - for(Networks networks : validateNetworks){ - if(networks.getModelInfo() == null){ - throw new ValidationException ("modelInfo in userParams network resources", true); - }else if(networks.getModelInfo().getModelCustomizationId() == null){ - throw new ValidationException ("modelCustomizationId in userParams network resources", true); - }else if(networks.getModelInfo().getModelVersionId() == null){ - throw new ValidationException("modelVersionId in userParams network resources", true); - } - if(networks.getCloudConfiguration() == null){ - throw new ValidationException ("cloudConfiguration in userParams network resources", true); - } - } - } - return info; - } - public void instanceNameValidation(ValidationInformation info, Service validate) throws ValidationException{ - if(!info.getRequestInfo().getInstanceName().equals(validate.getInstanceName())){ - throw new ValidationException("instanceName in requestInfo", "instanceName in userParams service"); - } - } - public void modelInfoValidation(ModelInfo info, ModelInfo userParamInfo) throws ValidationException{ - if(!info.getModelType().equals(userParamInfo.getModelType())){ - throw new ValidationException("modelType in modelInfo", "modelType in userParams service"); - } - if((info.getModelInvariantId() != null && userParamInfo.getModelInvariantId() != null) && - (!info.getModelInvariantId().equals(userParamInfo.getModelInvariantId()))){ - throw new ValidationException("modelInvariantId in modelInfo", "modelInvariantId in userParams service"); - } - if(!info.getModelVersionId().equals(userParamInfo.getModelVersionId())){ - throw new ValidationException("modelVersionId in modelInfo", "modelVersionId in userParams service"); - } - if((info.getModelName() != null && userParamInfo.getModelName() != null) && - (!info.getModelName().equals(userParamInfo.getModelName()))){ - throw new ValidationException("modelName in modelInfo", "modelName in userParams service"); - } - if((info.getModelVersion() != null && userParamInfo.getModelVersion() != null) && - (!info.getModelVersion().equals(userParamInfo.getModelVersion()))){ - throw new ValidationException("modelVersion in modelInfo", "modelVersion in userParams service"); - } - if((info.getModelCustomizationId() != null && userParamInfo.getModelCustomizationId() != null) && - (!info.getModelCustomizationId().equals(userParamInfo.getModelCustomizationId()))){ - throw new ValidationException("modelCustomizationId in modelInfo", "modelCustomizationId in userParams service"); - } - } -}
\ No newline at end of file +public class UserParamsValidation implements ValidationRule { + @Override + public ValidationInformation validate(ValidationInformation info) throws ValidationException { + Service validate = info.getUserParams(); + Actions action = info.getAction(); + + if (validate.getModelInfo() == null) { + throw new ValidationException("modelInfo in userParams", true); + } else if (validate.getModelInfo().getModelType() == null) { + throw new ValidationException("modelType in userParams service modelInfo", true); + } else if (validate.getModelInfo().getModelVersionId() == null) { + throw new ValidationException("modelVersionId in userParams service modelInfo", true); + } + modelInfoValidation(info.getSir().getRequestDetails().getModelInfo(), validate.getModelInfo()); + if (validate.getInstanceName() != null && info.getRequestInfo().getInstanceName() != null) { + instanceNameValidation(info, validate); + } + for (Vnfs vnf : validate.getResources().getVnfs()) { + if (vnf.getModelInfo() == null) { + throw new ValidationException("modelInfo in userParams vnf resources", true); + } else if (vnf.getModelInfo().getModelCustomizationId() == null) { + throw new ValidationException("modelCustomizationId in userParams vnf resources", true); + } else if (vnf.getModelInfo().getModelVersionId() == null) { + throw new ValidationException("modelVersionId in userParams vnf resources", true); + } + if (vnf.getCloudConfiguration() == null) { + throw new ValidationException("cloudConfiguration in userParams vnf resources", true); + } + if (action == Action.createInstance || action == Action.assignInstance) { + if (vnf.getPlatform() == null) { + throw new ValidationException("platform in userParams vnf resources", true); + } + if (vnf.getProductFamilyId() == null) { + throw new ValidationException("productFamilyId in userParams vnf resources", true); + } + } + if (vnf.getPlatform() != null && vnf.getPlatform().getPlatformName() == null) { + throw new ValidationException("platformName in userParams vnf resources", true); + } + if (vnf.getVfModules().isEmpty()) { + throw new ValidationException("vfModules in userParams vnf resources", true); + } + for (VfModules vfModules : vnf.getVfModules()) { + if (vfModules.getModelInfo() == null) { + throw new ValidationException("modelInfo in userParams vfModules resources", true); + } else if (vfModules.getModelInfo().getModelCustomizationId() == null) { + throw new ValidationException("modelCustomizationId in userParams vfModule resources", true); + } else if (vfModules.getModelInfo().getModelVersionId() == null) { + throw new ValidationException("modelVersionId in userParams vfModule resources", true); + } + } + } + + List<Networks> validateNetworks = new ArrayList<>(); + validateNetworks = validate.getResources().getNetworks(); + if (validateNetworks != null) { + for (Networks networks : validateNetworks) { + if (networks.getModelInfo() == null) { + throw new ValidationException("modelInfo in userParams network resources", true); + } else if (networks.getModelInfo().getModelCustomizationId() == null) { + throw new ValidationException("modelCustomizationId in userParams network resources", true); + } else if (networks.getModelInfo().getModelVersionId() == null) { + throw new ValidationException("modelVersionId in userParams network resources", true); + } + if (networks.getCloudConfiguration() == null) { + throw new ValidationException("cloudConfiguration in userParams network resources", true); + } + } + } + return info; + } + + public void instanceNameValidation(ValidationInformation info, Service validate) throws ValidationException { + if (!info.getRequestInfo().getInstanceName().equals(validate.getInstanceName())) { + throw new ValidationException("instanceName in requestInfo", "instanceName in userParams service"); + } + } + + public void modelInfoValidation(ModelInfo info, ModelInfo userParamInfo) throws ValidationException { + if (!info.getModelType().equals(userParamInfo.getModelType())) { + throw new ValidationException("modelType in modelInfo", "modelType in userParams service"); + } + if ((info.getModelInvariantId() != null && userParamInfo.getModelInvariantId() != null) + && (!info.getModelInvariantId().equals(userParamInfo.getModelInvariantId()))) { + throw new ValidationException("modelInvariantId in modelInfo", "modelInvariantId in userParams service"); + } + if (!info.getModelVersionId().equals(userParamInfo.getModelVersionId())) { + throw new ValidationException("modelVersionId in modelInfo", "modelVersionId in userParams service"); + } + if ((info.getModelName() != null && userParamInfo.getModelName() != null) + && (!info.getModelName().equals(userParamInfo.getModelName()))) { + throw new ValidationException("modelName in modelInfo", "modelName in userParams service"); + } + if ((info.getModelVersion() != null && userParamInfo.getModelVersion() != null) + && (!info.getModelVersion().equals(userParamInfo.getModelVersion()))) { + throw new ValidationException("modelVersion in modelInfo", "modelVersion in userParams service"); + } + if ((info.getModelCustomizationId() != null && userParamInfo.getModelCustomizationId() != null) + && (!info.getModelCustomizationId().equals(userParamInfo.getModelCustomizationId()))) { + throw new ValidationException("modelCustomizationId in modelInfo", + "modelCustomizationId in userParams service"); + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationInformation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationInformation.java index 7fc9567123..68b2a78a85 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationInformation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationInformation.java @@ -22,7 +22,6 @@ package org.onap.so.apihandlerinfra.validation; import java.util.HashMap; - import org.onap.so.apihandlerinfra.Actions; import org.onap.so.serviceinstancebeans.LineOfBusiness; import org.onap.so.serviceinstancebeans.OwningEntity; @@ -33,148 +32,186 @@ import org.onap.so.serviceinstancebeans.RequestParameters; import org.onap.so.serviceinstancebeans.Service; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; -public class ValidationInformation{ - ServiceInstancesRequest sir; - HashMap<String,String> instanceIdMap; - Actions action; - int reqVersion; - String requestScope; - Boolean aLaCarteFlag; - RequestParameters requestParameters; - RequestInfo requestInfo; - String serviceInstanceType; - String vfModuleModelName; - String vnfType; - String asdcServiceModelVersion; - String vfModuleType; - String networkType; - Platform platform; - LineOfBusiness lob; - Project project; - OwningEntity owningEntity; - Service userParams; - - public ValidationInformation(ServiceInstancesRequest sir, HashMap<String,String> instanceIdMap, - Actions action, int reqVersion, Boolean aLaCarteFlag, RequestParameters requestParameters){ - this.sir = sir; - this.instanceIdMap = instanceIdMap; - this.action = action; - this.reqVersion = reqVersion; - this.aLaCarteFlag = aLaCarteFlag; - this.requestParameters = requestParameters; - } - public ServiceInstancesRequest getSir(){ - return this.sir; - } - public void setSir(ServiceInstancesRequest value){ - this.sir = value; - } - public HashMap<String, String> getInstanceIdMap(){ - return this.instanceIdMap; - } - public void setInstanceIdMap(HashMap<String, String> value){ - this.instanceIdMap = value; - } - public Actions getAction(){ - return this.action; - } - public void setAction(Actions value){ - this.action = value; - } - public RequestInfo getRequestInfo(){ - return this.requestInfo; - } - public void setRequestInfo(RequestInfo value){ - this.requestInfo = value; - } - public int getReqVersion(){ - return this.reqVersion; - } - public void setReqVersion(int value){ - this.reqVersion = value; - } - public String getRequestScope(){ - return this.requestScope; - } - public void setRequestScope(String value){ - this.requestScope = value; - } - public Boolean getALaCarteFlag(){ - return this.aLaCarteFlag; - } - public void setALaCarteFlag(Boolean value){ - this.aLaCarteFlag = value; - } - public RequestParameters getReqParameters(){ - return this.requestParameters; - } - public void setReqParameters(RequestParameters value){ - this.requestParameters = value; - } - public String getServiceInstanceType(){ - return this.serviceInstanceType; - } - public void setServiceInstanceType(String value){ - this.serviceInstanceType = value; - } - public String getVfModuleModelName(){ - return this.vfModuleModelName; - } - public void setVfModuleModelName(String value){ - this.vfModuleModelName = value; - } - public String getVnfType(){ - return this.vnfType; - } - public void setVnfType(String value){ - this.vnfType = value; - } - public String getAsdcServiceModelVersion(){ - return this.asdcServiceModelVersion; - } - public void setAsdcServiceModelVersion(String value){ - this.asdcServiceModelVersion = value; - } - public String getVfModuleType(){ - return this.vfModuleType; - } - public void setVfModuleType(String value){ - this.vfModuleType = value; - } - public String getNetworkType(){ - return this.networkType; - } - public void setNetworkType(String value){ - this.networkType = value; - } - public Platform getPlatform(){ - return this.platform; - } - public void setPlatform(Platform value){ - this.platform = value; - } - public LineOfBusiness getLOB(){ - return this.lob; - } - public void setLOB(LineOfBusiness value){ - this.lob = value; - } - public Project getProject(){ - return this.project; - } - public void setProject(Project value){ - this.project = value; - } - public OwningEntity getOE(){ - return this.owningEntity; - } - public void setOE(OwningEntity value){ - this.owningEntity = value; - } - public Service getUserParams(){ - return this.userParams; - } - public void setUserParams(Service value){ - this.userParams = value; - } -}
\ No newline at end of file +public class ValidationInformation { + ServiceInstancesRequest sir; + HashMap<String, String> instanceIdMap; + Actions action; + int reqVersion; + String requestScope; + Boolean aLaCarteFlag; + RequestParameters requestParameters; + RequestInfo requestInfo; + String serviceInstanceType; + String vfModuleModelName; + String vnfType; + String asdcServiceModelVersion; + String vfModuleType; + String networkType; + Platform platform; + LineOfBusiness lob; + Project project; + OwningEntity owningEntity; + Service userParams; + + public ValidationInformation(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, + int reqVersion, Boolean aLaCarteFlag, RequestParameters requestParameters) { + this.sir = sir; + this.instanceIdMap = instanceIdMap; + this.action = action; + this.reqVersion = reqVersion; + this.aLaCarteFlag = aLaCarteFlag; + this.requestParameters = requestParameters; + } + + public ServiceInstancesRequest getSir() { + return this.sir; + } + + public void setSir(ServiceInstancesRequest value) { + this.sir = value; + } + + public HashMap<String, String> getInstanceIdMap() { + return this.instanceIdMap; + } + + public void setInstanceIdMap(HashMap<String, String> value) { + this.instanceIdMap = value; + } + + public Actions getAction() { + return this.action; + } + + public void setAction(Actions value) { + this.action = value; + } + + public RequestInfo getRequestInfo() { + return this.requestInfo; + } + + public void setRequestInfo(RequestInfo value) { + this.requestInfo = value; + } + + public int getReqVersion() { + return this.reqVersion; + } + + public void setReqVersion(int value) { + this.reqVersion = value; + } + + public String getRequestScope() { + return this.requestScope; + } + + public void setRequestScope(String value) { + this.requestScope = value; + } + + public Boolean getALaCarteFlag() { + return this.aLaCarteFlag; + } + + public void setALaCarteFlag(Boolean value) { + this.aLaCarteFlag = value; + } + + public RequestParameters getReqParameters() { + return this.requestParameters; + } + + public void setReqParameters(RequestParameters value) { + this.requestParameters = value; + } + + public String getServiceInstanceType() { + return this.serviceInstanceType; + } + + public void setServiceInstanceType(String value) { + this.serviceInstanceType = value; + } + + public String getVfModuleModelName() { + return this.vfModuleModelName; + } + + public void setVfModuleModelName(String value) { + this.vfModuleModelName = value; + } + + public String getVnfType() { + return this.vnfType; + } + + public void setVnfType(String value) { + this.vnfType = value; + } + + public String getAsdcServiceModelVersion() { + return this.asdcServiceModelVersion; + } + + public void setAsdcServiceModelVersion(String value) { + this.asdcServiceModelVersion = value; + } + + public String getVfModuleType() { + return this.vfModuleType; + } + + public void setVfModuleType(String value) { + this.vfModuleType = value; + } + + public String getNetworkType() { + return this.networkType; + } + + public void setNetworkType(String value) { + this.networkType = value; + } + + public Platform getPlatform() { + return this.platform; + } + + public void setPlatform(Platform value) { + this.platform = value; + } + + public LineOfBusiness getLOB() { + return this.lob; + } + + public void setLOB(LineOfBusiness value) { + this.lob = value; + } + + public Project getProject() { + return this.project; + } + + public void setProject(Project value) { + this.project = value; + } + + public OwningEntity getOE() { + return this.owningEntity; + } + + public void setOE(OwningEntity value) { + this.owningEntity = value; + } + + public Service getUserParams() { + return this.userParams; + } + + public void setUserParams(Service value) { + this.userParams = value; + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationRule.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationRule.java index a5d85f6533..e8073bd1d1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationRule.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/ValidationRule.java @@ -23,6 +23,6 @@ package org.onap.so.apihandlerinfra.validation; import org.onap.so.exceptions.ValidationException; -public interface ValidationRule{ - ValidationInformation validate(ValidationInformation info)throws ValidationException; -}
\ No newline at end of file +public interface ValidationRule { + ValidationInformation validate(ValidationInformation info) throws ValidationException; +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ActionType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ActionType.java index 15fe0a5be3..796db8c32a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ActionType.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ActionType.java @@ -19,10 +19,10 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // @@ -34,10 +34,13 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for action-type. + * <p> + * Java class for action-type. * - * <p>The following schema fragment specifies the expected content contained within this class. * <p> + * The following schema fragment specifies the expected content contained within this class. + * <p> + * * <pre> * <simpleType name="action-type"> * <restriction base="{http://www.w3.org/2001/XMLSchema}string"> @@ -59,15 +62,7 @@ import javax.xml.bind.annotation.XmlType; @XmlEnum public enum ActionType { - CREATE, - SETSTATUS, - REPLACE, - UPDATE, - DELETE, - CREATE_VF_MODULE, - UPDATE_VF_MODULE, - DELETE_VF_MODULE, - NOT_PROVIDED; + CREATE, SETSTATUS, REPLACE, UPDATE, DELETE, CREATE_VF_MODULE, UPDATE_VF_MODULE, DELETE_VF_MODULE, NOT_PROVIDED; public String value() { return name(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ModelType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ModelType.java index 3f708c49d5..e24ecd4eac 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ModelType.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ModelType.java @@ -22,11 +22,7 @@ package org.onap.so.apihandlerinfra.vnfbeans; /* * Enum for Status values returned by API Handler to Tail-F -*/ + */ public enum ModelType { - service, - vnf, - vfModule, - volumeGroup, - network + service, vnf, vfModule, volumeGroup, network } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ObjectFactory.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ObjectFactory.java index 72be61105b..2236b09f2a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ObjectFactory.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/ObjectFactory.java @@ -19,10 +19,10 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // @@ -36,31 +36,28 @@ import javax.xml.namespace.QName; /** - * This object contains factory methods for each - * Java content interface and Java element interface - * generated in the org.onap.so.apihandlerinfra.vnfbeans1 package. - * <p>An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. + * This object contains factory methods for each Java content interface and Java element interface generated in the + * org.onap.so.apihandlerinfra.vnfbeans1 package. + * <p> + * An ObjectFactory allows you to programatically construct new instances of the Java representation for XML content. + * The Java representation of XML content can consist of schema derived interfaces and classes representing the binding + * of schema type definitions, element declarations and model groups. Factory methods for each of these are provided in + * this class. * */ @XmlRegistry public class ObjectFactory { private final static QName _VnfParams_QNAME = new QName("http://org.onap/so/infra/vnf-request/v1", "vnf-params"); - private final static QName _NetworkParams_QNAME = new QName("http://org.onap/so/infra/vnf-request/v1", "network-params"); + private final static QName _NetworkParams_QNAME = + new QName("http://org.onap/so/infra/vnf-request/v1", "network-params"); /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.onap.so.apihandlerinfra.vnfbeans1 + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: + * org.onap.so.apihandlerinfra.vnfbeans1 * */ - public ObjectFactory() { - } + public ObjectFactory() {} /** * Create an instance of {@link VnfInputs } @@ -102,7 +99,7 @@ public class ObjectFactory { return new VnfRequest(); } - + /** * Create an instance of {@link VnfTypes } * @@ -118,7 +115,7 @@ public class ObjectFactory { public VnfRequests createVnfRequests() { return new VnfRequests(); } - + /** * Create an instance of {@link VfModuleModelName } * @@ -126,7 +123,7 @@ public class ObjectFactory { public VfModuleModelName createVfModuleModelName() { return new VfModuleModelName(); } - + /** * Create an instance of {@link VfModuleModelNames } * @@ -135,9 +132,8 @@ public class ObjectFactory { return new VfModuleModelNames(); } - - - + + /** * Create an instance of {@link JAXBElement }{@code <}{@link Object }{@code >}} * diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/RequestInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/RequestInfo.java index dc8457c6a4..2af0a02d17 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/RequestInfo.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/RequestInfo.java @@ -37,9 +37,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -63,16 +65,8 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "requestId", - "action", - "requestStatus", - "statusMessage", - "progress", - "startTime", - "endTime", - "source" -}) +@XmlType(name = "", propOrder = {"requestId", "action", "requestStatus", "statusMessage", "progress", "startTime", + "endTime", "source"}) @XmlRootElement(name = "request-info") public class RequestInfo { @@ -94,9 +88,7 @@ public class RequestInfo { /** * Gets the value of the requestId property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public String getRequestId() { @@ -106,9 +98,7 @@ public class RequestInfo { /** * Sets the value of the requestId property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setRequestId(String value) { @@ -118,9 +108,7 @@ public class RequestInfo { /** * Gets the value of the action property. * - * @return - * possible object is - * {@link ActionType } + * @return possible object is {@link ActionType } * */ public ActionType getAction() { @@ -130,9 +118,7 @@ public class RequestInfo { /** * Sets the value of the action property. * - * @param value - * allowed object is - * {@link ActionType } + * @param value allowed object is {@link ActionType } * */ public void setAction(ActionType value) { @@ -142,9 +128,7 @@ public class RequestInfo { /** * Gets the value of the requestStatus property. * - * @return - * possible object is - * {@link RequestStatusType } + * @return possible object is {@link RequestStatusType } * */ public RequestStatusType getRequestStatus() { @@ -154,9 +138,7 @@ public class RequestInfo { /** * Sets the value of the requestStatus property. * - * @param value - * allowed object is - * {@link RequestStatusType } + * @param value allowed object is {@link RequestStatusType } * */ public void setRequestStatus(RequestStatusType value) { @@ -166,9 +148,7 @@ public class RequestInfo { /** * Gets the value of the statusMessage property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public String getStatusMessage() { @@ -178,9 +158,7 @@ public class RequestInfo { /** * Sets the value of the statusMessage property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setStatusMessage(String value) { @@ -190,9 +168,7 @@ public class RequestInfo { /** * Gets the value of the progress property. * - * @return - * possible object is - * {@link Integer } + * @return possible object is {@link Integer } * */ public String getProgress() { @@ -202,9 +178,7 @@ public class RequestInfo { /** * Sets the value of the progress property. * - * @param value - * allowed object is - * {@link Integer } + * @param value allowed object is {@link Integer } * */ public void setProgress(String value) { @@ -214,9 +188,7 @@ public class RequestInfo { /** * Gets the value of the startTime property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public String getStartTime() { @@ -226,9 +198,7 @@ public class RequestInfo { /** * Sets the value of the startTime property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setStartTime(String value) { @@ -238,9 +208,7 @@ public class RequestInfo { /** * Gets the value of the endTime property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public String getEndTime() { @@ -250,9 +218,7 @@ public class RequestInfo { /** * Sets the value of the endTime property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setEndTime(String value) { @@ -262,9 +228,7 @@ public class RequestInfo { /** * Gets the value of the source property. * - * @return - * possible object is - * {@link String } + * @return possible object is {@link String } * */ public String getSource() { @@ -274,9 +238,7 @@ public class RequestInfo { /** * Sets the value of the source property. * - * @param value - * allowed object is - * {@link String } + * @param value allowed object is {@link String } * */ public void setSource(String value) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/RequestStatusType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/RequestStatusType.java index 8c98b9f801..d7250c6ebf 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/RequestStatusType.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/RequestStatusType.java @@ -34,10 +34,13 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for request-status-type. + * <p> + * Java class for request-status-type. * - * <p>The following schema fragment specifies the expected content contained within this class. * <p> + * The following schema fragment specifies the expected content contained within this class. + * <p> + * * <pre> * <simpleType name="request-status-type"> * <restriction base="{http://www.w3.org/2001/XMLSchema}string"> @@ -53,12 +56,7 @@ import javax.xml.bind.annotation.XmlType; @XmlEnum public enum RequestStatusType { - COMPLETE, - FAILED, - IN_PROGRESS, - PENDING, - TIMEOUT, - UNLOCKED; + COMPLETE, FAILED, IN_PROGRESS, PENDING, TIMEOUT, UNLOCKED; public String value() { return name(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VfModuleModelName.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VfModuleModelName.java index 74065482f8..1bf99b1362 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VfModuleModelName.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VfModuleModelName.java @@ -19,10 +19,10 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // @@ -38,9 +38,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -63,40 +65,31 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "modelName", - "modelVersion", - "modelInvariantUuid", - "isBase", - "id", - "description", - "asdcServiceModelVersion" -}) +@XmlType(name = "", propOrder = {"modelName", "modelVersion", "modelInvariantUuid", "isBase", "id", "description", + "asdcServiceModelVersion"}) @XmlRootElement(name = "vf-module-model-name") public class VfModuleModelName { - @XmlElement(name="model-name", required = true) + @XmlElement(name = "model-name", required = true) protected String modelName; - @XmlElement(name="model-version", required = true) + @XmlElement(name = "model-version", required = true) protected String modelVersion; - @XmlElement(name="model-invariant-uuid", required = true) + @XmlElement(name = "model-invariant-uuid", required = true) protected String modelInvariantUuid; - @XmlElement(name="is-base", required = true) + @XmlElement(name = "is-base", required = true) protected Boolean isBase; - @XmlElement(name="id", required = true) + @XmlElement(name = "id", required = true) protected String id; - @XmlElement(name="description", required = true) + @XmlElement(name = "description", required = true) protected String description; - @XmlElement(name="asdc-service-model-version", required = true) + @XmlElement(name = "asdc-service-model-version", required = true) protected String asdcServiceModelVersion; /** * Gets the value of the modelName property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getModelName() { return modelName; @@ -105,22 +98,18 @@ public class VfModuleModelName { /** * Sets the value of the modelName property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setModelName(String value) { this.modelName = value; } - + /** * Gets the value of the modelVersion property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getModelVersion() { return modelVersion; @@ -129,22 +118,18 @@ public class VfModuleModelName { /** * Sets the value of the modelVersion property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setModelVersion(String value) { this.modelVersion = value; } - + /** * Gets the value of the modelInvariantUuid property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getModelInvariantUuid() { return modelInvariantUuid; @@ -153,22 +138,18 @@ public class VfModuleModelName { /** * Sets the value of the modelInvariantUuid property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setModelInvariantUuid(String value) { this.modelInvariantUuid = value; } - + /** * Gets the value of the isBase property. * - * @return - * possible object is - * {@link Boolean } - * + * @return possible object is {@link Boolean } + * */ public Boolean getIsBase() { return isBase; @@ -177,10 +158,8 @@ public class VfModuleModelName { /** * Sets the value of the isBase property. * - * @param value - * allowed object is - * {@link Boolean } - * + * @param value allowed object is {@link Boolean } + * */ public void setIsBase(Boolean value) { this.isBase = value; @@ -189,10 +168,8 @@ public class VfModuleModelName { /** * Gets the value of the id property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getId() { return id; @@ -201,10 +178,8 @@ public class VfModuleModelName { /** * Sets the value of the id property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setId(String value) { this.id = value; @@ -213,10 +188,8 @@ public class VfModuleModelName { /** * Gets the value of the description property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getDescription() { return description; @@ -225,22 +198,18 @@ public class VfModuleModelName { /** * Sets the value of the description property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setDescription(String value) { this.description = value; } - + /** * Gets the value of the asdcServiceModelVersion property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getAsdcServiceModelVersion() { return asdcServiceModelVersion; @@ -249,10 +218,8 @@ public class VfModuleModelName { /** * Sets the value of the asdcServiceModelVersion property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setAsdcServiceModelVersion(String value) { this.asdcServiceModelVersion = value; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VfModuleModelNames.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VfModuleModelNames.java index 9904884620..2b334f262d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VfModuleModelNames.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VfModuleModelNames.java @@ -19,10 +19,10 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // @@ -31,7 +31,6 @@ package org.onap.so.apihandlerinfra.vnfbeans; import java.util.ArrayList; import java.util.List; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -40,9 +39,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -59,9 +60,7 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "vfModuleModelName" -}) +@XmlType(name = "", propOrder = {"vfModuleModelName"}) @XmlRootElement(name = "vf-module-model-names") public class VfModuleModelNames { @@ -72,21 +71,20 @@ public class VfModuleModelNames { * Gets the value of the vfModuleModelName property. * * <p> - * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a <CODE>set</CODE> method for the vnfType property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to + * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for + * the vnfType property. * * <p> * For example, to add a new item, do as follows: + * * <pre> - * getVfModuleModelName().add(newItem); + * getVfModuleModelName().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list - * {@link VfModuleModelName } + * Objects of the following type(s) are allowed in the list {@link VfModuleModelName } * * */ @@ -96,9 +94,9 @@ public class VfModuleModelNames { } return this.vfModuleModelName; } - + public void setVfModuleModelName(List<VfModuleModelName> vfModuleModelName) { - this.vfModuleModelName=vfModuleModelName; + this.vfModuleModelName = vfModuleModelName; } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfInputs.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfInputs.java index 8816d0d4fc..f6b539dbe5 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfInputs.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfInputs.java @@ -19,10 +19,10 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // @@ -37,9 +37,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -81,32 +83,14 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "vnfId", - "vfModuleId", - "vnfName", - "vfModuleName", - "vnfType", - "vfModuleModelName", - "asdcServiceModelVersion", - "serviceInstanceId", - "backoutOnFailure", - "serviceType", - "serviceId", - "aicNodeClli", - "aicCloudRegion", - "tenantId", - "provStatus", - "volumeGroupName", - "volumeGroupId", - // BEGIN - elements valid only on BPMN interface - "personaModelId", - "personaModelVersion", - "isBaseVfModule", - "vnfPersonaModelId", - "vnfPersonaModelVersion" - // END - elements valid only on BPMN interface -}) +@XmlType(name = "", + propOrder = {"vnfId", "vfModuleId", "vnfName", "vfModuleName", "vnfType", "vfModuleModelName", + "asdcServiceModelVersion", "serviceInstanceId", "backoutOnFailure", "serviceType", "serviceId", + "aicNodeClli", "aicCloudRegion", "tenantId", "provStatus", "volumeGroupName", "volumeGroupId", + // BEGIN - elements valid only on BPMN interface + "personaModelId", "personaModelVersion", "isBaseVfModule", "vnfPersonaModelId", "vnfPersonaModelVersion" + // END - elements valid only on BPMN interface + }) @XmlRootElement(name = "vnf-inputs") public class VnfInputs { @@ -158,10 +142,8 @@ public class VnfInputs { /** * Gets the value of the vnfId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVnfId() { return vnfId; @@ -170,10 +152,8 @@ public class VnfInputs { /** * Sets the value of the vnfId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVnfId(String value) { this.vnfId = value; @@ -182,10 +162,8 @@ public class VnfInputs { /** * Gets the value of the vnfName property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVnfName() { return vnfName; @@ -194,10 +172,8 @@ public class VnfInputs { /** * Sets the value of the vnfName property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVnfName(String value) { this.vnfName = value; @@ -206,10 +182,8 @@ public class VnfInputs { /** * Gets the value of the vnfType property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVnfType() { return vnfType; @@ -218,22 +192,18 @@ public class VnfInputs { /** * Sets the value of the vnfType property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVnfType(String value) { this.vnfType = value; } - + /** * Gets the value of the serviceInstanceId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getServiceInstanceId() { return serviceInstanceId; @@ -242,10 +212,8 @@ public class VnfInputs { /** * Sets the value of the serviceInstanceId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setServiceInstanceId(String value) { this.serviceInstanceId = value; @@ -254,10 +222,8 @@ public class VnfInputs { /** * Gets the value of the serviceType property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getServiceType() { return serviceType; @@ -266,22 +232,18 @@ public class VnfInputs { /** * Sets the value of the serviceType property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setServiceType(String value) { this.serviceType = value; } - + /** * Gets the value of the serviceId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getServiceId() { return serviceId; @@ -290,12 +252,10 @@ public class VnfInputs { /** * Sets the value of the serviceId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ - public void setServiceId (String value) { + public void setServiceId(String value) { this.serviceId = value; } @@ -303,10 +263,8 @@ public class VnfInputs { /** * Gets the value of the aicNodeClli property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getAicNodeClli() { return aicNodeClli; @@ -315,22 +273,18 @@ public class VnfInputs { /** * Sets the value of the aicNodeClli property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setAicNodeClli(String value) { this.aicNodeClli = value; } - + /** * Gets the value of the aicCloudRegion property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getAicCloudRegion() { return aicCloudRegion; @@ -339,10 +293,8 @@ public class VnfInputs { /** * Sets the value of the aicCloudRegion property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setAicCloudRegion(String value) { this.aicCloudRegion = value; @@ -351,10 +303,8 @@ public class VnfInputs { /** * Gets the value of the tenantId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getTenantId() { return tenantId; @@ -363,10 +313,8 @@ public class VnfInputs { /** * Sets the value of the tenantId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setTenantId(String value) { this.tenantId = value; @@ -375,10 +323,8 @@ public class VnfInputs { /** * Gets the value of the provStatus property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getProvStatus() { return provStatus; @@ -387,22 +333,18 @@ public class VnfInputs { /** * Sets the value of the provStatus property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setProvStatus(String value) { this.provStatus = value; } - + /** * Gets the value of the volumeGroupName property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVolumeGroupName() { return volumeGroupName; @@ -411,22 +353,18 @@ public class VnfInputs { /** * Sets the value of the volumeGroupName property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVolumeGroupName(String value) { this.volumeGroupName = value; } - + /** * Gets the value of the volumeGroupId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVolumeGroupId() { return volumeGroupId; @@ -435,22 +373,18 @@ public class VnfInputs { /** * Sets the value of the volumeGroupId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVolumeGroupId(String value) { this.volumeGroupId = value; } - + /** * Gets the value of the vfModuleId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVfModuleId() { return vfModuleId; @@ -459,22 +393,18 @@ public class VnfInputs { /** * Sets the value of the vfModuleId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVfModuleId(String value) { this.vfModuleId = value; } - + /** * Gets the value of the vfModuleName property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVfModuleName() { return vfModuleName; @@ -483,22 +413,18 @@ public class VnfInputs { /** * Sets the value of the vfModuleName property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVfModuleName(String value) { this.vfModuleName = value; } - + /** * Gets the value of the vfModuleModelName property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVfModuleModelName() { return vfModuleModelName; @@ -507,22 +433,18 @@ public class VnfInputs { /** * Sets the value of the vfModuleModelName property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVfModuleModelName(String value) { this.vfModuleModelName = value; } - + /** * Gets the value of the asdcServiceModelVersion property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getAsdcServiceModelVersion() { return asdcServiceModelVersion; @@ -531,22 +453,18 @@ public class VnfInputs { /** * Sets the value of the asdcServiceModelVersion property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setAsdcServiceModelVersion(String value) { this.asdcServiceModelVersion = value; } - + /** * Gets the value of the backoutOnFailure property. * - * @return - * possible object is - * {@link Boolean } - * + * @return possible object is {@link Boolean } + * */ public Boolean getBackoutOnFailure() { return backoutOnFailure; @@ -555,22 +473,18 @@ public class VnfInputs { /** * Sets the value of the backoutOnFailure property. * - * @param value - * allowed object is - * {@link Boolean } - * + * @param value allowed object is {@link Boolean } + * */ public void setBackoutOnFailure(Boolean value) { this.backoutOnFailure = value; } - + /** * Gets the value of the personaModelId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getPersonaModelId() { return personaModelId; @@ -579,22 +493,18 @@ public class VnfInputs { /** * Sets the value of the personaModelId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setPersonaModelId(String value) { this.personaModelId = value; } - + /** * Gets the value of the personaModelVersion property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getPersonaModelVersion() { return personaModelVersion; @@ -603,23 +513,19 @@ public class VnfInputs { /** * Sets the value of the personaModelVersion property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setPersonaModelVersion(String value) { this.personaModelVersion = value; } - - + + /** * Gets the value of the isBaseVfModule property. * - * @return - * possible object is - * {@link Boolean } - * + * @return possible object is {@link Boolean } + * */ public Boolean getIsBaseVfModule() { return isBaseVfModule; @@ -628,22 +534,18 @@ public class VnfInputs { /** * Sets the value of the isBaseVfModule property. * - * @param value - * allowed object is - * {@link Boolean } - * + * @param value allowed object is {@link Boolean } + * */ public void setIsBaseVfModule(Boolean value) { this.isBaseVfModule = value; } - + /** * Gets the value of the vnfPersonaModelId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVnfPersonaModelId() { return vnfPersonaModelId; @@ -652,22 +554,18 @@ public class VnfInputs { /** * Sets the value of the vnfPersonaModelId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVnfPersonaModelId(String value) { this.vnfPersonaModelId = value; } - + /** * Gets the value of the vnfPersonaModelVersion property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVnfPersonaModelVersion() { return vnfPersonaModelVersion; @@ -676,14 +574,12 @@ public class VnfInputs { /** * Sets the value of the vnfPersonaModelVersion property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVnfPersonaModelVersion(String value) { this.vnfPersonaModelVersion = value; - } + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfOutputs.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfOutputs.java index 114a3ae137..051dcce5d3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfOutputs.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfOutputs.java @@ -19,10 +19,10 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // @@ -37,9 +37,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -63,16 +65,8 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "vnfId", - "vfModuleId", - "vnfName", - "vfModuleName", - "aicNodeClli", - "tenantId", - "volumeGroupName", - "volumeGroupId" -}) +@XmlType(name = "", propOrder = {"vnfId", "vfModuleId", "vnfName", "vfModuleName", "aicNodeClli", "tenantId", + "volumeGroupName", "volumeGroupId"}) @XmlRootElement(name = "vnf-outputs") public class VnfOutputs { @@ -96,10 +90,8 @@ public class VnfOutputs { /** * Gets the value of the vnfId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVnfId() { return vnfId; @@ -108,22 +100,18 @@ public class VnfOutputs { /** * Sets the value of the vnfId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVnfId(String value) { this.vnfId = value; } - + /** * Gets the value of the vfModuleId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVfModuleId() { return vfModuleId; @@ -132,10 +120,8 @@ public class VnfOutputs { /** * Sets the value of the vfModuleId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVfModuleId(String value) { this.vfModuleId = value; @@ -146,10 +132,8 @@ public class VnfOutputs { /** * Gets the value of the vnfName property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVnfName() { return vnfName; @@ -158,22 +142,18 @@ public class VnfOutputs { /** * Sets the value of the vnfName property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVnfName(String value) { this.vnfName = value; } - + /** * Gets the value of the vfModuleName property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVfModuleName() { return vfModuleName; @@ -182,10 +162,8 @@ public class VnfOutputs { /** * Sets the value of the vfModuleName property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVfModuleName(String value) { this.vfModuleName = value; @@ -195,10 +173,8 @@ public class VnfOutputs { /** * Gets the value of the aicNodeClli property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getAicNodeClli() { return aicNodeClli; @@ -207,10 +183,8 @@ public class VnfOutputs { /** * Sets the value of the aicNodeClli property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setAicNodeClli(String value) { this.aicNodeClli = value; @@ -219,10 +193,8 @@ public class VnfOutputs { /** * Gets the value of the tenantId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getTenantId() { return tenantId; @@ -231,22 +203,18 @@ public class VnfOutputs { /** * Sets the value of the tenantId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setTenantId(String value) { this.tenantId = value; } - + /** * Gets the value of the volumeGroupName property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVolumeGroupName() { return volumeGroupName; @@ -255,22 +223,18 @@ public class VnfOutputs { /** * Sets the value of the volumeGroupName property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVolumeGroupName(String value) { this.volumeGroupName = value; } - + /** * Gets the value of the volumeGroupId property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getVolumeGroupId() { return volumeGroupId; @@ -279,10 +243,8 @@ public class VnfOutputs { /** * Sets the value of the volumeGroupId property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setVolumeGroupId(String value) { this.volumeGroupId = value; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfRequest.java index 07b186e149..9007f7c97b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfRequest.java @@ -19,10 +19,10 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // @@ -37,9 +37,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -61,12 +63,7 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "requestInfo", - "vnfInputs", - "vnfParams", - "vnfOutputs" -}) +@XmlType(name = "", propOrder = {"requestInfo", "vnfInputs", "vnfParams", "vnfOutputs"}) @XmlRootElement(name = "vnf-request") public class VnfRequest { @@ -78,15 +75,13 @@ public class VnfRequest { protected Object vnfParams; @XmlElement(name = "vnf-outputs") protected VnfOutputs vnfOutputs; - + /** * Gets the value of the requestInfo property. * - * @return - * possible object is - * {@link RequestInfo } - * + * @return possible object is {@link RequestInfo } + * */ public RequestInfo getRequestInfo() { return requestInfo; @@ -95,10 +90,8 @@ public class VnfRequest { /** * Sets the value of the requestInfo property. * - * @param value - * allowed object is - * {@link RequestInfo } - * + * @param value allowed object is {@link RequestInfo } + * */ public void setRequestInfo(RequestInfo value) { this.requestInfo = value; @@ -107,10 +100,8 @@ public class VnfRequest { /** * Gets the value of the vnfInputs property. * - * @return - * possible object is - * {@link VnfInputs } - * + * @return possible object is {@link VnfInputs } + * */ public VnfInputs getVnfInputs() { return vnfInputs; @@ -119,10 +110,8 @@ public class VnfRequest { /** * Sets the value of the vnfInputs property. * - * @param value - * allowed object is - * {@link VnfInputs } - * + * @param value allowed object is {@link VnfInputs } + * */ public void setVnfInputs(VnfInputs value) { this.vnfInputs = value; @@ -131,10 +120,8 @@ public class VnfRequest { /** * Gets the value of the vnfParams property. * - * @return - * possible object is - * {@link Object } - * + * @return possible object is {@link Object } + * */ public Object getVnfParams() { return vnfParams; @@ -143,10 +130,8 @@ public class VnfRequest { /** * Sets the value of the vnfParams property. * - * @param value - * allowed object is - * {@link Object } - * + * @param value allowed object is {@link Object } + * */ public void setVnfParams(Object value) { this.vnfParams = value; @@ -155,10 +140,8 @@ public class VnfRequest { /** * Gets the value of the vnfOutputs property. * - * @return - * possible object is - * {@link VnfOutputs } - * + * @return possible object is {@link VnfOutputs } + * */ public VnfOutputs getVnfOutputs() { return vnfOutputs; @@ -167,13 +150,11 @@ public class VnfRequest { /** * Sets the value of the vnfOutputs property. * - * @param value - * allowed object is - * {@link VnfOutputs } - * + * @param value allowed object is {@link VnfOutputs } + * */ public void setVnfOutputs(VnfOutputs value) { this.vnfOutputs = value; } - } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfRequests.java index caa0cae84d..677b983205 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfRequests.java @@ -19,10 +19,10 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // @@ -31,7 +31,6 @@ package org.onap.so.apihandlerinfra.vnfbeans; import java.util.ArrayList; import java.util.List; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -40,9 +39,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -59,9 +60,7 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "vnfRequest" -}) +@XmlType(name = "", propOrder = {"vnfRequest"}) @XmlRootElement(name = "vnf-requests") public class VnfRequests { @@ -72,21 +71,20 @@ public class VnfRequests { * Gets the value of the vnfRequest property. * * <p> - * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a <CODE>set</CODE> method for the vnfRequest property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to + * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for + * the vnfRequest property. * * <p> * For example, to add a new item, do as follows: + * * <pre> - * getVnfRequest().add(newItem); + * getVnfRequest().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list - * {@link VnfRequest } + * Objects of the following type(s) are allowed in the list {@link VnfRequest } * * */ @@ -98,6 +96,6 @@ public class VnfRequests { } public void setVnfRequest(List<VnfRequest> vnfRequest) { - this.vnfRequest=vnfRequest; + this.vnfRequest = vnfRequest; } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfType.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfType.java index dd556a7c34..1917839b47 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfType.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfType.java @@ -19,10 +19,10 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // @@ -37,9 +37,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -58,11 +60,7 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "type", - "id", - "description" -}) +@XmlType(name = "", propOrder = {"type", "id", "description"}) @XmlRootElement(name = "vnf-type") public class VnfType { @@ -76,10 +74,8 @@ public class VnfType { /** * Gets the value of the type property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getType() { return type; @@ -88,10 +84,8 @@ public class VnfType { /** * Sets the value of the type property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setType(String value) { this.type = value; @@ -100,10 +94,8 @@ public class VnfType { /** * Gets the value of the id property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getId() { return id; @@ -112,10 +104,8 @@ public class VnfType { /** * Sets the value of the id property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setId(String value) { this.id = value; @@ -124,10 +114,8 @@ public class VnfType { /** * Gets the value of the description property. * - * @return - * possible object is - * {@link String } - * + * @return possible object is {@link String } + * */ public String getDescription() { return description; @@ -136,10 +124,8 @@ public class VnfType { /** * Sets the value of the description property. * - * @param value - * allowed object is - * {@link String } - * + * @param value allowed object is {@link String } + * */ public void setDescription(String value) { this.description = value; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfTypes.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfTypes.java index 6728c69172..7ce179de8e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfTypes.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/VnfTypes.java @@ -19,10 +19,10 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // @@ -31,7 +31,6 @@ package org.onap.so.apihandlerinfra.vnfbeans; import java.util.ArrayList; import java.util.List; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; @@ -40,9 +39,11 @@ import javax.xml.bind.annotation.XmlType; /** - * <p>Java class for anonymous complex type. + * <p> + * Java class for anonymous complex type. * - * <p>The following schema fragment specifies the expected content contained within this class. + * <p> + * The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType> @@ -59,9 +60,7 @@ import javax.xml.bind.annotation.XmlType; * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "vnfType" -}) +@XmlType(name = "", propOrder = {"vnfType"}) @XmlRootElement(name = "vnf-types") public class VnfTypes { @@ -72,21 +71,20 @@ public class VnfTypes { * Gets the value of the vnfType property. * * <p> - * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a <CODE>set</CODE> method for the vnfType property. + * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to + * the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for + * the vnfType property. * * <p> * For example, to add a new item, do as follows: + * * <pre> - * getVnfType().add(newItem); + * getVnfType().add(newItem); * </pre> * * * <p> - * Objects of the following type(s) are allowed in the list - * {@link VnfType } + * Objects of the following type(s) are allowed in the list {@link VnfType } * * */ @@ -96,9 +94,9 @@ public class VnfTypes { } return this.vnfType; } - - public void setVnfType( List<VnfType> vnfType) { - this.vnfType=vnfType; + + public void setVnfType(List<VnfType> vnfType) { + this.vnfType = vnfType; } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/package-info.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/package-info.java index 3eb84299f4..efcfecffce 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/package-info.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/vnfbeans/package-info.java @@ -19,12 +19,13 @@ */ // -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2015.09.03 at 02:02:13 PM EDT +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2015.09.03 at 02:02:13 PM EDT // -@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.onap/so/infra/vnf-request/v1", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +@javax.xml.bind.annotation.XmlSchema(namespace = "http://org.onap/so/infra/vnf-request/v1", + elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) package org.onap.so.apihandlerinfra.vnfbeans; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ActivitySequence.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ActivitySequence.java index 594b43e07d..75cc1ecec6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ActivitySequence.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ActivitySequence.java @@ -24,10 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "name", - "description" -}) +@JsonPropertyOrder({"name", "description"}) public class ActivitySequence { @JsonProperty("name") @@ -39,8 +36,7 @@ public class ActivitySequence { * No args constructor for use in serialization * */ - public ActivitySequence() { - } + public ActivitySequence() {} /** * diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ArtifactInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ArtifactInfo.java index 0861ff2033..26f37c1319 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ArtifactInfo.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/ArtifactInfo.java @@ -24,17 +24,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "artifactType", - "artifactUuid", - "artifactName", - "artifactVersion", - "artifactDescription", - "workflowName", - "operationName", - "workflowSource", - "workflowResourceTarget" -}) +@JsonPropertyOrder({"artifactType", "artifactUuid", "artifactName", "artifactVersion", "artifactDescription", + "workflowName", "operationName", "workflowSource", "workflowResourceTarget"}) public class ArtifactInfo { @JsonProperty("artifactType") @@ -60,8 +51,7 @@ public class ArtifactInfo { * No args constructor for use in serialization * */ - public ArtifactInfo() { - } + public ArtifactInfo() {} /** * @@ -75,7 +65,9 @@ public class ArtifactInfo { * @param artifactUuid * @param artifactDescription */ - public ArtifactInfo(String artifactType, String artifactUuid, String artifactName, String artifactVersion, String artifactDescription, String workflowName, String operationName, String workflowSource, String workflowResourceTarget) { + public ArtifactInfo(String artifactType, String artifactUuid, String artifactName, String artifactVersion, + String artifactDescription, String workflowName, String operationName, String workflowSource, + String workflowResourceTarget) { super(); this.artifactType = artifactType; this.artifactUuid = artifactUuid; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/Validation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/Validation.java index 3a4d5cb5f0..324f368c26 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/Validation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/Validation.java @@ -24,10 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "maxLength", - "allowableChars" -}) +@JsonPropertyOrder({"maxLength", "allowableChars"}) public class Validation { @JsonProperty("maxLength") @@ -39,8 +36,7 @@ public class Validation { * No args constructor for use in serialization * */ - public Validation() { - } + public Validation() {} /** * diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowInputParameter.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowInputParameter.java index 416442c216..8cbd622667 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowInputParameter.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowInputParameter.java @@ -25,14 +25,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "label", - "inputType", - "required", - "validation", - "soFieldName", - "soPayloadLocation" -}) +@JsonPropertyOrder({"label", "inputType", "required", "validation", "soFieldName", "soPayloadLocation"}) public class WorkflowInputParameter { @JsonProperty("label") @@ -52,8 +45,7 @@ public class WorkflowInputParameter { * No args constructor for use in serialization * */ - public WorkflowInputParameter() { - } + public WorkflowInputParameter() {} /** * @@ -64,7 +56,8 @@ public class WorkflowInputParameter { * @param required * @param soFieldName */ - public WorkflowInputParameter(String label, String inputType, Boolean required, List<Validation> validation, String soFieldName, String soPayloadLocation) { + public WorkflowInputParameter(String label, String inputType, Boolean required, List<Validation> validation, + String soFieldName, String soPayloadLocation) { super(); this.label = label; this.inputType = inputType; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecification.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecification.java index 86dc44ef39..d8a0a8b662 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecification.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecification.java @@ -25,11 +25,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "artifactInfo", - "activitySequence", - "workflowInputParameters" -}) +@JsonPropertyOrder({"artifactInfo", "activitySequence", "workflowInputParameters"}) public class WorkflowSpecification { @JsonProperty("artifactInfo") @@ -43,8 +39,7 @@ public class WorkflowSpecification { * No args constructor for use in serialization * */ - public WorkflowSpecification() { - } + public WorkflowSpecification() {} /** * @@ -52,7 +47,8 @@ public class WorkflowSpecification { * @param artifactInfo * @param workflowInputParameters */ - public WorkflowSpecification(ArtifactInfo artifactInfo, List<ActivitySequence> activitySequence, List<WorkflowInputParameter> workflowInputParameters) { + public WorkflowSpecification(ArtifactInfo artifactInfo, List<ActivitySequence> activitySequence, + List<WorkflowInputParameter> workflowInputParameters) { super(); this.artifactInfo = artifactInfo; this.activitySequence = activitySequence; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationList.java index c6bf4e3d41..ba54e7271a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationList.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecificationList.java @@ -24,9 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "workflowSpecification" -}) +@JsonPropertyOrder({"workflowSpecification"}) public class WorkflowSpecificationList { @JsonProperty("workflowSpecification") @@ -36,8 +34,7 @@ public class WorkflowSpecificationList { * No args constructor for use in serialization * */ - public WorkflowSpecificationList() { - } + public WorkflowSpecificationList() {} /** * diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecifications.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecifications.java index ffe9980af4..922f5601d5 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecifications.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/workflowspecificationbeans/WorkflowSpecifications.java @@ -25,9 +25,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ - "workflowSpecificationList" -}) +@JsonPropertyOrder({"workflowSpecificationList"}) public class WorkflowSpecifications { @JsonProperty("workflowSpecificationList") @@ -37,8 +35,7 @@ public class WorkflowSpecifications { * No args constructor for use in serialization * */ - public WorkflowSpecifications() { - } + public WorkflowSpecifications() {} /** * @@ -59,7 +56,8 @@ public class WorkflowSpecifications { this.workflowSpecificationList = workflowSpecificationList; } - public WorkflowSpecifications withWorkflowSpecificationList(List<WorkflowSpecificationList> workflowSpecificationList) { + public WorkflowSpecifications withWorkflowSpecificationList( + List<WorkflowSpecificationList> workflowSpecificationList) { this.workflowSpecificationList = workflowSpecificationList; return this; } |