diff options
author | Byung-Woo Jun <byung-woo.jun@est.tech> | 2020-07-08 16:20:50 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-07-08 16:20:50 +0000 |
commit | 3232bd4383677e949632521899a6914151a114af (patch) | |
tree | 36d15f7e21d31b5ce45453407fa51ae4d984df17 /mso-api-handlers/mso-api-handler-infra/src/main | |
parent | fcc6583ccb1bc232758aea663e609e20afd98154 (diff) | |
parent | 76e89e2d541404b074f28865fd8ca1f426f9ce07 (diff) |
Merge "Service level workflow retrieving API"
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main')
-rw-r--r-- | mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java index 357497591d..0f7cf5fc6a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java @@ -81,12 +81,13 @@ public class WorkflowSpecificationsHandler { @Transactional public Response queryWorkflowSpecifications(@QueryParam("vnfModelVersionId") String vnfModelVersionId, - @QueryParam("pnfModelVersionId") String pnfModelVersionId, @PathParam("version") String version) + @QueryParam("pnfModelVersionId") String pnfModelVersionId, + @QueryParam("resourceTarget") String resourceTarget, @PathParam("version") String version) throws Exception { String apiVersion = version.substring(1); List<Workflow> workflows = new ArrayList<>(); - if (vnfModelVersionId == null && pnfModelVersionId == null) { + if (vnfModelVersionId == null && pnfModelVersionId == null && resourceTarget == null) { workflows.addAll(queryWorkflowSpecificationsForAll()); } else { // 1. query workflow specifications for given vnfModelVersionId if need. @@ -106,6 +107,16 @@ public class WorkflowSpecificationsHandler { workflows.addAll(pnfWorkflows); } } + + // 3. query workflow specifications for given resourceTarget + if (resourceTarget != null) { + List<Workflow> workflowsForResourceTarget = queryWorkflowsForResourceTarget(resourceTarget); + logger.debug( + "Retrieved " + workflowsForResourceTarget.size() + " workflows for given resource target."); + if (workflowsForResourceTarget.size() > 0) { + workflows.addAll(workflowsForResourceTarget); + } + } } // Deduplication @@ -119,11 +130,16 @@ public class WorkflowSpecificationsHandler { apiVersion); } + /** + * @deprecated As of G release, workflows for all resource types (pnf,vnf,service) can be fetched using + * /workflowSpecifications/{version:[vV]1}/workflows?resourceTarget={resourceType} API + */ @Path("/{version:[vV]1}/pnfWorkflows") @GET @Operation(description = "Finds pnf workflow specifications", responses = @ApiResponse( content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) @Transactional + @Deprecated public Response getWorkflowsSpecForPnf(@PathParam("version") String version) throws Exception { final String pnf_resource = "pnf"; @@ -132,7 +148,7 @@ public class WorkflowSpecificationsHandler { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - List<Workflow> workflows = catalogDbClient.findWorkflowByResourceTarget(pnf_resource); + List<Workflow> workflows = queryWorkflowsForResourceTarget(pnf_resource); Optional<String> optional = getResponseByWorkflowSpec(workflows); return builder.buildResponse(HttpStatus.SC_OK, "", optional.isPresent() ? optional.get() : EMPTY_BODY, @@ -296,4 +312,11 @@ public class WorkflowSpecificationsHandler { List<Workflow> workflows = catalogDbClient.findWorkflowByPnfModelUUID(pnfModelVersionId); return workflows; } + + private List<Workflow> queryWorkflowsForResourceTarget(String resourceTarget) { + List<Workflow> workflows = catalogDbClient.findWorkflowByResourceTarget(resourceTarget); + return workflows; + } + + } |