-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - MSO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.mso.bpmn.common.scripts;
-
-import java.text.SimpleDateFormat
-
-import org.camunda.bpm.engine.runtime.Execution
-import org.openecomp.mso.bpmn.core.WorkflowException
-
-
-// SDNC Adapter Request/Response processing
-
-public class SDNCAdapter extends AbstractServiceTaskProcessor {
-
- def Prefix="SDNCA_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- // Script Task: Process SDNC Workflow Request
- // Params: Workflow Execution
- // Assume: Received SDNCAdapterWorkflowRequest is in variable 'sdncAdapterWorkflowRequest'
- // Put created SDNCAdapterRequest in variable 'sdncAdapterRequest'
- public void preProcessRequest (Execution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- try{
-
- utils.log("DEBUG", "=========== Begin PreProcess SDNCAdapterRequestScript ===========", isDebugEnabled)
- utils.log("DEBUG", "Incoming sdncAdapterWorkflowRequest:\n" + execution.getVariable("sdncAdapterWorkflowRequest"), isDebugEnabled)
-
- // Initialize some variables used throughout the flow
- execution.setVariable("prefix", Prefix)
- execution.setVariable("sdncAdapterResponse", "")
- execution.setVariable("asynchronousResponseTimeout", false)
- execution.setVariable("continueListening", false)
- execution.setVariable("SDNCA_SuccessIndicator", false)
-
- // Authorization Info
- String basicAuthValue = execution.getVariable("URN_mso_adapters_po_auth")
- utils.log("DEBUG", "Obtained BasicAuth userid password for sdnc adapter:" + basicAuthValue, isDebugEnabled)
- try {
- def encodedString = utils.getBasicAuth(basicAuthValue, execution.getVariable("URN_mso_msoKey"))
- execution.setVariable("BasicAuthHeaderValue",encodedString)
- } catch (IOException ex) {
- utils.log("ERROR", "Unable to encode username password string")
- }
-
- // TODO Use variables instead of passing xml request - Huh?
-
- // Get original RequestHeader
- def sdncwfreq= execution.getVariable("sdncAdapterWorkflowRequest")
- def requestHeader = utils.getNodeXml(sdncwfreq, "RequestHeader")
- requestHeader = requestHeader.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "")
- utils.log("DEBUG", "RequestHeader:\n" + requestHeader, isDebugEnabled)
-
- // Set Callback URL to use from URN Mapping or jBoss Property
- def origCallbackUrl = utils.getNodeText(requestHeader, "CallbackUrl")
- def callbackUrlToUse = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
- MsoUtils msoUtil = new MsoUtils()
- def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host")
- if((useQualifiedHostName!=null) && (useQualifiedHostName.equals("true"))){
- callbackUrlToUse = msoUtil.getQualifiedHostNameForCallback(callbackUrlToUse)
- }
- utils.log("DEBUG", "Callback URL to use:\n" + callbackUrlToUse, isDebugEnabled)
- requestHeader = requestHeader.replace(origCallbackUrl, callbackUrlToUse)
-
- // Get parameters from request header
- def sdnca_svcInstanceId = utils.getNodeText1(requestHeader, "SvcInstanceId") // optional
- utils.log("DEBUG", "SvcInstanceId: " + sdnca_svcInstanceId, isDebugEnabled)
- def sdnca_msoAction = utils.getNodeText1(requestHeader, "MsoAction") // optional
- utils.log("DEBUG", "MsoAction: " + sdnca_msoAction, isDebugEnabled)
- def sdnca_svcAction = utils.getNodeText(requestHeader, "SvcAction")
- utils.log("DEBUG", "SvcAction: " + sdnca_svcAction, isDebugEnabled)
- def sdnca_svcOperation = utils.getNodeText(requestHeader, "SvcOperation")
- utils.log("DEBUG", "SvcOperation: " + sdnca_svcOperation, isDebugEnabled)
- def sdncRequestData = utils.getChildNodes(sdncwfreq, "SDNCRequestData")
- sdncRequestData = sdncRequestData.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "")
- sdncRequestData = sdncRequestData.replaceAll('tag0:', '').replaceAll(':tag0', '')
- utils.log("DEBUG", "SDNCRequestData:\n" + sdncRequestData, isDebugEnabled)
- def sdnca_serviceType = ""
- if (utils.nodeExists(sdncwfreq, "service-type")) {
- sdnca_serviceType = utils.getNodeText(sdncwfreq, "service-type")
- }
- utils.log("DEBUG", "service-type: " + sdnca_serviceType, isDebugEnabled)
- def serviceConfigActivate = false
- def source = ''
- if ((sdnca_svcAction == 'activate') && (sdnca_svcOperation == 'service-configuration-operation') && (sdnca_serviceType == 'uCPE-VMS')) {
- serviceConfigActivate = true
- if (utils.nodeExists(sdncwfreq, 'source')) {
- source = utils.getNodeText(sdncwfreq, 'source')
- }
- }
- execution.setVariable("serviceConfigActivate", serviceConfigActivate)
- utils.log("DEBUG", "serviceConfigActivate: " + serviceConfigActivate, isDebugEnabled)
- execution.setVariable("source", source)
- utils.log("DEBUG", "source: " + source, isDebugEnabled)
-
- //calling process should pass a generated uuid if sending multiple sdnc requests
- def requestId = utils.getNodeText(requestHeader, "RequestId")
- execution.setVariable(Prefix + "requestId", requestId)
-
- // Prepare SDNC Request to the SDNC Adapter
- String sdncAdapterRequest = """
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
- <SOAP-ENV:Body>
- <aetgt:SDNCAdapterRequest xmlns:aetgt="http://org.openecomp/workflow/sdnc/adapter/schema/v1" xmlns:sdncadaptersc="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
- <sdncadapter:RequestHeader xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
- <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>"""
-
- if (sdnca_svcInstanceId != null) {
- sdncAdapterRequest += """
- <sdncadapter:SvcInstanceId>${sdnca_svcInstanceId}</sdncadapter:SvcInstanceId>"""
- }
-
- sdncAdapterRequest += """
- <sdncadapter:SvcAction>${sdnca_svcAction}</sdncadapter:SvcAction>
- <sdncadapter:SvcOperation>${sdnca_svcOperation}</sdncadapter:SvcOperation>
- <sdncadapter:CallbackUrl>${callbackUrlToUse}</sdncadapter:CallbackUrl>"""
-
- if (sdnca_msoAction != null) {
- sdncAdapterRequest += """
- <sdncadapter:MsoAction>${sdnca_msoAction}</sdncadapter:MsoAction>"""
- }
-
- sdncAdapterRequest += """
- </sdncadapter:RequestHeader>
- <sdncadaptersc:RequestData>${sdncRequestData}</sdncadaptersc:RequestData></aetgt:SDNCAdapterRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>"""
-
- utils.logAudit("Outgoing SDNCAdapterRequest:\n" + sdncAdapterRequest)
- execution.setVariable("sdncAdapterRequest", sdncAdapterRequest)
-
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * OPENECOMP - MSO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.mso.bpmn.common.scripts;\r
+\r
+import java.text.SimpleDateFormat\r
+\r
+import org.camunda.bpm.engine.runtime.Execution\r
+import org.openecomp.mso.bpmn.core.WorkflowException\r
+\r
+\r
+// SDNC Adapter Request/Response processing\r
+\r
+public class SDNCAdapter extends AbstractServiceTaskProcessor {\r
+\r
+ def Prefix="SDNCA_"\r
+ ExceptionUtil exceptionUtil = new ExceptionUtil()\r
+\r
+ // Script Task: Process SDNC Workflow Request\r
+ // Params: Workflow Execution\r
+ // Assume: Received SDNCAdapterWorkflowRequest is in variable 'sdncAdapterWorkflowRequest'\r
+ // Put created SDNCAdapterRequest in variable 'sdncAdapterRequest'\r
+ public void preProcessRequest (Execution execution) {\r
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+ try{\r
+\r
+ utils.log("DEBUG", "=========== Begin PreProcess SDNCAdapterRequestScript ===========", isDebugEnabled)\r
+ utils.log("DEBUG", "Incoming sdncAdapterWorkflowRequest:\n" + execution.getVariable("sdncAdapterWorkflowRequest"), isDebugEnabled)\r
+\r
+ // Initialize some variables used throughout the flow\r
+ execution.setVariable("prefix", Prefix)\r
+ execution.setVariable("sdncAdapterResponse", "")\r
+ execution.setVariable("asynchronousResponseTimeout", false)\r
+ execution.setVariable("continueListening", false)\r
+ execution.setVariable("SDNCA_SuccessIndicator", false)\r
+\r
+ // Authorization Info\r
+ String basicAuthValue = execution.getVariable("URN_mso_adapters_po_auth")\r
+ utils.log("DEBUG", "Obtained BasicAuth userid password for sdnc adapter:" + basicAuthValue, isDebugEnabled)\r
+ try {\r
+ def encodedString = utils.getBasicAuth(basicAuthValue, execution.getVariable("URN_mso_msoKey"))\r
+ execution.setVariable("BasicAuthHeaderValue",encodedString)\r
+ } catch (IOException ex) {\r
+ utils.log("ERROR", "Unable to encode username password string")\r
+ }\r
+\r
+ // TODO Use variables instead of passing xml request - Huh?\r
+\r
+ // Get original RequestHeader\r
+ def sdncwfreq= execution.getVariable("sdncAdapterWorkflowRequest")\r
+ def requestHeader = utils.getNodeXml(sdncwfreq, "RequestHeader")\r
+ requestHeader = requestHeader.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "")\r
+ utils.log("DEBUG", "RequestHeader:\n" + requestHeader, isDebugEnabled)\r
+\r
+ // Set Callback URL to use from URN Mapping or jBoss Property\r
+ def origCallbackUrl = utils.getNodeText(requestHeader, "CallbackUrl")\r
+ def callbackUrlToUse = execution.getVariable("URN_mso_workflow_sdncadapter_callback")\r
+ MsoUtils msoUtil = new MsoUtils()\r
+ def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host")\r
+ if((useQualifiedHostName!=null) && (useQualifiedHostName.equals("true"))){\r
+ callbackUrlToUse = msoUtil.getQualifiedHostNameForCallback(callbackUrlToUse)\r
+ }\r
+ utils.log("DEBUG", "Callback URL to use:\n" + callbackUrlToUse, isDebugEnabled)\r
+ requestHeader = requestHeader.replace(origCallbackUrl, callbackUrlToUse)\r
+\r
+ // Get parameters from request header\r
+ def sdnca_svcInstanceId = utils.getNodeText1(requestHeader, "SvcInstanceId") // optional\r
+ utils.log("DEBUG", "SvcInstanceId: " + sdnca_svcInstanceId, isDebugEnabled)\r
+ def sdnca_msoAction = utils.getNodeText1(requestHeader, "MsoAction") // optional\r
+ utils.log("DEBUG", "MsoAction: " + sdnca_msoAction, isDebugEnabled)\r
+ def sdnca_svcAction = utils.getNodeText(requestHeader, "SvcAction")\r
+ utils.log("DEBUG", "SvcAction: " + sdnca_svcAction, isDebugEnabled)\r
+ def sdnca_svcOperation = utils.getNodeText(requestHeader, "SvcOperation")\r
+ utils.log("DEBUG", "SvcOperation: " + sdnca_svcOperation, isDebugEnabled)\r
+ def sdncRequestData = utils.getChildNodes(sdncwfreq, "SDNCRequestData")\r
+ sdncRequestData = sdncRequestData.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "")\r
+ sdncRequestData = sdncRequestData.replaceAll('tag0:', '').replaceAll(':tag0', '')\r
+ utils.log("DEBUG", "SDNCRequestData:\n" + sdncRequestData, isDebugEnabled)\r
+ def sdnca_serviceType = ""\r
+ if (utils.nodeExists(sdncwfreq, "service-type")) {\r
+ sdnca_serviceType = utils.getNodeText(sdncwfreq, "service-type")\r
+ }\r
+ utils.log("DEBUG", "service-type: " + sdnca_serviceType, isDebugEnabled)\r
+ def serviceConfigActivate = false\r
+ def source = ''\r
+ if ((sdnca_svcAction == 'activate') && (sdnca_svcOperation == 'service-configuration-operation') && (sdnca_serviceType == 'uCPE-VMS')) {\r
+ serviceConfigActivate = true\r
+ if (utils.nodeExists(sdncwfreq, 'source')) {\r
+ source = utils.getNodeText(sdncwfreq, 'source')\r
+ }\r
+ }\r
+ execution.setVariable("serviceConfigActivate", serviceConfigActivate)\r
+ utils.log("DEBUG", "serviceConfigActivate: " + serviceConfigActivate, isDebugEnabled)\r
+ execution.setVariable("source", source)\r
+ utils.log("DEBUG", "source: " + source, isDebugEnabled)\r
+\r
+ //calling process should pass a generated uuid if sending multiple sdnc requests\r
+ def requestId = utils.getNodeText(requestHeader, "RequestId")\r
+ execution.setVariable(Prefix + "requestId", requestId)\r
+\r
+ // Prepare SDNC Request to the SDNC Adapter\r
+ String sdncAdapterRequest = """\r
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">\r
+ <SOAP-ENV:Body>\r
+ <aetgt:SDNCAdapterRequest xmlns:aetgt="http://org.openecomp/workflow/sdnc/adapter/schema/v1" xmlns:sdncadaptersc="http://org.openecomp/workflow/sdnc/adapter/schema/v1">\r
+ <sdncadapter:RequestHeader xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">\r
+ <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>"""\r
+\r
+ if (sdnca_svcInstanceId != null) {\r
+ sdncAdapterRequest += """\r
+ <sdncadapter:SvcInstanceId>${sdnca_svcInstanceId}</sdncadapter:SvcInstanceId>"""\r
+ }\r
+\r
+ sdncAdapterRequest += """\r
+ <sdncadapter:SvcAction>${sdnca_svcAction}</sdncadapter:SvcAction>\r
+ <sdncadapter:SvcOperation>${sdnca_svcOperation}</sdncadapter:SvcOperation>\r
+ <sdncadapter:CallbackUrl>${callbackUrlToUse}</sdncadapter:CallbackUrl>"""\r
+\r
+ if (sdnca_msoAction != null) {\r
+ sdncAdapterRequest += """\r
+ <sdncadapter:MsoAction>${sdnca_msoAction}</sdncadapter:MsoAction>"""\r
+ }\r
+\r
+ sdncAdapterRequest += """\r
+ </sdncadapter:RequestHeader>\r
+ <sdncadaptersc:RequestData>${sdncRequestData}</sdncadaptersc:RequestData></aetgt:SDNCAdapterRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>"""\r
+\r
+ utils.logAudit("Outgoing SDNCAdapterRequest:\n" + sdncAdapterRequest)\r
+ execution.setVariable("sdncAdapterRequest", sdncAdapterRequest)\r
+\r
utils.log("DEBUG", execution.getVariable("sdncAdapterRequest"), isDebugEnabled)
utils.log("DEBUG", execution.getVariable("URN_mso_adapters_sdnc_endpoint"), isDebugEnabled)
- }catch(Exception e){
- utils.log("DEBUG", 'Internal Error occured during PreProcess Method: ' + e, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 9999, 'Internal Error occured during PreProcess Method') // TODO: what message and error code?
- }
- utils.log("DEBUG","=========== End pre Process SDNCRequestScript ===========", isDebugEnabled)
- }
-
- public void postProcessResponse (Execution execution) {
-
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- try{
- utils.log("DEBUG","=========== Begin POSTProcess SDNCAdapter ===========", isDebugEnabled)
- utils.log("DEBUG","Incoming sdncAdapterCallbackRequest:\n" + execution.getVariable("sdncAdapterCallbackRequest"), isDebugEnabled)
-
- // Check the sdnccallback request and get the responsecode
- def sdnccallbackreq = execution.getVariable("sdncAdapterCallbackRequest")
- def callbackRequestData = ""
- def callbackHeader = ""
- utils.logAudit("SDNCAdapterCallback Request :" + sdnccallbackreq)
-
- if(sdnccallbackreq != null){
- callbackHeader = utils.getNodeXml(sdnccallbackreq, "CallbackHeader")
- callbackRequestData = utils.getNodeXml(sdnccallbackreq, "RequestData")
-
- callbackHeader = callbackHeader.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "")
- utils.log("DEBUG","SDNCCallbackHeader is:\n" + callbackHeader, isDebugEnabled)
-
- callbackRequestData = callbackRequestData.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "")
- utils.log("DEBUG","DECODED SDNCCallback RequestData is:\n" + callbackRequestData, isDebugEnabled)
-
- String sdncAdapterWorkflowResponse ="""
+ }catch(Exception e){\r
+ utils.log("DEBUG", 'Internal Error occured during PreProcess Method: ' + e, isDebugEnabled)\r
+ exceptionUtil.buildAndThrowWorkflowException(execution, 9999, 'Internal Error occured during PreProcess Method') // TODO: what message and error code?\r
+ }\r
+ utils.log("DEBUG","=========== End pre Process SDNCRequestScript ===========", isDebugEnabled)\r
+ }\r
+\r
+ public void postProcessResponse (Execution execution) {\r
+\r
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+ try{\r
+ utils.log("DEBUG","=========== Begin POSTProcess SDNCAdapter ===========", isDebugEnabled)\r
+ utils.log("DEBUG","Incoming sdncAdapterCallbackRequest:\n" + execution.getVariable("sdncAdapterCallbackRequest"), isDebugEnabled)\r
+\r
+ // Check the sdnccallback request and get the responsecode\r
+ def sdnccallbackreq = execution.getVariable("sdncAdapterCallbackRequest")\r
+ def callbackRequestData = ""\r
+ def callbackHeader = ""\r
+ utils.logAudit("SDNCAdapterCallback Request :" + sdnccallbackreq)\r
+ \r
+ if(sdnccallbackreq != null){\r
+ callbackHeader = utils.getNodeXml(sdnccallbackreq, "CallbackHeader")\r
+ callbackRequestData = utils.getNodeXml(sdnccallbackreq, "RequestData")\r
+\r
+ callbackHeader = callbackHeader.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "")\r
+ utils.log("DEBUG","SDNCCallbackHeader is:\n" + callbackHeader, isDebugEnabled)\r
+\r
+ callbackRequestData = callbackRequestData.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "")\r
+ utils.log("DEBUG","DECODED SDNCCallback RequestData is:\n" + callbackRequestData, isDebugEnabled)\r
+\r
+ String sdncAdapterWorkflowResponse ="""\r
<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1">
- <sdncadapterworkflow:response-data>
- ${callbackHeader}
- ${callbackRequestData}
- </sdncadapterworkflow:response-data>
- </sdncadapterworkflow:SDNCAdapterWorkflowResponse>"""
-
-
- utils.log("DEBUG","Outgoing sdncAdapterWorkflowResponse:\n" + sdncAdapterWorkflowResponse, isDebugEnabled)
- sdncAdapterWorkflowResponse = utils.formatXml(sdncAdapterWorkflowResponse)
- utils.logAudit("sdncAdapterWorkflowResponse :" + sdncAdapterWorkflowResponse)
- execution.setVariable("sdncAdapterResponse", sdncAdapterWorkflowResponse)
- // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead
- execution.setVariable("WorkflowResponse", sdncAdapterWorkflowResponse)
-
- // Check final indicator to determine if we are to continue listening or not
- def String enhancedCallbackRequestData = callbackRequestData.replaceAll("&", "&")
- enhancedCallbackRequestData = enhancedCallbackRequestData.replaceAll("<", "<")
- enhancedCallbackRequestData = enhancedCallbackRequestData.replaceAll(">", ">")
- // replace the data with '&' (ex: subscriber-name= 'FOUR SEASONS HEATING & COOLING'
- enhancedCallbackRequestData = enhancedCallbackRequestData.replace("&", "&")
- utils.log("DEBUG","EnhancedCallbackRequestData:\n" + enhancedCallbackRequestData, isDebugEnabled)
- execution.setVariable("enhancedCallbackRequestData", enhancedCallbackRequestData)
- def continueListening = false
- if (utils.nodeExists(enhancedCallbackRequestData, "ack-final-indicator")) {
- if (utils.getNodeText(enhancedCallbackRequestData, "ack-final-indicator") == 'N') {
- continueListening = true
- }
- }
- execution.setVariable("continueListening", continueListening)
- utils.log("DEBUG", "Continue Listening: " + continueListening, isDebugEnabled)
- }else{
- // Timed out waiting for asynchronous message, build error response
- exceptionUtil.buildWorkflowException(execution, 500, "SDNC Callback Timeout Error")
- execution.setVariable("asynchronousResponseTimeout", true)
- utils.log("DEBUG", "Timed out waiting for asynchronous message", isDebugEnabled)
- }
- }catch(Exception e){
- utils.log("DEBUG", 'Internal Error occured during PostProcess Method: ' + e, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 9999, 'Internal Error occured during PostProcess Method') // TODO: what message and error code?
- }
- utils.log("DEBUG","=========== End POSTProcess SDNCAdapter ===========", isDebugEnabled)
- }
-
- public void callbackResponsecheck(Execution execution){
-
- def sdnccallbackreq=execution.getVariable("sdncAdapterCallbackRequest")
- utils.logAudit("sdncAdapterCallbackRequest :" + sdnccallbackreq)
- if (sdnccallbackreq==null){
- execution.setVariable("callbackResponseReceived",false);
- }else{
- execution.setVariable("callbackResponseReceived",true);
- }
- }
-
- public void resetCallbackRequest(Execution execution) {
-
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
-
- utils.log("DEBUG","=========== Begin Reset Callback Info SDNCAdapter ===========", isDebugEnabled)
-
- // Clear sdncAdapterCallbackRequest variable
- execution.removeVariable("sdncAdapterCallbackRequest")
-
- // Determine and set SDNC Timeout Value
- def enhancedCallbackRequestData = execution.getVariable("enhancedCallbackRequestData")
- utils.logAudit("sdncAdapter - enhancedCallbackRequestData :" + enhancedCallbackRequestData)
- def interim = false
- if (enhancedCallbackRequestData != null) {
- if (utils.nodeExists(enhancedCallbackRequestData, "ack-final-indicator")) {
- if (utils.getNodeText(enhancedCallbackRequestData, "ack-final-indicator") == 'N') {
- interim = true
- }
- }
- }
- def timeoutValue = execution.getVariable("URN_mso_sdnc_timeout")
- def sdncAdapterWorkflowRequest = execution.getVariable("sdncAdapterWorkflowRequest")
- if (interim && utils.nodeExists(sdncAdapterWorkflowRequest, "InterimSDNCTimeOutValueInHours")) {
- timeoutValue = "PT" + utils.getNodeText(sdncAdapterWorkflowRequest, "InterimSDNCTimeOutValueInHours") + "H"
- } else if (utils.nodeExists(sdncAdapterWorkflowRequest, "SDNCTimeOutValueInMinutes")) {
- timeoutValue = "PT" + utils.getNodeText(sdncAdapterWorkflowRequest, "SDNCTimeOutValueInMinutes") + "M"
- }
- execution.setVariable("sdncTimeoutValue", timeoutValue)
- utils.log("DEBUG", "Setting SDNC Timeout Value to " + timeoutValue, isDebugEnabled)
-
- utils.log("DEBUG","=========== End Reset Callback Info SDNCAdapter ===========", isDebugEnabled)
- }
-
-
- public void prepareDBMessage(Execution execution) {
-
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
-
- utils.log("DEBUG","=========== Begin Prepare DB Message SDNCAdapter ===========", isDebugEnabled)
-
- // Create DB Message
- def dbRequestId = execution.getVariable("mso-request-id")
- String dbUpdateInterimStageCompletion = """
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
- <SOAP-ENV:Body>
- <DBAdapter:updateInterimStageCompletion xmlns:DBAdapter="http://org.openecomp.mso/requestsdb">
- <requestId>${dbRequestId}</requestId>
- <interimStageCompletion>1</interimStageCompletion>
- <lastModifiedBy>BPEL</lastModifiedBy>
- </DBAdapter:updateInterimStageCompletion>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>
- """
-
- execution.setVariable("dbUpdateInterimStageCompletion", dbUpdateInterimStageCompletion)
- utils.logAudit("sdncAdapter - dbUpdateInterimStageCompletion :" + dbUpdateInterimStageCompletion)
- utils.log("DEBUG","DB UpdateInterimStageCompletion:\n" + dbUpdateInterimStageCompletion, isDebugEnabled)
- utils.log("DEBUG","=========== End Prepare DB Message SDNCAdapter ===========", isDebugEnabled)
- }
-
-
-
- public String generateCurrentTimeInUtc(){
- final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
- sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
- final String utcTime = sdf.format(new Date());
- return utcTime;
- }
-
- public void toggleSuccessIndicator(Execution execution){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- execution.setVariable("SDNCA_SuccessIndicator", true)
- utils.log("DEBUG","Setting SDNCA Success Indicator to True", isDebugEnabled)
- }
-
- public void assignError(Execution execution){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG","=========== Started Assign Error ===========", isDebugEnabled)
- WorkflowException wf = execution.getVariable("WorkflowException")
- if(wf == null){
- exceptionUtil.buildWorkflowException(execution, 5000, "SDNCAdapter Encountered an Internal Error") // TODO: Not sure what message and error code we want here.....
- }else{
- execution.setVariable("WorkflowException", wf)
- }
-
- utils.log("DEBUG","Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"), isDebugEnabled)
- utils.log("DEBUG","=========== End Assign Error ===========", isDebugEnabled)
- }
-
-}
-
+ <sdncadapterworkflow:response-data>\r
+ ${callbackHeader}\r
+ ${callbackRequestData}\r
+ </sdncadapterworkflow:response-data>\r
+ </sdncadapterworkflow:SDNCAdapterWorkflowResponse>"""\r
+\r
+\r
+ utils.log("DEBUG","Outgoing sdncAdapterWorkflowResponse:\n" + sdncAdapterWorkflowResponse, isDebugEnabled)\r
+ sdncAdapterWorkflowResponse = utils.formatXml(sdncAdapterWorkflowResponse)\r
+ utils.logAudit("sdncAdapterWorkflowResponse :" + sdncAdapterWorkflowResponse)\r
+ execution.setVariable("sdncAdapterResponse", sdncAdapterWorkflowResponse)\r
+ // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead\r
+ execution.setVariable("WorkflowResponse", sdncAdapterWorkflowResponse)\r
+\r
+ // Check final indicator to determine if we are to continue listening or not\r
+ def String enhancedCallbackRequestData = callbackRequestData.replaceAll("&", "&")\r
+ enhancedCallbackRequestData = enhancedCallbackRequestData.replaceAll("<", "<")\r
+ enhancedCallbackRequestData = enhancedCallbackRequestData.replaceAll(">", ">")\r
+ // replace the data with '&' (ex: subscriber-name= 'FOUR SEASONS HEATING & COOLING'\r
+ enhancedCallbackRequestData = enhancedCallbackRequestData.replace("&", "&")\r
+ utils.log("DEBUG","EnhancedCallbackRequestData:\n" + enhancedCallbackRequestData, isDebugEnabled)\r
+ execution.setVariable("enhancedCallbackRequestData", enhancedCallbackRequestData)\r
+ def continueListening = false\r
+ if (utils.nodeExists(enhancedCallbackRequestData, "ack-final-indicator")) {\r
+ if (utils.getNodeText(enhancedCallbackRequestData, "ack-final-indicator") == 'N') {\r
+ continueListening = true\r
+ }\r
+ }\r
+ execution.setVariable("continueListening", continueListening)\r
+ utils.log("DEBUG", "Continue Listening: " + continueListening, isDebugEnabled)\r
+ execution.setVariable("asynchronousResponseTimeout", false)\r
+ }else{\r
+ // Timed out waiting for asynchronous message, build error response\r
+ exceptionUtil.buildWorkflowException(execution, 500, "SDNC Callback Timeout Error")\r
+ execution.setVariable("asynchronousResponseTimeout", true)\r
+ utils.log("DEBUG", "Timed out waiting for asynchronous message", isDebugEnabled)\r
+ }\r
+ }catch(Exception e){\r
+ utils.log("DEBUG", 'Internal Error occured during PostProcess Method: ' + e, isDebugEnabled)\r
+ exceptionUtil.buildAndThrowWorkflowException(execution, 9999, 'Internal Error occured during PostProcess Method') // TODO: what message and error code?\r
+ }\r
+ utils.log("DEBUG","=========== End POSTProcess SDNCAdapter ===========", isDebugEnabled)\r
+ }\r
+\r
+ public void callbackResponsecheck(Execution execution){\r
+\r
+ def sdnccallbackreq=execution.getVariable("sdncAdapterCallbackRequest")\r
+ utils.logAudit("sdncAdapterCallbackRequest :" + sdnccallbackreq)\r
+ if (sdnccallbackreq==null){\r
+ execution.setVariable("callbackResponseReceived",false);\r
+ }else{\r
+ execution.setVariable("callbackResponseReceived",true);\r
+ }\r
+ }\r
+\r
+ public void resetCallbackRequest(Execution execution) {\r
+\r
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+\r
+ utils.log("DEBUG","=========== Begin Reset Callback Info SDNCAdapter ===========", isDebugEnabled)\r
+\r
+ // Clear sdncAdapterCallbackRequest variable\r
+ execution.removeVariable("sdncAdapterCallbackRequest")\r
+\r
+ // Determine and set SDNC Timeout Value\r
+ def enhancedCallbackRequestData = execution.getVariable("enhancedCallbackRequestData")\r
+ utils.logAudit("sdncAdapter - enhancedCallbackRequestData :" + enhancedCallbackRequestData)\r
+ def interim = false\r
+ if (enhancedCallbackRequestData != null) {\r
+ if (utils.nodeExists(enhancedCallbackRequestData, "ack-final-indicator")) {\r
+ if (utils.getNodeText(enhancedCallbackRequestData, "ack-final-indicator") == 'N') {\r
+ interim = true\r
+ }\r
+ }\r
+ }\r
+ def timeoutValue = execution.getVariable("URN_mso_sdnc_timeout")\r
+ def sdncAdapterWorkflowRequest = execution.getVariable("sdncAdapterWorkflowRequest")\r
+ if (interim && utils.nodeExists(sdncAdapterWorkflowRequest, "InterimSDNCTimeOutValueInHours")) {\r
+ timeoutValue = "PT" + utils.getNodeText(sdncAdapterWorkflowRequest, "InterimSDNCTimeOutValueInHours") + "H"\r
+ } else if (utils.nodeExists(sdncAdapterWorkflowRequest, "SDNCTimeOutValueInMinutes")) {\r
+ timeoutValue = "PT" + utils.getNodeText(sdncAdapterWorkflowRequest, "SDNCTimeOutValueInMinutes") + "M"\r
+ }\r
+ execution.setVariable("sdncTimeoutValue", timeoutValue)\r
+ utils.log("DEBUG", "Setting SDNC Timeout Value to " + timeoutValue, isDebugEnabled)\r
+\r
+ utils.log("DEBUG","=========== End Reset Callback Info SDNCAdapter ===========", isDebugEnabled)\r
+ }\r
+\r
+\r
+ public void prepareDBMessage(Execution execution) {\r
+\r
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+\r
+ utils.log("DEBUG","=========== Begin Prepare DB Message SDNCAdapter ===========", isDebugEnabled)\r
+\r
+ // Create DB Message\r
+ def dbRequestId = execution.getVariable("mso-request-id")\r
+ String dbUpdateInterimStageCompletion = """\r
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">\r
+ <SOAP-ENV:Body>\r
+ <DBAdapter:updateInterimStageCompletion xmlns:DBAdapter="http://org.openecomp.mso/requestsdb">\r
+ <requestId>${dbRequestId}</requestId>\r
+ <interimStageCompletion>1</interimStageCompletion>\r
+ <lastModifiedBy>BPEL</lastModifiedBy>\r
+ </DBAdapter:updateInterimStageCompletion>\r
+ </SOAP-ENV:Body>\r
+ </SOAP-ENV:Envelope>\r
+ """\r
+\r
+ execution.setVariable("dbUpdateInterimStageCompletion", dbUpdateInterimStageCompletion)\r
+ utils.logAudit("sdncAdapter - dbUpdateInterimStageCompletion :" + dbUpdateInterimStageCompletion)\r
+ utils.log("DEBUG","DB UpdateInterimStageCompletion:\n" + dbUpdateInterimStageCompletion, isDebugEnabled)\r
+ utils.log("DEBUG","=========== End Prepare DB Message SDNCAdapter ===========", isDebugEnabled)\r
+ }\r
+\r
+ public String generateCurrentTimeInUtc(){\r
+ final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");\r
+ sdf.setTimeZone(TimeZone.getTimeZone("UTC"));\r
+ final String utcTime = sdf.format(new Date());\r
+ return utcTime;\r
+ }\r
+\r
+ public void toggleSuccessIndicator(Execution execution){\r
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+ execution.setVariable("SDNCA_SuccessIndicator", true)\r
+ utils.log("DEBUG","Setting SDNCA Success Indicator to True", isDebugEnabled)\r
+ }\r
+\r
+ public void assignError(Execution execution){\r
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+ utils.log("DEBUG","=========== Started Assign Error ===========", isDebugEnabled)\r
+ WorkflowException wf = execution.getVariable("WorkflowException")\r
+ if(wf == null){\r
+ exceptionUtil.buildWorkflowException(execution, 5000, "SDNCAdapter Encountered an Internal Error") // TODO: Not sure what message and error code we want here.....\r
+ }else{\r
+ execution.setVariable("WorkflowException", wf)\r
+ }\r
+\r
+ utils.log("DEBUG","Outgoing WorkflowException is: " + execution.getVariable("WorkflowException"), isDebugEnabled)\r
+ utils.log("DEBUG","=========== End Assign Error ===========", isDebugEnabled)\r
+ }\r
+ \r
+ public void setTimeout(Execution execution){\r
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+ utils.log("DEBUG","=========== Started SetTimeout ===========", isDebugEnabled)\r
+ utils.log("DEBUG", "Timer expired, telling correlation service to stop listening", isDebugEnabled)\r
+ execution.setVariable("asynchronousResponseTimeout", true)\r
+ \r
+ utils.log("DEBUG", "Timed out branch sleeping for one second to give success branch a chance to complete if running", isDebugEnabled)\r
+ Thread.sleep(1000)\r
+ utils.log("DEBUG","=========== End SetTimeout ===========", isDebugEnabled)\r
+ }\r
+}\r