* ================================================================================
* Copyright (C) 2018 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
import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.logger.MsoLogger
+import org.onap.so.client.aai.AAIObjectType
+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.client.aai.entities.uri.AAIUriFactory
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
import org.onap.so.bpmn.common.scripts.ExceptionUtil;
import groovy.json.*
import org.onap.so.bpmn.common.scripts.AaiUtil;
*
*/
public class DoUpdateE2EServiceInstanceRollback extends AbstractServiceTaskProcessor{
- private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoUpdateE2EServiceInstanceRollback.class);
+ private static final Logger logger = LoggerFactory.getLogger( DoUpdateE2EServiceInstanceRollback.class);
String Prefix="DUPDSIRB_"
public void preProcessRequest(DelegateExecution execution) {
execution.setVariable("prefix",Prefix)
String msg = ""
- msoLogger.trace("preProcessRequest ")
+ logger.trace("preProcessRequest ")
execution.setVariable("rollbackAAI",false)
execution.setVariable("rollbackAdded",false)
execution.setVariable("rollbackDeleted",false)
try {
def rollbackData = execution.getVariable("rollbackData")
- msoLogger.debug("RollbackData:" + rollbackData)
+ logger.debug("RollbackData:" + rollbackData)
if (rollbackData != null) {
if (rollbackData.hasType("SERVICEINSTANCE")) {
throw e;
} catch (Exception ex){
msg = "Exception in Update ServiceInstance Rollback preProcessRequest " + ex.getMessage()
- msoLogger.debug(msg)
+ logger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- msoLogger.trace("Exit preProcessRequest ")
+ logger.trace("Exit preProcessRequest ")
}
public void postProcessRequest(DelegateExecution execution) {
- msoLogger.trace("postProcessRequest ")
+ logger.trace("postProcessRequest ")
String msg = ""
try {
execution.setVariable("rollbackData", null)
if(!succInAAI){
execution.setVariable("rolledBack", false) //both sdnc and aai must be successful to declare rollback Succesful
execution.setVariable("rollbackError", "Error deleting service-instance in AAI for rollback")
- msoLogger.debug("Error deleting service-instance in AAI for rollback", + serviceInstanceId)
+ logger.debug("Error deleting service-instance in AAI for rollback", + serviceInstanceId)
}
}
- msoLogger.trace("Exit postProcessRequest ")
+ logger.trace("Exit postProcessRequest ")
} catch (BpmnError e) {
msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + e.getMessage()
- msoLogger.debug(msg)
+ logger.debug(msg)
} catch (Exception ex) {
msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + ex.getMessage()
- msoLogger.debug(msg)
+ logger.debug(msg)
}
}
public void preProcessAAIPUT(DelegateExecution execution) {
def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')'
- msoLogger.info("Entered " + method)
+ logger.info("Entered " + method)
String msg = ""
- msoLogger.trace("preProcessAAIPUT ")
+ logger.trace("preProcessAAIPUT ")
String serviceInstanceVersion = execution.getVariable("serviceInstanceVersion_n")
// execution.setVariable("GENPS_serviceResourceVersion", serviceInstanceVersion)
String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
String modelUuid = execution.getVariable("model-version-id-original")
- //AAI PUT
- AaiUtil aaiUriUtil = new AaiUtil(this)
- utils.log("INFO","start create aai uri: " + aaiUriUtil, isDebugEnabled)
- String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution)
- utils.log("INFO","aai_uri: " + aai_uri, isDebugEnabled)
- String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri)
- utils.log("INFO","namespace: " + namespace, isDebugEnabled)
-
- 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>
- <resource-version>${MsoUtils.xmlEscape(serviceInstanceVersion)}</resource-version>
- <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.info("serviceInstanceData: " + serviceInstanceData)
- msoLogger.debug(serviceInstanceData)
- msoLogger.info(" aai_uri " + aai_uri + " namespace:" + namespace)
- msoLogger.info(" 'payload' to update Service Instance in AAI - " + "\n" + serviceInstanceData)
-
- msoLogger.info("Exited " + method)
+ org.onap.aai.domain.yang.ServiceInstance si = new org.onap.aai.domain.yang.ServiceInstance()
+ si.setServiceInstanceId(serviceInstanceId)
+ si.setServiceInstanceName(serviceInstanceName)
+ si.setServiceType(aaiServiceType)
+ si.setServiceRole(aaiServiceRole)
+ si.setModelInvariantId(modelInvariantUuid)
+ si.setModelVersionId(modelUuid)
+
+ execution.setVariable("serviceInstanceData", si)
+
+ logger.info("Exited " + method)
}
- public void postProcessAAIPUT(DelegateExecution execution) {
- msoLogger.trace("postProcessAAIPUT ")
+ public void updateServiceInstance(DelegateExecution execution) {
+ logger.trace("updateServiceInstance ")
String msg = ""
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
- {
+ org.onap.aai.domain.yang.ServiceInstance si = execution.getVariable("serviceInstanceData")
- }
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
+ client.update(uri, si)
} catch (BpmnError e) {
throw e;
} catch (Exception ex) {
- msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage()
- msoLogger.info(msg)
+ msg = "Exception in DoCreateServiceInstance.updateServiceInstance. " + ex.getMessage()
+ logger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- msoLogger.trace("Exit postProcessAAIPUT ")
+ logger.trace("Exit updateServiceInstance ")
}
public void processRollbackException(DelegateExecution execution){
- msoLogger.trace("processRollbackException ")
+ logger.trace("processRollbackException ")
try{
- msoLogger.debug("Caught an Exception in DoUpdateE2EServiceInstanceRollback")
+ logger.debug("Caught an Exception in DoUpdateE2EServiceInstanceRollback")
execution.setVariable("rollbackData", null)
execution.setVariable("rollbackError", "Caught exception in ServiceInstance Update Rollback")
execution.setVariable("WorkflowException", null)
}catch(BpmnError b){
- msoLogger.debug("BPMN Error during processRollbackExceptions Method: ")
+ logger.debug("BPMN Error during processRollbackExceptions Method: ")
}catch(Exception e){
- msoLogger.debug("Caught Exception during processRollbackExceptions Method: " + e.getMessage())
+ logger.debug("Caught Exception during processRollbackExceptions Method: " + e.getMessage())
}
- msoLogger.debug(" Exit processRollbackException")
+ logger.debug(" Exit processRollbackException")
}
public void processRollbackJavaException(DelegateExecution execution){
- msoLogger.trace("processRollbackJavaException ")
+ logger.trace("processRollbackJavaException ")
try{
execution.setVariable("rollbackData", null)
execution.setVariable("rollbackError", "Caught Java exception in ServiceInstance Update Rollback")
- msoLogger.debug("Caught Exception in processRollbackJavaException")
+ logger.debug("Caught Exception in processRollbackJavaException")
}catch(Exception e){
- msoLogger.debug("Caught Exception in processRollbackJavaException " + e.getMessage())
+ logger.debug("Caught Exception in processRollbackJavaException " + e.getMessage())
}
- msoLogger.trace("Exit processRollbackJavaException ")
+ logger.trace("Exit processRollbackJavaException ")
}
}