aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/main/java/org
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2019-04-08 16:45:20 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-08 16:45:20 +0000
commit54452b80a1cf4d22ef750bc1377f8c1b05431d57 (patch)
tree6247036b41a66c7470e232cefb24d3146eeea58f /mso-api-handlers/mso-api-handler-infra/src/main/java/org
parent840e68bac1cb39d536a46ad98193466eb320733a (diff)
parenteeaa95784e2bed48c82f8a5d2c8ed34cc57a37fd (diff)
Merge "Workflow Recipe Lookup"
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java49
1 files changed, 44 insertions, 5 deletions
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 1580c9fb34..51962f2b9e 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
@@ -29,9 +29,12 @@ import org.apache.http.HttpStatus;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandler.common.RequestClientParameter;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException;
import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException;
import org.onap.so.apihandlerinfra.exceptions.ValidateException;
import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo;
+import org.onap.so.db.catalog.beans.Workflow;
+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;
@@ -72,6 +75,9 @@ public class InstanceManagement {
private RequestsDbClient infraActiveRequestsClient;
@Autowired
+ private CatalogDbClient catalogDbClient;
+
+ @Autowired
private MsoRequest msoRequest;
@Autowired
@@ -156,7 +162,8 @@ public class InstanceManagement {
workflowUuid = instanceIdMap.get("workflowUuid");
}
- RecipeLookupResult recipeLookupResult = getCustomWorkflowUri(workflowUuid);
+ RecipeLookupResult recipeLookupResult = getInstanceManagementWorkflowRecipe(currentActiveReq, workflowUuid);
+
String serviceInstanceType = requestHandlerUtils.getServiceType(requestScope, sir, true);
serviceInstanceId = requestHandlerUtils.setServiceInstanceId(requestScope, sir);
@@ -196,11 +203,43 @@ public class InstanceManagement {
.errorInfo(errorLoggerInfo).build();
}
return requestHandlerUtils.postBPELRequest(currentActiveReq, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
- }
+ }
+
+ private RecipeLookupResult getInstanceManagementWorkflowRecipe(InfraActiveRequests currentActiveReq, String workflowUuid) throws ApiException {
+ RecipeLookupResult recipeLookupResult = null;
+
+ try {
+ recipeLookupResult = getCustomWorkflowUri(workflowUuid);
+ } catch (IOException e) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
+ .errorInfo(errorLoggerInfo).build();
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ throw validateException;
+ }
+
+ if (recipeLookupResult == null) {
+ ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
+ RecipeNotFoundException recipeNotFoundExceptionException = new RecipeNotFoundException.Builder("Recipe could not be retrieved from catalog DB.", HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR)
+ .errorInfo(errorLoggerInfo).build();
+ requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, recipeNotFoundExceptionException.getMessage());
+ throw recipeNotFoundExceptionException;
+ }
+
+ return recipeLookupResult;
+ }
- private RecipeLookupResult getCustomWorkflowUri(String workflowUuid) {
+ private RecipeLookupResult getCustomWorkflowUri(String workflowUuid) throws IOException {
- RecipeLookupResult recipeLookupResult = new RecipeLookupResult("/mso/async/services/VnfInPlaceUpdate", 180);
- return recipeLookupResult;
+ String recipeUri = null;
+ Workflow workflow = catalogDbClient.findWorkflowByArtifactUUID(workflowUuid);
+ if (workflow == null) {
+ return null;
+ }
+ else {
+ String workflowName = workflow.getArtifactName();
+ recipeUri = "/mso/async/services/" + workflowName;
+ }
+ return new RecipeLookupResult(recipeUri, 180);
}
}