diff options
Diffstat (limited to 'bpmn')
2 files changed, 38 insertions, 30 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 24246273e8..3fbdbbae1e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -81,6 +81,7 @@ public class WorkflowAction { private static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage"; private static final String SERVICE_INSTANCES = "serviceInstances"; + private static final String VF_MODULES = "vfModules"; private static final String WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI = "WorkflowAction was unable to verify if the instance name already exist in AAI."; private static final String G_ORCHESTRATION_FLOW = "gOrchestrationFlow"; private static final String G_ACTION = "requestAction"; @@ -664,35 +665,38 @@ public class WorkflowAction { } protected Resource extractResourceIdAndTypeFromUri(String uri) { - Pattern patt = Pattern.compile( - "[vV]\\d+.*?(?:(?:/(?<type>" + supportedTypes + ")(?:/(?<id>[^/]+))?)(?:/(?<action>[^/]+))?)?$"); - Matcher m = patt.matcher(uri); - Boolean generated = false; - - if (m.find()) { - logger.debug("found match on {} : {} " , uri , m); - String type = m.group("type"); - String id = m.group("id"); - String action = m.group("action"); - if (type == null) { - throw new IllegalArgumentException("Uri could not be parsed. No type found. " + uri); - } - if (action == null) { - if (type.equals(SERVICE_INSTANCES) && (id == null || id.equals("assign"))) { - id = UUID.randomUUID().toString(); - generated = true; - } - } else { - if (action.matches(supportedTypes)) { - id = UUID.randomUUID().toString(); - generated = true; - type = action; - } - } - return new Resource(WorkflowType.fromString(convertTypeFromPlural(type)), id, generated); - } else { - throw new IllegalArgumentException("Uri could not be parsed: " + uri); - } + Pattern patt = Pattern.compile( + "[vV]\\d+.*?(?:(?:/(?<type>" + supportedTypes + ")(?:/(?<id>[^/]+))?)(?:/(?<action>[^/]+))?)?$"); + Matcher m = patt.matcher(uri); + Boolean generated = false; + + if (m.find()) { + logger.debug("found match on {} : {} " , uri , m); + String type = m.group("type"); + String id = m.group("id"); + String action = m.group("action"); + if (type == null) { + throw new IllegalArgumentException("Uri could not be parsed. No type found. " + uri); + } + if (action == null) { + if (type.equals(SERVICE_INSTANCES) && (id == null || id.equals("assign"))) { + id = UUID.randomUUID().toString(); + generated = true; + }else if (type.equals(VF_MODULES) && id.equals("scaleOut")) { + id = UUID.randomUUID().toString(); + generated = true; + } + } else { + if (action.matches(supportedTypes)) { + id = UUID.randomUUID().toString(); + generated = true; + type = action; + } + } + return new Resource(WorkflowType.fromString(convertTypeFromPlural(type)), id, generated); + } else { + throw new IllegalArgumentException("Uri could not be parsed: " + uri); + } } protected String validateResourceIdInAAI(String generatedResourceId, WorkflowType type, String instanceName, diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index 65d16adb40..c27b5dd655 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -1318,7 +1318,7 @@ public class WorkflowActionTest extends BaseTaskTest { String uri5 = "'/v6/serviceInstances/123/vnfs"; String uri6 = "/v6/serviceInstances/123/vnfs/1234/someAction"; String uri7 = "/v6/serviceInstances/123/vnfs/1234/vfModules/5678/replace"; - + String uri8 = "/v6/serviceInstances/123/vnfs/1234/vfModules/scaleOut"; Resource expected1 = new Resource(WorkflowType.SERVICE, "123", true); Resource expected2 = new Resource(WorkflowType.VNF, "1234", false); Resource expected3 = new Resource(WorkflowType.VNF, "1234", false); @@ -1344,6 +1344,10 @@ public class WorkflowActionTest extends BaseTaskTest { result = workflowAction.extractResourceIdAndTypeFromUri(uri7); assertEquals(expected4.getResourceId(),result.getResourceId()); assertEquals(expected4.getResourceType(),result.getResourceType()); + result = workflowAction.extractResourceIdAndTypeFromUri(uri8); + assertEquals(UUID.randomUUID().toString().length(),result.getResourceId().length()); + assertEquals("VfModule", result.getResourceType().toString()); + } @Test |