* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
* 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
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.infrastructure.scripts;
+package org.onap.so.bpmn.infrastructure.scripts
+
+import org.onap.so.logger.ErrorCode;
import static org.apache.commons.lang3.StringUtils.*;
import javax.ws.rs.NotFoundException
-import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.aai.domain.yang.ServiceInstance
-import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.onap.so.bpmn.common.scripts.CatalogDbUtils;
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.core.RollbackData
import org.onap.so.client.aai.AAIResourcesClient
import org.onap.so.client.aai.entities.AAIResultWrapper
import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.logger.MessageEnum
-import org.onap.so.logger.MsoLogger
-import org.springframework.web.util.UriUtils;
-
-import groovy.json.*
-
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import org.springframework.web.util.UriUtils
+import org.onap.so.bpmn.core.UrnPropertiesReader
/**
* This groovy class supports the <class>DoCreateServiceInstance.bpmn</class> process.
*
*/
public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor {
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateE2EServiceInstance.class);
+ private static final Logger logger = LoggerFactory.getLogger( DoCreateE2EServiceInstance.class);
String Prefix="DCRESI_"
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
- CatalogDbUtils cutils = new CatalogDbUtils()
public void preProcessRequest (DelegateExecution execution) {
String msg = ""
- msoLogger.trace("preProcessRequest ")
+ logger.trace("preProcessRequest ")
try {
execution.setVariable("prefix", Prefix)
//Inputs
//requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology
String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
- msoLogger.info(" ***** globalSubscriberId *****" + globalSubscriberId)
+ logger.info(" ***** globalSubscriberId *****" + globalSubscriberId)
//requestDetails.requestParameters. for AAI PUT & SDNC assignTopology
String serviceType = execution.getVariable("serviceType")
- msoLogger.info(" ***** serviceType *****" + serviceType)
+ logger.info(" ***** serviceType *****" + serviceType)
//requestDetails.requestParameters. for SDNC assignTopology
String productFamilyId = execution.getVariable("productFamilyId") //AAI productFamilyId
if (isBlank(globalSubscriberId)) {
msg = "Input globalSubscriberId is null"
- msoLogger.info(msg)
+ logger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
if (isBlank(serviceType)) {
msg = "Input serviceType is null"
- msoLogger.info(msg)
+ logger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
execution.setVariable("productFamilyId", "")
}
- String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
+ String sdncCallbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback", execution)
if (isBlank(sdncCallbackUrl)) {
msg = "URN_mso_workflow_sdncadapter_callback is null"
- msoLogger.info(msg)
+ logger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
- msoLogger.info("SDNC Callback URL: " + sdncCallbackUrl)
+ logger.info("SDNC Callback URL: " + sdncCallbackUrl)
//requestDetails.modelInfo.for AAI PUT servieInstanceData
//requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData
oStatus = "Created"
}
- String statusLine = isBlank(oStatus) ? "" : "<orchestration-status>${MsoUtils.xmlEscape(oStatus)}</orchestration-status>"
-
- AaiUtil aaiUriUtil = new AaiUtil(this)
- String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution)
- String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri)
- String serviceInstanceData =
- """<service-instance xmlns=\"${namespace}\">
- <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
- <service-instance-name>${MsoUtils.xmlEscape(serviceInstanceName)}</service-instance-name>
- <service-type>${MsoUtils.xmlEscape(aaiServiceType)}</service-type>
- <service-role>${MsoUtils.xmlEscape(aaiServiceRole)}</service-role>
- ${statusLine}
- <model-invariant-id>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-id>
- <model-version-id>${MsoUtils.xmlEscape(modelUuid)}</model-version-id>
- </service-instance>""".trim()
- execution.setVariable("serviceInstanceData", serviceInstanceData)
- msoLogger.debug(serviceInstanceData)
- msoLogger.info(" aai_uri " + aai_uri + " namespace:" + namespace)
- msoLogger.info(" 'payload' to create Service Instance in AAI - " + "\n" + serviceInstanceData)
+ org.onap.aai.domain.yang.ServiceInstance si = new org.onap.aai.domain.yang.ServiceInstance()
+ si.setServiceInstanceName(serviceInstanceName)
+ si.setServiceType(aaiServiceType)
+ si.setServiceRole(aaiServiceRole)
+ si.setOrchestrationStatus(oStatus)
+ si.setModelInvariantId(modelInvariantUuid)
+ si.setModelVersionId(modelUuid)
+ si.setInputParameters(uuiRequest)
+ execution.setVariable("serviceInstanceData", si)
} catch (BpmnError e) {
throw e;
} catch (Exception ex){
msg = "Exception in preProcessRequest " + ex.getMessage()
- msoLogger.info(msg)
+ logger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- msoLogger.trace("Exit preProcessRequest ")
+ logger.trace("Exit preProcessRequest ")
}
public void prepareDecomposeService(DelegateExecution execution) {
try {
- msoLogger.trace("Inside prepareDecomposeService of create generic e2e service ")
+ logger.trace("Inside prepareDecomposeService of create generic e2e service ")
String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
String modelUuid = execution.getVariable("modelUuid")
//here modelVersion is not set, we use modelUuid to decompose the service.
}"""
execution.setVariable("serviceModelInfo", serviceModelInfo)
- msoLogger.trace("Completed prepareDecomposeService of create generic e2e service ")
+ logger.trace("Completed prepareDecomposeService of create generic e2e service ")
} catch (Exception ex) {
// try error in method block
String exceptionMessage = "Bpmn error encountered in create generic e2e service flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage()
}
public void processDecomposition(DelegateExecution execution) {
- msoLogger.trace("Inside processDecomposition() of create generic e2e service flow ")
+ logger.trace("Inside processDecomposition() of create generic e2e service flow ")
try {
ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
} catch (Exception ex) {
String exceptionMessage = "Bpmn error encountered in create generic e2e service flow. processDecomposition() - " + ex.getMessage()
- msoLogger.debug(exceptionMessage)
+ logger.debug(exceptionMessage)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
}
}
}
public void postProcessAAIGET(DelegateExecution execution) {
- msoLogger.trace("postProcessAAIGET ")
+ logger.trace("postProcessAAIGET ")
String msg = ""
try {
String serviceInstanceName = execution.getVariable("serviceInstanceName")
boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
if(!succInAAI){
- msoLogger.info("Error getting Service-instance from AAI", + serviceInstanceName)
+ logger.info("Error getting Service-instance from AAI", + serviceInstanceName)
WorkflowException workflowException = execution.getVariable("WorkflowException")
- msoLogger.debug("workflowException: " + workflowException)
+ logger.debug("workflowException: " + workflowException)
if(workflowException != null){
exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
}
else
{
msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI
- msoLogger.info(msg)
+ logger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
}
}
{
boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
if(foundInAAI){
- msoLogger.info("Found Service-instance in AAI")
+ logger.info("Found Service-instance in AAI")
msg = "ServiceInstance already exists in AAI:" + serviceInstanceName
- msoLogger.info(msg)
+ logger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
}
}
throw e;
} catch (Exception ex) {
msg = "Exception in DoCreateServiceInstance.postProcessAAIGET. " + ex.getMessage()
- msoLogger.info(msg)
+ logger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- msoLogger.trace("Exit postProcessAAIGET ")
+ logger.trace("Exit postProcessAAIGET ")
}
//TODO use create if not exist
- public void postProcessAAIPUT(DelegateExecution execution) {
- msoLogger.trace("postProcessAAIPUT ")
+ public void createServiceInstance(DelegateExecution execution) {
+ logger.trace("createServiceInstance ")
String msg = ""
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
try {
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator")
- if(!succInAAI){
- msoLogger.info("Error putting Service-instance in AAI", + serviceInstanceId)
- WorkflowException workflowException = execution.getVariable("WorkflowException")
- msoLogger.debug("workflowException: " + workflowException)
- if(workflowException != null){
- exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
- }
- }
- else
- {
- //start rollback set up
- RollbackData rollbackData = new RollbackData()
- def disableRollback = execution.getVariable("disableRollback")
- rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString())
- rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
- rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId)
- rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
- rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
- execution.setVariable("rollbackData", rollbackData)
- }
+ org.onap.aai.domain.yang.ServiceInstance si = execution.getVariable("serviceInstanceData")
+
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), serviceInstanceId)
+ client.create(uri, si)
} catch (BpmnError e) {
throw e;
} catch (Exception ex) {
- msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage()
- msoLogger.info(msg)
+ //start rollback set up
+ RollbackData rollbackData = new RollbackData()
+ def disableRollback = execution.getVariable("disableRollback")
+ rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString())
+ rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
+ rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId)
+ rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
+ rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
+ execution.setVariable("rollbackData", rollbackData)
+
+ msg = "Exception in DoCreateServiceInstance.createServiceInstance. " + ex.getMessage()
+ logger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- msoLogger.trace("Exit postProcessAAIPUT ")
+ logger.trace("Exit createServiceInstance ")
}
/**
AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId)
AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
- ServiceInstance si = wrapper.asBean(ServiceInstance.class)
- execution.setVariable("serviceInstanceName", si.getServiceInstanceName())
+ Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
+ execution.setVariable("serviceInstanceName", si.get().getServiceInstanceName())
}catch(BpmnError e) {
throw e;
}
}
-
public void postProcessAAIGET2(DelegateExecution execution) {
- msoLogger.trace("postProcessAAIGET2 ")
+ logger.trace("postProcessAAIGET2 ")
String msg = ""
try {
String serviceInstanceName = execution.getVariable("serviceInstanceName")
boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
if(!succInAAI){
- msoLogger.info("Error getting Service-instance from AAI in postProcessAAIGET2", + serviceInstanceName)
+ logger.info("Error getting Service-instance from AAI in postProcessAAIGET2", + serviceInstanceName)
WorkflowException workflowException = execution.getVariable("WorkflowException")
- msoLogger.debug("workflowException: " + workflowException)
+ logger.debug("workflowException: " + workflowException)
if(workflowException != null){
exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
}
else
{
msg = "Failure in postProcessAAIGET2 GENGS_SuccessIndicator:" + succInAAI
- msoLogger.info(msg)
+ logger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
}
}
String aaiService = execution.getVariable("GENGS_service")
if (!isBlank(aaiService) && (utils.nodeExists(aaiService, "service-instance-name"))) {
execution.setVariable("serviceInstanceName", utils.getNodeText(aaiService, "service-instance-name"))
- msoLogger.info("Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName"))
+ logger.info("Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName"))
}
}
}
throw e;
} catch (Exception ex) {
msg = "Exception in DoCreateServiceInstance.postProcessAAIGET2 " + ex.getMessage()
- msoLogger.info(msg)
+ logger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- msoLogger.trace("Exit postProcessAAIGET2 ")
+ logger.trace("Exit postProcessAAIGET2 ")
}
public void preProcessRollback (DelegateExecution execution) {
- msoLogger.trace("preProcessRollback ")
+ logger.trace("preProcessRollback ")
try {
Object workflowException = execution.getVariable("WorkflowException");
if (workflowException instanceof WorkflowException) {
- msoLogger.info("Prev workflowException: " + workflowException.getErrorMessage())
+ logger.info("Prev workflowException: " + workflowException.getErrorMessage())
execution.setVariable("prevWorkflowException", workflowException);
//execution.setVariable("WorkflowException", null);
}
} catch (BpmnError e) {
- msoLogger.info("BPMN Error during preProcessRollback")
+ logger.info("BPMN Error during preProcessRollback")
} catch(Exception ex) {
String msg = "Exception in preProcessRollback. " + ex.getMessage()
- msoLogger.info(msg)
+ logger.info(msg)
}
- msoLogger.trace("Exit preProcessRollback ")
+ logger.trace("Exit preProcessRollback ")
}
public void postProcessRollback (DelegateExecution execution) {
- msoLogger.trace("postProcessRollback ")
+ logger.trace("postProcessRollback ")
String msg = ""
try {
Object workflowException = execution.getVariable("prevWorkflowException");
if (workflowException instanceof WorkflowException) {
- msoLogger.info("Setting prevException to WorkflowException: ")
+ logger.info("Setting prevException to WorkflowException: ")
execution.setVariable("WorkflowException", workflowException);
}
execution.setVariable("rollbackData", null)
} catch (BpmnError b) {
- msoLogger.info("BPMN Error during postProcessRollback")
+ logger.info("BPMN Error during postProcessRollback")
throw b;
} catch(Exception ex) {
msg = "Exception in postProcessRollback. " + ex.getMessage()
- msoLogger.info(msg)
+ logger.info(msg)
}
- msoLogger.trace("Exit postProcessRollback ")
+ logger.trace("Exit postProcessRollback ")
}
public void preInitResourcesOperStatus(DelegateExecution execution){
- msoLogger.trace("STARTED preInitResourcesOperStatus Process ")
+ logger.trace("STARTED preInitResourcesOperStatus Process ")
try{
String serviceId = execution.getVariable("serviceInstanceId")
String operationId = execution.getVariable("operationId")
String progress = "0"
String reason = ""
String operationContent = "Prepare service creation"
- msoLogger.info("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType)
+ logger.info("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType)
serviceId = UriUtils.encode(serviceId,"UTF-8")
execution.setVariable("serviceInstanceId", serviceId)
execution.setVariable("operationId", operationId)
resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":"
}
- def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter"
+ def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.db.endpoint")
execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
- msoLogger.info("DB Adapter Endpoint is: " + dbAdapterEndpoint)
+ logger.info("DB Adapter Endpoint is: " + dbAdapterEndpoint)
String payload =
"""<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
payload = utils.formatXml(payload)
execution.setVariable("CVFMI_initResOperStatusRequest", payload)
- msoLogger.info("Outgoing initResourceOperationStatus: \n" + payload)
- msoLogger.debug("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload)
+ logger.info("Outgoing initResourceOperationStatus: \n" + payload)
+ logger.debug("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload)
}catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preInitResourcesOperStatus.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e);
+ logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception Occured Processing preInitResourcesOperStatus.", "BPMN",
+ ErrorCode.UnknownError.getValue(), e);
execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage())
}
- msoLogger.trace("COMPLETED preInitResourcesOperStatus Process ")
+ logger.trace("COMPLETED preInitResourcesOperStatus Process ")
}
- // if site location is in local Operator, create all resources in local ONAP;
+ // if site location is in local Operator, create all resources in local ONAP;
// if site location is in 3rd Operator, only process sp-partner to create all resources in 3rd ONAP
public void doProcessSiteLocation(DelegateExecution execution){
+ logger.trace("======== Start doProcessSiteLocation Process ======== ")
+ ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+ String uuiRequest = execution.getVariable("uuiRequest")
+ uuiRequest = ServicePluginFactory.getInstance().doProcessSiteLocation(serviceDecomposition, uuiRequest);
+ execution.setVariable("uuiRequest", uuiRequest)
+ execution.setVariable("serviceDecomposition", serviceDecomposition)
+
+ logger.trace("======== COMPLETED doProcessSiteLocation Process ======== ")
+ }
- msoLogger.trace("======== Start doProcessSiteLocation Process ======== ")
+ // Allocate cross link TPs(terminal points) for sotn network only
+ public void doTPResourcesAllocation(DelegateExecution execution){
+ logger.trace("======== Start doTPResourcesAllocation Process ======== ")
ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
String uuiRequest = execution.getVariable("uuiRequest")
- ServiceDecomposition serviceDecompositionforLocal = ServicePluginFactory.getInstance().doProcessSiteLocation(serviceDecomposition, uuiRequest);
- execution.setVariable("serviceDecomposition", serviceDecompositionforLocal)
-
- msoLogger.trace("======== COMPLETED doProcessSiteLocation Process ======== ")
+ uuiRequest = ServicePluginFactory.getInstance().doTPResourcesAllocation(execution, uuiRequest);
+ execution.setVariable("uuiRequest", uuiRequest)
+ logger.trace("======== COMPLETED doTPResourcesAllocation Process ======== ")
}
// prepare input param for using DoCreateResources.bpmn
public void preProcessForAddResource(DelegateExecution execution) {
- msoLogger.trace("STARTED preProcessForAddResource Process ")
+ logger.trace("STARTED preProcessForAddResource Process ")
ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
List<Resource> addResourceList = serviceDecomposition.getServiceResources()
execution.setVariable("addResourceList", addResourceList)
- msoLogger.trace("COMPLETED preProcessForAddResource Process ")
+ logger.trace("COMPLETED preProcessForAddResource Process ")
}
public void postProcessForAddResource(DelegateExecution execution) {