summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/main/groovy
diff options
context:
space:
mode:
authorYulian Han <elaine.hanyulian@huawei.com>2018-08-20 11:05:37 +0800
committerSeshu Kumar M <seshu.kumar.m@huawei.com>2018-08-21 07:37:32 +0000
commit32fdbf907f8ca5109461379508e3b28d575a9dc1 (patch)
tree822d6bd5b7381449cc281553e717bef7858e35b0 /bpmn/so-bpmn-infrastructure-common/src/main/groovy
parent8ad7083991ee9e9a0c026028cebc6ab24ca4d272 (diff)
Add device resource bpmn process for ccvpn uc
Bug fix for ccvpn uc Change-Id: Idaa55084f5ecb0dd3636c232cebc14fa70000013 Issue-ID: SO-683 Signed-off-by: Yulian Han <elaine.hanyulian@huawei.com>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main/groovy')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy86
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateDeviceResource.groovy194
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy177
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.groovy194
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy8
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy8
6 files changed, 551 insertions, 116 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy
index 1eb626101e..f11022dc08 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy
@@ -87,10 +87,6 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
boolean is3rdONAPExist = false
- if(inputParameters.has("id"))
- {
- String sppartnerId = inputParameters.get("id")
- }
if(inputParameters.has("url"))
{
String sppartnerUrl = inputParameters.get("url")
@@ -175,6 +171,8 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
{
callSource = inputParameters.get("CallSource")
if("ExternalAPI".equalsIgnoreCase(callSource)) {
+ String sppartnerId = inputParameters.get("SppartnerServiceId")
+ execution.setVariable(Prefix + "SppartnerServiceId", sppartnerId)
isLocalCall = false
}
}
@@ -235,7 +233,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
msoLogger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
- execution.setVariable("serviceInstanceId", serviceInstanceId)
+ execution.setVariable(Prefix + "ServiceInstanceId", serviceInstanceId)
msoLogger.info("serviceInstanceId:" + serviceInstanceId)
} catch (BpmnError e) {
@@ -288,21 +286,32 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
//get TP links from AAI for SOTN handoverMode only
String handoverMode = execution.getVariable(Prefix + "HandoverMode")
if("SOTN".equalsIgnoreCase(handoverMode)) {
- //to do get tp link in AAI
-
-
// Put TP Link info into serviceParameters
- String accessProviderId = ""
- String accessClientId = ""
- String accessTopologyId = ""
- String accessNodeId = ""
- String accessLtpId = ""
- JSONObject inputParameters = execution.getVariable(Prefix + "ServiceParameters")
- inputParameters.put("access-provider-id", accessProviderId)
- inputParameters.put("access-client-id", accessClientId)
- inputParameters.put("access-topology-id", accessTopologyId)
- inputParameters.put("access-node-id", accessNodeId)
- inputParameters.put("access-ltp-id", accessLtpId)
+ JSONObject inputParameters = execution.getVariable(Prefix + "ServiceParameters")
+
+ Map<String, Object> crossTPs = new HashMap<String, Object>();
+ crossTPs.put("local-access-provider-id", inputParameters.get("remote-access-provider-id"));
+ crossTPs.put("local-access-client-id", inputParameters.get("remote-access-client-id"));
+ crossTPs.put("local-access-topology-id", inputParameters.get("remote-access-topology-id"));
+ crossTPs.put("local-access-node-id", inputParameters.get("remote-access-node-id"));
+ crossTPs.put("local-access-ltp-id", inputParameters.get("remote-access-ltp-id"));
+ crossTPs.put("remote-access-provider-id", inputParameters.get("local-access-provider-id"));
+ crossTPs.put("remote-access-client-id", inputParameters.get("local-client-id"));
+ crossTPs.put("remote-access-topology-id", inputParameters.get("local-topology-id"));
+ crossTPs.put("remote-access-node-id", inputParameters.get("local-node-id"));
+ crossTPs.put("remote-access-ltp-id", inputParameters.get("local-ltp-id"));
+
+ inputParameters.put("local-access-provider-id", crossTPs.get("local-access-provider-id"));
+ inputParameters.put("local-access-client-id", crossTPs.get("local-access-client-id"));
+ inputParameters.put("local-access-topology-id", crossTPs.get("local-access-topology-id"));
+ inputParameters.put("local-access-node-id", crossTPs.get("local-access-node-id"));
+ inputParameters.put("local-access-ltp-id", crossTPs.get("local-access-ltp-id"));
+ inputParameters.put("remote-access-provider-id", crossTPs.get("remote-access-provider-id"));
+ inputParameters.put("remote-access-client-id", crossTPs.get("remote-client-id"));
+ inputParameters.put("remote-access-topology-id", crossTPs.get("remote-topology-id"));
+ inputParameters.put("remote-access-node-id", crossTPs.get("remote-node-id"));
+ inputParameters.put("remote-access-ltp-id", crossTPs.get("remote-ltp-id"));
+
execution.setVariable(Prefix + "ServiceParameters", inputParameters)
}
@@ -332,8 +341,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String action = "add" //for create
String serviceState = "active"
String serviceName = execution.getVariable("serviceInstanceName")
- String serviceType = execution.getVariable("serviceType")
- String serviceId = execution.getVariable("serviceInstanceId")
+ String serviceUuId = execution.setVariable(Prefix + "SppartnerUUID")
Map<String, String> valueMap = new HashMap<>()
valueMap.put("externalId", '"' + externalId + '"')
@@ -349,24 +357,36 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
valueMap.put("orderItemId", '"' + orderItemId + '"')
valueMap.put("action", '"' + action + '"')
valueMap.put("serviceState", '"' + serviceState + '"')
+ valueMap.put("serviceId", '""')//To be confirmed
valueMap.put("serviceName", '"' + serviceName + '"')
- valueMap.put("serviceType", '"' + serviceType + '"')
- valueMap.put("serviceId", '"' + serviceId + '"')
+ valueMap.put("serviceUuId", '"' + serviceUuId + '"')
ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(this)
// insert CallSource='ExternalAPI' to uuiRequest
- Map<String, String> callSourceMap = new HashMap<>()
- callSourceMap.put("inputName", "CallSource")
- callSourceMap.put("inputValue", "ExternalAPI")
- String _requestInputs_ = externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, callSourceMap)
+ Map<String, String> requestInputsMap = new HashMap<>()
+ requestInputsMap.put("inputName", "CallSource")
+ requestInputsMap.put("inputValue", "ExternalAPI")
+ String _requestInputs_ = externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
+
+ requestInputsMap.clear()
+ String serviceInstanceId = execution.getVariable(Prefix + "ServiceInstanceId")
+ requestInputsMap.put("inputName", "SppartnerServiceId")
+ requestInputsMap.put("inputValue", serviceInstanceId)
+ _requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
+
+ requestInputsMap.clear()
+ String serviceType = execution.getVariable("serviceType")
+ requestInputsMap.put("inputName", "serviceType")
+ requestInputsMap.put("inputValue", serviceType)
+ _requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
// Transfer all uuiRequest incomeParameters to ExternalAPI format
JSONObject inputParameters = execution.getVariable(Prefix + "ServiceParameters")
for(String key : inputParameters.keySet()) {
String inputName = key
String inputValue = inputParameters.opt(key)
- Map<String, String> requestInputsMap = new HashMap<>()
+ requestInputsMap.clear()
requestInputsMap.put("inputName", '"' + inputName+ '"')
requestInputsMap.put("inputValue", '"' + inputValue + '"')
_requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
@@ -437,7 +457,11 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
{
msoLogger.debug("Get ServiceOrder Received a Good Response")
- String serviceOrderState = responseObj.get("State")
+
+ String sppartnerServiceId = responseObj.get("orderIterm.service.id")
+ execution.setVariable(Prefix + "SppartnerServiceId", sppartnerServiceId)
+
+ String serviceOrderState = responseObj.get("orderIterm.state")
execution.setVariable(Prefix + "SuccessIndicator", true)
execution.setVariable("serviceOrderState", serviceOrderState)
@@ -492,10 +516,10 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
msoLogger.info(" ***** Started postCreateE2ESIin3rdONAP *****")
- String sppartnerId = UUID.randomUUID().toString()
+ String sppartnerId = execution.getVariable(Prefix + "SppartnerServiceId")
String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
String callSource = execution.getVariable(Prefix + "CallSource")
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ String serviceInstanceId = execution.getVariable(Prefix + "ServiceInstanceId")
String globalSubscriberId = execution.getVariable("globalSubscriberId")
String serviceType = execution.getVariable("serviceType")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateDeviceResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateDeviceResource.groovy
new file mode 100644
index 0000000000..15b63fb5ab
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateDeviceResource.groovy
@@ -0,0 +1,194 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.scripts
+
+import org.json.JSONObject
+import org.json.XML;
+
+import static org.apache.commons.lang3.StringUtils.*;
+import groovy.xml.XmlUtil
+import groovy.json.*
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.recipe.ResourceInput;
+import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
+import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder
+import org.onap.so.logger.MsoLogger
+import org.onap.so.rest.APIResponse
+import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
+
+import java.util.UUID;
+
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.apache.commons.lang3.*
+import org.apache.commons.codec.binary.Base64;
+import org.springframework.web.util.UriUtils
+import org.onap.so.rest.RESTClient
+import org.onap.so.rest.RESTConfig
+import org.onap.so.rest.APIResponse;
+import org.onap.so.bpmn.common.scripts.AaiUtil
+
+/**
+ * This groovy class supports the <class>CreateDeviceResource.bpmn</class> process.
+ * flow for Device Resource Create
+ */
+public class CreateDeviceResource extends AbstractServiceTaskProcessor {
+
+ String Prefix="CREDEVRES_"
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ JsonUtils jsonUtil = new JsonUtils()
+
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateDeviceResource.class)
+
+ public void preProcessRequest(DelegateExecution execution){
+ msoLogger.info(" ***** Started preProcessRequest *****")
+ try {
+
+ //get bpmn inputs from resource request.
+ String requestId = execution.getVariable("mso-request-id")
+ String requestAction = execution.getVariable("requestAction")
+ msoLogger.info("The requestAction is: " + requestAction)
+ String recipeParamsFromRequest = execution.getVariable("recipeParams")
+ msoLogger.info("The recipeParams is: " + recipeParamsFromRequest)
+ String resourceInput = execution.getVariable("resourceInput")
+ msoLogger.info("The resourceInput is: " + resourceInput)
+ //Get ResourceInput Object
+ ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
+ execution.setVariable(Prefix + "resourceInput", resourceInputObj)
+ String resourceInputPrameters = resourceInputObj.getResourceParameters()
+ String inputParametersJson = jsonUtil.getJsonValue(resourceInputPrameters, "requestInputs")
+ JSONObject inputParameters = new JSONObject(customizeResourceParam(inputParametersJson))
+ execution.setVariable(Prefix + "resourceRequestInputs", inputParameters)
+
+ //Deal with recipeParams
+ String recipeParamsFromWf = execution.getVariable("recipeParamXsd")
+ String resourceName = resourceInputObj.getResourceInstanceName()
+ //For sdnc requestAction default is "createNetworkInstance"
+ String operationType = "Network"
+ if(!StringUtils.isBlank(recipeParamsFromRequest)){
+ //the operationType from worflow(first node) is second priority.
+ operationType = jsonUtil.getJsonValue(recipeParamsFromRequest, "operationType")
+ }
+ if(!StringUtils.isBlank(recipeParamsFromWf)){
+ //the operationType from worflow(first node) is highest priority.
+ operationType = jsonUtil.getJsonValue(recipeParamsFromWf, "operationType")
+ }
+
+ execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId())
+ execution.setVariable("mso-request-id", requestId)
+
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception ex){
+ String msg = "Exception in preProcessRequest " + ex.getMessage()
+ msoLogger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+
+ String customizeResourceParam(String networkInputParametersJson) {
+ List<Map<String, Object>> paramList = new ArrayList();
+ JSONObject jsonObject = new JSONObject(networkInputParametersJson);
+ Iterator iterator = jsonObject.keys();
+ while (iterator.hasNext()) {
+ String key = iterator.next();
+ HashMap<String, String> hashMap = new HashMap();
+ hashMap.put("name", key);
+ hashMap.put("value", jsonObject.get(key))
+ paramList.add(hashMap)
+ }
+ Map<String, List<Map<String, Object>>> paramMap = new HashMap();
+ paramMap.put("param", paramList);
+
+ return new JSONObject(paramMap).toString();
+ }
+
+ public void checkDevType(DelegateExecution execution){
+ msoLogger.info(" ***** Started checkDevType *****")
+ try {
+
+ JSONObject inputParameters = execution.getVariable(Prefix + "resourceRequestInputs")
+
+ String devType = inputParameters.get("device_class")
+
+ if(StringUtils.isBlank(devType)) {
+ devType = "OTHER"
+ }
+
+ execution.setVariable("device_class", devType)
+
+ } catch (Exception ex){
+ String msg = "Exception in checkDevType " + ex.getMessage()
+ msoLogger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+
+ public void getVNFTemplatefromSDC(DelegateExecution execution){
+ msoLogger.info(" ***** Started getVNFTemplatefromSDC *****")
+ try {
+ // To do
+
+
+ } catch (Exception ex){
+ String msg = "Exception in getVNFTemplatefromSDC " + ex.getMessage()
+ msoLogger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+
+ public void postVNFInfoProcess(DelegateExecution execution){
+ msoLogger.info(" ***** Started postVNFInfoProcess *****")
+ try {
+ // To do
+
+
+ } catch (Exception ex){
+ String msg = "Exception in postVNFInfoProcess " + ex.getMessage()
+ msoLogger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+
+ public void sendSyncResponse (DelegateExecution execution) {
+ msoLogger.debug(" *** sendSyncResponse *** ")
+
+ try {
+ String operationStatus = "finished"
+ // RESTResponse for main flow
+ String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
+ msoLogger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp)
+ sendWorkflowResponse(execution, 202, resourceOperationResp)
+ execution.setVariable("sentSyncResponse", true)
+
+ } catch (Exception ex) {
+ String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
+ msoLogger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," ***** Exit sendSyncResopnse *****")
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy
index 88441271b1..63fd20eb2d 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy
@@ -40,6 +40,7 @@ import org.onap.so.rest.APIResponse
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory
import java.util.UUID
+import org.onap.so.logger.MsoLogger
import org.camunda.bpm.engine.runtime.Execution
import org.camunda.bpm.engine.delegate.BpmnError
@@ -52,7 +53,7 @@ import org.onap.so.rest.RESTConfig
/**
* This groovy class supports the <class>Delete3rdONAPE2EServiceInstance.bpmn</class> process.
- * flow for Delete E2EServiceInstance in 3rdONAP
+ * flow for Delete 3rdONAPE2EServiceInstance in 3rdONAP
*/
public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcessor {
@@ -62,27 +63,25 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
JsonUtils jsonUtil = new JsonUtils()
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, Delete3rdONAPE2EServiceInstance.class)
+
public void checkSPPartnerInfoFromAAI (DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started checkSPPartnerInfo *****", isDebugEnabled)
+ msoLogger.info(" ***** Started checkSPPartnerInfo *****")
try {
//get bpmn inputs from resource request.
String requestId = execution.getVariable("mso-request-id")
String requestAction = execution.getVariable("requestAction")
- utils.log("INFO","The requestAction is: " + requestAction, isDebugEnabled)
+ msoLogger.info("The requestAction is: " + requestAction)
String recipeParamsFromRequest = execution.getVariable("recipeParams")
- utils.log("INFO","The recipeParams is: " + recipeParamsFromRequest, isDebugEnabled)
+ msoLogger.info("The recipeParams is: " + recipeParamsFromRequest)
String resourceInput = execution.getVariable("resourceInput")
- utils.log("INFO","The resourceInput is: " + resourceInput, isDebugEnabled)
+ msoLogger.info("The resourceInput is: " + resourceInput)
//Get ResourceInput Object
ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
// set local resourceInput
execution.setVariable(Prefix + "ResourceInput", resourceInputObj)
String resourceInstanceId = resourceInputObj.getResourceInstancenUuid()
- String sppartnerId = resourceInstanceId
- execution.setVariable(Prefix + "SppartnerId", sppartnerId)
- utils.log("INFO", "sppartnerId:" + sppartnerId, isDebugEnabled)
// Get Sppartner from AAI
AaiUtil aaiUriUtil = new AaiUtil(this)
@@ -96,12 +95,8 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String callSource = "UUI"
String sppartnerUrl = ""
- String sppartnerVersion = ""
if(execution.getVariable(Prefix + "SuccessIndicator")) {
callSource = execution.getVariable(Prefix + "CallSource")
- sppartnerId = execution.getVariable(Prefix + "SppartnerId")
- sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
- sppartnerVersion = execution.getVariable(Prefix + "SppartnerVersion")
}
boolean is3rdONAPExist = false
@@ -118,14 +113,13 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
throw e
} catch (Exception ex){
String msg = "Exception in checkSPPartnerInfoFromAAI " + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
+ msoLogger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
}
public void checkLocallCall (DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started checkLocallCall *****", isDebugEnabled)
+ msoLogger.info(" ***** Started checkLocallCall *****")
boolean isLocalCall = true
String callSource = execution.getVariable(Prefix + "CallSource")
@@ -136,8 +130,7 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
}
public void preProcessRequest(DelegateExecution execution){
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started preProcessRequest *****", isDebugEnabled)
+ msoLogger.info(" ***** Started preProcessRequest *****")
try {
ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput")
String msg = ""
@@ -145,61 +138,60 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String globalSubscriberId = resourceInputObj.getGlobalSubscriberId()
if (isBlank(globalSubscriberId)) {
msg = "Input globalSubscriberId is null"
- utils.log("INFO", msg, isDebugEnabled)
+ msoLogger.info( msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
//set local variable
execution.setVariable("globalSubscriberId", globalSubscriberId)
- utils.log("INFO", "globalSubscriberId:" + globalSubscriberId, isDebugEnabled)
+ msoLogger.info( "globalSubscriberId:" + globalSubscriberId)
String serviceType = resourceInputObj.getServiceType()
if (isBlank(serviceType)) {
msg = "Input serviceType is null"
- utils.log("INFO", msg, isDebugEnabled)
+ msoLogger.info( msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
execution.setVariable("serviceType", serviceType)
- utils.log("INFO", "serviceType:" + serviceType, isDebugEnabled)
+ msoLogger.info( "serviceType:" + serviceType)
String operationId = resourceInputObj.getOperationId()
if (isBlank(operationId)) {
msg = "Input operationId is null"
- utils.log("INFO", msg, isDebugEnabled)
+ msoLogger.info( msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
execution.setVariable("operationId", operationId)
- utils.log("INFO", "operationId:" + operationId, isDebugEnabled)
+ msoLogger.info( "operationId:" + operationId)
String resourceName = resourceInputObj.getResourceInstanceName()
if (isBlank(resourceName)) {
msg = "Input resourceName is null"
- utils.log("INFO", msg, isDebugEnabled)
+ msoLogger.info( msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
execution.setVariable("resourceName", resourceName)
- utils.log("INFO", "resourceInstanceId:" + resourceName, isDebugEnabled)
+ msoLogger.info( "resourceInstanceId:" + resourceName)
String resourceTemplateId = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
if (isBlank(resourceTemplateId)) {
msg = "Input resourceTemplateId is null"
- utils.log("INFO", msg, isDebugEnabled)
+ msoLogger.info( msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
execution.setVariable("resourceTemplateId", resourceTemplateId)
- utils.log("INFO", "resourceTemplateId:" + resourceTemplateId, isDebugEnabled)
+ msoLogger.info( "resourceTemplateId:" + resourceTemplateId)
} catch (BpmnError e) {
throw e
} catch (Exception ex){
String msg = "Exception in preProcessRequest " + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
+ msoLogger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
}
public void prepareUpdateProgress(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started prepareUpdateProgress *****", isDebugEnabled)
+ msoLogger.info(" ***** Started prepareUpdateProgress *****")
ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
String operType = resourceInputObj.getOperationType()
String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
@@ -228,12 +220,11 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
</soapenv:Envelope>"""
setProgressUpdateVariables(execution, body)
- utils.log("INFO"," ***** End prepareUpdateProgress *****", isDebugEnabled)
+ msoLogger.info(" ***** End prepareUpdateProgress *****")
}
public void prepare3rdONAPRequest(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started prepare3rdONAPRequest *****", isDebugEnabled)
+ msoLogger.info(" ***** Started prepare3rdONAPRequest *****")
String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
String extAPIPath = sppartnerUrl + 'serviceOrder'
@@ -255,7 +246,10 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String serviceState = "active"
String serviceName = ""
String serviceType = execution.getVariable("serviceType")
- String serviceId = execution.getVariable(Prefix + "ServiceInstanceId")
+ String serviceId = execution.getVariable(Prefix + "SppartnerId")
+
+ queryServicefrom3rdONAP(execution)
+ String serviceUuId = execution.getVariable(Prefix + "serviceSpecificationId")
Map<String, String> valueMap = new HashMap<>()
valueMap.put("externalId", '"' + externalId + '"')
@@ -271,9 +265,10 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
valueMap.put("orderItemId", '"' + orderItemId + '"')
valueMap.put("action", '"' + action + '"')
valueMap.put("serviceState", '"' + serviceState + '"')
+ valueMap.put("serviceId", '"' + serviceId + '"')
valueMap.put("serviceName", '"' + serviceName + '"')
valueMap.put("serviceType", '"' + serviceType + '"')
- valueMap.put("serviceId", '"' + serviceId + '"')
+ valueMap.put("serviceUuId", '"' + serviceUuId + '"')
ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(this)
@@ -281,12 +276,46 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String payload = externalAPIUtil.setTemplate(ExternalAPIUtil.PostServiceOrderRequestsTemplate, valueMap)
execution.setVariable(Prefix + "Payload", payload)
- utils.log("INFO", "Exit " + prepare3rdONAPRequest, isDebugEnabled)
+ msoLogger.info( "Exit " + prepare3rdONAPRequest)
+ }
+
+ private void queryServicefrom3rdONAP(DelegateExecution execution)
+ {
+ msoLogger.info(" ***** Started queryServicefrom3rdONAP *****")
+
+ //https://{api_url}/nbi/api/v1/service/{serviceinstanceid}
+ String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
+ String extAPIPath = sppartnerUrl + "service/" + execution.setVariable(Prefix + "SppartnerId")
+
+ ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(this)
+
+ APIResponse response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
+
+ int responseCode = response.getStatusCode()
+ execution.setVariable(Prefix + "getServiceResponseCode", responseCode)
+ utils.log("DEBUG", "Get Service response code is: " + responseCode)
+
+ String extApiResponse = response.getResponseBodyAsString()
+ JSONObject responseObj = new JSONObject(extApiResponse)
+ execution.setVariable(Prefix + "getServiceResponse", extApiResponse)
+
+ //Process Response //200 OK 201 CREATED 202 ACCEPTED
+ if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
+ {
+ utils.log("DEBUG", "Get Service Received a Good Response")
+ String serviceUuid = responseObj.get("serviceSpecification.id")
+ execution.setVariable(Prefix + "serviceSpecificationId", serviceUuid)
+ }
+ else{
+ utils.log("DEBUG", "Get Service Received a Bad Response Code. Response Code is: " + responseCode)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Get Service Received a bad response from 3rdONAP External API")
+ }
+
+ msoLogger.info( "Exit " + queryServicefrom3rdONAP)
}
public void doDeleteE2ESIin3rdONAP(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started doDeleteE2ESIin3rdONAP *****", isDebugEnabled)
+ msoLogger.info(" ***** Started doDeleteE2ESIin3rdONAP *****")
String extAPIPath = execution.getVariable("ExternalAPIURL")
String payload = execution.getVariable(Prefix + "Payload")
@@ -297,7 +326,7 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
int responseCode = response.getStatusCode()
execution.setVariable(Prefix + "postServiceOrderResponseCode", responseCode)
- utils.log("DEBUG", "Post ServiceOrder response code is: " + responseCode, isDebugEnabled)
+ msoLogger.debug("Post ServiceOrder response code is: " + responseCode)
String extApiResponse = response.getResponseBodyAsString()
JSONObject responseObj = new JSONObject(extApiResponse)
@@ -306,23 +335,22 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
//200 OK 201 CREATED 202 ACCEPTED
{
- utils.log("DEBUG", "Post ServiceOrder Received a Good Response", isDebugEnabled)
+ msoLogger.debug("Post ServiceOrder Received a Good Response")
String serviceOrderId = responseObj.get("ServiceOrderId")
execution.setVariable(Prefix + "SuccessIndicator", true)
execution.setVariable("serviceOrderId", serviceOrderId)
}
else{
- utils.log("DEBUG", "Post ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
+ msoLogger.debug("Post ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Post ServiceOrder Received a bad response from 3rdONAP External API")
}
- utils.log("INFO", "Exit " + doDeleteE2ESIin3rdONAP, isDebugEnabled)
+ msoLogger.info( "Exit " + doDeleteE2ESIin3rdONAP)
}
public void getE2ESIProgressin3rdONAP(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started getE2ESIProgressin3rdONAP *****", isDebugEnabled)
+ msoLogger.info(" ***** Started getE2ESIProgressin3rdONAP *****")
String extAPIPath = execution.getVariable("ExternalAPIURL")
extAPIPath += "/" + execution.getVariable("ServiceOrderId")
@@ -333,7 +361,7 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
int responseCode = response.getStatusCode()
execution.setVariable(Prefix + "getServiceOrderResponseCode", responseCode)
- utils.log("DEBUG", "Get ServiceOrder response code is: " + responseCode, isDebugEnabled)
+ msoLogger.debug("Get ServiceOrder response code is: " + responseCode)
String extApiResponse = response.getResponseBodyAsString()
JSONObject responseObj = new JSONObject(extApiResponse)
@@ -342,7 +370,7 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
//Process Response //200 OK 201 CREATED 202 ACCEPTED
if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
{
- utils.log("DEBUG", "Get ServiceOrder Received a Good Response", isDebugEnabled)
+ msoLogger.debug("Get ServiceOrder Received a Good Response")
String serviceOrderState = responseObj.get("State")
execution.setVariable(Prefix + "SuccessIndicator", true)
execution.setVariable("serviceOrderState", serviceOrderState)
@@ -372,38 +400,36 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
execution.setVariable("statusDescription", "Delete Service Order Status is " + serviceOrderState)
}
else{
- utils.log("DEBUG", "Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
+ msoLogger.debug("Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode)
execution.setVariable("progress", 100)
execution.setVariable("status", "error")
execution.setVariable("statusDescription", "Get ServiceOrder Received a bad response")
exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Get ServiceOrder Received a bad response from 3rdONAP External API")
}
- utils.log("INFO", "Exit " + getE2ESIProgressin3rdONAP, isDebugEnabled)
+ msoLogger.info( "Exit " + getE2ESIProgressin3rdONAP)
}
/**
* delay 5 sec
*/
public void timeDelay(DelegateExecution execution) {
- def isDebugEnabled= execution.getVariable("isDebugLogEnabled")
try {
Thread.sleep(5000)
} catch(InterruptedException e) {
- utils.log("ERROR", "Time Delay exception" + e , isDebugEnabled)
+ utils.log("ERROR", "Time Delay exception" + e )
}
}
private void getSPPartnerInAAI(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started postDeleteE2ESIin3rdONAP *****", isDebugEnabled)
+ msoLogger.info(" ***** Started postDeleteE2ESIin3rdONAP *****")
AaiUtil aaiUriUtil = new AaiUtil(this)
String serviceAaiPath = execution.getVariable(Prefix + "serviceAaiPath")
APIResponse response = aaiUriUtil.executeAAIGetCall(execution, serviceAaiPath)
int responseCode = response.getStatusCode()
execution.setVariable(Prefix + "GetSppartnerResponseCode", responseCode)
- utils.log("DEBUG", " Get sppartner response code is: " + responseCode, isDebugEnabled)
+ msoLogger.debug(" Get sppartner response code is: " + responseCode)
String aaiResponse = response.getResponseBodyAsString()
aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
@@ -414,36 +440,35 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
//200 OK 201 CREATED 202 ACCEPTED
{
- utils.log("DEBUG", "GET sppartner Received a Good Response", isDebugEnabled)
+ msoLogger.debug("GET sppartner Received a Good Response")
execution.setVariable(Prefix + "SuccessIndicator", true)
execution.setVariable(Prefix + "FoundIndicator", true)
String sppartnerId = utils.getNodeText1(aaiResponse, "sppartner-id")
execution.setVariable(Prefix + "SppartnerId", sppartnerId)
- utils.log("DEBUG", " SppartnerId is: " + sppartnerId, isDebugEnabled)
+ msoLogger.debug(" SppartnerId is: " + sppartnerId)
String sppartnerUrl = utils.getNodeText1(aaiResponse, "sppartner-url")
execution.setVariable(Prefix + "SppartnerUrl", sppartnerUrl)
- utils.log("DEBUG", " SppartnerUrl is: " + sppartnerUrl, isDebugEnabled)
+ msoLogger.debug(" SppartnerUrl is: " + sppartnerUrl)
String callSource = utils.getNodeText1(aaiResponse, "sppartner-callsource")
execution.setVariable(Prefix + "CallSource", callSource)
- utils.log("DEBUG", " CallSource is: " + callSource, isDebugEnabled)
+ msoLogger.debug(" CallSource is: " + callSource)
String sppartnerVersion = utils.getNodeText1(aaiResponse, "resource-version")
execution.setVariable(Prefix + "SppartnerVersion", sppartnerVersion)
- utils.log("DEBUG", " Resource Version is: " + sppartnerVersion, isDebugEnabled)
+ msoLogger.debug(" Resource Version is: " + sppartnerVersion)
}
else
{
- utils.log("DEBUG", "Get sppartner Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
+ msoLogger.debug("Get sppartner Received a Bad Response Code. Response Code is: " + responseCode)
exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
throw new BpmnError("MSOWorkflowException")
}
- utils.log("INFO", "Exit " + deleteSPPartnerInAAI, isDebugEnabled)
+ msoLogger.info( "Exit " + deleteSPPartnerInAAI)
}
public void deleteSPPartnerInAAI(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started postDeleteE2ESIin3rdONAP *****", isDebugEnabled)
+ msoLogger.info(" ***** Started postDeleteE2ESIin3rdONAP *****")
String sppartnerId = execution.getVariable(Prefix + "SppartnerId")
String sppartnerUrl = execution.getVariable(Prefix + "sppartnerUrl")
@@ -454,7 +479,7 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, serviceAaiPath)
int responseCode = response.getStatusCode()
execution.setVariable(Prefix + "DeleteSppartnerResponseCode", responseCode)
- utils.log("DEBUG", " Get sppartner response code is: " + responseCode, isDebugEnabled)
+ msoLogger.debug(" Get sppartner response code is: " + responseCode)
String aaiResponse = response.getResponseBodyAsString()
aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
@@ -464,21 +489,21 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
//200 OK 201 CREATED 202 ACCEPTED
{
- utils.log("DEBUG", "Delete sppartner Received a Good Response", isDebugEnabled)
+ msoLogger.debug("Delete sppartner Received a Good Response")
execution.setVariable(Prefix + "SuccessIndicator", true)
}
else if(responseCode == 404){
- utils.log("DEBUG", " Delete sppartner Received a Not Found (404) Response", isDebugEnabled)
+ msoLogger.debug(" Delete sppartner Received a Not Found (404) Response")
execution.setVariable(Prefix + "FoundIndicator", false)
}
else
{
- utils.log("DEBUG", "Delete sppartner Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
+ msoLogger.debug("Delete sppartner Received a Bad Response Code. Response Code is: " + responseCode)
exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
throw new BpmnError("MSOWorkflowException")
}
- utils.log("INFO", "Exit " + deleteSPPartnerInAAI, isDebugEnabled)
+ msoLogger.info( "Exit " + deleteSPPartnerInAAI)
}
private void setProgressUpdateVariables(DelegateExecution execution, String body) {
@@ -488,32 +513,30 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
}
public void postProcess(DelegateExecution execution){
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started postProcess *****", isDebugEnabled)
+ msoLogger.info(" ***** Started postProcess *****")
String responseCode = execution.getVariable(Prefix + "putSppartnerResponseCode")
String responseObj = execution.getVariable(Prefix + "putSppartnerResponse")
- utils.log("INFO","response from AAI for put sppartner, response code :" + responseCode + " response object :" + responseObj, isDebugEnabled)
- utils.log("INFO"," ***** Exit postProcess *****", isDebugEnabled)
+ msoLogger.info("response from AAI for put sppartner, response code :" + responseCode + " response object :" + responseObj)
+ msoLogger.info(" ***** Exit postProcess *****")
}
public void sendSyncResponse (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled)
+ msoLogger.debug(" *** sendSyncResponse *** ")
try {
String operationStatus = "finished"
// RESTResponse for main flow
String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
- utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + resourceOperationResp, isDebugEnabled)
+ msoLogger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp)
sendWorkflowResponse(execution, 202, resourceOperationResp)
execution.setVariable("sentSyncResponse", true)
} catch (Exception ex) {
String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
+ msoLogger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled)
+ msoLogger.debug(" ***** Exit sendSyncResopnse *****")
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.groovy
new file mode 100644
index 0000000000..5a21fd7396
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.groovy
@@ -0,0 +1,194 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.scripts
+
+import org.json.JSONObject
+import org.json.XML;
+
+import static org.apache.commons.lang3.StringUtils.*;
+import groovy.xml.XmlUtil
+import groovy.json.*
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.recipe.ResourceInput;
+import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
+import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder
+import org.onap.so.logger.MsoLogger
+import org.onap.so.rest.APIResponse
+import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
+
+import java.util.UUID;
+
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.apache.commons.lang3.*
+import org.apache.commons.codec.binary.Base64;
+import org.springframework.web.util.UriUtils
+import org.onap.so.rest.RESTClient
+import org.onap.so.rest.RESTConfig
+import org.onap.so.rest.APIResponse;
+import org.onap.so.bpmn.common.scripts.AaiUtil
+
+/**
+ * This groovy class supports the <class>CreateDeviceResource.bpmn</class> process.
+ * flow for Device Resource Create
+ */
+public class DeleteDeviceResource extends AbstractServiceTaskProcessor {
+
+ String Prefix="DELDEVRES_"
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ JsonUtils jsonUtil = new JsonUtils()
+
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DeleteDeviceResource.class)
+
+ public void preProcessRequest(DelegateExecution execution){
+ msoLogger.info(" ***** Started preProcessRequest *****")
+ try {
+
+ //get bpmn inputs from resource request.
+ String requestId = execution.getVariable("mso-request-id")
+ String requestAction = execution.getVariable("requestAction")
+ msoLogger.info("The requestAction is: " + requestAction)
+ String recipeParamsFromRequest = execution.getVariable("recipeParams")
+ msoLogger.info("The recipeParams is: " + recipeParamsFromRequest)
+ String resourceInput = execution.getVariable("resourceInput")
+ msoLogger.info("The resourceInput is: " + resourceInput)
+ //Get ResourceInput Object
+ ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
+ execution.setVariable(Prefix + "resourceInput", resourceInputObj)
+ String resourceInputPrameters = resourceInputObj.getResourceParameters()
+ String inputParametersJson = jsonUtil.getJsonValue(resourceInputPrameters, "requestInputs")
+ JSONObject inputParameters = new JSONObject(customizeResourceParam(inputParametersJson))
+ execution.setVariable(Prefix + "resourceRequestInputs", inputParameters)
+
+ //Deal with recipeParams
+ String recipeParamsFromWf = execution.getVariable("recipeParamXsd")
+ String resourceName = resourceInputObj.getResourceInstanceName()
+ //For sdnc requestAction default is "createNetworkInstance"
+ String operationType = "Network"
+ if(!StringUtils.isBlank(recipeParamsFromRequest)){
+ //the operationType from worflow(first node) is second priority.
+ operationType = jsonUtil.getJsonValue(recipeParamsFromRequest, "operationType")
+ }
+ if(!StringUtils.isBlank(recipeParamsFromWf)){
+ //the operationType from worflow(first node) is highest priority.
+ operationType = jsonUtil.getJsonValue(recipeParamsFromWf, "operationType")
+ }
+
+ execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId())
+ execution.setVariable("mso-request-id", requestId)
+
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception ex){
+ String msg = "Exception in preProcessRequest " + ex.getMessage()
+ msoLogger.debug( msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+
+ String customizeResourceParam(String networkInputParametersJson) {
+ List<Map<String, Object>> paramList = new ArrayList();
+ JSONObject jsonObject = new JSONObject(networkInputParametersJson);
+ Iterator iterator = jsonObject.keys();
+ while (iterator.hasNext()) {
+ String key = iterator.next();
+ HashMap<String, String> hashMap = new HashMap();
+ hashMap.put("name", key);
+ hashMap.put("value", jsonObject.get(key))
+ paramList.add(hashMap)
+ }
+ Map<String, List<Map<String, Object>>> paramMap = new HashMap();
+ paramMap.put("param", paramList);
+
+ return new JSONObject(paramMap).toString();
+ }
+
+ public void checkDevType(DelegateExecution execution){
+ utils.log("INFO"," ***** Started checkDevType *****")
+ try {
+
+ JSONObject inputParameters = execution.getVariable(Prefix + "resourceRequestInputs")
+
+ String devType = inputParameters.get("device_class")
+
+ if(StringUtils.isBlank(devType)) {
+ devType = "OTHER"
+ }
+
+ execution.setVariable("device_class", devType)
+
+ } catch (Exception ex){
+ String msg = "Exception in checkDevType " + ex.getMessage()
+ msoLogger.debug( msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+
+ public void getVNFTemplatefromSDC(DelegateExecution execution){
+ utils.log("INFO"," ***** Started getVNFTemplatefromSDC *****")
+ try {
+ // To do
+
+
+ } catch (Exception ex){
+ String msg = "Exception in getVNFTemplatefromSDC " + ex.getMessage()
+ msoLogger.debug( msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+
+ public void postVNFInfoProcess(DelegateExecution execution){
+ utils.log("INFO"," ***** Started postVNFInfoProcess *****")
+ try {
+ // To do
+
+
+ } catch (Exception ex){
+ String msg = "Exception in postVNFInfoProcess " + ex.getMessage()
+ msoLogger.debug( msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+
+ public void sendSyncResponse (DelegateExecution execution) {
+ msoLogger.debug( " *** sendSyncResponse *** ")
+
+ try {
+ String operationStatus = "finished"
+ // RESTResponse for main flow
+ String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
+ msoLogger.debug( " sendSyncResponse to APIH:" + "\n" + resourceOperationResp)
+ sendWorkflowResponse(execution, 202, resourceOperationResp)
+ execution.setVariable("sentSyncResponse", true)
+
+ } catch (Exception ex) {
+ String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
+ msoLogger.debug( msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ msoLogger.debug(" ***** Exit sendSyncResopnse *****")
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy
index 9591898ed0..d571c00f47 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
*
@@ -183,9 +183,9 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{
def currentIndex = execution.getVariable("currentResourceIndex")
List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList")
Resource currentResource = sequencedResourceList.get(currentIndex)
- execution.setVariable("resourceType", currentResource.getModelInfo().getModelName())
+ execution.setVariable("resourceType", currentResource.getModelInfo().getModelName())
msoLogger.info("Now we deal with resouce:" + currentResource.getModelInfo().getModelName())
- msoLogger.trace("COMPLETED getCurrentResoure Process ")
+ msoLogger.trace("COMPLETED getCurrentResoure Process ")
}
public void parseNextResource(DelegateExecution execution){
@@ -261,7 +261,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{
} else {
String exceptionMessage = "Resource receipe is not found for resource modeluuid: " +
resourceInput.getResourceModelInfo().getModelUuid()
- utils.log("ERROR", exceptionMessage, isDebugEnabled)
+ msoLogger.trace(exceptionMessage)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, exceptionMessage)
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy
index 827d44726b..76dba27890 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy
@@ -330,11 +330,11 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
)){
jObj.put("resourceInstanceId", eValue)
}
- // for sp-partner
- if(rt == "sp-partner" && eKey.equals("sp-partner.id")) {
+ // for sp-partner and others
+ else if(eKey.equals(rt + ".id")){
jObj.put("resourceInstanceId", eValue)
- String sppartnerName = "sp-partner" + eValue
- jObj.put("resourceType", sppartnerName)
+ String resourceName = rt + eValue;
+ jObj.put("resourceType", resourceName)
}
else if(eKey.equals(rt + ".id")){
jObj.put("resourceInstanceId", eValue)