Merge "Adding Junit"
[so.git] / bpmn / MSOInfrastructureBPMN / src / main / groovy / org / openecomp / mso / bpmn / vcpe / scripts / DoCreateAllottedResourceBRG.groovy
index b46721c..7d7c862 100644 (file)
@@ -28,7 +28,7 @@ import org.openecomp.mso.rest.APIResponse
 
 import java.util.UUID;
 import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.runtime.Execution
+import org.camunda.bpm.engine.delegate.DelegateExecution
 import org.apache.commons.lang3.*
 import org.springframework.web.util.UriUtils;
 import static org.apache.commons.lang3.StringUtils.*
@@ -45,6 +45,8 @@ import static org.apache.commons.lang3.StringUtils.*
  * @param - disableRollback
  * @param - failExists  - O
  * @param - serviceInstanceId
+ * @param - globalCustomerId - O
+ * @param - subscriptionServiceType - O
  * @param - parentServiceInstanceId
  * @param - allottedReourceId - O
  * @param - allottedResourceModelInfo
@@ -70,7 +72,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
        ExceptionUtil exceptionUtil = new ExceptionUtil()
        JsonUtils jsonUtil = new JsonUtils()
 
-       public void preProcessRequest (Execution execution) {
+       public void preProcessRequest (DelegateExecution execution) {
 
                def isDebugEnabled = execution.getVariable(DebugFlag)
                String msg = ""
@@ -89,6 +91,15 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
                        execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
                        utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
 
+                       String sdncReplDelay = execution.getVariable('URN_mso_workflow_sdnc_replication_delay')
+                       if (isBlank(sdncReplDelay)) {
+                               msg = "URN_mso_workflow_sdnc_replication_delay is null"
+                               utils.log("DEBUG", msg, isDebugEnabled)
+                               exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+                       }
+                       execution.setVariable("sdncReplDelay", sdncReplDelay)
+                       utils.log("DEBUG","SDNC replication delay: " + sdncReplDelay, isDebugEnabled)
+
                        //Request Inputs
                        if (isBlank(execution.getVariable("serviceInstanceId"))){
                                msg = "Input serviceInstanceId is null"
@@ -141,7 +152,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
                utils.log("DEBUG"," ***** Exit preProcessRequest *****",  isDebugEnabled)
        }
 
-       public void getAaiAR (Execution execution) {
+       public void getAaiAR (DelegateExecution execution) {
 
                def isDebugEnabled = execution.getVariable(DebugFlag)
                utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled)
@@ -179,7 +190,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
                utils.log("DEBUG"," *****Exit getAaiAR *****", isDebugEnabled)
        }
 
-       public void createAaiAR(Execution execution) {
+       public void createAaiAR(DelegateExecution execution) {
 
                def isDebugEnabled=execution.getVariable(DebugFlag)
                utils.log("DEBUG"," ***** createAaiAR ***** ", isDebugEnabled)
@@ -301,7 +312,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
                utils.log("DEBUG"," *** Exit createAaiAR*** ", isDebugEnabled)
        }
 
-       public String buildSDNCRequest(Execution execution, String action, String sdncRequestId) {
+       public String buildSDNCRequest(DelegateExecution execution, String action, String sdncRequestId) {
 
                def isDebugEnabled = execution.getVariable(DebugFlag)
                String msg = ""
@@ -312,6 +323,8 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
 
                        String allottedResourceId = execution.getVariable("allottedResourceId")
                        String serviceInstanceId = execution.getVariable("serviceInstanceId")
+                       String globalCustomerId = execution.getVariable("globalCustomerId")
+                       String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
                        String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId")
                        String callbackUrl = execution.getVariable("sdncCallbackUrl")
                        String requestId = execution.getVariable("msoRequestId")
@@ -365,23 +378,23 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
                                        </request-information>
                                        <service-information>
                                                <service-id></service-id>
-                                               <subscription-service-type></subscription-service-type>
-                                               <onap-model-information></onap-model-information>
-                                               <service-instance-id>${parentServiceInstanceId}</service-instance-id>
+                                               <subscription-service-type>${subscriptionServiceType}</subscription-service-type>
+                                               <ecomp-model-information></ecomp-model-information>
+                                               <service-instance-id>${serviceInstanceId}</service-instance-id>
                                                <subscriber-name/>
-                                               <global-customer-id></global-customer-id>
+                                               <global-customer-id>${globalCustomerId}</global-customer-id>
                                        </service-information>
                                        <allotted-resource-information>
                                                <allotted-resource-id>${allottedResourceId}</allotted-resource-id>    
                                                <allotted-resource-type>brg</allotted-resource-type>
                                                <parent-service-instance-id>${parentServiceInstanceId}</parent-service-instance-id>   
-                                               <onap-model-information>
+                                               <ecomp-model-information>
                                                        <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid>
                                                        <model-uuid>${modelUUId}</model-uuid>
                                                        <model-customization-uuid>${modelCustomizationId}</model-customization-uuid>
                                                        <model-version>${modelVersion}</model-version>
                                                        <model-name>${modelName}</model-name>
-                                               </onap-model-information>
+                                               </ecomp-model-information>
                                        </allotted-resource-information>
                                        <brg-request-input>
                                                        <brg-wan-mac-address>${brgWanMacAddress}</brg-wan-mac-address>
@@ -403,7 +416,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
                return sdncReq
        }
 
-       public void preProcessSDNCAssign(Execution execution) {
+       public void preProcessSDNCAssign(DelegateExecution execution) {
 
                def isDebugEnabled = execution.getVariable(DebugFlag)
                String msg = ""
@@ -433,7 +446,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
                utils.log("DEBUG"," *****Exit preProcessSDNCAssign *****", isDebugEnabled)
        }
 
-       public void preProcessSDNCCreate(Execution execution) {
+       public void preProcessSDNCCreate(DelegateExecution execution) {
 
                def isDebugEnabled = execution.getVariable(DebugFlag)
                String msg = ""
@@ -463,7 +476,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
                utils.log("DEBUG"," *****Exit preProcessSDNCCreate *****", isDebugEnabled)
        }
 
-       public void preProcessSDNCActivate(Execution execution) {
+       public void preProcessSDNCActivate(DelegateExecution execution) {
 
                def isDebugEnabled = execution.getVariable(DebugFlag)
                String msg = ""
@@ -493,7 +506,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
                utils.log("DEBUG"," *****Exit preProcessSDNCActivate *****", isDebugEnabled)
        }
 
-       public void validateSDNCResp(Execution execution, String response, String method){
+       public void validateSDNCResp(DelegateExecution execution, String response, String method){
 
                def isDebugLogEnabled=execution.getVariable(DebugFlag)
                utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled)
@@ -533,7 +546,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
                logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled)
        }
 
-       public void preProcessSDNCGet(Execution execution){
+       public void preProcessSDNCGet(DelegateExecution execution){
                def isDebugLogEnabled = execution.getVariable(DebugFlag)
                utils.log("DEBUG", "*** preProcessSDNCGet *** ", isDebugLogEnabled)
                try{
@@ -563,11 +576,6 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
                        String serviceInstanceId = execution.getVariable("serviceInstanceId")
                        String sdncRequestId = UUID.randomUUID().toString()
                        
-                       String tsleep = execution.getVariable("junitSleepMs")
-                       
-                       //workaround for sdnc replication issue
-                       sleep(tsleep == null ? 5000 : tsleep as Long)
-
                        //neeed the same url as used by vfmodules
                        String SDNCGetRequest =
                        """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
@@ -593,7 +601,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
                utils.log("DEBUG", "*** Exit preProcessSDNCGet *** ", isDebugLogEnabled)
        }
        
-       public void updateAaiAROrchStatus(Execution execution, String status){
+       public void updateAaiAROrchStatus(DelegateExecution execution, String status){
                def isDebugEnabled = execution.getVariable(DebugFlag)
                utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled)
                String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create
@@ -602,7 +610,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
                utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled)
        }
        
-       public void generateOutputs(Execution execution)
+       public void generateOutputs(DelegateExecution execution)
        {
                def isDebugEnabled=execution.getVariable(DebugFlag)
                utils.log("DEBUG"," ***** generateOutputs ***** ", isDebugEnabled)
@@ -625,7 +633,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
                
        }
 
-       public void preProcessRollback (Execution execution) {
+       public void preProcessRollback (DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable(DebugFlag)
                utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled)
                try {
@@ -646,7 +654,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
                utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled)
        }
 
-       public void postProcessRollback (Execution execution) {
+       public void postProcessRollback (DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable(DebugFlag)
                utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled)
                String msg = ""