1710 Rebase - Second Attempt
[so.git] / bpmn / MSOCommonBPMN / src / main / groovy / org / openecomp / mso / bpmn / common / scripts / AllottedResourceUtils.groovy
index 540fe03..8e2403c 100644 (file)
@@ -6,8 +6,17 @@ import org.camunda.bpm.engine.runtime.Execution;
 import org.openecomp.mso.bpmn.core.WorkflowException\r
 import org.openecomp.mso.rest.APIResponse;\r
 \r
+\r
+import org.apache.commons.lang3.*\r
+import org.camunda.bpm.engine.delegate.BpmnError\r
+import org.camunda.bpm.engine.runtime.Execution;\r
+\r
+import groovy.util.XmlParser\r
+import groovy.util.Node\r
+import static org.apache.commons.lang3.StringUtils.*;\r
+\r
 class AllottedResourceUtils {\r
-       \r
+\r
        private AbstractServiceTaskProcessor taskProcessor\r
        ExceptionUtil exceptionUtil = new ExceptionUtil()\r
        MsoUtils utils;\r
@@ -84,6 +93,18 @@ class AllottedResourceUtils {
                utils.log("DEBUG", " ***** Exit GetARbyId ***** AR:" + ar, isDebugEnabled)\r
                return ar;\r
        }\r
+       \r
+       public String getPSIFmARLink(Execution execution, String arLink)\r
+       {\r
+               def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+               // Path: /aai/{version}/business/customers/customer/{cust}/service-subscriptions/service-subscription/{subs}/service-instances/service-instance/{psiid}/allotted-resources/allotted-resource/{arid}\r
+               utils.log("DEBUG", " ***** getPSIFmARLink ***** path:" + arLink, isDebugEnabled)\r
+               String[] split = arLink.split("/service-instance/")\r
+               String[] splitB =  split[1].split("/allotted-resources/")\r
+               String siId = splitB[0]\r
+               utils.log("DEBUG", " ***** Exit getARLinkbyId ***** parentServiceInstanceId:" + siId , isDebugEnabled)\r
+               return siId\r
+       }\r
 \r
        // get Allotted Resource Link by AllottedResourceId using Nodes Query\r
        // used on Delete - called from getARbyId\r
@@ -222,10 +243,10 @@ class AllottedResourceUtils {
                try{\r
 \r
                        String updateReq =      """\r
-                               {\r
-                               "orchestration-status": "Created""\r
-                               }\r
-                               """\r
+                                       {\r
+                                       "orchestration-status": "${status}"\r
+                                       }\r
+                                       """\r
 \r
                        utils.log("DEBUG", 'AAI AR URI: ' + aaiARPath, isDebugEnabled)\r
 \r