aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp
diff options
context:
space:
mode:
authorArthur Martella <amartell@research.att.com>2017-09-08 13:27:46 -0400
committerArthur Martella <amartell@research.att.com>2017-09-08 13:32:24 -0400
commit62cd6aaaf74aa91ee0037c0e155c8e7284f07567 (patch)
tree68c0c53c9156f5aa3c6b3599ac940770f986633d /mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp
parentfa1a211d28a912892fcd888569df033900eb01ee (diff)
1710 Rebase - Second Attempt
This commit rebases changes from openecomp-mso/internal-staging-1710 up to and including this codecloud commit: 54483fc6606ddb1591a2e9da61bff8712325f924 Wed Sep 6 18:12:56 2017 -0400 Rebasing was done on a branch on top of this commit in so/master in ONAP: 93fbdfbe46104f8859d4754040f979cb7997c157 Thu Sep 7 16:42:59 2017 +0000 Change-Id: I4ad9abf40da32bf5bdca43e868b8fa2dbcd9dc59 Issue-id: SO-107 Signed-off-by: Arthur Martella <amartell@research.att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Action.java5
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/GlobalHealthcheckHandler.java48
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/HealthcheckHandler.java58
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java226
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java173
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java13
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java10
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java16
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NodeHealthcheckHandler.java46
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java48
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RequestActionMap.java1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java1400
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/TasksHandler.java328
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java20
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java10
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java15
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java15
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java20
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java10
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java16
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestParameters.java27
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestDetails.java55
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestInfo.java74
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskList.java334
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskRequestReference.java57
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariableValue.java108
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariables.java39
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksGetResponse.java36
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksRequest.java34
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/ValidResponses.java52
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/Value.java56
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/Variables.java76
34 files changed, 2639 insertions, 813 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Action.java
index 8df4c87898..6ff8f252b2 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Action.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/Action.java
@@ -27,5 +27,8 @@ public enum Action {
createInstance,
updateInstance,
deleteInstance,
- configureInstance
+ configureInstance,
+ replaceInstance,
+ activateInstance,
+ deactivateInstance
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/GlobalHealthcheckHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/GlobalHealthcheckHandler.java
new file mode 100644
index 0000000000..6123ee906c
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/GlobalHealthcheckHandler.java
@@ -0,0 +1,48 @@
+package org.openecomp.mso.apihandlerinfra;
+
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.HEAD;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+
+import org.openecomp.mso.HealthCheckUtils;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.utils.UUIDChecker;
+
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+
+@Path("/globalhealthcheck")
+@Api(value="/globalhealthcheck",description="APIH Infra Global Health Check")
+public class GlobalHealthcheckHandler {
+
+ public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
+
+ @HEAD
+ @GET
+ @Produces("text/html")
+ @ApiOperation(value="Performing global health check",response=Response.class)
+ public Response globalHealthcheck (@DefaultValue("true") @QueryParam("enableBpmn") boolean enableBpmn) {
+ long startTime = System.currentTimeMillis ();
+ MsoLogger.setServiceName ("GlobalHealthcheck");
+ // Generate a Request Id
+ String requestId = UUIDChecker.generateUUID(msoLogger);
+ HealthCheckUtils healthCheck = new HealthCheckUtils ();
+ if (!healthCheck.siteStatusCheck (msoLogger, startTime)) {
+ return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
+ }
+
+ if (healthCheck.verifyGlobalHealthCheck(enableBpmn, requestId)) {
+ msoLogger.debug("globalHealthcheck - Successful");
+ return HealthCheckUtils.HEALTH_CHECK_RESPONSE;
+ } else {
+ msoLogger.debug("globalHealthcheck - At leaset one of the sub-modules is not available");
+ return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
+ }
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/HealthcheckHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/HealthcheckHandler.java
index 0ae1695516..bc8c2e03cf 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/HealthcheckHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/HealthcheckHandler.java
@@ -25,14 +25,17 @@ import javax.ws.rs.HEAD;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.DefaultValue;
import javax.ws.rs.core.Response;
-import org.openecomp.mso.HealthCheckUtils;
+import org.openecomp.mso.HealthCheckUtils;
import org.openecomp.mso.logger.MsoLogger;
import org.openecomp.mso.utils.UUIDChecker;
-@Path("/")
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+
+@Path("/healthcheck")
+@Api(value="/healthcheck",description="API Handler Infra Health Check")
public class HealthcheckHandler {
public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
@@ -41,8 +44,8 @@ public class HealthcheckHandler {
@HEAD
@GET
- @Path("/healthcheck")
@Produces("text/html")
+ @ApiOperation(value="Perform Health Check",response=Response.class)
public Response healthcheck (@QueryParam("requestId") String requestId) {
long startTime = System.currentTimeMillis ();
MsoLogger.setServiceName ("Healthcheck");
@@ -62,51 +65,4 @@ public class HealthcheckHandler {
msoLogger.debug("healthcheck - Successful");
return HealthCheckUtils.HEALTH_CHECK_RESPONSE;
}
-
- @HEAD
- @GET
- @Path("/nodehealthcheck")
- @Produces("text/html")
- public Response nodeHealthcheck () {
- long startTime = System.currentTimeMillis ();
- MsoLogger.setServiceName ("NodeHealthcheck");
- // Generate a Request Id
- String requestId = UUIDChecker.generateUUID(msoLogger);
- HealthCheckUtils healthCheck = new HealthCheckUtils ();
- if (!healthCheck.siteStatusCheck (msoLogger, startTime)) {
- return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
- }
-
- if (healthCheck.verifyNodeHealthCheck(HealthCheckUtils.NodeType.APIH, requestId)) {
- msoLogger.debug("nodeHealthcheck - Successful");
- return HealthCheckUtils.HEALTH_CHECK_RESPONSE;
- } else {
- msoLogger.debug("nodeHealthcheck - At leaset one of the sub-modules is not available.");
- return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
- }
- }
-
- @HEAD
- @GET
- @Path("/globalhealthcheck")
- @Produces("text/html")
- public Response globalHealthcheck (@DefaultValue("true") @QueryParam("enableBpmn") boolean enableBpmn) {
- long startTime = System.currentTimeMillis ();
- MsoLogger.setServiceName ("GlobalHealthcheck");
- // Generate a Request Id
- String requestId = UUIDChecker.generateUUID(msoLogger);
- HealthCheckUtils healthCheck = new HealthCheckUtils ();
- if (!healthCheck.siteStatusCheck (msoLogger, startTime)) {
- return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
- }
-
- if (healthCheck.verifyGlobalHealthCheck(enableBpmn, requestId)) {
- msoLogger.debug("globalHealthcheck - Successful");
- return HealthCheckUtils.HEALTH_CHECK_RESPONSE;
- } else {
- msoLogger.debug("globalHealthcheck - At leaset one of the sub-modules is not available");
- return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
- }
- }
-
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java
new file mode 100644
index 0000000000..d1e60a1cca
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ManualTasks.java
@@ -0,0 +1,226 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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
+ *
+ * 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=========================================================
+ */
+package org.openecomp.mso.apihandlerinfra;
+
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoAlarmLogger;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.utils.UUIDChecker;
+
+import com.wordnik.swagger.annotations.ApiOperation;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.openecomp.mso.apihandler.common.ValidationException;
+import org.openecomp.mso.apihandler.common.ErrorNumbers;
+import org.openecomp.mso.apihandler.common.RequestClient;
+import org.openecomp.mso.apihandler.common.RequestClientFactory;
+import org.openecomp.mso.apihandler.common.ResponseHandler;
+import org.openecomp.mso.apihandlerinfra.tasksbeans.*;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
+
+
+@Path("/tasks")
+public class ManualTasks {
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
+ private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
+ public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
+
+ @POST
+ @Path("/{version:[vV]1}/{taskId}/complete")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Complete specified task",response=Response.class)
+ public Response completeTask(String request, @PathParam("version") String version, @PathParam("taskId") String taskId) {
+
+ String requestId = UUIDChecker.generateUUID(msoLogger);
+ long startTime = System.currentTimeMillis ();
+ msoLogger.debug ("requestId is: " + requestId);
+ TasksRequest tr = null;
+
+ MsoRequest msoRequest = new MsoRequest (requestId);
+
+ try{
+ ObjectMapper mapper = new ObjectMapper();
+ tr= mapper.readValue(request, TasksRequest.class);
+
+ if (tr.getRequestDetails() == null) {
+ throw new ValidationException("requestDetails");
+ }
+ if (tr.getRequestDetails().getRequestInfo() == null) {
+ throw new ValidationException("requestInfo");
+ }
+ if (empty(tr.getRequestDetails().getRequestInfo().getSource())) {
+ throw new ValidationException("source");
+ }
+ if (empty(tr.getRequestDetails().getRequestInfo().getRequestorId())) {
+ throw new ValidationException("requestorId");
+ }
+
+ } catch(Exception e){
+ msoLogger.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);
+
+ msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, request, e);
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
+ return response;
+ }
+
+ // Transform the request to Camunda-style Complete request
+ Variables variablesForComplete = new Variables();
+ Value sourceValue = new Value();
+ sourceValue.setValue(tr.getRequestDetails().getRequestInfo().getSource());
+ Value responseValue = new Value();
+ responseValue.setValue(tr.getRequestDetails().getRequestInfo().getResponseValue().name());
+ Value requestorIdValue = new Value();
+ requestorIdValue.setValue(tr.getRequestDetails().getRequestInfo().getRequestorId());
+ variablesForComplete.setSource(sourceValue);
+ variablesForComplete.setResponseValue(responseValue);
+ variablesForComplete.setRequestorId(requestorIdValue);
+
+ String camundaJsonReq = null;
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, true);
+ camundaJsonReq = mapper.writeValueAsString(variablesForComplete);
+ msoLogger.debug("Camunda Json Request: " + camundaJsonReq);
+ } catch(Exception e){
+ msoLogger.debug ("Mapping of JSON object to Camunda request failed : ", e);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException,
+ "Mapping of JSON object to Camunda Request failed. " + e.getMessage(),
+ ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
+
+ msoLogger.error (MessageEnum.APIH_GENERAL_EXCEPTION, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.UnknownError, request, e);
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Mapping of JSON object to Camunda request failed");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
+ return response;
+ }
+
+ RequestClient requestClient = null;
+ HttpResponse response = null;
+ long subStartTime = System.currentTimeMillis();
+ String requestUrl = "/mso/task/" + taskId + "/complete";
+ try {
+ requestClient = RequestClientFactory.getRequestClient (requestUrl, MsoPropertiesUtils.loadMsoProperties ());
+ // Capture audit event
+ msoLogger.debug ("MSO API Handler Posting call to Camunda engine for url: " + requestClient.getUrl ());
+
+ System.out.println("URL : " + requestClient.getUrl ());
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Mapping of JSON object to Camunda request failed");
+
+ response = requestClient.post(camundaJsonReq);
+
+ msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", requestUrl, null);
+ } catch (Exception e) {
+ msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", requestUrl, null);
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,
+ MsoException.ServiceException,
+ "Failed calling bpmn " + e.getMessage (),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES,
+ null);
+ alarmLogger.sendAlarm ("MsoConfigurationError",
+ MsoAlarmLogger.CRITICAL,
+ Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
+ msoRequest.updateFinalStatus (Status.FAILED);
+ msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
+ return resp;
+ }
+
+ if (response == null) {
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,
+ MsoException.ServiceException,
+ "bpelResponse is null",
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES,
+ null);
+ msoRequest.updateFinalStatus (Status.FAILED);
+ msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Null response from BPMN");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
+ return resp;
+ }
+
+ 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) {
+ msoLogger.debug ("Received good response from Camunda");
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.IN_PROGRESS);
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN completed the request");
+ TaskRequestReference trr = new TaskRequestReference();
+ trr.setTaskId(taskId);
+ String completeResp = null;
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, true);
+ completeResp = mapper.writeValueAsString(trr);
+ }
+ catch (Exception e) {
+ msoLogger.debug("Unable to format response");
+ Response resp = msoRequest.buildServiceErrorResponse(bpelStatus,
+ MsoException.ServiceException,
+ "Request Failed due to bad response format" ,
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
+ null);
+ msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Bad response format");
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Bad response format");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
+ return resp;
+ }
+ msoLogger.debug("Response to the caller: " + completeResp);
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) completeResp);
+ return Response.status (HttpStatus.SC_ACCEPTED).entity (completeResp).build ();
+ } else {
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response resp = msoRequest.buildServiceErrorResponse(bpelStatus,
+ MsoException.ServiceException,
+ "Request Failed due to BPEL error with HTTP Status= %1" ,
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
+ null);
+ msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty");
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPEL engine is empty");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
+ return resp;
+ }
+
+ }
+
+ 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/openecomp/mso/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java
index 5b84a59b6b..0407903d40 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java
@@ -64,13 +64,14 @@ import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestInfo;
import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestParameters;
import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceException;
import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.SubscriberInfo;
import org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType;
import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfInputs;
import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest;
-import org.openecomp.mso.db.HibernateUtils;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.requestsdb.HibernateUtilsRequestsDb;
+import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
import org.openecomp.mso.requestsdb.InfraActiveRequests;
import org.openecomp.mso.requestsdb.RequestsDatabase;
import org.openecomp.mso.utils.UUIDChecker;
@@ -109,7 +110,7 @@ public class MsoRequest {
private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
private static final String NOT_PROVIDED = "not provided";
- protected HibernateUtils hibernateUtils = new HibernateUtilsRequestsDb ();
+ protected AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager ();
MsoRequest (String requestId) {
this.requestId = requestId;
@@ -287,10 +288,31 @@ public class MsoRequest {
this.requestScope = modelInfo.getModelType().name();
+ // modelCustomizationId is required when usePreLoad is false for v4 and higher for VF Module Create
+ if(requestParameters != null && reqVersion > 3 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.createInstance && !requestParameters.isUsePreload()) {
+ if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
+ throw new ValidationException("modelCustomizationId");
+ }
+ }
+
+ // modelCustomizationId is required when usePreLoad is false for v5 and higher for VF Module Replace
+ if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vfModule.name()) && action == Action.replaceInstance && !requestParameters.isUsePreload()) {
+ if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId())) {
+ throw new ValidationException("modelCustomizationId");
+ }
+ }
+
+ // modelCustomizationId or modelCustomizationName are required when usePreLoad is false for v5 and higher for VNF Replace
+ if(requestParameters != null && reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action == Action.replaceInstance && !requestParameters.isUsePreload()) {
+ if(!UUIDChecker.isValidUUID(modelInfo.getModelCustomizationId()) && modelInfo.getModelCustomizationName() == null) {
+ throw new ValidationException("modelCustomizationId or modelCustomizationName");
+ }
+ }
+
//is required for serviceInstance delete macro when aLaCarte=false (v3)
- //create and updates except for network
+ //create and updates except for network (except v4)
if (empty (modelInfo.getModelInvariantId ()) && ((this.reqVersion >2 && !this.aLaCarteFlag && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) ||
- !(requestScope.equalsIgnoreCase (ModelType.network.name ())) && (action == Action.createInstance || action == Action.updateInstance))) {
+ !(this.reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ())) && (action == Action.createInstance || action == Action.updateInstance))) {
throw new ValidationException ("modelInvariantId");
}
@@ -307,11 +329,17 @@ public class MsoRequest {
throw new ValidationException ("modelName");
}
- if (empty (modelInfo.getModelVersion ()) && ((this.reqVersion >2 && !this.aLaCarteFlag && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) ||
- !(requestScope.equalsIgnoreCase (ModelType.network.name ())) && (action == Action.createInstance || action == Action.updateInstance))) {
+ if (empty (modelInfo.getModelVersion ()) && ((this.reqVersion == 3 && !this.aLaCarteFlag && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) ||
+ !(this.reqVersion < 4 && requestScope.equalsIgnoreCase (ModelType.network.name ())) && (action == Action.createInstance || action == Action.updateInstance))) {
throw new ValidationException ("modelVersion");
}
+ // modelVersionId doesn't exist in v2, not required field in v3, is required for serviceInstance delete macro when aLaCarte=false in v4
+ if (this.reqVersion > 3 && empty (modelInfo.getModelVersionId()) && ((!this.aLaCarteFlag && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.deleteInstance) ||
+ (action == Action.createInstance || action == Action.updateInstance))) {
+ throw new ValidationException ("modelVersionId");
+ }
+
if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && action != Action.deleteInstance && empty (modelInfo.getModelCustomizationName ())) {
if(this.reqVersion<=2){
throw new ValidationException ("modelCustomizationName");
@@ -328,12 +356,9 @@ public class MsoRequest {
if(!empty(modelInfo.getModelNameVersionId())){
modelInfo.setModelVersionId(modelInfo.getModelNameVersionId());
}
- if(!empty(modelInfo.getModelVersionId())){
- modelInfo.setModelNameVersionId(modelInfo.getModelVersionId());
- }
this.cloudConfiguration = sir.getRequestDetails ().getCloudConfiguration ();
- if ( (((!this.aLaCarteFlag && requestScope.equalsIgnoreCase (ModelType.service.name ())) ||
+ if ( (((!this.aLaCarteFlag && requestScope.equalsIgnoreCase (ModelType.service.name ()) && this.reqVersion < 5) ||
(!requestScope.equalsIgnoreCase (ModelType.service.name ())) && action != Action.updateInstance))
&& cloudConfiguration == null) {
throw new ValidationException ("cloudConfiguration");
@@ -349,7 +374,6 @@ public class MsoRequest {
}
-
if (requestScope.equalsIgnoreCase (ModelType.service.name ()) && action == Action.createInstance) {
if (requestParameters == null) {
throw new ValidationException ("requestParameters");
@@ -358,6 +382,16 @@ public class MsoRequest {
throw new ValidationException ("subscriptionServiceType");
}
}
+
+ if (this.reqVersion > 4 && requestScope.equalsIgnoreCase (ModelType.service.name ()) && action == Action.createInstance) {
+ SubscriberInfo subscriberInfo = sir.getRequestDetails ().getSubscriberInfo();
+ if (subscriberInfo == null) {
+ throw new ValidationException ("subscriberInfo");
+ }
+ if (empty (subscriberInfo.getGlobalSubscriberId ())) {
+ throw new ValidationException ("globalSubscriberId");
+ }
+ }
if(requestScope.equalsIgnoreCase(ModelType.service.name())){
this.serviceInstanceType = modelInfo.getModelName();
@@ -378,10 +412,20 @@ public class MsoRequest {
}
}
- if (empty (requestInfo.getProductFamilyId ()) && ((requestScope.equalsIgnoreCase (ModelType.vnf.name ()) && action == Action.createInstance) ||
- (requestScope.equalsIgnoreCase (ModelType.network.name ()) && (action == Action.createInstance || action == Action.updateInstance)))) {
+ 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)) ||
+ (this.reqVersion > 3 && !this.aLaCarteFlag && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.createInstance)) {
throw new ValidationException ("productFamilyId");
}
+ }
+
+ //required for all operations in V4
+ if(empty(requestInfo.getRequestorId()) && this.reqVersion > 3) {
+ throw new ValidationException ("requestorId");
+ }
if (empty (requestInfo.getSource ())) {
throw new ValidationException ("source");
@@ -401,11 +445,12 @@ public class MsoRequest {
for(RelatedInstanceList relatedInstanceList : instanceList){
RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
- if (relatedInstance.getModelInfo () == null) {
+ ModelInfo relatedInstanceModelInfo = relatedInstance.getModelInfo ();
+ if (relatedInstanceModelInfo == null) {
throw new ValidationException ("modelInfo in relatedInstance");
}
- if (relatedInstance.getModelInfo ().getModelType () == null) {
+ if (relatedInstanceModelInfo.getModelType () == null) {
throw new ValidationException ("modelType in relatedInstance");
}
@@ -426,50 +471,47 @@ public class MsoRequest {
if (action != Action.deleteInstance) {
+ if(!relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup)) {
- // ModelInvariantId is not required in volumeGroup relatedInstance
- if(!(relatedInstance.getModelInfo ().getModelType ().equals(ModelType.volumeGroup)) &&
- empty (relatedInstance.getModelInfo ().getModelInvariantId ())) {
+ if(empty (relatedInstanceModelInfo.getModelInvariantId ())) {
throw new ValidationException ("modelInvariantId in relatedInstance");
+ } else if(this.reqVersion > 3 && 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 (relatedInstance.getModelInfo ().getModelInvariantId ()) &&
- !UUIDChecker.isValidUUID (relatedInstance.getModelInfo ().getModelInvariantId ())) {
+ if (!empty (relatedInstanceModelInfo.getModelInvariantId ()) &&
+ !UUIDChecker.isValidUUID (relatedInstanceModelInfo.getModelInvariantId ())) {
throw new ValidationException ("modelInvariantId format in relatedInstance");
}
-
- if (empty(relatedInstance.getModelInfo ().getModelName ()) &&
- !(relatedInstance.getModelInfo ().getModelType ().equals (ModelType.volumeGroup))) {
- throw new ValidationException ("modelName in relatedInstance");
}
- if (empty (relatedInstance.getModelInfo ().getModelVersion ()) &&
- !(relatedInstance.getModelInfo ().getModelType ().equals (ModelType.volumeGroup))) {
- throw new ValidationException ("modelVersion in relatedInstance");
- }
+ if (empty (relatedInstanceModelInfo.getModelCustomizationName ()) && relatedInstanceModelInfo.getModelType ().equals (ModelType.vnf) ) {
+ if(this.reqVersion >=3 && empty (relatedInstanceModelInfo.getModelCustomizationId()) && action != Action.deleteInstance) {
+ throw new ValidationException ("modelCustomizationName or modelCustomizationId in relatedInstance of vnf");
+ } else if(this.reqVersion < 3) {
+ throw new ValidationException ("modelCustomizationName in relatedInstance");
}
-
- if (empty (relatedInstance.getModelInfo ().getModelCustomizationName ()) &&
- relatedInstance.getModelInfo ().getModelType ().equals (ModelType.vnf)) {
- throw new ValidationException ("modelCustomizationName in relatedInstance");
}
- if(relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) {
+ if(relatedInstanceModelInfo.getModelType().equals(ModelType.service)) {
isRelatedServiceInstancePresent = true;
if (!relatedInstance.getInstanceId ().equals (this.sir.getServiceInstanceId ())) {
throw new ValidationException ("serviceInstanceId matching the serviceInstanceId in request URI");
}
- serviceModelName = relatedInstance.getModelInfo ().getModelName ();
- asdcServiceModelVersion = relatedInstance.getModelInfo().getModelVersion ();
- }
- else if(relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) {
+ serviceModelName = relatedInstanceModelInfo.getModelName ();
+ asdcServiceModelVersion = relatedInstanceModelInfo.getModelVersion ();
+ } else if(relatedInstanceModelInfo.getModelType().equals(ModelType.vnf)) {
isRelatedVnfInstancePresent = true;
if (!relatedInstance.getInstanceId ().equals (this.sir.getVnfInstanceId ())) {
throw new ValidationException ("vnfInstanceId matching the vnfInstanceId in request URI");
}
- vnfModelName = relatedInstance.getModelInfo().getModelCustomizationName();
- }
- else if(relatedInstance.getModelInfo().getModelType().equals(ModelType.volumeGroup)) {
+ vnfModelName = relatedInstanceModelInfo.getModelCustomizationName();
+ } else if(relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup)) {
volumeGroupId = relatedInstance.getInstanceId ();
}
}
@@ -556,21 +598,22 @@ public class MsoRequest {
try{
if(queryParam.equalsIgnoreCase("filter")){
-
- StringTokenizer st = new StringTokenizer(entry.getValue().get(0), ":");
-
- int counter=0;
- String mapKey=null;
- List<String> orchestrationList = new ArrayList<String>();
- while (st.hasMoreElements()) {
- if(counter == 0){
- mapKey = st.nextElement() + "";
- } else{
- orchestrationList.add(st.nextElement() + "");
- }
- counter++;
- }
- orchestrationFilterParams.put(mapKey, orchestrationList);
+ for(String value : entry.getValue()) {
+ StringTokenizer st = new StringTokenizer(value, ":");
+
+ int counter=0;
+ String mapKey=null;
+ List<String> orchestrationList = new ArrayList<String>();
+ while (st.hasMoreElements()) {
+ if(counter == 0){
+ mapKey = st.nextElement() + "";
+ } else{
+ orchestrationList.add(st.nextElement() + "");
+ }
+ counter++;
+ }
+ orchestrationFilterParams.put(mapKey, orchestrationList);
+ }
}
}catch(Exception e){
@@ -590,7 +633,7 @@ public class MsoRequest {
Session session = null;
try {
- session = hibernateUtils.getSessionFactory ().openSession ();
+ session = requestsDbSessionFactoryManager.getSessionFactory ().openSession ();
session.beginTransaction ();
if (null == sir) {
@@ -727,7 +770,7 @@ public class MsoRequest {
public void updateFinalStatus (Status status) {
int result = 0;
try {
- result = RequestsDatabase.updateInfraFinalStatus (requestId,
+ result = (RequestsDatabase.getInstance()).updateInfraFinalStatus (requestId,
status.toString (),
this.errorMessage,
this.progress,
@@ -939,6 +982,20 @@ public class MsoRequest {
//mapper.configure(Feature.WRAP_ROOT_VALUE, true);
msoLogger.debug ("building sir from object " + sir);
requestJSON = mapper.writeValueAsString(sir);
+
+ // Perform mapping from VID-style modelInfo fields to ASDC-style modelInfo fields
+
+ msoLogger.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\":");
+ msoLogger.debug("REQUEST JSON after mapping: " + requestJSON);
+
return requestJSON;
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java
index 59b93eadde..f61a50bb06 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkInfoHandler.java
@@ -39,8 +39,6 @@ import javax.xml.bind.Unmarshaller;
import javax.xml.transform.sax.SAXSource;
import org.apache.http.HttpStatus;
-import org.xml.sax.InputSource;
-
import org.openecomp.mso.apihandler.common.ValidationException;
import org.openecomp.mso.apihandlerinfra.networkbeans.ActionType;
import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkInputs;
@@ -55,8 +53,13 @@ import org.openecomp.mso.requestsdb.InfraActiveRequests;
import org.openecomp.mso.requestsdb.InfraRequests;
import org.openecomp.mso.requestsdb.RequestsDatabase;
import org.openecomp.mso.utils.UUIDChecker;
+import org.xml.sax.InputSource;
+
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
@Path("/{version: v1|v2|v3}/network-request")
+@Api(value="/{version: v1|v2|v3}/network-request",description="API Requests for network requests")
public class NetworkInfoHandler {
protected ObjectFactory beansObjectFactory = new ObjectFactory ();
@@ -64,6 +67,7 @@ public class NetworkInfoHandler {
private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
@GET
+ @ApiOperation(value="Finds Network Requests",response=Response.class)
public Response queryFilters (@QueryParam("network-type") String networkType,
@QueryParam("service-type") String serviceType,
@QueryParam("aic-node-clli") String aicNodeClli,
@@ -94,6 +98,7 @@ public class NetworkInfoHandler {
@GET
@Path(Constants.REQUEST_ID_PATH)
+ @ApiOperation(value="Add a Network Outputs from requestId and version",response=Response.class)
public Response getRequest (@PathParam("request-id") String requestId, @PathParam("version") String version) {
// Check INFRA_ACTIVE_REQUESTS table to find info
// on this request
@@ -213,7 +218,7 @@ public class NetworkInfoHandler {
String responseString = null;
- InfraActiveRequests activeReq = RequestsDatabase.getRequestFromInfraActive (requestId, "NETWORK");
+ InfraActiveRequests activeReq = (RequestsDatabase.getInstance()).getRequestFromInfraActive (requestId, "NETWORK");
if (activeReq != null) {
// build response for active
responseString = infraRequestsResponse (activeReq, version);
@@ -230,7 +235,7 @@ public class NetworkInfoHandler {
getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue);
- List <InfraActiveRequests> activeReqList = RequestsDatabase.getRequestListFromInfraActive (queryAttribute,
+ List <InfraActiveRequests> activeReqList = (RequestsDatabase.getInstance()).getRequestListFromInfraActive (queryAttribute,
queryValue,
"NETWORK");
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java
index c25f5ce1ef..4f022c2b16 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkMsoInfraRequest.java
@@ -56,10 +56,10 @@ import org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType;
import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoLogger;
import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.db.HibernateUtils;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
import org.openecomp.mso.requestsdb.InfraActiveRequests;
import org.openecomp.mso.requestsdb.RequestsDatabase;
-import org.openecomp.mso.requestsdb.HibernateUtilsRequestsDb;
+import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
public class NetworkMsoInfraRequest {
@@ -80,7 +80,7 @@ public class NetworkMsoInfraRequest {
private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
private static final String NOT_PROVIDED = "not provided";
- protected HibernateUtils hibernateUtils = new HibernateUtilsRequestsDb ();
+ protected AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager ();
NetworkMsoInfraRequest (String requestId) {
this.requestId = requestId;
@@ -255,7 +255,7 @@ public class NetworkMsoInfraRequest {
Session session = null;
try {
- session = hibernateUtils.getSessionFactory ().openSession ();
+ session = requestsDbSessionFactoryManager.getSessionFactory ().openSession ();
session.beginTransaction ();
InfraActiveRequests aq = new InfraActiveRequests ();
@@ -348,7 +348,7 @@ public class NetworkMsoInfraRequest {
public void updateFinalStatus (Status status) {
try {
- RequestsDatabase.updateInfraFinalStatus (requestId,
+ (RequestsDatabase.getInstance()).updateInfraFinalStatus (requestId,
status.toString (),
this.errorMessage,
this.progress,
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java
index 8d44d213b1..1922cb421a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandler.java
@@ -94,6 +94,8 @@ public class NetworkRequestHandler {
.entity (NOT_FOUND)
.build ();
+ private RequestsDatabase requestDB = RequestsDatabase.getInstance();
+
@GET
public Response queryFilters (@QueryParam("network-type") String networkType,
@QueryParam("service-type") String serviceType,
@@ -244,7 +246,7 @@ public class NetworkRequestHandler {
String responseString = null;
- InfraActiveRequests activeReq = RequestsDatabase.getRequestFromInfraActive (requestId, "NETWORK");
+ InfraActiveRequests activeReq = requestDB.getRequestFromInfraActive (requestId, "NETWORK");
if (activeReq != null) {
// build response for active
responseString = infraRequestsResponse (activeReq, version);
@@ -261,7 +263,7 @@ public class NetworkRequestHandler {
getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue);
- List <InfraActiveRequests> activeReqList = RequestsDatabase.getRequestListFromInfraActive (queryAttribute,
+ List <InfraActiveRequests> activeReqList = requestDB.getRequestListFromInfraActive (queryAttribute,
queryValue,
"NETWORK");
@@ -433,7 +435,7 @@ public class NetworkRequestHandler {
InfraActiveRequests dup = null;
try {
- dup = RequestsDatabase.checkDuplicateByVnfName (msoRequest.getNetworkInputs ().getNetworkName (),
+ dup = requestDB.checkDuplicateByVnfName (msoRequest.getNetworkInputs ().getNetworkName (),
msoRequest.getRequestInfo ().getAction ().value (),
"NETWORK");
@@ -471,7 +473,7 @@ public class NetworkRequestHandler {
InfraActiveRequests dup = null;
msoLogger.debug ("Checking for a duplicate with the same network-id");
try {
- dup = RequestsDatabase.checkDuplicateByVnfId (msoRequest.getNetworkInputs ().getNetworkId (),
+ dup = requestDB.checkDuplicateByVnfId (msoRequest.getNetworkInputs ().getNetworkId (),
msoRequest.getRequestInfo ().getAction ().value (),
"NETWORK");
@@ -511,7 +513,7 @@ public class NetworkRequestHandler {
String orchestrationURI = "";
// Query MSO Catalog DB
- try (CatalogDatabase db = new CatalogDatabase()) {
+ try (CatalogDatabase db = CatalogDatabase.getInstance()) {
Recipe recipe = null;
@@ -618,7 +620,7 @@ public class NetworkRequestHandler {
String bpelXMLResponseBody = respHandler.getResponseBody ();
msoLogger.debug ("Received from BPEL: " + bpelXMLResponseBody);
msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.networkbeans.RequestStatusType.IN_PROGRESS);
- RequestsDatabase.updateInfraStatus (msoRequest.getRequestId (),
+ requestDB.updateInfraStatus (msoRequest.getRequestId (),
Status.IN_PROGRESS.toString (),
Constants.PROGRESS_REQUEST_IN_PROGRESS,
Constants.MODIFIED_BY_APIHANDLER);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java
index 3bdb745b15..bd47c8a4dd 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NetworkTypesHandler.java
@@ -26,28 +26,34 @@ import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import org.apache.http.HttpStatus;
-
import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkType;
import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkTypes;
import org.openecomp.mso.apihandlerinfra.networkbeans.ObjectFactory;
import org.openecomp.mso.db.catalog.CatalogDatabase;
import org.openecomp.mso.db.catalog.beans.NetworkResource;
import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.requestsdb.RequestsDatabase;
import org.openecomp.mso.utils.UUIDChecker;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+
@Path(Constants.NETWORK_TYPES_PATH)
+@Api(value="/{version: v1|v2|v3}/network-types",description="API Requests to find Network Types")
public class NetworkTypesHandler {
private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
@GET
- public Response getNetworkTypes () {
+ @ApiOperation(value="Finds Network Types",response=Response.class)
+ public Response getNetworkTypes (@PathParam("version") String version) {
long startTime = System.currentTimeMillis ();
MsoLogger.setServiceName ("getNetworkTypes");
// Generate a Request Id
@@ -55,7 +61,7 @@ public class NetworkTypesHandler {
msoLogger.debug ("Incoming request received for getNetworkTypes");
List <NetworkResource> networkResources = null;
- try (CatalogDatabase db = new CatalogDatabase()){
+ try (CatalogDatabase db = CatalogDatabase.getInstance()){
networkResources = db.getAllNetworkResources ();
} catch (Exception e) {
msoLogger.debug ("No connection to catalog DB", e);
@@ -75,9 +81,9 @@ public class NetworkTypesHandler {
for (int i = 0; i < networkResources.size (); i++) {
NetworkType networkType = beansObjectFactory.createNetworkType ();
NetworkResource vr = networkResources.get (i);
- networkType.setType (vr.getNetworkType ());
+ networkType.setType (vr.getModelName());
networkType.setDescription (vr.getDescription ());
- networkType.setId (String.valueOf (vr.getId ()));
+ networkType.setId (String.valueOf (vr.getModelUUID()));
networkTypes.getNetworkType ().add (networkType);
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NodeHealthcheckHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NodeHealthcheckHandler.java
new file mode 100644
index 0000000000..cb4b94ce3a
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/NodeHealthcheckHandler.java
@@ -0,0 +1,46 @@
+package org.openecomp.mso.apihandlerinfra;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.HEAD;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Response;
+
+import org.openecomp.mso.HealthCheckUtils;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.utils.UUIDChecker;
+
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+
+@Path("/nodehealthcheck")
+@Api(value="/nodehealthcheck",description="API Handler Infra Node Health Check")
+public class NodeHealthcheckHandler {
+
+ public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
+
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
+
+ @HEAD
+ @GET
+ @Produces("text/html")
+ @ApiOperation(value="Performing node health check",response=Response.class)
+ public Response nodeHealthcheck () {
+ long startTime = System.currentTimeMillis ();
+ MsoLogger.setServiceName ("NodeHealthcheck");
+ // Generate a Request Id
+ String requestId = UUIDChecker.generateUUID(msoLogger);
+ HealthCheckUtils healthCheck = new HealthCheckUtils ();
+ if (!healthCheck.siteStatusCheck (msoLogger, startTime)) {
+ return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
+ }
+
+ if (healthCheck.verifyNodeHealthCheck(HealthCheckUtils.NodeType.APIH, requestId)) {
+ msoLogger.debug("nodeHealthcheck - Successful");
+ return HealthCheckUtils.HEALTH_CHECK_RESPONSE;
+ } else {
+ msoLogger.debug("nodeHealthcheck - At leaset one of the sub-modules is not available.");
+ return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
+ }
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java
index f42ba97e89..4f0bad9028 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequests.java
@@ -24,7 +24,12 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import javax.ws.rs.*;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
@@ -33,16 +38,26 @@ import javax.ws.rs.core.UriInfo;
import org.apache.http.HttpStatus;
import org.codehaus.jackson.map.ObjectMapper;
-
import org.openecomp.mso.apihandler.common.ErrorNumbers;
-import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.*;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.GetOrchestrationListResponse;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.GetOrchestrationResponse;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.InstanceReferences;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.Request;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestDetails;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestList;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestStatus;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest;
import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoAlarmLogger;
import org.openecomp.mso.logger.MsoLogger;
import org.openecomp.mso.requestsdb.InfraActiveRequests;
import org.openecomp.mso.requestsdb.RequestsDatabase;
-@Path("/")
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+
+@Path("/orchestrationRequests")
+@Api(value="/orchestrationRequests",description="API Requests for Orchestration requests")
public class OrchestrationRequests {
public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
@@ -51,6 +66,8 @@ public class OrchestrationRequests {
private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
+ private RequestsDatabase requestsDB = RequestsDatabase.getInstance();
+
/**
*
*/
@@ -59,9 +76,10 @@ public class OrchestrationRequests {
}
@GET
- @Path("/orchestrationRequests/{version:[vV][2-3]}/{requestId}")
+ @Path("/{version:[vV][2-5]}/{requestId}")
+ @ApiOperation(value="Find Orchestrated Requests for a given requestId",response=Response.class)
@Produces(MediaType.APPLICATION_JSON)
- public Response getOrchestrationRequest(@PathParam("requestId") String requestId) {
+ public Response getOrchestrationRequest(@PathParam("requestId") String requestId, @PathParam("version") String version) {
GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse();
@@ -72,7 +90,7 @@ public class OrchestrationRequests {
InfraActiveRequests requestDB = null;
try {
- requestDB = RequestsDatabase.getRequestFromInfraActive(requestId);
+ requestDB = requestsDB.getRequestFromInfraActive(requestId);
} catch (Exception e) {
msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Request DB - Infra Request Lookup", e);
@@ -112,9 +130,10 @@ public class OrchestrationRequests {
}
@GET
- @Path("/orchestrationRequests/{version:[vV][2-3]}")
+ @Path("/{version:[vV][2-5]}")
+ @ApiOperation(value="Find Orchestrated Requests for a URI Information",response=Response.class)
@Produces(MediaType.APPLICATION_JSON)
- public Response getOrchestrationRequest(@Context UriInfo ui) {
+ public Response getOrchestrationRequest(@Context UriInfo ui, @PathParam("version") String version) {
long startTime = System.currentTimeMillis ();
@@ -131,7 +150,7 @@ public class OrchestrationRequests {
Map<String, List<String>> orchestrationMap = msoRequest.getOrchestrationFilters(queryParams);
- activeRequests = RequestsDatabase.getOrchestrationFiltersFromInfraActive(orchestrationMap);
+ activeRequests = requestsDB.getOrchestrationFiltersFromInfraActive(orchestrationMap);
orchestrationList = new GetOrchestrationListResponse();
@@ -166,10 +185,11 @@ public class OrchestrationRequests {
@POST
- @Path("/orchestrationRequests/v3/{requestId}/unlock")
+ @Path("/{version: [vV][3-5]}/{requestId}/unlock")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
- public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId) {
+ @ApiOperation(value="Unlock Orchestrated Requests for a given requestId",response=Response.class)
+ public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId, @PathParam("version") String version) {
MsoRequest msoRequest = new MsoRequest (requestId);
@@ -218,7 +238,7 @@ public class OrchestrationRequests {
}
try {
- requestDB = RequestsDatabase.getRequestFromInfraActive(requestId);
+ requestDB = requestsDB.getRequestFromInfraActive(requestId);
if(requestDB == null) {
Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
@@ -238,7 +258,7 @@ public class OrchestrationRequests {
if(status == Status.IN_PROGRESS || status == Status.PENDING){
msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.UNLOCKED);
reqStatus.setRequestState(Status.UNLOCKED.toString ());
- RequestsDatabase.updateInfraStatus (requestId,
+ requestsDB.updateInfraStatus (requestId,
Status.UNLOCKED.toString (),
Constants.MODIFIED_BY_APIHANDLER);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RequestActionMap.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RequestActionMap.java
index 940fcc9c57..e6887a59e9 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RequestActionMap.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/RequestActionMap.java
@@ -43,6 +43,7 @@ public class RequestActionMap {
actionMap.put("createInstance", "createInstance");
actionMap.put("deleteInstance", "deleteInstance");
actionMap.put("updateInstance", "updateInstance");
+ actionMap.put("replaceInstance", "replaceInstance");
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java
index 988d72cc6f..91888f8a35 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java
@@ -36,55 +36,91 @@ import javax.ws.rs.core.Response;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.codehaus.jackson.map.ObjectMapper;
-
-import org.openecomp.mso.apihandler.common.*;
-import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.*;
+import org.openecomp.mso.apihandler.common.ErrorNumbers;
+import org.openecomp.mso.apihandler.common.RequestClient;
+import org.openecomp.mso.apihandler.common.RequestClientFactory;
+import org.openecomp.mso.apihandler.common.ResponseHandler;
+import org.openecomp.mso.apihandler.common.ValidationException;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ModelInfo;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RelatedInstance;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RelatedInstanceList;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestParameters;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestReferences;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesResponse;
import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.*;
+import org.openecomp.mso.db.catalog.beans.NetworkResource;
+import org.openecomp.mso.db.catalog.beans.Recipe;
+import org.openecomp.mso.db.catalog.beans.Service;
+import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
+import org.openecomp.mso.db.catalog.beans.VfModule;
+import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
+import org.openecomp.mso.db.catalog.beans.VnfRecipe;
+import org.openecomp.mso.db.catalog.beans.VnfResource;
+import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoAlarmLogger;
import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
import org.openecomp.mso.requestsdb.InfraActiveRequests;
import org.openecomp.mso.requestsdb.RequestsDatabase;
import org.openecomp.mso.utils.UUIDChecker;
-@Path("/serviceInstances/{version:[vV][2-3]}")
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+
+@Path("/serviceInstances")
+@Api(value="/serviceInstances",description="API Requests for Service Instances")
public class ServiceInstances {
- private HashMap<String, String> instanceIdMap = new HashMap<String,String>();
+ private HashMap<String, String> instanceIdMap = new HashMap<String,String>();
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
+ private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
+ public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
+ @POST
+ @Path("/{version:[vV][3-5]}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Create a Service Instance on a version provided",response=Response.class)
+ public Response createServiceInstance(String request, @PathParam("version") String version) {
- private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
+ Response response = serviceInstances(request, Action.createInstance, null, version);
- public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
+ return response;
+ }
+
+ @POST
+ @Path("/{version:[vV][5]}/{serviceInstanceId}/activate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Activate provided Service Instance",response=Response.class)
+ public Response activateServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId) {
- private static MsoJavaProperties props = MsoPropertiesUtils.loadMsoProperties ();
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ Response response = serviceInstances(request, Action.activateInstance, instanceIdMap, version);
- /**
- *
- */
- public ServiceInstances() {
- // TODO Auto-generated constructor stub
+ return response;
}
-
+
@POST
- @Path("/")
+ @Path("/{version:[vV][5]}/{serviceInstanceId}/deactivate")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
- public Response createServiceInstance(String request, @PathParam("version") String version) {
+ @ApiOperation(value="Deactivate provided Service Instance",response=Response.class)
+ public Response deactivateServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId) {
- Response response = serviceInstances(request, Action.createInstance, null, version);
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ Response response = serviceInstances(request, Action.deactivateInstance, instanceIdMap, version);
return response;
}
+
@DELETE
- @Path("/{serviceInstanceId}")
+ @Path("/{version:[vV][3-5]}/{serviceInstanceId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Delete provided Service Instance",response=Response.class)
public Response deleteServiceInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId) {
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
@@ -93,23 +129,56 @@ public class ServiceInstances {
}
@POST
- @Path("/{serviceInstanceId}/vnfs")
+ @Path("/{version:[vV][3-5]}/{serviceInstanceId}/vnfs")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Create VNF on a specified version and serviceInstance",response=Response.class)
public Response createVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId) {
- msoLogger.debug ("version is: " + version);
+ msoLogger.debug ("version is: " + version);
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
Response response = serviceInstances(request, Action.createInstance, instanceIdMap, version);
return response;
}
+
+ @POST
+ @Path("/{version:[vV][5]}/{serviceInstanceId}/vnfs/{vnfInstanceId}/replace")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Replace provided VNF instance",response=Response.class)
+ public Response replaceVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId) {
+ msoLogger.debug ("version is: " + version);
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ Response response = serviceInstances(request, Action.replaceInstance, instanceIdMap, version);
+
+ return response;
+ }
+
+ @PUT
+ @Path("/{version:[vV][5]}/{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)
+ public Response updateVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId) {
+
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ Response response = serviceInstances(request, Action.updateInstance, instanceIdMap, version);
+
+ return response;
+ }
+
@DELETE
- @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}")
+ @Path("/{version:[vV][3-5]}/{serviceInstanceId}/vnfs/{vnfInstanceId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Delete provided VNF instance",response=Response.class)
public Response deleteVnfInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId) {
+ @PathParam("vnfInstanceId") String vnfInstanceId) {
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
@@ -119,26 +188,46 @@ public class ServiceInstances {
}
@POST
- @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules")
+ @Path("/{version:[vV][3-5]}/{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)
public Response createVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId) {
- msoLogger.debug ("version is: " + version);
+ @PathParam("vnfInstanceId") String vnfInstanceId) {
+ msoLogger.debug ("version is: " + version);
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
Response response = serviceInstances(request, Action.createInstance, instanceIdMap, version);
return response;
}
+
+ @POST
+ @Path("/{version:[vV][5]}/{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)
+ public Response replaceVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
+ @PathParam("vnfInstanceId") String vnfInstanceId,
+ @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId) {
+
+ msoLogger.debug ("version is: " + version);
+ instanceIdMap.put("serviceInstanceId", serviceInstanceId);
+ instanceIdMap.put("vnfInstanceId", vnfInstanceId);
+ instanceIdMap.put("vfModuleInstanceId", vfmoduleInstanceId);
+ Response response = serviceInstances(request, Action.replaceInstance, instanceIdMap, version);
+
+ return response;
+ }
@PUT
- @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}")
+ @Path("/{version:[vV][3-5]}/{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)
public Response updateVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId,
- @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId) {
+ @PathParam("vnfInstanceId") String vnfInstanceId,
+ @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId) {
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
@@ -149,12 +238,13 @@ public class ServiceInstances {
}
@DELETE
- @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}")
+ @Path("/{version:[vV][3-5]}/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfmoduleInstanceId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Delete provided VfModule instance",response=Response.class)
public Response deleteVfModuleInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId,
- @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId) {
+ @PathParam("vnfInstanceId") String vnfInstanceId,
+ @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId) {
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
@@ -167,11 +257,12 @@ public class ServiceInstances {
@POST
- @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups")
+ @Path("/{version:[vV][3-5]}/{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)
public Response createVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId) {
+ @PathParam("vnfInstanceId") String vnfInstanceId) {
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("vnfInstanceId", vnfInstanceId);
@@ -181,12 +272,13 @@ public class ServiceInstances {
}
@PUT
- @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}")
+ @Path("/{version:[vV][3-5]}/{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)
public Response updateVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId,
- @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId) {
+ @PathParam("vnfInstanceId") String vnfInstanceId,
+ @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId) {
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
@@ -198,12 +290,13 @@ public class ServiceInstances {
}
@DELETE
- @Path("/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}")
+ @Path("/{version:[vV][3-5]}/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupInstanceId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Delete provided VolumeGroup instance",response=Response.class)
public Response deleteVolumeGroupInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("vnfInstanceId") String vnfInstanceId,
- @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId) {
+ @PathParam("vnfInstanceId") String vnfInstanceId,
+ @PathParam("volumeGroupInstanceId") String volumeGroupInstanceId) {
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
@@ -215,9 +308,10 @@ public class ServiceInstances {
}
@POST
- @Path("/{serviceInstanceId}/networks")
+ @Path("/{version:[vV][3-5]}/{serviceInstanceId}/networks")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Create NetworkInstance on a specified version and serviceInstance ",response=Response.class)
public Response createNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId) {
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
@@ -227,11 +321,12 @@ public class ServiceInstances {
}
@PUT
- @Path("/{serviceInstanceId}/networks/{networkInstanceId}")
+ @Path("/{version:[vV][3-5]}/{serviceInstanceId}/networks/{networkInstanceId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Update VolumeGroup on a specified version, serviceInstance, networkInstance",response=Response.class)
public Response updateNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("networkInstanceId") String networkInstanceId) {
+ @PathParam("networkInstanceId") String networkInstanceId) {
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("networkInstanceId", networkInstanceId);
@@ -241,11 +336,12 @@ public class ServiceInstances {
}
@DELETE
- @Path("/{serviceInstanceId}/networks/{networkInstanceId}")
+ @Path("/{version:[vV][3-5]}/{serviceInstanceId}/networks/{networkInstanceId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value="Delete provided Network instance",response=Response.class)
public Response deleteNetworkInstance(String request, @PathParam("version") String version, @PathParam("serviceInstanceId") String serviceInstanceId,
- @PathParam("networkInstanceId") String networkInstanceId) {
+ @PathParam("networkInstanceId") String networkInstanceId) {
instanceIdMap.put("serviceInstanceId", serviceInstanceId);
instanceIdMap.put("networkInstanceId", networkInstanceId);
@@ -258,573 +354,647 @@ public class ServiceInstances {
private Response serviceInstances(String requestJSON, Action action, HashMap<String,String> instanceIdMap, String version) {
- String requestId = UUIDChecker.generateUUID(msoLogger);
- long startTime = System.currentTimeMillis ();
- msoLogger.debug ("requestId is: " + requestId);
- ServiceInstancesRequest sir = null;
-
- MsoRequest msoRequest = new MsoRequest (requestId);
-
-
- try{
- ObjectMapper mapper = new ObjectMapper();
- sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
-
- } catch(Exception e){
- msoLogger.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);
- if (msoRequest.getRequestId () != null) {
- msoLogger.debug ("Mapping of request to JSON object failed");
- msoRequest.createRequestRecord (Status.FAILED, action);
- }
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
-
- try{
- msoRequest.parse(sir, instanceIdMap, action, version);
- } catch (Exception e) {
- msoLogger.debug ("Validation failed: ", e);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException,
- "Error parsing request. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- if (msoRequest.getRequestId () != null) {
- msoLogger.debug ("Logging failed message to the database");
- msoRequest.createRequestRecord (Status.FAILED, action);
- }
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- InfraActiveRequests dup = null;
- String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
- String requestScope = sir.getRequestDetails().getModelInfo().getModelType().name();
- try {
- if(!(instanceName==null && requestScope.equals("service") && action == Action.createInstance)){
- dup = RequestsDatabase.checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope);
- }
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Error during duplicate check ", e);
-
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException,
- e.getMessage(),
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null) ;
-
-
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Error during duplicate check");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- if (dup != null) {
- // Found the duplicate record. Return the appropriate error.
- String instance = null;
- if(instanceName != null){
- instance = instanceName;
- }else{
- instance = instanceIdMap.get(requestScope + "InstanceId");
- }
- String dupMessage = "Error: Locked instance - This " + requestScope + " (" + instance + ") " + "already has a request being worked with a status of " + dup.getRequestStatus() + " (RequestId - " + dup.getRequestId() + "). The existing request must finish or be cleaned up before proceeding.";
- //List<String> variables = new ArrayList<String>();
- //variables.add(dup.getRequestStatus());
-
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT, MsoException.ServiceException,
- dupMessage,
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- null) ;
-
-
- msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, dupMessage, "", "", MsoLogger.ErrorCode.SchemaError, "Duplicate request - Subscriber already has a request for this service");
- msoRequest.createRequestRecord (Status.FAILED, action);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, dupMessage);
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
-
- ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
-
- RequestReferences referencesResponse = new RequestReferences();
-
- referencesResponse.setRequestId(requestId);
-
- serviceResponse.setRequestReferences(referencesResponse);
-
- CatalogDatabase db = null;
- try {
- db = new CatalogDatabase ();
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- "No communication to catalog DB " + e.getMessage (),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES,
- null);
- alarmLogger.sendAlarm ("MsoDatabaseAccessError",
- MsoAlarmLogger.CRITICAL,
- Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
- msoRequest.createRequestRecord (Status.FAILED,action);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with DB");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
-
-
- RecipeLookupResult recipeLookupResult = null;
- try {
- recipeLookupResult = getServiceInstanceOrchestrationURI (db, msoRequest, action);
- } catch (ValidationException e) {
- msoLogger.debug ("Validation failed: ", e);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException,
- "Error validating request. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- if (msoRequest.getRequestId () != null) {
- msoLogger.debug ("Logging failed message to the database");
- msoRequest.createRequestRecord (Status.FAILED, action);
- }
- msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Exception while querying Catalog DB", e);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- "Recipe could not be retrieved from catalog DB " + e.getMessage (),
- ErrorNumbers.SVC_GENERAL_SERVICE_ERROR,
- null);
- alarmLogger.sendAlarm ("MsoDatabaseAccessError",
- MsoAlarmLogger.CRITICAL,
- Messages.errors.get (ErrorNumbers.ERROR_FROM_CATALOG_DB));
- msoRequest.createRequestRecord (Status.FAILED,action);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while querying Catalog DB");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- db.close();
- return response;
- }
-
- if (recipeLookupResult == null) {
- msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "No recipe found in DB");
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- "Recipe does not exist in catalog DB",
- ErrorNumbers.SVC_GENERAL_SERVICE_ERROR,
- null);
- msoRequest.createRequestRecord (Status.FAILED, action);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "No recipe found in DB");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- db.close();
- return response;
- }
-
-
- Boolean isBaseVfModule = false;
-
- if (msoRequest.getModelInfo().getModelType().equals(ModelType.vfModule)) {
- String asdcServiceModelVersion = msoRequest.getAsdcServiceModelVersion ();
-
- // Get VF Module-specific base module indicator
- VfModule vfm = null;
-
- if (asdcServiceModelVersion != null && !asdcServiceModelVersion.isEmpty ()) {
- vfm = db.getVfModuleType (msoRequest.getVfModuleType (), asdcServiceModelVersion);
- }
- else {
- vfm = db.getVfModuleType (msoRequest.getVfModuleType ());
- }
-
- if (vfm != null) {
- if (vfm.getIsBase() == 1) {
- 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
- msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "VF Module Type", "", MsoLogger.ErrorCode.DataError, "No VfModuleType found in DB");
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- String serviceVersionText = "";
- if (asdcServiceModelVersion != null && !asdcServiceModelVersion.isEmpty ()) {
- serviceVersionText = " with version " + asdcServiceModelVersion;
- }
- Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException,
- "VnfType " + msoRequest.getVnfType () + " and VF Module Model Name " + msoRequest.getVfModuleModelName() + serviceVersionText + " not found in MSO Catalog DB",
- ErrorNumbers.SVC_BAD_PARAMETER,
- null);
- msoRequest.createRequestRecord (Status.FAILED, action);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "No matching vfModuleType found in DB");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- db.close();
- return response;
- }
- }
-
- db.close();
-
- String serviceInstanceId = "";
- String vnfId = "";
- String vfModuleId = "";
- String volumeGroupId = "";
- String networkId = "";
- ServiceInstancesRequest siReq = msoRequest.getServiceInstancesRequest();
-
- if(siReq.getServiceInstanceId () != null){
- serviceInstanceId = siReq.getServiceInstanceId ();
- }
-
- if(siReq.getVnfInstanceId () != null){
- vnfId = siReq.getVnfInstanceId ();
- }
-
- if(siReq.getVfModuleInstanceId () != null){
- vfModuleId = siReq.getVfModuleInstanceId ();
- }
-
- if(siReq.getVolumeGroupInstanceId () != null){
- volumeGroupId = siReq.getVolumeGroupInstanceId ();
- }
-
- if(siReq.getNetworkInstanceId () != null){
- networkId = siReq.getNetworkInstanceId ();
- }
-
-
- requestId = msoRequest.getRequestId ();
- msoLogger.debug ("requestId is: " + requestId);
- msoLogger.debug ("About to insert a record");
-
- try {
- msoRequest.createRequestRecord (Status.PENDING, action);
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, "Exception while creating record in DB", "", "", MsoLogger.ErrorCode.SchemaError, "Exception while creating record in DB", e);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_INTERNAL_SERVER_ERROR,
- MsoException.ServiceException,
- "Exception while creating record in DB " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER,
- null);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while creating record in DB");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
- return response;
- }
-
- RequestClient requestClient = null;
- HttpResponse response = null;
- long subStartTime = System.currentTimeMillis();
- try {
- requestClient = RequestClientFactory.getRequestClient (recipeLookupResult.getOrchestrationURI (), props);
- // Capture audit event
- msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ());
-
- System.out.println("URL : " + requestClient.getUrl ());
-
- response = requestClient.post(requestId, isBaseVfModule, recipeLookupResult.getRecipeTimeout (), action.name (),
- serviceInstanceId, vnfId, vfModuleId, volumeGroupId, networkId,
- msoRequest.getServiceInstanceType (),
- msoRequest.getVnfType (), msoRequest.getVfModuleType (),
- msoRequest.getNetworkType (), msoRequest.getRequestJSON());
-
- msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI (), null);
- } catch (Exception e) {
- msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI (), null);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,
- MsoException.ServiceException,
- "Failed calling bpmn " + e.getMessage (),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES,
- null);
- alarmLogger.sendAlarm ("MsoConfigurationError",
- MsoAlarmLogger.CRITICAL,
- Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
- msoRequest.updateFinalStatus (Status.FAILED);
- msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- }
-
- if (response == null) {
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,
- MsoException.ServiceException,
- "bpelResponse is null",
- ErrorNumbers.SVC_NO_SERVER_RESOURCES,
- null);
- msoRequest.updateFinalStatus (Status.FAILED);
- msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Null response from BPMN");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- }
-
- ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ());
- int bpelStatus = respHandler.getStatus ();
-
- // BPEL accepted the request, the request is in progress
- if (bpelStatus == HttpStatus.SC_ACCEPTED) {
- String camundaJSONResponseBody = respHandler.getResponseBody ();
- msoLogger.debug ("Received from Camunda: " + camundaJSONResponseBody);
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.IN_PROGRESS);
- RequestsDatabase.updateInfraStatus (msoRequest.getRequestId (),
- Status.IN_PROGRESS.toString (),
- Constants.PROGRESS_REQUEST_IN_PROGRESS,
- Constants.MODIFIED_BY_APIHANDLER);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN accepted the request, the request is in progress");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) camundaJSONResponseBody);
- return Response.status (HttpStatus.SC_ACCEPTED).entity (camundaJSONResponseBody).build ();
- } else {
- List<String> variables = new ArrayList<String>();
- variables.add(bpelStatus + "");
- String camundaJSONResponseBody = respHandler.getResponseBody ();
- if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty ()) {
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- 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);
- msoRequest.updateFinalStatus (Status.FAILED);
- msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is failed with HTTP Status=" + bpelStatus);
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPMN engine is failed");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- } else {
- msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response resp = msoRequest.buildServiceErrorResponse(bpelStatus,
- MsoException.ServiceException,
- "Request Failed due to BPEL error with HTTP Status= %1" ,
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
- variables);
- msoRequest.updateFinalStatus (Status.FAILED);
- msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty");
- msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPEL engine is empty");
- msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
- return resp;
- }
- }
-
- //return Response.status (HttpStatus.SC_ACCEPTED).entity (serviceResponse).build ();
- // return serviceResponse;
+ String requestId = UUIDChecker.generateUUID(msoLogger);
+ long startTime = System.currentTimeMillis ();
+ msoLogger.debug ("requestId is: " + requestId);
+ ServiceInstancesRequest sir = null;
+
+ MsoRequest msoRequest = new MsoRequest (requestId);
+
+
+ try{
+ ObjectMapper mapper = new ObjectMapper();
+ sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);
+
+ } catch(Exception e){
+ msoLogger.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);
+ if (msoRequest.getRequestId () != null) {
+ msoLogger.debug ("Mapping of request to JSON object failed");
+ msoRequest.createRequestRecord (Status.FAILED, action);
+ }
+ msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Mapping of request to JSON object failed");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
+ return response;
+ }
+
+
+ try{
+ msoRequest.parse(sir, instanceIdMap, action, version);
+ } catch (Exception e) {
+ msoLogger.debug ("Validation failed: ", e);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException,
+ "Error parsing request. " + e.getMessage(),
+ ErrorNumbers.SVC_BAD_PARAMETER, null);
+ if (msoRequest.getRequestId () != null) {
+ msoLogger.debug ("Logging failed message to the database");
+ msoRequest.createRequestRecord (Status.FAILED, action);
+ }
+ msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
+ return response;
+ }
+
+ InfraActiveRequests dup = null;
+ String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
+ String requestScope = sir.getRequestDetails().getModelInfo().getModelType().name();
+ try {
+ if(!(instanceName==null && requestScope.equals("service") && (action == Action.createInstance || action == Action.activateInstance))){
+ dup = (RequestsDatabase.getInstance()).checkInstanceNameDuplicate (instanceIdMap, instanceName, requestScope);
+ }
+ } catch (Exception e) {
+ msoLogger.error (MessageEnum.APIH_DUPLICATE_CHECK_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Error during duplicate check ", e);
+
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException,
+ e.getMessage(),
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
+ null) ;
+
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Error during duplicate check");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
+ return response;
+ }
+
+ if (dup != null) {
+ // Found the duplicate record. Return the appropriate error.
+ String instance = null;
+ if(instanceName != null){
+ instance = instanceName;
+ }else{
+ instance = instanceIdMap.get(requestScope + "InstanceId");
+ }
+ String dupMessage = "Error: Locked instance - This " + requestScope + " (" + instance + ") " + "already has a request being worked with a status of " + dup.getRequestStatus() + " (RequestId - " + dup.getRequestId() + "). The existing request must finish or be cleaned up before proceeding.";
+ //List<String> variables = new ArrayList<String>();
+ //variables.add(dup.getRequestStatus());
+
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT, MsoException.ServiceException,
+ dupMessage,
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
+ null) ;
+
+
+ msoLogger.warn (MessageEnum.APIH_DUPLICATE_FOUND, dupMessage, "", "", MsoLogger.ErrorCode.SchemaError, "Duplicate request - Subscriber already has a request for this service");
+ msoRequest.createRequestRecord (Status.FAILED, action);
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, dupMessage);
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
+ return response;
+ }
+
+
+ ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
+
+ RequestReferences referencesResponse = new RequestReferences();
+
+ referencesResponse.setRequestId(requestId);
+
+ serviceResponse.setRequestReferences(referencesResponse);
+
+ CatalogDatabase db = null;
+ try {
+ db = CatalogDatabase.getInstance();
+ } catch (Exception e) {
+ msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e);
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
+ MsoException.ServiceException,
+ "No communication to catalog DB " + e.getMessage (),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES,
+ null);
+ alarmLogger.sendAlarm ("MsoDatabaseAccessError",
+ MsoAlarmLogger.CRITICAL,
+ Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
+ msoRequest.createRequestRecord (Status.FAILED,action);
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while communciate with DB");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
+ return response;
+ }
+
+
+
+ RecipeLookupResult recipeLookupResult = null;
+ try {
+ recipeLookupResult = getServiceInstanceOrchestrationURI (db, msoRequest, action);
+ } catch (ValidationException e) {
+ msoLogger.debug ("Validation failed: ", e);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException,
+ "Error validating request. " + e.getMessage(),
+ ErrorNumbers.SVC_BAD_PARAMETER, null);
+ if (msoRequest.getRequestId () != null) {
+ msoLogger.debug ("Logging failed message to the database");
+ msoRequest.createRequestRecord (Status.FAILED, action);
+ }
+ msoLogger.error (MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.SchemaError, requestJSON, e);
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError, "Validation of the input request failed");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
+ return response;
+ } catch (Exception e) {
+ msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "Exception while querying Catalog DB", e);
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
+ MsoException.ServiceException,
+ "Recipe could not be retrieved from catalog DB " + e.getMessage (),
+ ErrorNumbers.SVC_GENERAL_SERVICE_ERROR,
+ null);
+ alarmLogger.sendAlarm ("MsoDatabaseAccessError",
+ MsoAlarmLogger.CRITICAL,
+ Messages.errors.get (ErrorNumbers.ERROR_FROM_CATALOG_DB));
+ msoRequest.createRequestRecord (Status.FAILED,action);
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while querying Catalog DB");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
+ db.close();
+ return response;
+ }
+
+ if (recipeLookupResult == null) {
+ msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.DataError, "No recipe found in DB");
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
+ MsoException.ServiceException,
+ "Recipe does not exist in catalog DB",
+ ErrorNumbers.SVC_GENERAL_SERVICE_ERROR,
+ null);
+ msoRequest.createRequestRecord (Status.FAILED, action);
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "No recipe found in DB");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
+ db.close();
+ return response;
+ }
+
+
+ Boolean isBaseVfModule = false;
+
+ if (msoRequest.getModelInfo().getModelType().equals(ModelType.vfModule)) {
+ String asdcServiceModelVersion = msoRequest.getAsdcServiceModelVersion ();
+
+ // Get VF Module-specific base module indicator
+ VfModule vfm = null;
+
+ String modelVersionId = msoRequest.getModelInfo().getModelVersionId();
+
+ if(modelVersionId != null) {
+ vfm = db.getVfModuleByModelUuid(modelVersionId);
+ } else {
+ vfm = db.getVfModuleByModelInvariantUuidAndModelVersion(msoRequest.getModelInfo().getModelInvariantId(), msoRequest.getModelInfo().getModelVersion());
+ }
+
+ if (vfm != null) {
+ if (vfm.getIsBase() == 1) {
+ 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
+ msoLogger.error (MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "VF Module Type", "", MsoLogger.ErrorCode.DataError, "No VfModuleType found in DB");
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ String serviceVersionText = "";
+ if (asdcServiceModelVersion != null && !asdcServiceModelVersion.isEmpty ()) {
+ serviceVersionText = " with version " + asdcServiceModelVersion;
+ }
+ Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_NOT_FOUND,
+ MsoException.ServiceException,
+ "VnfType " + msoRequest.getVnfType () + " and VF Module Model Name " + msoRequest.getVfModuleModelName() + serviceVersionText + " not found in MSO Catalog DB",
+ ErrorNumbers.SVC_BAD_PARAMETER,
+ null);
+ msoRequest.createRequestRecord (Status.FAILED, action);
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound, "No matching vfModuleType found in DB");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
+ db.close();
+ return response;
+ }
+ }
+
+ db.close();
+
+ String serviceInstanceId = "";
+ String vnfId = "";
+ String vfModuleId = "";
+ String volumeGroupId = "";
+ String networkId = "";
+ ServiceInstancesRequest siReq = msoRequest.getServiceInstancesRequest();
+
+ if(siReq.getServiceInstanceId () != null){
+ serviceInstanceId = siReq.getServiceInstanceId ();
+ }
+
+ if(siReq.getVnfInstanceId () != null){
+ vnfId = siReq.getVnfInstanceId ();
+ }
+
+ if(siReq.getVfModuleInstanceId () != null){
+ vfModuleId = siReq.getVfModuleInstanceId ();
+ }
+
+ if(siReq.getVolumeGroupInstanceId () != null){
+ volumeGroupId = siReq.getVolumeGroupInstanceId ();
+ }
+
+ if(siReq.getNetworkInstanceId () != null){
+ networkId = siReq.getNetworkInstanceId ();
+ }
+
+
+ requestId = msoRequest.getRequestId ();
+ msoLogger.debug ("requestId is: " + requestId);
+ msoLogger.debug ("About to insert a record");
+
+ try {
+ msoRequest.createRequestRecord (Status.PENDING, action);
+ } catch (Exception e) {
+ msoLogger.error (MessageEnum.APIH_DB_ACCESS_EXC_REASON, "Exception while creating record in DB", "", "", MsoLogger.ErrorCode.SchemaError, "Exception while creating record in DB", e);
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse (HttpStatus.SC_INTERNAL_SERVER_ERROR,
+ MsoException.ServiceException,
+ "Exception while creating record in DB " + e.getMessage(),
+ ErrorNumbers.SVC_BAD_PARAMETER,
+ null);
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError, "Exception while creating record in DB");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
+ return response;
+ }
+
+ RequestClient requestClient = null;
+ HttpResponse response = null;
+ long subStartTime = System.currentTimeMillis();
+ try {
+ requestClient = RequestClientFactory.getRequestClient (recipeLookupResult.getOrchestrationURI (), MsoPropertiesUtils.loadMsoProperties ());
+ // Capture audit event
+ msoLogger.debug ("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl ());
+
+ System.out.println("URL : " + requestClient.getUrl ());
+
+ response = requestClient.post(requestId, isBaseVfModule, recipeLookupResult.getRecipeTimeout (), action.name (),
+ serviceInstanceId, vnfId, vfModuleId, volumeGroupId, networkId,
+ msoRequest.getServiceInstanceType (),
+ msoRequest.getVnfType (), msoRequest.getVfModuleType (),
+ msoRequest.getNetworkType (), msoRequest.getRequestJSON());
+
+ msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI (), null);
+ } catch (Exception e) {
+ msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI (), null);
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,
+ MsoException.ServiceException,
+ "Failed calling bpmn " + e.getMessage (),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES,
+ null);
+ alarmLogger.sendAlarm ("MsoConfigurationError",
+ MsoAlarmLogger.CRITICAL,
+ Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
+ msoRequest.updateFinalStatus (Status.FAILED);
+ msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
+ return resp;
+ }
+
+ if (response == null) {
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,
+ MsoException.ServiceException,
+ "bpelResponse is null",
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES,
+ null);
+ msoRequest.updateFinalStatus (Status.FAILED);
+ msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Null response from BPMN");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
+ return resp;
+ }
+
+ ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ());
+ int bpelStatus = respHandler.getStatus ();
+
+ // BPEL accepted the request, the request is in progress
+ if (bpelStatus == HttpStatus.SC_ACCEPTED) {
+ String camundaJSONResponseBody = respHandler.getResponseBody ();
+ msoLogger.debug ("Received from Camunda: " + camundaJSONResponseBody);
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.IN_PROGRESS);
+ (RequestsDatabase.getInstance()).updateInfraStatus (msoRequest.getRequestId (),
+ Status.IN_PROGRESS.toString (),
+ Constants.PROGRESS_REQUEST_IN_PROGRESS,
+ Constants.MODIFIED_BY_APIHANDLER);
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN accepted the request, the request is in progress");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) camundaJSONResponseBody);
+ return Response.status (HttpStatus.SC_ACCEPTED).entity (camundaJSONResponseBody).build ();
+ } else {
+ List<String> variables = new ArrayList<String>();
+ variables.add(bpelStatus + "");
+ String camundaJSONResponseBody = respHandler.getResponseBody ();
+ if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty ()) {
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ 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);
+ msoRequest.updateFinalStatus (Status.FAILED);
+ msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is failed with HTTP Status=" + bpelStatus);
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPMN engine is failed");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
+ return resp;
+ } else {
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response resp = msoRequest.buildServiceErrorResponse(bpelStatus,
+ MsoException.ServiceException,
+ "Request Failed due to BPEL error with HTTP Status= %1" ,
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
+ variables);
+ msoRequest.updateFinalStatus (Status.FAILED);
+ msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty");
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPEL engine is empty");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
+ return resp;
+ }
+ }
+
+ //return Response.status (HttpStatus.SC_ACCEPTED).entity (serviceResponse).build ();
+ // return serviceResponse;
}
- private RecipeLookupResult getServiceInstanceOrchestrationURI (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception {
- RecipeLookupResult recipeLookupResult = null;
- //if the aLaCarte flag is set to TRUE, the API-H should choose the “VID_DEFAULT” recipe for the requested action
-
- msoLogger.debug("aLaCarteFlag is " + msoRequest.getALaCarteFlag());
- // Query MSO Catalog DB
-
- if (msoRequest.getModelInfo().getModelType().equals(ModelType.service)) {
- recipeLookupResult = getServiceURI(db, msoRequest, action);
- }
- else if (msoRequest.getModelInfo().getModelType().equals(ModelType.vfModule) ||
- msoRequest.getModelInfo().getModelType().equals(ModelType.volumeGroup) || msoRequest.getModelInfo().getModelType().equals(ModelType.vnf)) {
-
- recipeLookupResult = getVnfOrVfModuleUri(db, msoRequest, action);
-
- }else if (msoRequest.getModelInfo().getModelType().equals(ModelType.network)) {
-
- recipeLookupResult = getNetworkUri(db, msoRequest, action);
- }
-
- if (recipeLookupResult != null) {
- msoLogger.debug ("Orchestration URI is: " + recipeLookupResult.getOrchestrationURI() + ", recipe Timeout is: " + Integer.toString(recipeLookupResult.getRecipeTimeout ()));
- }
- else {
- msoLogger.debug("No matching recipe record found");
- }
- return recipeLookupResult;
- }
-
-
- private RecipeLookupResult getServiceURI (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception {
- // SERVICE REQUEST
- // Construct the default service name
- // TODO need to make this a configurable property
- String sourceDefaultServiceName = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
- String defaultService = "*";
-
- Service serviceRecord = null;
- int serviceId;
- ServiceRecipe recipe = null;
-
- //if an aLaCarte flag was Not sent in the request, look first if there is a custom recipe for the specific model version
- if(!msoRequest.getALaCarteFlag()){
- serviceRecord = db.getServiceByVersionAndInvariantId(msoRequest.getModelInfo().getModelInvariantId(), msoRequest.getModelInfo().getModelVersion());
- if(serviceRecord !=null){
- serviceId = serviceRecord.getId();
- recipe = db.getServiceRecipe(serviceId, action.name());
- }
- }
-
- if (recipe == null) {
- //find source(initiator) default recipe
- recipe = db.getServiceRecipeByServiceNameAndAction(sourceDefaultServiceName, action.name());
- }
- if (recipe == null) {
- //find default recipe
- recipe = db.getServiceRecipeByServiceNameAndAction(defaultService, action.name());
- }
- if(recipe==null){
- return null;
- }
- return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ());
-
- }
-
-
- private RecipeLookupResult getVnfOrVfModuleUri (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception {
-
- String vnfComponentType = msoRequest.getModelInfo().getModelType().name();
-
- RelatedInstanceList[] instanceList = null;
- if (msoRequest.getServiceInstancesRequest().getRequestDetails() != null) {
- instanceList = msoRequest.getServiceInstancesRequest().getRequestDetails().getRelatedInstanceList();
- }
-
- String serviceModelName = null;
- String vnfModelName = null;
- String asdcServiceModelVersion = null;
- String modelVersion = msoRequest.getModelInfo().getModelVersion();
- Recipe recipe = null;
- String defaultVnfType = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
- String modelCustomizationId = msoRequest.getModelInfo().getModelCustomizationId();
- String vfModuleModelName = msoRequest.getModelInfo().getModelName();
- if (instanceList != null) {
-
- for(RelatedInstanceList relatedInstanceList : instanceList){
-
- RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
- ModelInfo modelInfo = relatedInstance.getModelInfo();
- if(modelInfo.getModelType().equals(ModelType.service)){
- serviceModelName = modelInfo.getModelName();
- asdcServiceModelVersion = modelInfo.getModelVersion();
- }
-
- if(modelInfo.getModelType().equals(ModelType.vnf)){
- vnfModelName = modelInfo.getModelCustomizationName();
- if (null == vnfModelName || vnfModelName.trim().isEmpty()) {
- VnfResource vnfResource = db.getVnfResourceByModelCustomizationId(modelInfo.getModelCustomizationUuid(), modelInfo.getModelVersion());
- vnfModelName = vnfResource.getModelName();
- }
- }
- }
-
- if(msoRequest.getModelInfo().getModelType().equals(ModelType.vnf)) {
- String modelCustomizationName = msoRequest.getModelInfo().getModelCustomizationName();
-
- VnfResource vnfResource = null;
-
- // Validation for vnfResource
- if(modelCustomizationName!=null) {
- vnfResource = db.getVnfResource(serviceModelName + "/" + modelCustomizationName, asdcServiceModelVersion);
- }else{
- vnfResource = db.getVnfResourceByModelCustomizationId(modelCustomizationId, asdcServiceModelVersion);
- }
-
- if(vnfResource==null){
- throw new ValidationException("catalog entry");
- }
-
- VnfRecipe vnfRecipe = db.getVnfRecipe(defaultVnfType, action.name());
-
- if (vnfRecipe == null) {
- return null;
- }
-
- return new RecipeLookupResult (vnfRecipe.getOrchestrationUri(), vnfRecipe.getRecipeTimeout());
- }else{
- String vnfType = serviceModelName + "/" + vnfModelName;
- String vfModuleType = vnfType + "::" + vfModuleModelName;
- List<VfModule> vfModule = db.getVfModule(vfModuleType, modelCustomizationId, asdcServiceModelVersion, modelVersion, action.name());
- if(vfModule==null || vfModule.isEmpty()){
- throw new ValidationException("catalog entry");
- }else{
- if(!msoRequest.getALaCarteFlag() && action != Action.deleteInstance){
- recipe = db.getVnfComponentsRecipeByVfModule(vfModule, action.name());
- }
- }
- if (recipe == null) {
- msoLogger.debug("recipe is null, getting default");
- recipe = db.getVnfComponentsRecipeByVfModuleId("VID_DEFAULT", vnfComponentType, action.name());
-
- if (recipe == null) {
- return null;
- }
- }
-
- }
- } else {
- msoLogger.debug("recipe is null, getting default");
-
- if(msoRequest.getModelInfo().getModelType().equals(ModelType.vnf)) {
- recipe = db.getVnfRecipe(defaultVnfType, action.name());
- if (recipe == null) {
- return null;
- }
- } else {
- recipe = db.getVnfComponentsRecipeByVfModuleId("VID_DEFAULT", vnfComponentType, action.name());
-
- if (recipe == null) {
- return null;
- }
- }
- }
-
- return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ());
- }
-
- private RecipeLookupResult getNetworkUri (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception {
-
- String sourceDefaultNetworkType = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
- String defaultNetworkType = "*";
-
- String modelName = msoRequest.getModelInfo().getModelName();
- Recipe recipe = null;
- //if an aLaCarte flag was Not sent in the request, look first if there is a custom recipe for the specific ModelCustomizationId
- if(!msoRequest.getALaCarteFlag()){
- String networkType = null;
-
- if(msoRequest.getModelInfo().getModelCustomizationId()!=null){
- NetworkResource networkResource = db.getNetworkResourceByModelCustUuid(msoRequest.getModelInfo().getModelCustomizationId());
- if(networkResource!=null){
- networkType = networkResource.getNetworkType();
- }else{
- throw new ValidationException("no catalog entry found");
- }
- }else{
- //ok for version < 3
- networkType = modelName;
- }
-
- //find latest version Recipe for the given networkType and action
- recipe = db.getNetworkRecipe(networkType, action.name());
- }
-
- if(recipe == null){
- //find source(initiator) default recipe
- recipe = db.getNetworkRecipe(sourceDefaultNetworkType, action.name());
- }
- if(recipe == null){
- //find default recipe
- recipe = db.getNetworkRecipe(defaultNetworkType, action.name());
- }
- if (recipe == null) {
- return null;
- }
- return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ());
- }
+ private RecipeLookupResult getServiceInstanceOrchestrationURI (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception {
+ RecipeLookupResult recipeLookupResult = null;
+ //if the aLaCarte flag is set to TRUE, the API-H should choose the “VID_DEFAULT” recipe for the requested action
+
+ msoLogger.debug("aLaCarteFlag is " + msoRequest.getALaCarteFlag());
+ // Query MSO Catalog DB
+
+ if (msoRequest.getModelInfo().getModelType().equals(ModelType.service)) {
+ recipeLookupResult = getServiceURI(db, msoRequest, action);
+ }
+ else if (msoRequest.getModelInfo().getModelType().equals(ModelType.vfModule) ||
+ msoRequest.getModelInfo().getModelType().equals(ModelType.volumeGroup) || msoRequest.getModelInfo().getModelType().equals(ModelType.vnf)) {
+
+ recipeLookupResult = getVnfOrVfModuleUri(db, msoRequest, action);
+
+ }else if (msoRequest.getModelInfo().getModelType().equals(ModelType.network)) {
+
+ recipeLookupResult = getNetworkUri(db, msoRequest, action);
+ }
+
+ if (recipeLookupResult != null) {
+ msoLogger.debug ("Orchestration URI is: " + recipeLookupResult.getOrchestrationURI() + ", recipe Timeout is: " + Integer.toString(recipeLookupResult.getRecipeTimeout ()));
+ }
+ else {
+ msoLogger.debug("No matching recipe record found");
+ }
+ return recipeLookupResult;
+ }
+
+
+ private RecipeLookupResult getServiceURI (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception {
+ // SERVICE REQUEST
+ // Construct the default service name
+ // TODO need to make this a configurable property
+ String defaultServiceModelName = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
+
+ Service serviceRecord = null;
+ ModelInfo modelInfo = msoRequest.getModelInfo();
+ if(msoRequest.getALaCarteFlag()){
+ serviceRecord = db.getServiceByModelName(defaultServiceModelName);
+ }else{
+ serviceRecord = db.getServiceByModelUUID(modelInfo.getModelVersionId()); // ModelVersionId is not required in v3
+ if(serviceRecord == null) {
+ serviceRecord = db.getServiceByVersionAndInvariantId(modelInfo.getModelInvariantId(), modelInfo.getModelVersion());
+ }
+ }
+
+ ServiceRecipe recipe = null;
+ if(serviceRecord !=null){
+ recipe = db.getServiceRecipeByModelUUID(serviceRecord.getModelUUID(), action.name());
+ }
+ //if an aLaCarte flag was sent in the request, throw an error if the recipe was not found
+ RequestParameters reqParam = msoRequest.getServiceInstancesRequest().getRequestDetails().getRequestParameters();
+ if(reqParam!=null && reqParam.isALaCarteSet() && recipe==null){
+ return null;
+ }else if (recipe == null) { //aLaCarte wasn't sent, so we'll try the default
+ serviceRecord = db.getServiceByModelName(defaultServiceModelName);
+ recipe = db.getServiceRecipeByModelUUID(serviceRecord.getModelUUID(), action.name());
+ }
+
+ if(modelInfo.getModelVersionId() == null) {
+ modelInfo.setModelVersionId(serviceRecord.getModelUUID());
+ }
+ if(recipe==null){
+ return null;
+ }
+ return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ());
+ }
+
+
+ private RecipeLookupResult getVnfOrVfModuleUri (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception {
+
+ ModelInfo modelInfo = msoRequest.getModelInfo();
+ String vnfComponentType = modelInfo.getModelType().name();
+
+ RelatedInstanceList[] instanceList = null;
+ if (msoRequest.getServiceInstancesRequest().getRequestDetails() != null) {
+ instanceList = msoRequest.getServiceInstancesRequest().getRequestDetails().getRelatedInstanceList();
+ }
+
+ Recipe recipe = null;
+ String defaultVnfType = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
+ 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) {
+ vnfResource = db.getVnfResourceByModelCustomizationId(modelCustomizationId);
+ } else {
+ Service service = db.getServiceByModelUUID(relatedInstanceModelVersionId);
+ if(service == null) {
+ service = db.getServiceByVersionAndInvariantId(relatedInstanceModelInvariantId, relatedInstanceVersion);
+ }
+
+ if(service == null) {
+ throw new ValidationException("service in relatedInstance");
+ }
+
+ vrc = db.getVnfResourceCustomizationByModelCustomizationName(modelCustomizationName, service.getModelUUID());
+ if(vrc != null) {
+ vnfResource = vrc.getVnfResource();
+ modelInfo.setModelCustomizationId(vrc.getModelCustomizationUuid());
+ modelInfo.setModelCustomizationUuid(vrc.getModelCustomizationUuid());
+ }
+ }
+
+ if(vnfResource==null){
+ throw new ValidationException("catalog entry");
+ } else {
+ if(modelInfo.getModelVersionId() == null) {
+ modelInfo.setModelVersionId(vnfResource.getModelUuid());
+ }
+ }
+
+ VnfRecipe vnfRecipe = db.getVnfRecipe(defaultVnfType, action.name());
+
+ if (vnfRecipe == null) {
+ return null;
+ }
+
+ return new RecipeLookupResult (vnfRecipe.getOrchestrationUri(), vnfRecipe.getRecipeTimeout());
+ } else {
+ // 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[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.
+ // **If relatedInstance.modelInfo[vnf].modelVersionId was not provided, use relatedInstance.modelInfo[vnf].modelInvariantId + modelVersion instead
+ // to lookup modelVersionId (MODEL_UUID) in vnf_resource table. Once the vnf’s 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). **If modelInfo[vfModule|volumeGroup].modelVersionId was not
+ // provided (potentially in v2/v3), use modelInfo[vfModule|volumeGroup].modelInvariantId + modelVersion instead. 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).
+
+ if(!msoRequest.getALaCarteFlag()) {
+ VfModuleCustomization vfmc = null;
+ VnfResourceCustomization vnfrc = null;
+ VfModule vfModule = null;
+
+ if( modelInfo.getModelCustomizationId() != null) {
+ vfmc = db.getVfModuleCustomizationByModelCustomizationId(modelInfo.getModelCustomizationId());
+ } else {
+ vnfrc =db.getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId(relatedInstanceModelCustomizationName, relatedInstanceModelVersionId);
+ if(vnfrc == null) {
+ vnfrc = db.getVnfResourceCustomizationByModelInvariantId(relatedInstanceModelInvariantId, relatedInstanceVersion, relatedInstanceModelCustomizationName);
+ }
+
+ List<VfModuleCustomization> list = db.getVfModuleCustomizationByVnfModuleCustomizationUuid(vnfrc.getModelCustomizationUuid());
+
+ String vfModuleModelUUID = modelInfo.getModelVersionId();
+ for(VfModuleCustomization vf : list) {
+ if(vfModuleModelUUID != null) {
+ vfModule = db.getVfModuleByModelCustomizationIdAndVersion(vf.getModelCustomizationUuid(), vfModuleModelUUID);
+ } else {
+ vfModule = db.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId(vf.getModelCustomizationUuid(), modelInfo.getModelVersion(), modelInfo.getModelInvariantId());
+ }
+
+ if(vfModule != null) {
+ modelInfo.setModelCustomizationId(vf.getModelCustomizationUuid());
+ modelInfo.setModelCustomizationUuid(vf.getModelCustomizationUuid());
+ break;
+ }
+ }
+ }
+
+ if(vfmc == null && vfModule == null) {
+ throw new ValidationException("no catalog entry found");
+ } 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 = db.getVnfComponentsRecipeByVfModuleModelUUId(vfModule.getModelUUID(), vnfComponentType, action.name());
+ }
+
+ if(recipe == null) {
+ recipe = db.getVnfComponentsRecipeByVfModuleModelUUId(defaultVnfType, vnfComponentType, action.name());
+ if (recipe == null) {
+ recipe = db.getVnfComponentsRecipeByVfModuleModelUUId("*", vnfComponentType, action.name());
+ }
+
+ if(recipe == null) {
+ return null;
+ }
+ }
+ }
+ } else {
+ msoLogger.debug("recipe is null, getting default");
+
+ if(modelInfo.getModelType().equals(ModelType.vnf)) {
+ recipe = db.getVnfRecipe(defaultVnfType, action.name());
+ if (recipe == null) {
+ return null;
+ }
+ } else {
+ recipe = db.getVnfComponentsRecipeByVfModuleModelUUId("VID_DEFAULT", vnfComponentType, action.name());
+
+ if (recipe == null) {
+ return null;
+ }
+ }
+ }
+
+ return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ());
+ }
+
+ private RecipeLookupResult getNetworkUri (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception {
+
+ String defaultNetworkType = msoRequest.getRequestInfo().getSource() + "_DEFAULT";
+
+ ModelInfo modelInfo = msoRequest.getModelInfo();
+ String modelName = modelInfo.getModelName();
+ Recipe recipe = null;
+ if(msoRequest.getALaCarteFlag()){
+ recipe = db.getNetworkRecipe(defaultNetworkType, action.name());
+ }else{
+ if(modelInfo.getModelCustomizationId()!=null){
+ NetworkResource networkResource = db.getNetworkResourceByModelCustUuid(modelInfo.getModelCustomizationId());
+ if(networkResource!=null){
+ if(modelInfo.getModelVersionId() == null) {
+ modelInfo.setModelVersionId(networkResource.getModelUUID());
+ }
+ recipe = db.getNetworkRecipe(networkResource.getModelName(), action.name());
+ }else{
+ throw new ValidationException("no catalog entry found");
+ }
+ }else{
+ //ok for version < 3 and action delete
+ recipe = db.getNetworkRecipe(modelName, action.name());
+ }
+ if(recipe == null){
+ recipe = db.getNetworkRecipe(defaultNetworkType, action.name());
+ }
+ }
+ if (recipe == null) {
+ return null;
+ }
+ return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ());
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/TasksHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/TasksHandler.java
new file mode 100644
index 0000000000..b191a3d767
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/TasksHandler.java
@@ -0,0 +1,328 @@
+/*-
+ * #%L
+ * MSO
+ * %%
+ * Copyright (C) 2016 OPENECOMP - MSO
+ * %%
+ * 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
+ *
+ * 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.
+ * #L%
+ */
+
+package org.openecomp.mso.apihandlerinfra;
+
+import org.openecomp.mso.apihandlerinfra.tasksbeans.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.codehaus.jackson.map.ObjectMapper;
+
+import org.openecomp.mso.apihandler.common.ErrorNumbers;
+import org.openecomp.mso.apihandler.common.RequestClient;
+import org.openecomp.mso.apihandler.common.RequestClientFactory;
+import org.openecomp.mso.apihandler.common.ResponseHandler;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoAlarmLogger;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.utils.UUIDChecker;
+
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+
+@Path("/tasks")
+@Api(value="/tasks/{version: [vV]1}",description="Queries of Manual Tasks")
+public class TasksHandler {
+
+ private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
+ public final static String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
+ public final static String requestUrl = "mso/task/";
+
+ @Path("/{version:[vV]1}")
+ @GET
+ @ApiOperation(value="Finds Manual Tasks",response=Response.class)
+ 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) {
+ Response responseBack = null;
+ long startTime = System.currentTimeMillis ();
+ String requestId = UUIDChecker.generateUUID(msoLogger);
+ MsoLogger.setServiceName ("ManualTasksQuery");
+ // Generate a Request Id
+ UUIDChecker.generateUUID(msoLogger);
+ msoLogger.debug ("Incoming request received for queryFilter with taskId:" + taskId
+ + " originalRequestId:" + originalRequestId
+ + " subscriptionServiceType:" + subscriptionServiceType
+ + " nfRole:" + nfRole
+ + " buildingBlockName:" + buildingBlockName
+ + " originalRequestDate:" + originalRequestDate
+ + " originalRequestorId: " + originalRequestorId);
+
+ // Prepare the query string to /task interface
+ TaskVariables tv = new TaskVariables();
+
+ List<TaskVariableValue> tvvList = new ArrayList<TaskVariableValue>();
+
+ if (originalRequestId != null) {
+ 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);
+ }
+ if (nfRole != null) {
+ 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);
+ }
+ if (originalRequestDate != null) {
+ 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);
+ }
+
+ tv.setTaskVariables(tvvList);
+
+ RequestClient requestClient = null;
+ MsoRequest msoRequest = new MsoRequest(requestId);
+ HttpResponse response = null;
+ long subStartTime = System.currentTimeMillis();
+
+ try {
+ requestClient = RequestClientFactory.getRequestClient (requestUrl, MsoPropertiesUtils.loadMsoProperties ());
+ // Capture audit event
+ msoLogger.debug ("MSO API Handler Post call to Camunda engine for url: " + requestClient.getUrl ());
+
+ System.out.println("URL : " + requestClient.getUrl ());
+ ObjectMapper mapper = new ObjectMapper();
+ String camundaJsonReq = mapper.writeValueAsString(tv);
+ msoLogger.debug("Camunda Json Request: " + camundaJsonReq);
+ response = requestClient.post(camundaJsonReq);
+
+ msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", requestUrl, null);
+ } catch (Exception e) {
+ msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", requestUrl, null);
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,
+ MsoException.ServiceException,
+ "Failed calling bpmn " + e.getMessage (),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES,
+ null);
+ alarmLogger.sendAlarm ("MsoConfigurationError",
+ MsoAlarmLogger.CRITICAL,
+ Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
+ msoRequest.updateFinalStatus (Status.FAILED);
+ msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
+ return resp;
+ }
+ TasksGetResponse trr = new TasksGetResponse();
+ List<TaskList> taskList = new ArrayList<TaskList>();
+
+ ResponseHandler respHandler = new ResponseHandler (response, requestClient.getType ());
+ int bpelStatus = respHandler.getStatus ();
+ if (bpelStatus == HttpStatus.SC_NO_CONTENT || bpelStatus == HttpStatus.SC_ACCEPTED) {
+ msoLogger.debug ("Received good response from Camunda");
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN completed the request");
+ 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");
+ msoLogger.debug("taskId is: " + id);
+ if (taskId != null && !taskId.equals(id)) {
+ continue;
+ }
+ // Get variables info for each task ID
+ TaskList taskListEntry = null;
+ try {
+ taskListEntry = getTaskInfo(id);
+ msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", requestUrl, null);
+ } catch (Exception e) {
+ msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", requestUrl, null);
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response resp = msoRequest.buildServiceErrorResponse (HttpStatus.SC_BAD_GATEWAY,
+ MsoException.ServiceException,
+ "Failed calling bpmn " + e.getMessage (),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES,
+ null);
+ alarmLogger.sendAlarm ("MsoConfigurationError",
+ MsoAlarmLogger.CRITICAL,
+ Messages.errors.get (ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
+
+ msoLogger.error (MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
+ return resp;
+ }
+ taskList.add(taskListEntry);
+
+ }
+ trr.setTaskList(taskList);
+ }
+
+ } else {
+ msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response resp = msoRequest.buildServiceErrorResponse(bpelStatus,
+ MsoException.ServiceException,
+ "Request Failed due to BPEL error with HTTP Status= %1" ,
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
+ null);
+ msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty");
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Response from BPEL engine is empty");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
+ return resp;
+ }
+
+
+ String jsonResponse = null;
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ jsonResponse = mapper.writeValueAsString(trr);
+ }
+ catch (Exception e) {
+ msoLogger.debug("Unable to format response");
+ Response resp = msoRequest.buildServiceErrorResponse(500,
+ MsoException.ServiceException,
+ "Request Failed due to bad response format" ,
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
+ null);
+ msoLogger.error (MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl (), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Bad response format");
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, "Bad response format");
+ msoLogger.debug ("End of the transaction, the final response is: " + (String) resp.getEntity ());
+ return resp;
+ }
+
+
+ msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful");
+ responseBack = Response.status (HttpStatus.SC_ACCEPTED).entity (jsonResponse).build ();
+ // msoLogger.debug ("End of the transaction, the final response is: " + (String) response.getEntity ());
+ return responseBack;
+
+ }
+
+ protected MsoLogger getMsoLogger () {
+ return msoLogger;
+ }
+
+ // Makes a GET call to Camunda to get variables for this task
+ private TaskList getTaskInfo(String taskId) throws Exception {
+ TaskList taskList = null;
+ String getRequestUrl = requestUrl + taskId + "/variables";
+ HttpResponse getResponse = null;
+ long subStartTime = System.currentTimeMillis();
+
+ RequestClient requestClient = RequestClientFactory.getRequestClient (getRequestUrl, MsoPropertiesUtils.loadMsoProperties ());
+ // Capture audit event
+ msoLogger.debug ("MSO API Handler Get call to Camunda engine for url: " + requestClient.getUrl ());
+ getResponse = requestClient.get();
+
+ ResponseHandler respHandler = new ResponseHandler (getResponse, requestClient.getType ());
+ int bpelStatus = respHandler.getStatus ();
+ if (bpelStatus == HttpStatus.SC_ACCEPTED) {
+ msoLogger.debug ("Received good response from Camunda");
+
+ msoLogger.recordAuditEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN completed the request");
+ String respBody = respHandler.getResponseBody();
+ if (respBody != null) {
+ taskList = buildTaskList(taskId, respBody);
+ }
+ else {
+ throw new Exception("Null task info from Camunda");
+ }
+
+ }
+ else {
+ throw new Exception ("Bad GET response from Camunda. Status is " + bpelStatus);
+ }
+
+ return taskList;
+
+ }
+
+ private TaskList buildTaskList(String taskId, String respBody) {
+ 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.setValidResponses(new JSONArray("[" + getOptVariableValue(variables, "validResponses").toLowerCase() + "]"));
+
+ return taskList;
+ }
+
+ private String getOptVariableValue(JSONObject variables, String name) {
+ 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/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java
index 07d70e9982..aee6c8f2c1 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VfModuleModelNamesHandler.java
@@ -26,21 +26,24 @@ import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import org.apache.http.HttpStatus;
-
import org.openecomp.mso.apihandlerinfra.vnfbeans.VfModuleModelName;
import org.openecomp.mso.apihandlerinfra.vnfbeans.VfModuleModelNames;
import org.openecomp.mso.apihandlerinfra.vnfbeans.ObjectFactory;
import org.openecomp.mso.db.catalog.CatalogDatabase;
import org.openecomp.mso.db.catalog.beans.VfModule;
import org.openecomp.mso.logger.MsoLogger;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
@Path(Constants.VF_MODULE_MODEL_NAMES_PATH)
+@Api(value="/{version: v2|v3}/vf-module-model-names",description="API Requests to find Vf Module model names")
public class VfModuleModelNamesHandler {
private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
@@ -48,13 +51,14 @@ public class VfModuleModelNamesHandler {
private static final String LOG_REPLY_NAME = "MSO-APIH:InfrastructurePortal.";
@GET
- public Response getVfModuleModelNames () {
+ @ApiOperation(value="Finds Vf Module Model Names",response=Response.class)
+ public Response getVfModuleModelNames (@PathParam("version") String version) {
long startTime = System.currentTimeMillis ();
String methodName = "getVfModuleModelNames";
MsoLogger.setServiceName (LOG_SERVICE_NAME + methodName);
msoLogger.debug ("Incoming request received for vfModuleModelNames");
List <VfModule> vfModules = null;
- try (CatalogDatabase db = new CatalogDatabase()){
+ try (CatalogDatabase db = CatalogDatabase.getInstance()){
vfModules = db.getAllVfModules ();
} catch (Exception e) {
msoLogger.debug ("No connection to catalog DB", e);
@@ -79,7 +83,7 @@ public class VfModuleModelNamesHandler {
vfModuleModelName.setModelInvariantUuid (vm.getModelInvariantUuid ());
vfModuleModelName.setIsBase(vm.isBase());
vfModuleModelName.setDescription (vm.getDescription ());
- vfModuleModelName.setId (String.valueOf (vm.getId ()));
+ vfModuleModelName.setId (String.valueOf (vm.getModelUUID()));
vfModuleModelName.setAsdcServiceModelVersion(vm.getVersion ());
vfModuleModelNames.getVfModuleModelName ().add (vfModuleModelName);
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java
index 7494747879..c87d450cef 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfInfoHandler.java
@@ -31,18 +31,13 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
-
-import org.apache.http.HttpStatus;
-
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.sax.SAXSource;
-import org.xml.sax.InputSource;
-
+import org.apache.http.HttpStatus;
import org.openecomp.mso.apihandler.common.ValidationException;
import org.openecomp.mso.apihandlerinfra.vnfbeans.ActionType;
import org.openecomp.mso.apihandlerinfra.vnfbeans.ObjectFactory;
@@ -53,12 +48,17 @@ import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfOutputs;
import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest;
import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequests;
import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.requestsdb.InfraRequests;
import org.openecomp.mso.requestsdb.InfraActiveRequests;
+import org.openecomp.mso.requestsdb.InfraRequests;
import org.openecomp.mso.requestsdb.RequestsDatabase;
import org.openecomp.mso.utils.UUIDChecker;
+import org.xml.sax.InputSource;
+
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
@Path("/{version: v1|v2|v3}/vnf-request")
+@Api(value="/{version: v1|v2|v3}/vnf-request",description="API Requests of vnfRequest")
public class VnfInfoHandler {
protected ObjectFactory beansObjectFactory = new ObjectFactory ();
@@ -67,6 +67,7 @@ public class VnfInfoHandler {
@GET
+ @ApiOperation(value="Finds Volume Requests",response=Response.class)
public Response queryFilters (@QueryParam("vnf-type") String vnfType,
@QueryParam("service-type") String serviceType,
@QueryParam("aic-node-clli") String aicNodeClli,
@@ -99,6 +100,7 @@ public class VnfInfoHandler {
@GET
@Path(Constants.REQUEST_ID_PATH)
+ @ApiOperation(value="Add a Vnf Outputs from requestId and version",response=Response.class)
public Response getRequest (@PathParam("request-id") String requestId, @PathParam("version") String version) {
// Check INFRA_ACTIVE_REQUESTS table to find info
// on this request
@@ -253,7 +255,7 @@ public class VnfInfoHandler {
String responseString = null;
- InfraActiveRequests activeReq = RequestsDatabase.getRequestFromInfraActive (requestId, getRequestType ());
+ InfraActiveRequests activeReq = (RequestsDatabase.getInstance()).getRequestFromInfraActive (requestId, getRequestType ());
if (activeReq != null) {
// build response for active
responseString = infraRequestsResponse (activeReq, version);
@@ -270,7 +272,7 @@ public class VnfInfoHandler {
getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue);
- List <InfraActiveRequests> activeReqList = RequestsDatabase.getRequestListFromInfraActive (queryAttribute,
+ List <InfraActiveRequests> activeReqList = (RequestsDatabase.getInstance()).getRequestListFromInfraActive (queryAttribute,
queryValue,
getRequestType ());
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java
index bfcbe0d4d5..87667952d4 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequest.java
@@ -59,10 +59,10 @@ import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest;
import org.openecomp.mso.logger.MsoLogger;
import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.db.HibernateUtils;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
import org.openecomp.mso.requestsdb.InfraActiveRequests;
import org.openecomp.mso.requestsdb.RequestsDatabase;
-import org.openecomp.mso.requestsdb.HibernateUtilsRequestsDb;
+import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
public class VnfMsoInfraRequest {
@@ -84,7 +84,7 @@ public class VnfMsoInfraRequest {
private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
private static final String NOT_PROVIDED = "not provided";
- protected HibernateUtils hibernateUtils = new HibernateUtilsRequestsDb ();
+ protected AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager ();
VnfMsoInfraRequest (String requestId) {
this.requestId = requestId;
@@ -279,7 +279,7 @@ public class VnfMsoInfraRequest {
Session session = null;
try {
- session = hibernateUtils.getSessionFactory ().openSession ();
+ session = requestsDbSessionFactoryManager.getSessionFactory ().openSession ();
session.beginTransaction ();
InfraActiveRequests aq = new InfraActiveRequests ();
@@ -399,7 +399,7 @@ public class VnfMsoInfraRequest {
public void updateFinalStatus (Status status) {
int result = 0;
try {
- result = RequestsDatabase.updateInfraFinalStatus (requestId,
+ result = (RequestsDatabase.getInstance()).updateInfraFinalStatus (requestId,
status.toString (),
this.errorMessage,
this.progress,
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java
index 617172be08..024a84ca9b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandler.java
@@ -97,7 +97,8 @@ public class VnfRequestHandler {
private static final Response NOT_STARTED_RESPONSE = Response.status (HttpStatus.SC_SERVICE_UNAVAILABLE)
.entity (NOT_FOUND)
.build ();
-
+ private RequestsDatabase requestDB = RequestsDatabase.getInstance();
+
@GET
public Response queryFilters (@QueryParam("vnf-type") String vnfType,
@QueryParam("service-type") String serviceType,
@@ -285,7 +286,7 @@ public class VnfRequestHandler {
String responseString = null;
- InfraActiveRequests activeReq = RequestsDatabase.getRequestFromInfraActive (requestId, getRequestType ());
+ InfraActiveRequests activeReq = requestDB.getRequestFromInfraActive (requestId, getRequestType ());
if (activeReq != null) {
// build response for active
responseString = infraRequestsResponse (activeReq, version);
@@ -302,7 +303,7 @@ public class VnfRequestHandler {
getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue);
- List <InfraActiveRequests> activeReqList = RequestsDatabase.getRequestListFromInfraActive (queryAttribute,
+ List <InfraActiveRequests> activeReqList = requestDB.getRequestListFromInfraActive (queryAttribute,
queryValue,
getRequestType ());
@@ -471,7 +472,7 @@ public class VnfRequestHandler {
msoLogger.debug ("Checking for a duplicate with the same vnf-name");
InfraActiveRequests dup = null;
try {
- dup = RequestsDatabase.checkDuplicateByVnfName (msoRequest.getVnfInputs ().getVnfName (),
+ dup = requestDB.checkDuplicateByVnfName (msoRequest.getVnfInputs ().getVnfName (),
msoRequest.getRequestInfo ().getAction ().value (),
"VNF");
@@ -508,7 +509,7 @@ public class VnfRequestHandler {
InfraActiveRequests dup = null;
msoLogger.debug ("Checking for a duplicate with the same vnf-id");
try {
- dup = RequestsDatabase.checkDuplicateByVnfId (msoRequest.getVnfInputs ().getVnfId (),
+ dup = requestDB.checkDuplicateByVnfId (msoRequest.getVnfInputs ().getVnfId (),
msoRequest.getRequestInfo ().getAction ().value (),
"VNF");
@@ -548,7 +549,7 @@ public class VnfRequestHandler {
String orchestrationURI = "";
// Query MSO Catalog DB
- try (CatalogDatabase db = new CatalogDatabase()){
+ try (CatalogDatabase db = CatalogDatabase.getInstance()){
Recipe recipe = null;
@@ -755,7 +756,7 @@ public class VnfRequestHandler {
String bpelXMLResponseBody = respHandler.getResponseBody ();
msoLogger.debug ("Received from BPEL: " + bpelXMLResponseBody);
msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.IN_PROGRESS);
- RequestsDatabase.updateInfraStatus (msoRequest.getRequestId (),
+ requestDB.updateInfraStatus (msoRequest.getRequestId (),
Status.IN_PROGRESS.toString (),
Constants.PROGRESS_REQUEST_IN_PROGRESS,
Constants.MODIFIED_BY_APIHANDLER);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java
index 0b595855df..868828ba60 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VnfTypesHandler.java
@@ -27,27 +27,35 @@ import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfTypes;
import org.openecomp.mso.db.catalog.CatalogDatabase;
import org.openecomp.mso.db.catalog.beans.VnfResource;
import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.requestsdb.RequestsDatabase;
import org.openecomp.mso.utils.UUIDChecker;
import org.apache.http.HttpStatus;
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+
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 javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
+
import java.io.StringWriter;
import java.util.List;
@Path(Constants.VNF_TYPES_PATH)
+@Api(value="/{version: v1|v2|v3}/vnf-types",description="API Requests of vnfTypes")
public class VnfTypesHandler {
private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
@GET
- public Response getVnfTypes (@QueryParam("vnf-role") String vnfRole) {
+ @ApiOperation(value="Finds Vnf Types",response=Response.class)
+ public Response getVnfTypes (@QueryParam("vnf-role") String vnfRole, @PathParam("version") String version) {
long startTime = System.currentTimeMillis ();
MsoLogger.setServiceName ("GetVnfTypes");
@@ -56,7 +64,7 @@ public class VnfTypesHandler {
msoLogger.debug ("Incoming request received for getVnfTypes with vnf-role:" + vnfRole);
List <VnfResource> vnfResources = null;
- try(CatalogDatabase db = new CatalogDatabase ()) {
+ try(CatalogDatabase db = CatalogDatabase.getInstance()) {
if (vnfRole != null) {
vnfResources = db.getVnfResourcesByRole (vnfRole);
} else {
@@ -80,9 +88,8 @@ public class VnfTypesHandler {
for (int i = 0; i < vnfResources.size (); i++) {
VnfType vnfType = beansObjectFactory.createVnfType ();
VnfResource vr = vnfResources.get (i);
- vnfType.setType (vr.getVnfType ());
vnfType.setDescription (vr.getDescription ());
- vnfType.setId (String.valueOf (vr.getId ()));
+ vnfType.setId (String.valueOf (vr.getModelUuid()));
vnfTypes.getVnfType ().add (vnfType);
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java
index 3190fc507e..1891c00521 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandler.java
@@ -31,18 +31,13 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
-
-import org.apache.http.HttpStatus;
-
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.sax.SAXSource;
-import org.xml.sax.InputSource;
-
+import org.apache.http.HttpStatus;
import org.openecomp.mso.apihandler.common.ValidationException;
import org.openecomp.mso.apihandlerinfra.volumebeans.ActionType;
import org.openecomp.mso.apihandlerinfra.volumebeans.ObjectFactory;
@@ -53,12 +48,17 @@ import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeOutputs;
import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequest;
import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequests;
import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.requestsdb.InfraRequests;
import org.openecomp.mso.requestsdb.InfraActiveRequests;
+import org.openecomp.mso.requestsdb.InfraRequests;
import org.openecomp.mso.requestsdb.RequestsDatabase;
import org.openecomp.mso.utils.UUIDChecker;
+import org.xml.sax.InputSource;
+
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
@Path("/{version: v1|v2|v3}/volume-request")
+@Api(value="/{version: v1|v2|v3}/volume-request",description="API Requests for volumeRequest")
public class VolumeInfoHandler {
protected ObjectFactory beansObjectFactory = new ObjectFactory ();
@@ -66,6 +66,7 @@ public class VolumeInfoHandler {
private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
@GET
+ @ApiOperation(value="Finds Volume Requests",response=Response.class)
public Response queryFilters (@QueryParam("vnf-type") String vnfType,
@QueryParam("service-type") String serviceType,
@QueryParam("aic-node-clli") String aicNodeClli,
@@ -96,6 +97,7 @@ public class VolumeInfoHandler {
@GET
@Path(Constants.REQUEST_ID_PATH)
+ @ApiOperation(value="Find Volume Outputs by requestId and verison",response=Response.class)
public Response getRequest (@PathParam("request-id") String requestId, @PathParam("version") String version) {
// Check INFRA_ACTIVE_REQUESTS table to find info
@@ -233,7 +235,7 @@ public class VolumeInfoHandler {
String responseString = null;
- InfraActiveRequests activeReq = RequestsDatabase.getRequestFromInfraActive (requestId,
+ InfraActiveRequests activeReq = (RequestsDatabase.getInstance()).getRequestFromInfraActive (requestId,
"VOLUME");
if (activeReq != null) {
// build response for active
@@ -251,7 +253,7 @@ public class VolumeInfoHandler {
getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue);
- List <InfraActiveRequests> activeReqList = RequestsDatabase.getRequestListFromInfraActive (queryAttribute,
+ List <InfraActiveRequests> activeReqList = (RequestsDatabase.getInstance()).getRequestListFromInfraActive (queryAttribute,
queryValue,
"VOLUME");
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java
index 911ac48d03..340d3dbecc 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeMsoInfraRequest.java
@@ -54,11 +54,11 @@ import org.openecomp.mso.apihandlerinfra.volumebeans.ObjectFactory;
import org.openecomp.mso.apihandlerinfra.volumebeans.RequestInfo;
import org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType;
import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequest;
-import org.openecomp.mso.db.HibernateUtils;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
import org.openecomp.mso.logger.MsoLogger;
import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.requestsdb.HibernateUtilsRequestsDb;
+import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
import org.openecomp.mso.requestsdb.InfraActiveRequests;
import org.openecomp.mso.requestsdb.RequestsDatabase;
@@ -78,7 +78,7 @@ public class VolumeMsoInfraRequest {
private long startTime;
private long progress = Constants.PROGRESS_REQUEST_RECEIVED;
- protected HibernateUtils hibernateUtils = new HibernateUtilsRequestsDb ();
+ protected AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager ();
private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH);
private static final String NOT_PROVIDED = "not provided";
@@ -282,7 +282,7 @@ public class VolumeMsoInfraRequest {
Session session = null;
try {
- session = hibernateUtils.getSessionFactory ().openSession ();
+ session = requestsDbSessionFactoryManager.getSessionFactory ().openSession ();
session.beginTransaction ();
InfraActiveRequests aq = new InfraActiveRequests ();
@@ -376,7 +376,7 @@ public class VolumeMsoInfraRequest {
public void updateFinalStatus (Status status) {
int result = 0;
try {
- result = RequestsDatabase.updateInfraFinalStatus(requestId, status.toString (),
+ result = (RequestsDatabase.getInstance()).updateInfraFinalStatus(requestId, status.toString (),
this.errorMessage, this.progress, this.responseBody, Constants.MODIFIED_BY_APIHANDLER);
} catch (Exception e) {
msoLogger.error(MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "Exception in updateFinalStatus");
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java
index 7c1b74c684..1fa6161cc6 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandler.java
@@ -97,6 +97,8 @@ public class VolumeRequestHandler {
.entity (NOT_FOUND)
.build ();
+ private RequestsDatabase requestDB = RequestsDatabase.getInstance();
+
@GET
public Response queryFilters (@QueryParam("vnf-type") String vnfType,
@QueryParam("service-type") String serviceType,
@@ -265,7 +267,7 @@ public class VolumeRequestHandler {
String responseString = null;
- InfraActiveRequests activeReq = RequestsDatabase.getRequestFromInfraActive (requestId,
+ InfraActiveRequests activeReq = requestDB.getRequestFromInfraActive (requestId,
"VOLUME");
if (activeReq != null) {
// build response for active
@@ -283,7 +285,7 @@ public class VolumeRequestHandler {
getMsoLogger ().debug ("getRequest based on " + queryAttribute + ": " + queryValue);
- List <InfraActiveRequests> activeReqList = RequestsDatabase.getRequestListFromInfraActive (queryAttribute,
+ List <InfraActiveRequests> activeReqList = requestDB.getRequestListFromInfraActive (queryAttribute,
queryValue,
"VOLUME");
@@ -468,7 +470,7 @@ public class VolumeRequestHandler {
InfraActiveRequests dup = null;
try {
- dup = RequestsDatabase.checkDuplicateByVnfName (msoRequest.getVolumeInputs ().getVolumeGroupName (),
+ dup = requestDB.checkDuplicateByVnfName (msoRequest.getVolumeInputs ().getVolumeGroupName (),
msoRequest.getRequestInfo ().getAction ().value (),
"VOLUME");
@@ -506,7 +508,7 @@ public class VolumeRequestHandler {
InfraActiveRequests dup = null;
msoLogger.debug ("Checking for a duplicate with the same volume-group-id");
try {
- dup = RequestsDatabase.checkDuplicateByVnfId (msoRequest.getVolumeInputs ().getVolumeGroupId (),
+ dup = requestDB.checkDuplicateByVnfId (msoRequest.getVolumeInputs ().getVolumeGroupId (),
msoRequest.getRequestInfo ().getAction ().value (),
"VOLUME");
@@ -545,7 +547,7 @@ public class VolumeRequestHandler {
String orchestrationURI = "";
// Query MSO Catalog DB
- try(CatalogDatabase db = new CatalogDatabase ()) {
+ try(CatalogDatabase db = CatalogDatabase.getInstance()) {
Recipe recipe = null;
if (version.equals(Constants.SCHEMA_VERSION_V1)) {
@@ -597,7 +599,7 @@ public class VolumeRequestHandler {
// If no recipe for the vnf type is found, look for generic recipe with "*" in vf module id
if (recipe == null) {
- recipe = db.getVnfComponentsRecipeByVfModuleId (Constants.VNF_TYPE_WILDCARD,
+ recipe = db.getVnfComponentsRecipeByVfModuleModelUUId (Constants.VNF_TYPE_WILDCARD,
Constants.VOLUME_GROUP_COMPONENT_TYPE,
msoRequest.getRequestInfo ().getAction ().value ());
}
@@ -695,7 +697,7 @@ public class VolumeRequestHandler {
String bpelXMLResponseBody = respHandler.getResponseBody ();
msoLogger.debug ("Received from BPEL: " + bpelXMLResponseBody);
msoRequest.setStatus (org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType.IN_PROGRESS);
- RequestsDatabase.updateInfraStatus (msoRequest.getRequestId (),
+ requestDB.updateInfraStatus (msoRequest.getRequestId (),
Status.IN_PROGRESS.toString (),
Constants.PROGRESS_REQUEST_IN_PROGRESS,
Constants.MODIFIED_BY_APIHANDLER);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestParameters.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestParameters.java
index dee0649184..d6b79bf1eb 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestParameters.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/serviceinstancebeans/RequestParameters.java
@@ -21,7 +21,6 @@
package org.openecomp.mso.apihandlerinfra.serviceinstancebeans;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -29,8 +28,6 @@ import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
-import org.openecomp.mso.apihandlerinfra.MsoRequest;
-
@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
public class RequestParameters {
@@ -44,6 +41,10 @@ public class RequestParameters {
private boolean autoBuildVfModules = false;
@JsonSerialize(include=Inclusion.ALWAYS)
private boolean cascadeDelete = false;
+ @JsonSerialize(include=Inclusion.ALWAYS)
+ private boolean usePreload=true; // usePreload would always be true for Update
+ @JsonSerialize(include=Inclusion.ALWAYS)
+ private boolean rebuildVolumeGroups = false;
public String getSubscriptionServiceType() {
@@ -107,12 +108,30 @@ public class RequestParameters {
this.cascadeDelete = cascadeDelete;
}
+ public boolean isUsePreload() {
+ return usePreload;
+ }
+
+ public void setUsePreload(boolean usePreload) {
+ this.usePreload = usePreload;
+ }
+
+ public boolean rebuildVolumeGroups() {
+ return rebuildVolumeGroups;
+ }
+
+ public void setRebuildVolumeGroups(boolean rebuildVolumeGroups) {
+ this.rebuildVolumeGroups = rebuildVolumeGroups;
+ }
+
@Override
public String toString() {
return "RequestParameters [subscriptionServiceType="
+ subscriptionServiceType + ", userParams=" + userParams
+ ", aLaCarte=" + aLaCarte + ", autoBuildVfModules="
- + autoBuildVfModules + "]";
+ + autoBuildVfModules + ", usePreload="
+ + usePreload + ", rebuildVolumeGroups="
+ + rebuildVolumeGroups +"]";
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestDetails.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestDetails.java
new file mode 100644
index 0000000000..3f9627e6e2
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestDetails.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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
+ *
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.apihandlerinfra.tasksbeans;
+
+import org.codehaus.jackson.map.annotate.JsonRootName;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+@JsonRootName(value = "requestDetails")
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class RequestDetails {
+
+ protected RequestInfo requestInfo;
+ /**
+ * Gets the value of the requestInfo property.
+ *
+ * @return
+ * possible object is
+ * {@link RequestInfo }
+ *
+ */
+ public RequestInfo getRequestInfo() {
+ return requestInfo;
+ }
+
+ /**
+ * Sets the value of the requestInfo property.
+ *
+ * @param value
+ * allowed object is
+ * {@link RequestInfo }
+ *
+ */
+ public void setRequestInfo(RequestInfo value) {
+ this.requestInfo = value;
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestInfo.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestInfo.java
new file mode 100644
index 0000000000..2a06d5f7e8
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/RequestInfo.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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
+ *
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.apihandlerinfra.tasksbeans;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class RequestInfo {
+
+ protected String source;
+ protected ValidResponses responseValue;
+ protected String requestorId;
+
+ /**
+ * Gets the value of the source property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getSource() {
+ return source;
+ }
+
+ /**
+ * Sets the value of the source property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSource(String value) {
+ this.source = value;
+ }
+
+ public ValidResponses getResponseValue() {
+ return responseValue;
+ }
+
+ public void setResponseValue(ValidResponses responseValue) {
+ this.responseValue = responseValue;
+ }
+
+
+ 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/openecomp/mso/apihandlerinfra/tasksbeans/TaskList.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskList.java
new file mode 100644
index 0000000000..5cb90bb8c6
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskList.java
@@ -0,0 +1,334 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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
+ *
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.apihandlerinfra.tasksbeans;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+
+import org.json.JSONArray;
+
+@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 JSONArray validResponses;
+
+ /**
+ * Gets the value of the taskId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getTaskId() {
+ return taskId;
+ }
+
+ /**
+ * Sets the value of the taskId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setTaskId(String value) {
+ this.taskId = value;
+ }
+
+ /**
+ * Gets the value of the type property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Sets the value of the type property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setType(String value) {
+ this.type = value;
+ }
+
+ /**
+ * Gets the value of the nfRole property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getNfRole() {
+ return nfRole;
+ }
+
+ /**
+ * Sets the value of the nfRole property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setNfRole(String value) {
+ this.nfRole = value;
+ }
+
+ /**
+ * Gets the value of the subscriptionServiceType property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getSubscriptionServiceType() {
+ return subscriptionServiceType;
+ }
+
+ /**
+ * Sets the value of the subscriptionServiceType property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSubscriptionServiceType(String value) {
+ this.subscriptionServiceType = value;
+ }
+
+ /**
+ * Gets the value of the originalRequestId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getOriginalRequestId() {
+ return originalRequestId;
+ }
+
+ /**
+ * Sets the value of the originalRequestId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setOriginalRequestId(String value) {
+ this.originalRequestId = value;
+ }
+
+ /**
+ * Gets the value of the originalRequestorId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getOriginalRequestorId() {
+ return originalRequestorId;
+ }
+
+ /**
+ * Sets the value of the originalRequestorId property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setOriginalRequestorId(String value) {
+ this.originalRequestorId = value;
+ }
+
+ /**
+ * Gets the value of the errorSource property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getErrorSource() {
+ return errorSource;
+ }
+
+ /**
+ * Sets the value of the errorSource property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setErrorSource(String value) {
+ this.errorSource = value;
+ }
+
+ /**
+ * Gets the value of the errorCode property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getErrorCode() {
+ return errorCode;
+ }
+
+ /**
+ * Sets the value of the errorCode property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setErrorCode(String value) {
+ this.errorCode = value;
+ }
+
+ /**
+ * Gets the value of the errorMessage property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ /**
+ * Sets the value of the errorMessage property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setErrorMessage(String value) {
+ this.errorMessage = value;
+ }
+
+ /**
+ * Gets the value of the buildingBlockName property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getBuildingBlockName() {
+ return buildingBlockName;
+ }
+
+ /**
+ * Sets the value of the buildingBlockName property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setBuildingBlockName(String value) {
+ this.buildingBlockName = value;
+ }
+
+ /**
+ * Gets the value of the buildingBlockStep property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getBuildingBlockStep() {
+ return buildingBlockStep;
+ }
+
+ /**
+ * Sets the value of the buildingBlockStep property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setBuildingBlockStep(String value) {
+ this.buildingBlockStep = value;
+ }
+
+ /**
+ * Gets the value of the validResponses property.
+ *
+ * @return
+ * possible object is
+ * {@link ValidResponses }
+ *
+ */
+ public JSONArray getValidResponses() {
+ return validResponses;
+ }
+
+ /**
+ * Sets the value of the validResponses property.
+ *
+ * @param value
+ * allowed object is
+ * {@link ValidResponses }
+ *
+ */
+ public void setValidResponses(JSONArray value) {
+ this.validResponses = value;
+ }
+
+
+
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskRequestReference.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskRequestReference.java
new file mode 100644
index 0000000000..a3403ec35c
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskRequestReference.java
@@ -0,0 +1,57 @@
+/* ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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
+ *
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.apihandlerinfra.tasksbeans;
+
+import org.codehaus.jackson.map.annotate.JsonRootName;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+@JsonRootName(value = "taskRequestReference")
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class TaskRequestReference {
+
+ protected String taskId;
+
+ /**
+ * Gets the value of the taskId property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getTaskId() {
+ return taskId;
+ }
+
+ /**
+ * Sets the value of the taskId property.
+ *
+ * @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/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariableValue.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariableValue.java
new file mode 100644
index 0000000000..51521b9f00
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariableValue.java
@@ -0,0 +1,108 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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
+ *
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.apihandlerinfra.tasksbeans;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class TaskVariableValue {
+
+ protected String name;
+ protected String value;
+ protected String operator;
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @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 }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @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 }
+ *
+ */
+ public String getOperator() {
+ return operator;
+ }
+
+ /**
+ * Sets the value of the operator property.
+ *
+ * @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/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariables.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariables.java
new file mode 100644
index 0000000000..9d0701ce25
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TaskVariables.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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
+ *
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.apihandlerinfra.tasksbeans;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import java.util.List;
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class TaskVariables {
+
+ private List<TaskVariableValue> taskVariables;
+
+ public List<TaskVariableValue> getTaskVariables() {
+ return taskVariables;
+ }
+
+ public void setTaskVariables(List<TaskVariableValue> taskVariables) {
+ this.taskVariables = taskVariables;
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksGetResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksGetResponse.java
new file mode 100644
index 0000000000..6bcdd93639
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksGetResponse.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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
+ *
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.apihandlerinfra.tasksbeans;
+
+import java.util.List;
+
+public class TasksGetResponse {
+
+ private List<TaskList> taskList;
+
+ public List<TaskList> getTaskList() {
+ return taskList;
+ }
+
+ public void setTaskList(List<TaskList> taskList) {
+ this.taskList = taskList;
+ }
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksRequest.java
new file mode 100644
index 0000000000..b4006743b7
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/TasksRequest.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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
+ *
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.apihandlerinfra.tasksbeans;
+
+public class TasksRequest {
+
+ private RequestDetails requestDetails;
+
+ 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/openecomp/mso/apihandlerinfra/tasksbeans/ValidResponses.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/ValidResponses.java
new file mode 100644
index 0000000000..3db6f99cd1
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/ValidResponses.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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
+ *
+ * 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=========================================================
+ */
+
+//
+// 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.openecomp.mso.apihandlerinfra.tasksbeans;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+
+public enum ValidResponses {
+
+ rollback,
+ abort,
+ skip,
+ retry
+ ;
+
+ public String value() {
+ return name();
+ }
+
+ public static ValidResponses fromValue(String v) {
+ return valueOf(v);
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/Value.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/Value.java
new file mode 100644
index 0000000000..bf1c5e0f69
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/Value.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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
+ *
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.apihandlerinfra.tasksbeans;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class Value {
+
+ protected String value;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @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/openecomp/mso/apihandlerinfra/tasksbeans/Variables.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/Variables.java
new file mode 100644
index 0000000000..6f5298bbaf
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/tasksbeans/Variables.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - MSO
+ * ================================================================================
+ * 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
+ *
+ * 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=========================================================
+ */
+
+package org.openecomp.mso.apihandlerinfra.tasksbeans;
+
+import org.codehaus.jackson.map.annotate.JsonRootName;
+
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
+@JsonRootName(value = "variables")
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
+public class Variables {
+
+ protected Value source;
+ protected Value responseValue;
+ protected Value requestorId;
+
+ /**
+ * Gets the value of the source property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public Value getSource() {
+ return source;
+ }
+
+ /**
+ * Sets the value of the source property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSource(Value value) {
+ this.source = value;
+ }
+
+ public Value getResponseValue() {
+ return responseValue;
+ }
+
+ public void setResponseValue(Value responseValue) {
+ this.responseValue = responseValue;
+ }
+
+
+ public Value getRequestorId() {
+ return requestorId;
+ }
+
+ public void setRequestorId(Value requestorId) {
+ this.requestorId = requestorId;
+ }
+
+}