summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main/java
diff options
context:
space:
mode:
authorGamboa, Gilbert <gilbert.g.gamboa@att.com>2019-12-11 14:00:42 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2019-12-11 14:00:42 -0500
commit043cf84e1b3624d3acb49adb29ec268da8c6ea54 (patch)
treea2bfd3f0a87a353264e9e7f38c57748fae7fac29 /bpmn/MSOCommonBPMN/src/main/java
parent02c068ce771ee4522936f2d15f41c2b631e965a8 (diff)
Include service-instance-id and
Include service-instance-id and service-model-version-id in the exception message if service-instance or service model is not found. Issue-ID: SO-2565 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Ia088d241374af4422cb76d16e86ddd7ecc45593a
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/java')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java96
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/ServiceModelNotFoundException.java15
2 files changed, 69 insertions, 42 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index 3f664cb821..951c4ccf32 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -62,6 +62,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException;
+import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.ServiceModelNotFoundException;
import org.onap.so.client.aai.AAICommonObjectMapperProvider;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.entities.AAIResultWrapper;
@@ -253,41 +254,46 @@ public class BBInputSetup implements JavaDelegate {
String bbName = executeBB.getBuildingBlock().getBpmnFlowName();
String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID);
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = null;
- if (serviceInstanceId != null) {
- aaiServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
- }
Service service = null;
boolean isReplace = false;
- if (aaiServiceInstance != null) {
- if (requestAction.equalsIgnoreCase("replaceInstance")) {
- RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList();
- if (relatedInstanceList != null) {
- for (RelatedInstanceList relatedInstList : relatedInstanceList) {
- RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
- if (relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) {
- service = bbInputSetupUtils
- .getCatalogServiceByModelUUID(relatedInstance.getModelInfo().getModelVersionId());
- isReplace = true;
+ if (serviceInstanceId != null) {
+ aaiServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
+ if (aaiServiceInstance != null) {
+ if (requestAction.equalsIgnoreCase("replaceInstance")) {
+ RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList();
+ if (relatedInstanceList != null) {
+ for (RelatedInstanceList relatedInstList : relatedInstanceList) {
+ RelatedInstance relatedInstance = relatedInstList.getRelatedInstance();
+ if (relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) {
+ service = bbInputSetupUtils.getCatalogServiceByModelUUID(
+ relatedInstance.getModelInfo().getModelVersionId());
+ isReplace = true;
+ }
}
}
+ } else {
+ service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ }
+ if (service == null) {
+ String message = String.format(
+ "Related service instance model not found in MSO CatalogDB: model-version-id=%s",
+ aaiServiceInstance.getModelVersionId());
+ throw new ServiceModelNotFoundException(message);
}
} else {
- service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ String message = String.format("Related service instance from AAI not found: service-instance-id=%s",
+ serviceInstanceId);
+ throw new NoServiceInstanceFoundException(message);
}
}
- if (aaiServiceInstance != null && service != null) {
- ServiceInstance serviceInstance = this.getExistingServiceInstance(aaiServiceInstance);
- serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(service));
- this.populateObjectsOnAssignAndCreateFlows(executeBB.getRequestId(), requestDetails, service, bbName,
- serviceInstance, lookupKeyMap, resourceId, vnfType, executeBB.getBuildingBlock().getKey(),
- executeBB.getConfigurationResourceKeys(), isReplace);
- return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction,
- null);
- } else {
- logger.debug("Related Service Instance from AAI: {}", aaiServiceInstance);
- logger.debug("Related Service Instance Model Info from AAI: {}", service);
- throw new Exception("Could not find relevant information for related Service Instance");
- }
+
+ ServiceInstance serviceInstance = this.getExistingServiceInstance(aaiServiceInstance);
+ serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(service));
+ this.populateObjectsOnAssignAndCreateFlows(executeBB.getRequestId(), requestDetails, service, bbName,
+ serviceInstance, lookupKeyMap, resourceId, vnfType, executeBB.getBuildingBlock().getKey(),
+ executeBB.getConfigurationResourceKeys(), isReplace);
+ return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null);
+
}
protected GeneralBuildingBlock getGBBCM(ExecuteBuildingBlock executeBB, RequestDetails requestDetails,
@@ -1279,24 +1285,30 @@ public class BBInputSetup implements JavaDelegate {
String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID);
RequestDetails requestDetails = executeBB.getRequestDetails();
GeneralBuildingBlock gBB = null;
+ Service service = null;
if (serviceInstanceId != null) {
aaiServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
+ if (aaiServiceInstance != null) {
+ service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ if (service == null) {
+ String message = String.format(
+ "Related service instance model not found in MSO CatalogDB: model-version-id=%s",
+ aaiServiceInstance.getModelVersionId());
+ throw new ServiceModelNotFoundException(message);
+ }
+ } else {
+ String message = String.format("Related service instance from AAI not found: service-instance-id=%s",
+ serviceInstanceId);
+ throw new NoServiceInstanceFoundException(message);
+ }
}
- Service service = null;
- if (aaiServiceInstance != null) {
- service = bbInputSetupUtils.getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
- }
- if (aaiServiceInstance != null && service != null) {
- ServiceInstance serviceInstance = this.getExistingServiceInstance(aaiServiceInstance);
- serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(service));
- updateInstanceName(executeBB.getRequestId(), ModelType.service, serviceInstance.getServiceInstanceName());
- gBB = populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null);
- } else {
- logger.debug("Related Service Instance from AAI: {}", aaiServiceInstance);
- logger.debug("Related Service Instance Model Info from AAI: {}", service);
- throw new Exception("Could not find relevant information for related Service Instance");
- }
- ServiceInstance serviceInstance = gBB.getServiceInstance();
+
+ ServiceInstance serviceInstance = this.getExistingServiceInstance(aaiServiceInstance);
+ serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(service));
+ updateInstanceName(executeBB.getRequestId(), ModelType.service, serviceInstance.getServiceInstanceName());
+ gBB = populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null);
+
+ serviceInstance = gBB.getServiceInstance();
CloudRegion cloudRegion = null;
if (cloudConfiguration == null) {
Optional<CloudRegion> cloudRegionOp = cloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/ServiceModelNotFoundException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/ServiceModelNotFoundException.java
new file mode 100644
index 0000000000..b9daad6626
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/ServiceModelNotFoundException.java
@@ -0,0 +1,15 @@
+package org.onap.so.bpmn.servicedecomposition.tasks.exceptions;
+
+public class ServiceModelNotFoundException extends Exception {
+
+ private static final long serialVersionUID = -5551887892983898061L;
+
+ public ServiceModelNotFoundException() {
+ super();
+ }
+
+ public ServiceModelNotFoundException(String message) {
+ super(message);
+ }
+
+}