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/WorkflowSpecificationsHandler.java29
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;
+ }
+
+
}