package org.onap.so.bpmn.infrastructure.scripts
-import com.fasterxml.jackson.databind.ObjectMapper
import groovy.json.JsonSlurper
import org.json.JSONObject
import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.so.beans.nsmf.JobStatusRequest
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.core.json.JsonUtils
try{
String requestId = execution.getVariable("msoRequestId")
logger.debug("RequestId :" + requestId)
- String jobId = execution.getVariable("jobId")
+ String responseId = execution.getVariable("responseId")
+ String jobId = execution.getVariable("jobId")
def jsonSlurper = new JsonSlurper()
HashMap<String,?> esrInfo = jsonSlurper.parseText(execution.getVariable("esrInfo"))
HashMap<String,?> serviceInfo = jsonSlurper.parseText(execution.getVariable("serviceInfo"))
logger.debug("serviceInfo" + serviceInfo.toString())
-
+
execution.setVariable("esrInfo", esrInfo)
execution.setVariable("serviceInfo", serviceInfo)
String endPoint = String.format("/api/rest/provMns/v1/NSS/jobs/%s", jobId)
String url = nssmfEndpoint + endPoint
execution.setVariable("NSSMF_AdapterEndpoint", url)
-
+
String payload = """
{
+ "responseId": "${responseId}",
"esrInfo": ${execution.getVariable("esrInfo") as JSONObject},
"serviceInfo": ${execution.getVariable("serviceInfo") as JSONObject}
}
execution.setVariable("NSSMF_AdapterRequest", payload.replaceAll("\\s+", ""))
execution.setVariable("startTime", System.currentTimeMillis())
logger.debug("Outgoing NSSMF_AdapterRequest: \n" + payload)
- }catch(Exception e){
+ }catch(Exception ex){
String msg = "Exception in QueryJobStatus.preProcessRequest " + ex.getMessage()
logger.error(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
responseDescriptorMap.put("statusDescription","Exception while querying job status")
String responseDescriptor = """
{
- "responseDescriptor": "${responseDescriptorMap}",
+ "responseDescriptor": "${responseDescriptorMap as JSONObject}"
}
"""
execution.setVariable("JobStatusCompleted", "TRUE")
responseDescriptorMap.put("statusDescription","timeout")
String responseDescriptor = """
{
- "responseDescriptor": "${responseDescriptorMap}",
+ "responseDescriptor": ${responseDescriptorMap as JSONObject}
}
"""
execution.setVariable("JobStatusCompleted", "TRUE")