summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap
diff options
context:
space:
mode:
authorElena Kuleshov <evn@att.com>2019-04-08 01:17:53 -0400
committerElena Kuleshov <evn@att.com>2019-04-08 10:04:51 -0400
commiteeaa95784e2bed48c82f8a5d2c8ed34cc57a37fd (patch)
tree634cc459e6fb8946b7c30170f3e9458b6bd71627 /mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap
parent2c8c818a1815758e14e88fe74b782c3e8be8ac4b (diff)
Workflow Recipe Lookup
Workflow Recipe Lookup and related Catalog Beans Change-Id: Ib1c3493106658d139861d2620dfb9cb382115744 Issue-ID: SO-1728 Signed-off-by: Kuleshov, Elena <evn@att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap')
-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);
}
}