* ============LICENSE_END=========================================================
*/
-package com.att.bpm.scripts
-
-import java.text.SimpleDateFormat
+package org.openecomp.mso.bpmn.common.scripts
import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.BpmnError
// Complete MSO Request processing
public initializeProcessVariables(Execution execution){
- def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
+ def method = getClass().getSimpleName() + '.initializeProcessVariables(' +'execution=' + execution.getId() +')'
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
logDebug('Entered ' + method, isDebugLogEnabled)
try {
/* Initialize all the process request variables in this block */
execution.setVariable("prefix",Prefix)
- //execution.setVariable("getLayer3ServiceDetailsV1Response","")
execution.setVariable("CMSO_request_id","")
execution.setVariable("CMSO_notification-url","")
execution.setVariable("CMSO_mso-bpel-name","")
execution.setVariable("CMSO_request_action","")
-
execution.setVariable("CMSO_notification-url-Ok", false)
execution.setVariable("CMSO_request_id-Ok", false)
- //These variabels are for Get Mso Aai Password Adapter
- execution.setVariable("CMSO_deliveryStatus", false)
-
//updateRequest Adapter process variables
execution.setVariable("CMSO_updateRequestResponse", "")
execution.setVariable("CMSO_updateRequestResponseCode", "")
- execution.setVariable("CMSO_updateFinalNotifyAckStatusSuccessPayload", "")
execution.setVariable("CMSO_updateFinalNotifyAckStatusFailedPayload", "")
- execution.setVariable("CMSO_gSendManagedNetworkStatusNotificationResponse", "")
//Set DB adapter variables here
- execution.setVariable("CMSO_updateFinalStatusSuccessPayload", "")
execution.setVariable("CMSO_updateDBStatusToSuccessPayload", "")
execution.setVariable("CMSO_updateInfraRequestDBPayload", "")
execution.setVariable("CMSO_setUpdateDBstatustoSuccessPayload", "")
- execution.setVariable("CMSO_setUpdateFinalNotifyAckStatusPayload", "")
-
- //NotifyOMXSuccessFailureViaCSI Adapter variables
- execution.setVariable("CMSO_notifyOMXSuccessFailureViaCSIPayload", "")
- execution.setVariable("CMSO_notifyOMXSuccessFailureViaCSIResponseCode", null)
- execution.setVariable("CMSO_notifyOMXSuccessFailureViaCSIResponse", "")
//Auth variables
execution.setVariable("BasicAuthHeaderValue","")
public void preProcessRequest (Execution execution) {
initializeProcessVariables(execution)
- def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
+ def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')'
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- utils.log("DEBUG", "*** Started CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled);
+// utils.log("DEBUG", "*** Started CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled);
logDebug('Entered ' + method, isDebugLogEnabled)
try {
def xml = execution.getVariable("CompleteMsoProcessRequest")
utils.log("DEBUG", "CMSO_notification-url-Ok --> " + execution.getVariable("CMSO_notification-url-Ok"), isDebugLogEnabled)
utils.log("DEBUG", "CMSO_request_id-Ok --> " + execution.getVariable("CMSO_request_id-Ok"), isDebugLogEnabled)
+ // set the DHV/Service Instantiation values if specified in the request
+ execution.setVariable("CMSO_is_srv_inst_req", String.valueOf("true".equals(utils.getNodeText1(xml, "is-srv-inst-req"))))
+ utils.log("DEBUG", "CMSO_is_srv_inst_req --> " + execution.getVariable("CMSO_is_srv_inst_req"), isDebugLogEnabled)
+ execution.setVariable("CMSO_is_json_content", String.valueOf("JSON".equals(utils.getNodeText1(xml, "resp-content-type"))))
+ utils.log("DEBUG", "CMSO_is_json_content --> " + execution.getVariable("CMSO_is_json_content"), isDebugLogEnabled)
+ execution.setVariable("CMSO_service_inst_id", utils.getNodeText1(xml, "service-instance-id"))
+ utils.log("DEBUG", "CMSO_service_inst_id --> " + execution.getVariable("CMSO_service_inst_id"), isDebugLogEnabled)
+ execution.setVariable("CMSO_start_time", utils.getNodeText1(xml, "start-time"))
+ utils.log("DEBUG", "CMSO_start_time --> " + execution.getVariable("CMSO_start_time"), isDebugLogEnabled)
+ // this variable is used by the camunda flow to set the Content-Type for the async response
+ if (execution.getVariable("CMSO_is_srv_inst_req").equals("true") &&
+ execution.getVariable("CMSO_is_json_content").equals("true")) {
+ execution.setVariable("CMSO_content_type", "application/json")
+ } else {
+ execution.setVariable("CMSO_content_type", "text/xml")
+ }
+
logDebug('Exited ' + method, isDebugLogEnabled)
} catch (BpmnError e) {
throw e;
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in " + method)
}
- utils.log("DEBUG", "*** Completed CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled);
+// utils.log("DEBUG", "*** Completed CompleteMsoProcess preProcessRequest Method ***", isDebugLogEnabled);
}
public void postProcessResponse (Execution execution) {
- def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
+ def method = getClass().getSimpleName() + '.postProcessResponse(' +'execution=' + execution.getId() +')'
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
logDebug('Entered ' + method, isDebugLogEnabled)
- utils.log("DEBUG", "*** Started CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled);
+// utils.log("DEBUG", "*** Started CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled);
try {
def msoCompletionResponse = """
- <sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://ecomp.att.com/mso/workflow/schema/v1">
+ <sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1">
<sdncadapterworkflow:out>BPEL ${execution.getVariable("CMSO_mso-bpel-name")} completed</sdncadapterworkflow:out>
</sdncadapterworkflow:MsoCompletionResponse>
""".trim()
logError('Caught exception in ' + method, e)
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
}
- utils.log("DEBUG", "*** Completed CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled);
+// utils.log("DEBUG", "*** Completed CompleteMsoProcess PostProcessRequest Method ***", isDebugLogEnabled);
}
- public void updateFinalNotifyAckStatusSuccessPayload (Execution execution){
- def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
- try {
-
- def deliveryStatus = execution.getVariable("CMSO_deliveryStatus")
- String responseStatus = ""
- String responseCode = ""
- String responseBodyXml = ""
-
- if(deliveryStatus == true){
- responseStatus = "SUCCESS"
- responseCode = "200"
- responseBodyXml = """<responseBody>${execution.getVariable("CMSO_gSendManagedNetworkStatusNotificationResponse")}</responseBody>"""
- }else{
- responseStatus = "FAILED"
- responseCode = execution.getVariable("CCDStatusCode")
- }
-
- String payload = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://com.att.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <req:updateRequest>
- <requestId>${execution.getVariable("CMSO_request_id")}</requestId>
- <lastModifiedBy>BPEL</lastModifiedBy>
- <responseStatus>${responseStatus}</responseStatus>
- <responseCode>${responseCode}</responseCode>
- ${responseBodyXml}
- </req:updateRequest>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- execution.setVariable("CMSO_updateFinalNotifyAckStatusSuccessPayload", payload)
- utils.logAudit("updateFinalNotifyAckStatusPayload: " + payload)
- logDebug('Exited ' + method, isDebugLogEnabled)
-
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
- }
- }
-
-
- public String updateFinalStatusSuccessPayload (Execution execution){
-
- def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
+ public void updateDBStatusToSuccessPayload (Execution execution){
+ def method = getClass().getSimpleName() + '.updateDBStatusToSuccessPayload(' +'execution=' + execution.getId() +')'
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
logDebug('Entered ' + method, isDebugLogEnabled)
+
try {
- String payload = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://com.att.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <req:updateRequest>
- <requestId>${execution.getVariable("CMSO_request_id")}</requestId>
- <lastModifiedBy>BPEL</lastModifiedBy>
- <responseStatus>SUCCESS</responseStatus>
- </req:updateRequest>
- </soapenv:Body>
- </soapenv:Envelope>
- """
- execution.setVariable("CMSO_updateFinalStatusSuccessPayload", payload)
- utils.logAudit("updateFinalStatusSuccessPayload: " + payload)
- logDebug('Exited ' + method, isDebugLogEnabled)
- //println("CMSO_updateFinalStatusSuccessPayload --> " + execution.getVariable("CMSO_updateFinalStatusSuccessPayload"))
-
- return execution.getVariable("CMSO_updateFinalStatusSuccessPayload")
-
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
+ // Catalog DB headers Authorization
+ String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth")
+ utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled)
+
+ def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey"))
+ execution.setVariable("BasicAuthHeaderValueDB",encodedString)
+ } catch (IOException ex) {
+ String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage()
+ utils.log("DEBUG", dataErrorMessage, isDebugLogEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
}
- }
-
- public void updateDBStatusToSuccessPayload (Execution execution){
- def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
+
try {
String payload = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://com.att.mso/requestsdb">
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb">
<soapenv:Header/>
<soapenv:Body>
<req:updateStatus>
public void setUpdateDBstatustoSuccessPayload (Execution execution){
- def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
+ def method = getClass().getSimpleName() + '.setUpdateDBstatustoSuccessPayload(' +'execution=' + execution.getId() +')'
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
logDebug('Entered ' + method, isDebugLogEnabled)
+
+ try {
+ String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth")
+ utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled)
+
+ def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey"))
+ execution.setVariable("BasicAuthHeaderValueDB",encodedString)
+ } catch (IOException ex) {
+ String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage()
+ utils.log("DEBUG", dataErrorMessage, isDebugLogEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
+ }
+
try {
def xml = execution.getVariable("CompleteMsoProcessRequest")
utils.log("DEBUG", "Incoming Instance Id Xml: " + idXml, isDebugLogEnabled)
String payload = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://com.att.mso/requestsdb">
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb">
<soapenv:Header/>
<soapenv:Body>
<req:updateInfraRequest>
logDebug('Exited ' + method, isDebugLogEnabled)
}
- public String updateFinalNotifyAckStatusPayload (Execution execution){
-
- def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
- try {
- String payload = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://com.att.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <req:updateResponseStatus>
- <requestId>${execution.getVariable("CMSO_request_id")}</requestId>
- <lastModifiedBy>BPEL</lastModifiedBy>
- <responseStatus>SENDING_FINAL_NOTIFY</responseStatus>
- </req:updateResponseStatus>
- </soapenv:Body>
- </soapenv:Envelope>
- """
- execution.setVariable("CMSO_setUpdateFinalNotifyAckStatusPayload", payload)
- utils.logAudit("updateFinalNotifyAckStatusPayload: " + payload)
- logDebug('Exited ' + method, isDebugLogEnabled)
-
- return execution.getVariable("CMSO_setUpdateFinalNotifyAckStatusPayload")
-
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
- }
-
- }
-
- // public void decryptMsoPassword (Execution execution) {
- //
- // def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
- // def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- // logDebug('Entered ' + method, isDebugLogEnabled)
- // try {
- // def encryptedPwd=execution.getVariable("URN_mso_csi_pwd")
- // def msoKey = execution.getVariable("URN_mso_msoKey")
- //
- // String basicAuthValue = utils.getBasicAuth(encryptedPwd, msoKey)
- // execution.setVariable("BasicAuthHeaderValueCSI",basicAuthValue)
- // logDebug('Exited ' + method, isDebugLogEnabled)
- // } catch (BpmnError e) {
- // throw e;
- // } catch (IOException e) {
- // logError('Caught exception in ' + method, e)
- // workflowException(execution, 'Internal Error', 2000)
- // }
- // }
-
- public String notifyOMXSuccessFailureViaCSIPayload (Execution execution) {
-
- return "";
- }
-
- public String notifyCCDSuccessPayload (Execution execution) {
-
- def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
- try {
-
- String payload ="""
- <ns:status-notification xmlns:ns="http://ecomp.att.com/mso/statusnotification/schema/v1" xmlns:msoservtypes="http://ecomp.att.com/mso/request/types/v1">
- <msoservtypes:request-id>${execution.getVariable("CMSO_request_id")}</msoservtypes:request-id>
- <msoservtypes:request-action>${execution.getVariable("CMSO_request_action")}</msoservtypes:request-action>
- <msoservtypes:source>${execution.getVariable("CMSO_source")}</msoservtypes:source>
- <msoservtypes:ack-final-indicator>Y</msoservtypes:ack-final-indicator>
- </ns:status-notification>
- """
- execution.setVariable("CMSO_notifyCCDSuccessPayload", payload)
- utils.logAudit("notifyCCDSuccessPayload: " + payload)
- logDebug('Exited ' + method, isDebugLogEnabled)
-
- return execution.getVariable("CMSO_notifyCCDSuccessPayload")
-
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method)
- }
-
-
- }
-
public void buildDataError (Execution execution, String message) {
- def method = getClass().getSimpleName() + '.sendResponse(' +'execution=' + execution.getId() +')'
+ def method = getClass().getSimpleName() + '.buildDataError(' +'execution=' + execution.getId() +')'
def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
logDebug('Entered ' + method, isDebugLogEnabled)
try {
def msoCompletionResponse = """
- <sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://ecomp.att.com/mso/workflow/schema/v1">
+ <sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1">
<sdncadapterworkflow:out>BPEL ${execution.getVariable("CMSO_mso-bpel-name")} FAILED</sdncadapterworkflow:out>
</sdncadapterworkflow:MsoCompletionResponse>
""".trim()