Merge "Add execute resource recipe task script"
authorSeshu Kumar M <seshu.kumar.m@huawei.com>
Thu, 15 Mar 2018 08:03:37 +0000 (08:03 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 15 Mar 2018 08:03:37 +0000 (08:03 +0000)
1  2 
bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy

@@@ -21,6 -21,7 +21,7 @@@
  package org.openecomp.mso.bpmn.infrastructure.scripts;
  
  import static org.apache.commons.lang3.StringUtils.*;
+ import org.apache.http.HttpResponse
  import groovy.xml.XmlUtil
  import groovy.json.*
  
@@@ -52,7 -53,7 +53,7 @@@ import java.util.UUID
  import javax.mail.Quota.Resource;
  
  import org.camunda.bpm.engine.delegate.BpmnError
 -import org.camunda.bpm.engine.runtime.Execution
 +import org.camunda.bpm.engine.delegate.DelegateExecution
  import org.json.JSONObject;
  import org.json.JSONArray;
  import org.apache.commons.lang3.*
@@@ -91,7 -92,7 +92,7 @@@ public class DoCreateE2EServiceInstanc
        JsonUtils jsonUtil = new JsonUtils()
        CatalogDbUtils cutils = new CatalogDbUtils()
  
 -      public void preProcessRequest (Execution execution) {
 +      public void preProcessRequest (DelegateExecution execution) {
                def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
                String msg = ""
                utils.log("INFO"," ***** preProcessRequest *****",  isDebugEnabled)
                utils.log("INFO"," ***** Exit preProcessRequest *****",  isDebugEnabled)
        }
        
 -   public void prepareDecomposeService(Execution execution) {
 +   public void prepareDecomposeService(DelegateExecution execution) {
          def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
  
          try {
          }
       }
  
 -    public void processDecomposition (Execution execution) {
 +    public void processDecomposition(DelegateExecution execution) {
          def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
      
          utils.log("DEBUG", " ***** Inside processDecomposition() of  create generic e2e service flow ***** ", isDebugEnabled)    
          }
      }
      
 -    public void doServiceHoming(Execution execution) {
 +    public void doServiceHoming(DelegateExecution execution) {
          //Now Homing is not clear. So to be implemented.
      }
      
 -      public void postProcessAAIGET(Execution execution) {
 +      public void postProcessAAIGET(DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled)
                String msg = ""
                utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled)
        }
  
 -      public void postProcessAAIPUT(Execution execution) {
 +      public void postProcessAAIPUT(DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                utils.log("INFO"," ***** postProcessAAIPUT ***** ", isDebugEnabled)
                String msg = ""
                utils.log("INFO"," *** Exit postProcessAAIPUT *** ", isDebugEnabled)
        }
        
 -      public void postProcessAAIGET2(Execution execution) {
 +      public void postProcessAAIGET2(DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                utils.log("INFO"," ***** postProcessAAIGET2 ***** ", isDebugEnabled)
                String msg = ""
                utils.log("INFO"," *** Exit postProcessAAIGET2 *** ", isDebugEnabled)
        }
  
 -      public void preProcessRollback (Execution execution) {
 +      public void preProcessRollback (DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                utils.log("INFO"," ***** preProcessRollback ***** ", isDebugEnabled)
                try {
                utils.log("INFO"," *** Exit preProcessRollback *** ", isDebugEnabled)
        }
  
 -      public void postProcessRollback (Execution execution) {
 +      public void postProcessRollback (DelegateExecution execution) {
                def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
                utils.log("INFO"," ***** postProcessRollback ***** ", isDebugEnabled)
                String msg = ""
                utils.log("INFO"," *** Exit postProcessRollback *** ", isDebugEnabled)
        }
  
 -      public void preInitResourcesOperStatus(Execution execution){
 +      public void preInitResourcesOperStatus(DelegateExecution execution){
          def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
  
          utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
           execution.setVariable("resourceInput", resourceInput)
           utils.log("INFO", "======== COMPLETED prepareResourceRecipeRequest Process ======== ", isDebugEnabled)      
       }
+      
+      public void executeResourceRecipe(Execution execution){
+          def isDebugEnabled=execution.getVariable("isDebugLogEnabled")                 
+          utils.log("INFO", "======== Start executeResourceRecipe Process ======== ", isDebugEnabled) 
+          String requestId = execution.getVariable("msoRequestId")
+          String serviceInstanceId = execution.getVariable("serviceInstanceId")
+          String serviceType = execution.getVariable("serviceType")
+          ResourceInput resourceInput = execution.getVariable("resourceInput")
+          String requestAction = resourceInput.getOperationType()
+          JSONObject resourceRecipe = cutils.getResourceRecipe(execution, resourceInput.getResourceUuid(), requestAction)
+          String recipeUri = resourceRecipe.getString("orchestrationUri")
+          String recipeTimeOut = resourceRecipe.getString("recipeTimeout")
+          String recipeParamXsd = resourceRecipe.get("paramXSD")
+          HttpResponse resp = BpmnRestClient.post(recipeUri, requestId, recipeTimeout, requestAction, serviceInstanceId, serviceType, resourceInput.toString(), recipeParamXsd)
+          
+      }
  }