summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java341
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java121
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java162
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java81
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java92
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java41
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java13
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java16
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java15
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java21
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java2
25 files changed, 382 insertions, 584 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java
index f30b66c6b5..4e0ba083ea 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java
@@ -13,7 +13,6 @@ import org.json.JSONObject;
import org.onap.logging.filter.spring.SpringClientPayloadFilter;
import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
import org.onap.so.utils.CryptoUtils;
-import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
index d4bc4fd165..665fa547cc 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java
@@ -36,17 +36,16 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.*;
import org.onap.aai.domain.yang.v16.ServiceInstance;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.AAIResourcesClient;
-import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
-import org.onap.so.logger.LoggingAnchor;
-import org.apache.http.HttpResponse;
+import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.apache.http.HttpStatus;
import org.json.JSONObject;
+import org.onap.logging.filter.base.ErrorCode;
+import org.onap.so.apihandler.camundabeans.CamundaResponse;
+import org.onap.so.apihandler.common.CamundaClient;
import org.onap.so.apihandler.common.ErrorNumbers;
-import org.onap.so.apihandler.common.RequestClient;
-import org.onap.so.apihandler.common.RequestClientFactory;
import org.onap.so.apihandler.common.RequestClientParameter;
import org.onap.so.apihandler.common.ResponseBuilder;
import org.onap.so.apihandler.common.ResponseHandler;
@@ -56,6 +55,7 @@ import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceReq
import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceScaleRequest;
import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.GetE2EServiceInstanceResponse;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
import org.onap.so.constants.Status;
@@ -64,7 +64,7 @@ import org.onap.so.db.catalog.beans.ServiceRecipe;
import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.request.beans.OperationStatus;
import org.onap.so.db.request.client.RequestsDbClient;
-import org.onap.logging.filter.base.ErrorCode;
+import org.onap.so.logger.LoggingAnchor;
import org.onap.so.logger.MessageEnum;
import org.onap.so.serviceinstancebeans.ModelInfo;
import org.onap.so.serviceinstancebeans.ModelType;
@@ -76,6 +76,7 @@ import org.onap.so.serviceinstancebeans.SubscriberInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
@@ -106,9 +107,6 @@ public class E2EServiceInstances {
private MsoRequest msoRequest;
@Autowired
- private RequestClientFactory requestClientFactory;
-
- @Autowired
private RequestsDbClient requestsDbClient;
@Autowired
@@ -117,6 +115,12 @@ public class E2EServiceInstances {
@Autowired
private ResponseBuilder builder;
+ @Autowired
+ private CamundaClient camundaClient;
+
+ @Autowired
+ private ResponseHandler responseHandler;
+
/**
* POST Requests for E2E Service create Instance on a version provided
*
@@ -288,24 +292,16 @@ public class E2EServiceInstances {
String workflowUrl = "/mso/async/services/CompareModelofE2EServiceInstance";
int recipeTimeout = 180;
- RequestClient requestClient;
- HttpResponse response;
-
+ String bpmnRequest = null;
+ RequestClientParameter postParam = null;
try {
- requestClient = requestClientFactory.getRequestClient(workflowUrl);
-
JSONObject jjo = new JSONObject(requestJSON);
- String bpmnRequest = jjo.toString();
-
- // Capture audit event
- logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
+ bpmnRequest = jjo.toString();
String serviceId = instanceIdMap.get(SERVICE_ID);
String serviceType = e2eCompareModelReq.getServiceType();
- RequestClientParameter postParam = new RequestClientParameter.Builder().setRequestId(requestId)
- .setBaseVfModule(false).setRecipeTimeout(recipeTimeout).setRequestAction(action.name())
- .setServiceInstanceId(serviceId).setServiceType(serviceType).setRequestDetails(bpmnRequest)
- .setALaCarte(false).build();
- response = requestClient.post(postParam);
+ postParam = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(false)
+ .setRecipeTimeout(recipeTimeout).setRequestAction(action.name()).setServiceInstanceId(serviceId)
+ .setServiceType(serviceType).setRequestDetails(bpmnRequest).setALaCarte(false).build();
} catch (Exception e) {
Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
@@ -315,21 +311,7 @@ public class E2EServiceInstances {
logger.debug(END_OF_THE_TRANSACTION + resp.getEntity().toString());
return resp;
}
-
- if (response == null) {
- Response resp =
- msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
- "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
- logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(),
- MSO_PROP_APIHANDLER_INFRA, ErrorCode.BusinessProcessError.getValue(), "Null response from BPEL");
- logger.debug(END_OF_THE_TRANSACTION + resp.getEntity().toString());
- return resp;
- }
-
- ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
- int bpelStatus = respHandler.getStatus();
-
- return beplStatusUpdate(requestClient, respHandler, bpelStatus, version);
+ return postRequest(workflowUrl, postParam, version);
}
private Response getE2EServiceInstance(String serviceId, String operationId, String version) {
@@ -431,29 +413,21 @@ public class E2EServiceInstances {
return response;
}
- RequestClient requestClient;
- HttpResponse response;
+ String bpmnRequest = null;
+ RequestClientParameter postParam = null;
try {
- requestClient = requestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI());
-
JSONObject jjo = new JSONObject(requestJSON);
jjo.put("operationId", requestId);
-
- String bpmnRequest = jjo.toString();
-
- // Capture audit event
- logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
+ bpmnRequest = jjo.toString();
String serviceId = instanceIdMap.get(SERVICE_ID);
String operationType = instanceIdMap.get("operationType");
String serviceInstanceType = e2eActReq.getServiceType();
- RequestClientParameter clientParam = new RequestClientParameter.Builder().setRequestId(requestId)
- .setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
- .setRequestAction(action.name()).setServiceInstanceId(serviceId).setOperationType(operationType)
- .setServiceType(serviceInstanceType).setRequestDetails(bpmnRequest).setApiVersion(version)
- .setALaCarte(false).setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
- response = requestClient.post(clientParam);
-
+ postParam = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(false)
+ .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name())
+ .setServiceInstanceId(serviceId).setOperationType(operationType).setServiceType(serviceInstanceType)
+ .setRequestDetails(bpmnRequest).setApiVersion(version).setALaCarte(false)
+ .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
} catch (Exception e) {
Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
@@ -464,21 +438,7 @@ public class E2EServiceInstances {
logger.debug("End of the transaction, the final response is: " + resp.getEntity());
return resp;
}
-
- if (response == null) {
- Response resp =
- msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
- "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
- logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(),
- MSO_PROP_APIHANDLER_INFRA, ErrorCode.BusinessProcessError.getValue(), "Null response from BPEL");
- logger.debug(END_OF_THE_TRANSACTION + resp.getEntity());
- return resp;
- }
-
- ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
- int bpelStatus = respHandler.getStatus();
-
- return beplStatusUpdate(requestClient, respHandler, bpelStatus, version);
+ return postRequest(recipeLookupResult.getOrchestrationURI(), postParam, version);
}
private Response deleteE2EserviceInstances(String requestJSON, Action action, HashMap<String, String> instanceIdMap,
@@ -540,29 +500,19 @@ public class E2EServiceInstances {
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
-
- RequestClient requestClient;
- HttpResponse response;
-
+ String bpmnRequest = null;
+ RequestClientParameter clientParam = null;
try {
- requestClient = requestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI());
-
JSONObject jjo = new JSONObject(requestJSON);
jjo.put("operationId", requestId);
-
- String bpmnRequest = jjo.toString();
-
- // Capture audit event
- logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
+ bpmnRequest = jjo.toString();
String serviceId = instanceIdMap.get(SERVICE_ID);
String serviceInstanceType = e2eDelReq.getServiceType();
- RequestClientParameter clientParam = new RequestClientParameter.Builder().setRequestId(requestId)
- .setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
- .setRequestAction(action.name()).setServiceInstanceId(serviceId).setServiceType(serviceInstanceType)
- .setRequestDetails(bpmnRequest).setApiVersion(version).setALaCarte(false)
- .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
- response = requestClient.post(clientParam);
-
+ clientParam = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(false)
+ .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name())
+ .setServiceInstanceId(serviceId).setServiceType(serviceInstanceType).setRequestDetails(bpmnRequest)
+ .setApiVersion(version).setALaCarte(false).setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd())
+ .build();
} catch (Exception e) {
Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
@@ -574,20 +524,7 @@ public class E2EServiceInstances {
return resp;
}
- if (response == null) {
- Response resp =
- msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
- "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
- logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(),
- MSO_PROP_APIHANDLER_INFRA, ErrorCode.BusinessProcessError.getValue(), "Null response from BPEL");
- logger.debug(END_OF_THE_TRANSACTION + resp.getEntity());
- return resp;
- }
-
- ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
- int bpelStatus = respHandler.getStatus();
-
- return beplStatusUpdate(requestClient, respHandler, bpelStatus, version);
+ return postRequest(recipeLookupResult.getOrchestrationURI(), clientParam, version);
}
private Response updateE2EserviceInstances(String requestJSON, Action action, String version) throws ApiException {
@@ -657,51 +594,14 @@ public class E2EServiceInstances {
}
String serviceInstanceType = e2eSir.getService().getServiceType();
-
- RequestClient requestClient;
- HttpResponse response;
-
String sirRequestJson = convertToString(sir);
+ RequestClientParameter postParam = new RequestClientParameter.Builder().setRequestId(requestId)
+ .setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
+ .setRequestAction(action.name()).setServiceInstanceId(serviceId).setServiceType(serviceInstanceType)
+ .setRequestDetails(sirRequestJson).setApiVersion(version).setALaCarte(false)
+ .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
- try {
- requestClient = requestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI());
-
- // Capture audit event
- logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
- RequestClientParameter postParam = new RequestClientParameter.Builder().setRequestId(requestId)
- .setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
- .setRequestAction(action.name()).setServiceInstanceId(serviceId).setServiceType(serviceInstanceType)
- .setRequestDetails(sirRequestJson).setApiVersion(version).setALaCarte(false)
- .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
- response = requestClient.post(postParam);
- } catch (Exception e) {
- logger.debug("Exception while communicate with BPMN engine", e);
- Response getBPMNResp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
- MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
-
- logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(),
- MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(),
- "Exception while communicate with BPMN engine");
- logger.debug(END_OF_THE_TRANSACTION + getBPMNResp.getEntity());
-
- return getBPMNResp;
- }
-
- if (response == null) {
- Response getBPMNResp =
- msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
- "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
- logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(),
- MSO_PROP_APIHANDLER_INFRA, ErrorCode.BusinessProcessError.getValue(), "Null response from BPEL");
- logger.debug(END_OF_THE_TRANSACTION + getBPMNResp.getEntity());
- return getBPMNResp;
- }
-
- ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
- int bpelStatus = respHandler.getStatus();
-
- return beplStatusUpdate(requestClient, respHandler, bpelStatus, version);
+ return postRequest(recipeLookupResult.getOrchestrationURI(), postParam, version);
}
private Response processE2EserviceInstances(String requestJSON, Action action,
@@ -771,48 +671,14 @@ public class E2EServiceInstances {
String serviceInstanceType = e2eSir.getService().getServiceType();
String serviceId = e2eSir.getService().getServiceId();
- RequestClient requestClient;
- HttpResponse response;
-
String sirRequestJson = convertToString(sir);
+ RequestClientParameter parameter = new RequestClientParameter.Builder().setRequestId(requestId)
+ .setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
+ .setRequestAction(action.name()).setServiceInstanceId(serviceId).setServiceType(serviceInstanceType)
+ .setRequestDetails(sirRequestJson).setApiVersion(version).setALaCarte(false)
+ .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
- try {
- requestClient = requestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI());
-
- // Capture audit event
- logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
- RequestClientParameter parameter = new RequestClientParameter.Builder().setRequestId(requestId)
- .setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
- .setRequestAction(action.name()).setServiceInstanceId(serviceId).setServiceType(serviceInstanceType)
- .setRequestDetails(sirRequestJson).setApiVersion(version).setALaCarte(false)
- .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
- response = requestClient.post(parameter);
- } catch (Exception e) {
- Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
- MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
- ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
-
- logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(),
- MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(),
- "Exception while communicate with BPMN engine");
- logger.debug(END_OF_THE_TRANSACTION + resp.getEntity());
- return resp;
- }
-
- if (response == null) {
- Response resp =
- msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
- "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
- logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(),
- MSO_PROP_APIHANDLER_INFRA, ErrorCode.BusinessProcessError.getValue(), "Null response from BPEL");
- logger.debug(END_OF_THE_TRANSACTION + resp.getEntity());
- return resp;
- }
-
- ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
- int bpelStatus = respHandler.getStatus();
-
- return beplStatusUpdate(requestClient, respHandler, bpelStatus, version);
+ return postRequest(recipeLookupResult.getOrchestrationURI(), parameter, version);
}
private Response scaleE2EserviceInstances(String requestJSON, Action action, String version) throws ApiException {
@@ -865,90 +731,67 @@ public class E2EServiceInstances {
logger.debug(END_OF_THE_TRANSACTION + response.getEntity());
return response;
}
-
- RequestClient requestClient;
- HttpResponse response;
-
+ String bpmnRequest = null;
+ RequestClientParameter postParam = null;
try {
- requestClient = requestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI());
-
JSONObject jjo = new JSONObject(requestJSON);
jjo.put("operationId", requestId);
-
- String bpmnRequest = jjo.toString();
-
- // Capture audit event
- logger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
+ bpmnRequest = jjo.toString();
String serviceId = instanceIdMap.get(SERVICE_ID);
String serviceInstanceType = e2eScaleReq.getService().getServiceType();
- RequestClientParameter postParam = new RequestClientParameter.Builder().setRequestId(requestId)
- .setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout())
- .setRequestAction(action.name()).setServiceInstanceId(serviceId).setServiceType(serviceInstanceType)
- .setRequestDetails(bpmnRequest).setApiVersion(version).setALaCarte(false)
- .setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build();
- response = requestClient.post(postParam);
+ postParam = new RequestClientParameter.Builder().setRequestId(requestId).setBaseVfModule(false)
+ .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name())
+ .setServiceInstanceId(serviceId).setServiceType(serviceInstanceType).setRequestDetails(bpmnRequest)
+ .setApiVersion(version).setALaCarte(false).setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd())
+ .build();
} catch (Exception e) {
Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
- MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
+ MsoException.ServiceException, "Failed creating bpmnRequest " + e.getMessage(),
ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(),
MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(),
- "Exception while communicate with BPMN engine", e);
+ "Exception while creating bpmnRequest", e);
logger.debug(END_OF_THE_TRANSACTION + resp.getEntity());
return resp;
}
+ return postRequest(recipeLookupResult.getOrchestrationURI(), postParam, version);
+ }
- if (response == null) {
- Response resp =
- msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
- "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
+ protected Response postRequest(String orchestrationURI, RequestClientParameter postParam, String version)
+ throws ApiException {
+ ResponseEntity<String> response = null;
+ try {
+ response = camundaClient.post(postParam, orchestrationURI);
+ } catch (BPMNFailureException e) {
+ Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR,
+ MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(),
- MSO_PROP_APIHANDLER_INFRA, ErrorCode.BusinessProcessError.getValue(), "Null response from BPEL");
+ MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(),
+ "Exception while communicate with BPMN engine");
+ logger.debug(END_OF_THE_TRANSACTION + resp.getEntity());
+ return resp;
+ } catch (Exception e) {
+ Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
+ MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version);
+ logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(),
+ MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(),
+ "Exception while communicate with BPMN engine");
logger.debug(END_OF_THE_TRANSACTION + resp.getEntity());
return resp;
}
-
- ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
- int bpelStatus = respHandler.getStatus();
-
- return beplStatusUpdate(requestClient, respHandler, bpelStatus, version);
+ return bpelStatusUpdate(response, version);
}
- private Response beplStatusUpdate(RequestClient requestClient, ResponseHandler respHandler, int bpelStatus,
- String version) {
-
+ private Response bpelStatusUpdate(ResponseEntity<String> responseEntity, String version) throws ApiException {
String apiVersion = version.substring(1);
-
- // BPMN accepted the request, the request is in progress
- if (bpelStatus == HttpStatus.SC_ACCEPTED) {
- String camundaJSONResponseBody = respHandler.getResponseBody();
- logger.debug("Received from Camunda: " + camundaJSONResponseBody);
- logger.debug(END_OF_THE_TRANSACTION + camundaJSONResponseBody);
- return builder.buildResponse(HttpStatus.SC_ACCEPTED, null, camundaJSONResponseBody, apiVersion);
- } else {
- List<String> variables = new ArrayList<>();
- variables.add(bpelStatus + "");
- String camundaJSONResponseBody = respHandler.getResponseBody();
- if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty()) {
- Response resp = msoRequest.buildServiceErrorResponse(bpelStatus, MsoException.ServiceException,
- "Request Failed due to BPEL error with HTTP Status= %1 " + '\n' + camundaJSONResponseBody,
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables, version);
- logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_RESPONSE_ERROR.toString(),
- requestClient.getUrl(), ErrorCode.BusinessProcessError.getValue(),
- "Response from BPEL engine is failed with HTTP Status=" + bpelStatus);
- logger.debug(END_OF_THE_TRANSACTION + resp.getEntity());
- return resp;
- } else {
- Response resp = msoRequest.buildServiceErrorResponse(bpelStatus, MsoException.ServiceException,
- "Request Failed due to BPEL error with HTTP Status= %1",
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables, version);
- logger.error("", MessageEnum.APIH_BPEL_RESPONSE_ERROR.toString(), requestClient.getUrl(),
- ErrorCode.BusinessProcessError.getValue(), "Response from BPEL engine is empty");
- logger.debug(END_OF_THE_TRANSACTION + resp.getEntity());
- return resp;
- }
- }
+ responseHandler.acceptedResponse(responseEntity);
+ CamundaResponse camundaResponse = responseHandler.getCamundaResponse(responseEntity);
+ String response = camundaResponse.getResponse();
+ logger.debug(END_OF_THE_TRANSACTION + response);
+ return builder.buildResponse(HttpStatus.SC_ACCEPTED, null, response, apiVersion);
}
/**
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java
index 3007ddd7c9..f39a95e92c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java
@@ -197,6 +197,7 @@ public class InstanceManagement {
vnfId = sir.getVnfInstanceId();
}
+ currentActiveReq = setWorkflowNameAndOperationName(currentActiveReq, workflowUuid);
saveCurrentActiveRequest(currentActiveReq);
RequestClientParameter requestClientParameter;
@@ -293,6 +294,7 @@ public class InstanceManagement {
RecipeLookupResult recipeLookupResult = getInstanceManagementWorkflowRecipe(currentActiveReq, workflowUuid);
+ currentActiveReq = setWorkflowNameAndOperationName(currentActiveReq, workflowUuid);
saveCurrentActiveRequest(currentActiveReq);
RequestClientParameter requestClientParameter;
@@ -357,4 +359,14 @@ public class InstanceManagement {
}
return null;
}
+
+ protected InfraActiveRequests setWorkflowNameAndOperationName(InfraActiveRequests currentActiveReq,
+ String workflowUuid) {
+ Workflow workflow = catalogDbClient.findWorkflowByArtifactUUID(workflowUuid);
+ if (workflow != null) {
+ currentActiveReq.setWorkflowName(workflow.getName());
+ currentActiveReq.setOperationName(workflow.getOperationName());
+ }
+ return currentActiveReq;
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java
index 0ec61785fd..b01bbecf0a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java
@@ -34,15 +34,13 @@ import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
+import org.onap.logging.filter.base.ErrorCode;
+import org.onap.so.apihandler.common.CamundaClient;
import org.onap.so.apihandler.common.ErrorNumbers;
-import org.onap.so.apihandler.common.RequestClient;
-import org.onap.so.apihandler.common.RequestClientFactory;
import org.onap.so.apihandler.common.ResponseBuilder;
import org.onap.so.apihandler.common.ResponseHandler;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
-import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
import org.onap.so.apihandlerinfra.tasksbeans.TaskRequestReference;
@@ -50,12 +48,12 @@ import org.onap.so.apihandlerinfra.tasksbeans.TasksRequest;
import org.onap.so.apihandlerinfra.tasksbeans.Value;
import org.onap.so.apihandlerinfra.tasksbeans.Variables;
import org.onap.so.exceptions.ValidationException;
-import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.LoggingAnchor;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -76,13 +74,13 @@ public class ManualTasks {
private String taskUri;
@Autowired
- private RequestClientFactory reqClientFactory;
+ private ResponseBuilder builder;
@Autowired
- private MsoRequest msoRequest;
+ private CamundaClient camundaClient;
@Autowired
- private ResponseBuilder builder;
+ private ResponseHandler responseHandler;
@POST
@Path("/{version:[vV]1}/{taskId}/complete")
@@ -161,100 +159,37 @@ public class ManualTasks {
mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
camundaJsonReq = mapper.writeValueAsString(variablesForComplete);
} catch (JsonProcessingException e) {
-
- ErrorLoggerInfo errorLoggerInfo =
- new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, ErrorCode.UnknownError)
- .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
-
-
+ logger.error("Mapping of JSON object to Camunda request failed");
ValidateException validateException =
new ValidateException.Builder("Mapping of JSON object to Camunda request failed",
- HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR)
- .errorInfo(errorLoggerInfo).build();
+ HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).build();
throw validateException;
}
- RequestClient requestClient;
- HttpResponse response;
String requestUrl = taskUri + "/" + taskId + "/complete";
- try {
- requestClient = reqClientFactory.getRequestClient(requestUrl);
- // Capture audit event
-
- response = requestClient.post(camundaJsonReq);
-
- } catch (Exception e) {
-
- ErrorLoggerInfo errorLoggerInfo =
- new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError)
- .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
-
-
-
- BPMNFailureException bpmnFailureException =
- new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY),
- HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo)
- .build();
-
- throw bpmnFailureException;
- }
-
- if (response == null) {
- ErrorLoggerInfo errorLoggerInfo =
- new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.BusinessProcessError)
- .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ResponseEntity<String> response = camundaClient.post(camundaJsonReq, requestUrl);
+ int bpelStatus = responseHandler.setStatus(response.getStatusCodeValue());
- BPMNFailureException bpmnFailureException =
- new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY),
- HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo)
- .build();
-
- throw bpmnFailureException;
-
- }
-
- ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
- int bpelStatus = respHandler.getStatus();
-
- // BPEL accepted the request, the request is in progress
- if (bpelStatus == HttpStatus.SC_NO_CONTENT || bpelStatus == HttpStatus.SC_ACCEPTED) {
- logger.debug("Received good response from Camunda");
- TaskRequestReference trr = new TaskRequestReference();
- trr.setTaskId(taskId);
- String completeResp = null;
- try {
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
- completeResp = mapper.writeValueAsString(trr);
- } catch (JsonProcessingException e) {
-
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR,
- ErrorCode.BusinessProcessError).build();
-
-
- ValidateException validateException =
- new ValidateException.Builder("Request Failed due to bad response format", bpelStatus,
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
-
- throw validateException;
- }
- logger.debug("Response to the caller: {}", completeResp);
- logger.debug("End of the transaction, the final response is: {}", completeResp);
- return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestId, completeResp, apiVersion);
- } else {
- ErrorLoggerInfo errorLoggerInfo =
- new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcessError)
- .build();
-
-
- BPMNFailureException bpmnFailureException = new BPMNFailureException.Builder(String.valueOf(bpelStatus),
- bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
-
- throw bpmnFailureException;
-
+ responseHandler.acceptedOrNoContentResponse(response);
+ logger.debug("Received good response from Camunda");
+ TaskRequestReference trr = new TaskRequestReference();
+ trr.setTaskId(taskId);
+ String completeResp = null;
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
+ completeResp = mapper.writeValueAsString(trr);
+ } catch (JsonProcessingException e) {
+ logger.error("Unable to map response from Camunda");
+ ValidateException validateException =
+ new ValidateException.Builder("Request Failed due to bad response format", bpelStatus,
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).build();
+ throw validateException;
}
-
+ logger.debug("Response to the caller: {}", completeResp);
+ logger.debug("End of the transaction, the final response is: {}", completeResp);
+ return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestId, completeResp, apiVersion);
}
private static boolean empty(String s) {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
index ce371203ab..f3c3ec5ff1 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
@@ -42,8 +42,6 @@ import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-import org.onap.aai.domain.yang.GenericVnf;
-import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.Tenant;
import org.onap.so.apihandler.common.ResponseBuilder;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
index c43a050500..acd3a8321e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
@@ -49,7 +49,6 @@ import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandler.common.ResponseBuilder;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
-import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
import org.onap.so.constants.OrchestrationRequestFormat;
@@ -311,6 +310,19 @@ public class OrchestrationRequests {
request.setOriginalRequestId(originalRequestId);
}
+ if (!version.matches("v[1-7]")) {
+ String workflowName = iar.getWorkflowName();
+ if (workflowName == null) {
+ workflowName = iar.getRequestAction();
+ }
+ request.setWorkflowName(workflowName);
+
+ String operationName = iar.getOperationName();
+ if (operationName != null) {
+ request.setOperationName(operationName);
+ }
+ }
+
InstanceReferences ir = new InstanceReferences();
if (iar.getNetworkId() != null)
ir.setNetworkInstanceId(iar.getNetworkId());
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
index 9b37043b2d..a61975f529 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
@@ -38,22 +38,19 @@ import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import org.apache.commons.lang.StringUtils;
-import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
-import org.camunda.bpm.engine.history.HistoricProcessInstance;
import org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.apihandler.camundabeans.CamundaResponse;
+import org.onap.so.apihandler.common.CamundaClient;
import org.onap.so.apihandler.common.CommonConstants;
import org.onap.so.apihandler.common.ErrorNumbers;
-import org.onap.so.apihandler.common.RequestClient;
-import org.onap.so.apihandler.common.RequestClientFactory;
import org.onap.so.apihandler.common.RequestClientParameter;
import org.onap.so.apihandler.common.ResponseBuilder;
import org.onap.so.apihandler.common.ResponseHandler;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException;
-import org.onap.so.apihandlerinfra.exceptions.ClientConnectionException;
import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException;
import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException;
import org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException;
@@ -74,9 +71,7 @@ import org.onap.so.db.catalog.beans.VnfResource;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.request.beans.InfraActiveRequests;
-import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.exceptions.ValidationException;
-import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.LogConstants;
import org.onap.so.logger.MessageEnum;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
@@ -117,9 +112,6 @@ public class RequestHandlerUtils extends AbstractRestHandler {
private Environment env;
@Autowired
- private RequestClientFactory reqClientFactory;
-
- @Autowired
private ResponseBuilder builder;
@Autowired
@@ -131,122 +123,62 @@ public class RequestHandlerUtils extends AbstractRestHandler {
@Autowired
private CatalogDbClient catalogDbClient;
- public Response postBPELRequest(InfraActiveRequests currentActiveReq, RequestClientParameter requestClientParameter,
- String orchestrationUri, String requestScope) throws ApiException {
- HttpResponse response = null;
- RequestClient requestClient = null;
-
- try {
- requestClient = reqClientFactory.getRequestClient(orchestrationUri);
- response = requestClient.post(requestClientParameter);
- } catch (Exception e) {
- logger.error("Error posting request to BPMN", e);
- ErrorLoggerInfo errorLoggerInfo =
- new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError)
- .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- String url = requestClient != null ? requestClient.getUrl() : "";
- ClientConnectionException clientException =
- new ClientConnectionException.Builder(url, HttpStatus.SC_BAD_GATEWAY,
- ErrorNumbers.SVC_NO_SERVER_RESOURCES).cause(e).errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage());
- throw clientException;
- }
-
- if (response == null) {
+ @Autowired
+ private CamundaClient camundaClient;
- ErrorLoggerInfo errorLoggerInfo =
- new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.BusinessProcessError)
- .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- ClientConnectionException clientException = new ClientConnectionException.Builder(requestClient.getUrl(),
- HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage());
- throw clientException;
- }
+ @Autowired
+ private ResponseHandler responseHandler;
- ResponseHandler respHandler = null;
- int bpelStatus = 500;
+ protected ResponseEntity<String> postRequest(InfraActiveRequests currentActiveReq,
+ RequestClientParameter requestClientParameter, String orchestrationUri) throws ApiException {
try {
- respHandler = new ResponseHandler(response, requestClient.getType());
- bpelStatus = respHandler.getStatus();
+ return camundaClient.post(requestClientParameter, orchestrationUri);
} catch (ApiException e) {
- logger.error("Exception occurred", e);
- ErrorLoggerInfo errorLoggerInfo =
- new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError)
- .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- ValidateException validateException =
- new ValidateException.Builder("Exception caught mapping Camunda JSON response to object",
- HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
- .errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
- throw validateException;
+ updateStatus(currentActiveReq, Status.FAILED, e.getMessage());
+ throw e;
}
+ }
- // BPEL accepted the request, the request is in progress
- if (bpelStatus == HttpStatus.SC_ACCEPTED) {
- ServiceInstancesResponse jsonResponse;
- CamundaResponse camundaResp = respHandler.getResponse();
-
- if ("Success".equalsIgnoreCase(camundaResp.getMessage())) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- jsonResponse = mapper.readValue(camundaResp.getResponse(), ServiceInstancesResponse.class);
- jsonResponse.getRequestReferences().setRequestId(requestClientParameter.getRequestId());
- Optional<URL> selfLinkUrl =
- buildSelfLinkUrl(currentActiveReq.getRequestUrl(), requestClientParameter.getRequestId());
- if (selfLinkUrl.isPresent()) {
- jsonResponse.getRequestReferences().setRequestSelfLink(selfLinkUrl.get());
- } else {
- jsonResponse.getRequestReferences().setRequestSelfLink(null);
- }
- } catch (IOException e) {
- logger.error("Exception occurred", e);
- ErrorLoggerInfo errorLoggerInfo =
- new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.SchemaError)
- .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
- ValidateException validateException =
- new ValidateException.Builder("Exception caught mapping Camunda JSON response to object",
- HttpStatus.SC_NOT_ACCEPTABLE, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
- .errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
- throw validateException;
+ public Response postBPELRequest(InfraActiveRequests currentActiveReq, RequestClientParameter requestClientParameter,
+ String orchestrationUri, String requestScope) throws ApiException {
+ ObjectMapper mapper = new ObjectMapper();
+ ResponseEntity<String> response = postRequest(currentActiveReq, requestClientParameter, orchestrationUri);
+ ServiceInstancesResponse jsonResponse = null;
+ int bpelStatus = responseHandler.setStatus(response.getStatusCodeValue());
+ try {
+ responseHandler.acceptedResponse(response);
+ CamundaResponse camundaResponse = responseHandler.getCamundaResponse(response);
+ String responseBody = camundaResponse.getResponse();
+ if ("Success".equalsIgnoreCase(camundaResponse.getMessage())) {
+ jsonResponse = mapper.readValue(responseBody, ServiceInstancesResponse.class);
+ jsonResponse.getRequestReferences().setRequestId(requestClientParameter.getRequestId());
+ Optional<URL> selfLinkUrl =
+ buildSelfLinkUrl(currentActiveReq.getRequestUrl(), requestClientParameter.getRequestId());
+ if (selfLinkUrl.isPresent()) {
+ jsonResponse.getRequestReferences().setRequestSelfLink(selfLinkUrl.get());
+ } else {
+ jsonResponse.getRequestReferences().setRequestSelfLink(null);
}
- return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestClientParameter.getRequestId(),
- jsonResponse, requestClientParameter.getApiVersion());
+ } else {
+ BPMNFailureException bpmnException =
+ new BPMNFailureException.Builder(String.valueOf(bpelStatus) + responseBody, bpelStatus,
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).build();
+ updateStatus(currentActiveReq, Status.FAILED, bpmnException.getMessage());
+ throw bpmnException;
}
+ } catch (ApiException e) {
+ updateStatus(currentActiveReq, Status.FAILED, e.getMessage());
+ throw e;
+ } catch (IOException e) {
+ logger.error("Exception caught mapping Camunda JSON response to object: ", e);
+ updateStatus(currentActiveReq, Status.FAILED, e.getMessage());
+ throw new ValidateException.Builder("Exception caught mapping Camunda JSON response to object",
+ HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).build();
}
-
- List<String> variables = new ArrayList<>();
- variables.add(bpelStatus + "");
- String camundaJSONResponseBody = respHandler.getResponseBody();
- if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty()) {
-
- ErrorLoggerInfo errorLoggerInfo =
- new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcessError)
- .errorSource(requestClient.getUrl()).build();
- BPMNFailureException bpmnException =
- new BPMNFailureException.Builder(String.valueOf(bpelStatus) + camundaJSONResponseBody, bpelStatus,
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
-
- updateStatus(currentActiveReq, Status.FAILED, bpmnException.getMessage());
-
- throw bpmnException;
- } else {
-
- ErrorLoggerInfo errorLoggerInfo =
- new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, ErrorCode.BusinessProcessError)
- .errorSource(requestClient.getUrl()).build();
-
-
- BPMNFailureException servException = new BPMNFailureException.Builder(String.valueOf(bpelStatus),
- bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo).build();
- updateStatus(currentActiveReq, Status.FAILED, servException.getMessage());
-
- throw servException;
- }
+ return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestClientParameter.getRequestId(), jsonResponse,
+ requestClientParameter.getApiVersion());
}
-
-
@Override
public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage)
throws RequestDbFailureException {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java
index 418c702768..dadb7c7558 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java
@@ -22,7 +22,6 @@
package org.onap.so.apihandlerinfra;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -33,13 +32,12 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
-import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.json.JSONArray;
import org.json.JSONObject;
+import org.onap.logging.filter.base.ErrorCode;
+import org.onap.so.apihandler.common.CamundaClient;
import org.onap.so.apihandler.common.ErrorNumbers;
-import org.onap.so.apihandler.common.RequestClient;
-import org.onap.so.apihandler.common.RequestClientFactory;
import org.onap.so.apihandler.common.ResponseBuilder;
import org.onap.so.apihandler.common.ResponseHandler;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
@@ -50,12 +48,12 @@ import org.onap.so.apihandlerinfra.tasksbeans.TaskList;
import org.onap.so.apihandlerinfra.tasksbeans.TaskVariableValue;
import org.onap.so.apihandlerinfra.tasksbeans.TaskVariables;
import org.onap.so.apihandlerinfra.tasksbeans.TasksGetResponse;
-import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -79,10 +77,13 @@ public class TasksHandler {
private String requestUrl;
@Autowired
- private RequestClientFactory reqClientFactory;
+ private ResponseBuilder builder;
@Autowired
- private ResponseBuilder builder;
+ private CamundaClient camundaClient;
+
+ @Autowired
+ private ResponseHandler responseHandler;
@Path("/{version:[vV]1}")
@GET
@@ -148,18 +149,12 @@ public class TasksHandler {
}
tv.setTaskVariables(tvvList);
-
- RequestClient requestClient = null;
-
- HttpResponse response = null;
+ ResponseEntity<String> response = null;
+ String camundaJsonReq = null;
try {
- requestClient = reqClientFactory.getRequestClient(requestUrl);
- // Capture audit event
ObjectMapper mapper = new ObjectMapper();
- String camundaJsonReq = mapper.writeValueAsString(tv);
- response = requestClient.post(camundaJsonReq);
-
+ camundaJsonReq = mapper.writeValueAsString(tv);
} catch (JsonProcessingException e) {
ErrorLoggerInfo errorLoggerInfo =
new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError)
@@ -167,21 +162,16 @@ public class TasksHandler {
throw new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(),
HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo)
.build();
-
- } catch (IOException e) {
- ErrorLoggerInfo errorLoggerInfo =
- new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError)
- .build();
- throw new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY), HttpStatus.SC_BAD_GATEWAY,
- ErrorNumbers.SVC_NO_SERVER_RESOURCES).cause(e).errorInfo(errorLoggerInfo).build();
}
+
+ response = camundaClient.post(camundaJsonReq, requestUrl);
TasksGetResponse trr = new TasksGetResponse();
List<TaskList> taskList = new ArrayList<>();
- ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
- int bpelStatus = respHandler.getStatus();
- String respBody = respHandler.getResponseBody();
- if ((bpelStatus == HttpStatus.SC_NO_CONTENT || bpelStatus == HttpStatus.SC_ACCEPTED) && (null != respBody)) {
+ int bpelStatus = responseHandler.setStatus(response.getStatusCodeValue());
+ String respBody = response.getBody();
+ responseHandler.acceptedOrNoContentResponse(response);
+ if (null != respBody) {
JSONArray data = new JSONArray(respBody);
@@ -230,45 +220,22 @@ public class TasksHandler {
private TaskList getTaskInfo(String taskId) throws ApiException {
TaskList taskList;
String getRequestUrl = UriBuilder.fromUri(requestUrl).path(taskId).path("variables").build().toString();
- HttpResponse getResponse;
-
- RequestClient requestClient = reqClientFactory.getRequestClient(getRequestUrl);
- // Capture audit event
- try {
- getResponse = requestClient.get();
- } catch (IOException e) {
- ErrorLoggerInfo errorLoggerInfo =
- new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError)
- .build();
- throw new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY), HttpStatus.SC_BAD_GATEWAY,
- ErrorNumbers.SVC_NO_SERVER_RESOURCES).cause(e).errorInfo(errorLoggerInfo).build();
- }
- ResponseHandler respHandler = new ResponseHandler(getResponse, requestClient.getType());
- int bpelStatus = respHandler.getStatus();
- if (bpelStatus == HttpStatus.SC_ACCEPTED) {
- String respBody = respHandler.getResponseBody();
- if (respBody != null) {
- taskList = buildTaskList(taskId, respBody);
- } else {
- ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR,
- ErrorCode.AvailabilityError).build();
- throw new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY),
- HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo)
- .build();
+ ResponseEntity<String> getResponse;
- }
+ getResponse = camundaClient.get(getRequestUrl);
+ responseHandler.acceptedResponse(getResponse);
+ String respBody = getResponse.getBody();
+ if (respBody != null) {
+ taskList = buildTaskList(taskId, respBody);
} else {
ErrorLoggerInfo errorLoggerInfo =
new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, ErrorCode.AvailabilityError)
.build();
-
- throw new BPMNFailureException.Builder(String.valueOf(bpelStatus), bpelStatus,
+ throw new BPMNFailureException.Builder(String.valueOf(HttpStatus.SC_BAD_GATEWAY), HttpStatus.SC_BAD_GATEWAY,
ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo).build();
}
-
return taskList;
-
}
private TaskList buildTaskList(String taskId, String respBody) {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java
index 4e3d8736c2..fc0048bacf 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/AAIDataRetrieval.java
@@ -1,19 +1,35 @@
package org.onap.so.apihandlerinfra.infra.rest;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
import java.util.Optional;
+import java.util.stream.Collectors;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.L3Network;
+import org.onap.aai.domain.yang.LInterface;
import org.onap.aai.domain.yang.Service;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.Tenant;
import org.onap.aai.domain.yang.VfModule;
+import org.onap.aai.domain.yang.VfModules;
import org.onap.aai.domain.yang.VolumeGroup;
+import org.onap.aai.domain.yang.VolumeGroups;
import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
-import org.onap.so.client.aai.AAIObjectPlurals;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.AAIResourcesClient;
-import org.onap.so.client.aai.entities.AAIResultWrapper;
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.aai.AAIDSLQueryClient;
+import org.onap.aaiclient.client.aai.AAIObjectPlurals;
+import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
+import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.graphinventory.entities.DSLQuery;
+import org.onap.aaiclient.client.graphinventory.entities.DSLQueryBuilder;
+import org.onap.aaiclient.client.graphinventory.entities.DSLStartNode;
+import org.onap.aaiclient.client.graphinventory.entities.Node;
+import org.onap.aaiclient.client.graphinventory.entities.Start;
+import org.onap.aaiclient.client.graphinventory.entities.TraversalBuilder;
+import org.onap.aaiclient.client.graphinventory.entities.__;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -25,6 +41,8 @@ public class AAIDataRetrieval {
private AAIResourcesClient aaiResourcesClient;
+ private AAIDSLQueryClient aaiDslQueryClient;
+
private static final Logger logger = LoggerFactory.getLogger(AAIDataRetrieval.class);
public ServiceInstance getServiceInstance(String serviceInstanceId) {
@@ -129,6 +147,22 @@ public class AAIDataRetrieval {
});
}
+ public List<LInterface> getLinterfacesOfVnf(String vnfId) {
+ DSLStartNode startNode = new DSLStartNode(AAIObjectType.GENERIC_VNF, __.key("generic-vnf-id", vnfId));
+ DSLQueryBuilder<Start, Node> builder = TraversalBuilder.fragment(startNode)
+ .to(__.node(AAIObjectType.VSERVER).to(__.node(AAIObjectType.L_INTERFACE).output()));
+ List<LInterface> linterfaces =
+ getAAIDSLQueryClient().querySingleResource(new DSLQuery(builder.build()), LInterface.class);
+ return linterfaces;
+ }
+
+ private AAIDSLQueryClient getAAIDSLQueryClient() {
+ if (aaiDslQueryClient == null) {
+ aaiDslQueryClient = new AAIDSLQueryClient();
+ }
+ return aaiDslQueryClient;
+ }
+
protected AAIResourcesClient getAaiResourcesClient() {
if (aaiResourcesClient == null) {
aaiResourcesClient = new AAIResourcesClient();
@@ -136,4 +170,52 @@ public class AAIDataRetrieval {
return aaiResourcesClient;
}
+ public boolean isVnfRelatedToVFModule(String vnfId) {
+ return !getVfModulesOfVnf(vnfId).isEmpty();
+ }
+
+ public List<VfModule> getVfModulesOfVnf(String vnfId) {
+ List<VfModule> vfModuleList = new ArrayList<VfModule>();
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, vnfId);
+ Optional<VfModules> vfModules = getAaiResourcesClient().get(VfModules.class, uri);
+ if (!vfModules.isPresent() || vfModules.get().getVfModule().isEmpty()) {
+ logger.debug("No VfModules attached to Vnf in AAI : {}", vnfId);
+ } else {
+ vfModuleList = vfModules.get().getVfModule();
+ }
+ return vfModuleList;
+ }
+
+ public Optional<String> getVfModuleIdsByVnfId(String vnfId) {
+ List<VfModule> vfModulesList = getVfModulesOfVnf(vnfId);
+ if (!vfModulesList.isEmpty()) {
+ return Optional.of(vfModulesList.stream().map(item -> item.getVfModuleId()).collect(Collectors.toList())
+ .stream().sorted().collect(Collectors.joining(",")));
+ } else {
+ return Optional.empty();
+ }
+ }
+
+ public List<VolumeGroup> getVolumeGroupsOfVnf(String vnfId) {
+ List<VolumeGroup> volumeGroupList = new ArrayList<VolumeGroup>();
+ AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
+ .relatedTo(AAIObjectPlurals.VOLUME_GROUP);
+ Optional<VolumeGroups> volumeGroups = getAaiResourcesClient().get(VolumeGroups.class, uri);
+ if (!volumeGroups.isPresent() || volumeGroups.get().getVolumeGroup().isEmpty()) {
+ logger.debug("No VolumeGroups attached to Vnf in AAI : {}", vnfId);
+ } else {
+ volumeGroupList = volumeGroups.get().getVolumeGroup();
+ }
+ return volumeGroupList;
+ }
+
+ public Optional<String> getVolumeGroupIdsByVnfId(String vnfId) {
+ List<VolumeGroup> volumeGroupList = getVolumeGroupsOfVnf(vnfId);
+ if (!volumeGroupList.isEmpty()) {
+ return Optional.of(volumeGroupList.stream().map(item -> item.getVolumeGroupId())
+ .collect(Collectors.toList()).stream().sorted().collect(Collectors.joining(",")));
+ } else {
+ return Optional.empty();
+ }
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java
index f37713d5b2..e8046a2cd9 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java
@@ -29,11 +29,12 @@ import org.onap.aai.domain.yang.L3Network;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.VolumeGroup;
+import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
import org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.constants.Status;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
@@ -56,12 +57,6 @@ public class BpmnRequestBuilder {
private static final String CLOUD_CONFIGURATION_COULD_NOT_BE_FOUND = "Cloud Configuration could not be found";
- private static final String CLOUD_REGION_ID = "cloud-region-id";
-
- private static final String CLOUD_OWNER = "cloud-owner";
-
- private static final String TENANT_ID = "tenant-id";
-
private static final String GENERIC_VNF_NOT_FOUND_IN_INVENTORY_VNF_ID =
"Generic Vnf Not Found In Inventory, VnfId: ";
@@ -277,17 +272,20 @@ public class BpmnRequestBuilder {
public CloudConfiguration mapCloudConfiguration(GenericVnf vnf, String vfModuleId) {
CloudConfiguration cloudConfig = new CloudConfiguration();
AAIResultWrapper wrapper = new AAIResultWrapper(vnf);
- Optional<org.onap.so.client.aai.entities.Relationships> relationshipsOpt = wrapper.getRelationships();
+ Optional<org.onap.aaiclient.client.aai.entities.Relationships> relationshipsOpt = wrapper.getRelationships();
String tenantId = null;
String cloudOwner = null;
String lcpRegionId = null;
if (relationshipsOpt.isPresent()) {
tenantId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst()
- .map(item -> item.getURIKeys().get(TENANT_ID)).orElse(null);
- cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst()
- .map(item -> item.getURIKeys().get(CLOUD_OWNER)).orElse(null);
- lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst()
- .map(item -> item.getURIKeys().get(CLOUD_REGION_ID)).orElse(null);
+ .map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId))
+ .orElse(null);
+ cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map(
+ item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudOwner))
+ .orElse(null);
+ lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map(
+ item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId))
+ .orElse(null);
}
if (tenantId == null || cloudOwner == null || lcpRegionId == null) {
@@ -319,17 +317,20 @@ public class BpmnRequestBuilder {
public CloudConfiguration mapCloudConfigurationVolume(GenericVnf vnf, VolumeGroup volumeGroup) {
CloudConfiguration cloudConfig = new CloudConfiguration();
AAIResultWrapper wrapper = new AAIResultWrapper(vnf);
- Optional<org.onap.so.client.aai.entities.Relationships> relationshipsOpt = wrapper.getRelationships();
+ Optional<org.onap.aaiclient.client.aai.entities.Relationships> relationshipsOpt = wrapper.getRelationships();
String tenantId = null;
String cloudOwner = null;
String lcpRegionId = null;
if (relationshipsOpt.isPresent()) {
tenantId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst()
- .map(item -> item.getURIKeys().get(TENANT_ID)).orElse(null);
- cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst()
- .map(item -> item.getURIKeys().get(CLOUD_OWNER)).orElse(null);
- lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst()
- .map(item -> item.getURIKeys().get(CLOUD_REGION_ID)).orElse(null);
+ .map(item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.TENANT.getUriParams().tenantId))
+ .orElse(null);
+ cloudOwner = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map(
+ item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudOwner))
+ .orElse(null);
+ lcpRegionId = relationshipsOpt.get().getRelatedUris(AAIObjectType.TENANT).stream().findFirst().map(
+ item -> item.getURIKeys().get(AAIFluentTypeBuilder.Types.CLOUD_REGION.getUriParams().cloudRegionId))
+ .orElse(null);
}
if (tenantId == null || cloudOwner == null || lcpRegionId == null) {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java
index 3fd672bf42..c806e9fc1b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java
@@ -20,16 +20,15 @@
package org.onap.so.apihandlerinfra.infra.rest.handler;
-import java.io.IOException;
import java.net.URL;
import java.sql.Timestamp;
import java.util.Map;
import java.util.Optional;
import javax.ws.rs.container.ContainerRequestContext;
import org.apache.http.HttpStatus;
+import org.onap.logging.filter.base.ErrorCode;
+import org.onap.so.apihandler.common.CamundaClient;
import org.onap.so.apihandler.common.ErrorNumbers;
-import org.onap.so.apihandler.common.RequestClient;
-import org.onap.so.apihandler.common.RequestClientFactory;
import org.onap.so.apihandler.common.RequestClientParameter;
import org.onap.so.apihandlerinfra.Action;
import org.onap.so.apihandlerinfra.Actions;
@@ -45,7 +44,6 @@ import org.onap.so.constants.Status;
import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
-import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.LogConstants;
import org.onap.so.logger.MessageEnum;
import org.onap.so.serviceinstancebeans.ModelType;
@@ -74,7 +72,7 @@ public abstract class AbstractRestHandler {
protected RequestsDbClient infraActiveRequestsClient;
@Autowired
- protected RequestClientFactory reqClientFactory;
+ private CamundaClient camundaClient;
public String getRequestUri(ContainerRequestContext context) {
String requestUri = context.getUriInfo().getPath();
@@ -151,10 +149,9 @@ public abstract class AbstractRestHandler {
public void callWorkflowEngine(RequestClientParameter requestClientParameter, String orchestrationUri)
throws WorkflowEngineConnectionException {
- RequestClient requestClient = reqClientFactory.getRequestClient(orchestrationUri);
try {
- requestClient.post(requestClientParameter);
- } catch (IOException e) {
+ camundaClient.post(requestClientParameter, orchestrationUri);
+ } catch (ApiException e) {
logger.error("Error Calling Workflow Engine", e);
throw new WorkflowEngineConnectionException("Error Calling Workflow Engine", e);
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java
index f75897dda1..89c5cbed9b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java
@@ -8,8 +8,9 @@ import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
-
+@Component
public class NetworkDeleteValidator implements RequestValidator {
@Autowired
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java
index 1dea57ad9c..50938e6826 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java
@@ -24,7 +24,9 @@ import java.util.Map;
import java.util.Optional;
import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import org.springframework.stereotype.Component;
+@Component
public interface RequestValidator {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java
index 0c7ba65cf4..843d94ce6c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java
@@ -6,11 +6,12 @@ import java.util.regex.Pattern;
import org.onap.so.apihandlerinfra.Action;
import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
-import org.onap.so.listener.Skip;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
-@Skip
+
+@Component
public class ServiceInstanceDeleteValidator implements RequestValidator {
@Autowired
@@ -18,8 +19,17 @@ public class ServiceInstanceDeleteValidator implements RequestValidator {
@Override
public boolean shouldRunFor(String requestUri, ServiceInstancesRequest request, Actions action) {
+ boolean isALaCarte = false;
+ if (request.getRequestDetails() != null && request.getRequestDetails().getRequestParameters() != null) {
+ if (request.getRequestDetails().getRequestParameters().getALaCarte() == null) {
+ isALaCarte = false;
+ } else {
+ isALaCarte = request.getRequestDetails().getRequestParameters().getALaCarte();
+ }
+
+ }
return Pattern.compile("[Vv][5-8]/serviceInstances/[^/]+").matcher(requestUri).matches()
- && action.equals(Action.deleteInstance);
+ && action.equals(Action.deleteInstance) && isALaCarte;
}
@Override
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java
index d54e60d153..a48fca8d0f 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java
@@ -8,8 +8,9 @@ import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
-
+@Component
public class VnfDeleteValidator implements RequestValidator {
@Autowired
@@ -24,8 +25,16 @@ public class VnfDeleteValidator implements RequestValidator {
@Override
public Optional<String> validate(Map<String, String> instanceIdMap, ServiceInstancesRequest request,
Map<String, String> queryParams) {
- if (aaiDataRetrieval.isVnfRelatedToVolumes(instanceIdMap.get("vnfInstanceId"))) {
- return Optional.of("Cannot delete vnf it is still related to existing volume groups");
+ final Optional<String> volumeGroupIds =
+ aaiDataRetrieval.getVolumeGroupIdsByVnfId(instanceIdMap.get("vnfInstanceId"));
+ final Optional<String> vfModuleIds = aaiDataRetrieval.getVfModuleIdsByVnfId(instanceIdMap.get("vnfInstanceId"));
+
+ if (volumeGroupIds.isPresent()) {
+ return Optional.of(String.format("Cannot delete vnf it is still related to existing volume group Ids - %s",
+ volumeGroupIds.get()));
+ } else if (vfModuleIds.isPresent()) {
+ return Optional.of(String.format("Cannot delete vnf it is still related to existing vfModule Ids - %s",
+ vfModuleIds.get()));
} else {
return Optional.empty();
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java
index f010d47f70..e3598af31d 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java
@@ -8,7 +8,9 @@ import org.onap.so.apihandlerinfra.Actions;
import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+@Component
public class VolumeGroupDeleteValidator implements RequestValidator {
@Autowired
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java
index db2b5b6b4e..822627863a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/AaiClientPropertiesImpl.java
@@ -22,8 +22,8 @@ package org.onap.so.apihandlerinfra.tenantisolation;
import java.net.MalformedURLException;
import java.net.URL;
-import org.onap.so.client.aai.AAIProperties;
-import org.onap.so.client.aai.AAIVersion;
+import org.onap.aaiclient.client.aai.AAIProperties;
+import org.onap.aaiclient.client.aai.AAIVersion;
import org.onap.so.spring.SpringContextHelper;
import org.springframework.context.ApplicationContext;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java
index 6942d441e6..a28298f859 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java
@@ -28,12 +28,12 @@ import java.util.Map;
import javax.ws.rs.NotFoundException;
import org.onap.aai.domain.yang.OperationalEnvironment;
import org.onap.so.apihandlerinfra.tenantisolation.exceptions.AAIClientCallFailed;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.AAIResourcesClient;
-import org.onap.so.client.aai.entities.AAIResultWrapper;
-import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
-import org.onap.so.client.graphinventory.entities.uri.Depth;
+import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.graphinventory.entities.uri.Depth;
import org.springframework.stereotype.Component;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java
index 1e5958c540..75a1c75e31 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java
@@ -24,8 +24,6 @@ package org.onap.so.apihandlerinfra.tenantisolation.helpers;
import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Component
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java
index f0943393ed..7aa6e0f831 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java
@@ -108,7 +108,6 @@ public class SDCClientHelper {
HttpClient httpClient = httpClientFactory.newJsonClient(url, ONAPComponents.SDC);
httpClient.addBasicAuthHeader(sdcClientAuth, msoKey);
httpClient.addAdditionalHeader("X-ECOMP-InstanceID", sdcActivateInstanceId);
- httpClient.addAdditionalHeader("X-ECOMP-RequestID", UUID.randomUUID().toString());
httpClient.addAdditionalHeader("Content-Type", SDCClientHelper.SDC_CONTENT_TYPE);
httpClient.addAdditionalHeader("Accept", SDCClientHelper.SDC_ACCEPT_TYPE);
httpClient.addAdditionalHeader("USER_ID", sdcActivateUserId);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
index 9b24a14f68..d4c66f62e4 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java
@@ -26,8 +26,13 @@ import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
import org.json.JSONObject;
import org.onap.aai.domain.yang.OperationalEnvironment;
+import org.onap.aaiclient.client.aai.AAIObjectType;
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
+import org.onap.aaiclient.client.aai.entities.Relationships;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.apihandler.common.ErrorNumbers;
-import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
@@ -36,13 +41,9 @@ import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
import org.onap.so.apihandlerinfra.tenantisolation.helpers.ActivateVnfDBHelper;
import org.onap.so.apihandlerinfra.tenantisolation.helpers.SDCClientHelper;
import org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.entities.AAIResultWrapper;
-import org.onap.so.client.aai.entities.Relationships;
-import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
-import org.onap.logging.filter.base.ErrorCode;
+import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.logger.MessageEnum;
import org.onap.so.requestsdb.RequestsDBHelper;
import org.slf4j.Logger;
@@ -58,7 +59,6 @@ public class ActivateVnfOperationalEnvironment {
private static final Logger logger = LoggerFactory.getLogger(ActivateVnfOperationalEnvironment.class);
private static final int DEFAULT_ACTIVATE_RETRY_COUNT = 3;
private static final String DISTRIBUTION_STATUS_SENT = "SENT";
- private static final String OPER_ENVIRONMENT_ID_KEY = "operational-environment-id";
@Autowired
private ActivateVnfDBHelper dbHelper;
@@ -97,8 +97,8 @@ public class ActivateVnfOperationalEnvironment {
List<AAIResourceUri> operationalEnvironments =
relationships.getRelatedAAIUris(AAIObjectType.OPERATIONAL_ENVIRONMENT);
if (!operationalEnvironments.isEmpty()) {
- ecompOperationalEnvironmentId =
- operationalEnvironments.get(0).getURIKeys().get(OPER_ENVIRONMENT_ID_KEY);
+ ecompOperationalEnvironmentId = operationalEnvironments.get(0).getURIKeys().get(
+ AAIFluentTypeBuilder.Types.OPERATIONAL_ENVIRONMENT.getUriParams().operationalEnvironmentId);
}
}
logger.debug(" vnfOperationalEnvironmentId : {}", vnfOperationalEnvironmentId);
@@ -123,7 +123,8 @@ public class ActivateVnfOperationalEnvironment {
.build();
throw new ValidateException.Builder(
" The ECOMP OE was not in aai record; the value of relationship.relationship-data key: "
- + OPER_ENVIRONMENT_ID_KEY,
+ + AAIFluentTypeBuilder.Types.OPERATIONAL_ENVIRONMENT
+ .getUriParams().operationalEnvironmentId,
HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).errorInfo(errorLoggerInfo)
.build();
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java
index 77579817ff..67c5aa2aaa 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java
@@ -40,7 +40,7 @@ import org.onap.so.apihandlerinfra.tenantisolation.helpers.ActivateVnfDBHelper;
import org.onap.so.apihandlerinfra.tenantisolation.helpers.SDCClientHelper;
import org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution;
import org.onap.so.apihandlerinfra.tenantisolationbeans.DistributionStatus;
-import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
import org.onap.logging.filter.base.ErrorCode;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java
index d6969a9851..23537a7687 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java
@@ -37,7 +37,7 @@ import org.onap.so.apihandlerinfra.tenantisolation.exceptions.TenantIsolationExc
import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientObjectBuilder;
import org.onap.so.apihandlerinfra.tenantisolationbeans.RelatedInstanceList;
-import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.grm.GRMClient;
import org.onap.so.client.grm.beans.OperationalInfo;
import org.onap.so.client.grm.beans.Property;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java
index 59f7621b90..b30140cd68 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java
@@ -32,7 +32,7 @@ import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientHelper;
-import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
import org.onap.logging.filter.base.ErrorCode;
import org.onap.so.logger.MessageEnum;
import org.onap.so.requestsdb.RequestsDBHelper;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java
index 01c7fd33f9..560622faf4 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/CustomWorkflowValidation.java
@@ -23,9 +23,7 @@
package org.onap.so.apihandlerinfra.validation;
import org.onap.so.exceptions.ValidationException;
-import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.onap.so.serviceinstancebeans.RequestParameters;
-import com.google.common.base.Strings;
public class CustomWorkflowValidation implements ValidationRule {