AT&T 1712 and 1802 release code
[so.git] / bpmn / MSOCommonBPMN / src / main / groovy / org / openecomp / mso / bpmn / common / scripts / DecomposeService.groovy
index 8d855e9..7a81ce5 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,7 +26,7 @@ import static org.apache.commons.lang3.StringUtils.*;
 
 import org.apache.commons.lang3.*
 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.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
 import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils
@@ -64,7 +64,7 @@ public class DecomposeService extends AbstractServiceTaskProcessor {
        CatalogDbUtils catalogDbUtils = new CatalogDbUtils()
        JsonUtils jsonUtils = new JsonUtils()
 
-       public void preProcessRequest (Execution execution) {
+       public void preProcessRequest (DelegateExecution execution) {
                def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
                String msg = ""
                utils.log("DEBUG"," ***** preProcessRequest of DecomposeService *****",  isDebugEnabled)
@@ -76,7 +76,13 @@ public class DecomposeService extends AbstractServiceTaskProcessor {
                        String requestId = execution.getVariable("msoRequestId")
                        String serviceInstanceId = execution.getVariable("serviceInstanceId")
                        String serviceModelInfo = execution.getVariable("serviceModelInfo")
-                       execution.setVariable("DDS_serviceModelInvariantId", jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantUuid"))
+                       String invariantId
+                       if(jsonUtils.jsonElementExist(serviceModelInfo, "modelInvariantUuid")){
+                               invariantId = jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantUuid")
+                       }else if(jsonUtils.jsonElementExist(serviceModelInfo, "modelInvariantId")){
+                               invariantId = jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantId")
+                       }
+                       execution.setVariable("DDS_serviceModelInvariantId", invariantId)
                        execution.setVariable("DDS_serviceModelUuid", jsonUtils.getJsonValue(serviceModelInfo, "modelUuid"))
                        execution.setVariable("DDS_modelVersion", jsonUtils.getJsonValue(serviceModelInfo, "modelVersion"))
                } catch (BpmnError e) {
@@ -89,7 +95,7 @@ public class DecomposeService extends AbstractServiceTaskProcessor {
                utils.log("DEBUG"," ***** Exit preProcessRequest of DecomposeService *****",  isDebugEnabled)
        }
 
-       public void queryCatalogDb (Execution execution) {
+       public void queryCatalogDb (DelegateExecution execution) {
                def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
                String msg = ""
                utils.log("DEBUG"," ***** queryCatalogDB of DecomposeService *****",  isDebugEnabled)
@@ -111,6 +117,13 @@ public class DecomposeService extends AbstractServiceTaskProcessor {
                                catalogDbResponse = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidAndServiceModelVersion(execution, serviceModelInvariantId, modelVersion, "v2")
                        else
                                catalogDbResponse = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuid(execution, serviceModelInvariantId, "v2")
+
+                       if (catalogDbResponse == null || catalogDbResponse.toString().equalsIgnoreCase("null")) {
+                               msg = "No data found in Catalog DB"
+                               utils.log("DEBUG", msg, isDebugEnabled)
+                               exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+                       }
+
                        String catalogDbResponseString = catalogDbResponse.toString()
 
                        execution.setVariable("DDS_catalogDbResponse", catalogDbResponseString)
@@ -128,7 +141,7 @@ public class DecomposeService extends AbstractServiceTaskProcessor {
 
 
 
-       public void actuallyDecomposeService (Execution execution) {
+       public void actuallyDecomposeService (DelegateExecution execution) {
                def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
                String msg = ""
                utils.log("DEBUG"," ***** actuallyDecomposeService of DecomposeService *****",  isDebugEnabled)