* ============LICENSE_END=========================================================
*/
-package com.att.bpm.scripts;
+package org.openecomp.mso.bpmn.common.scripts;
-import javax.xml.transform.Transformer
-import javax.xml.transform.TransformerException;
+import groovy.json.JsonSlurper
import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.impl.core.variable.value.ObjectValueImpl
import org.camunda.bpm.engine.runtime.Execution
import org.camunda.bpm.engine.variable.VariableMap
-
-
-
+import org.camunda.bpm.engine.variable.Variables
+import org.camunda.bpm.engine.variable.Variables.SerializationDataFormats
+import org.camunda.bpm.engine.variable.impl.value.ObjectValueImpl
+import org.openecomp.mso.bpmn.common.workflow.service.WorkflowCallbackResponse
+import org.openecomp.mso.bpmn.common.workflow.service.WorkflowContextHolder
import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.bpmn.gamma.workflow.service.WorkflowCallbackResponse
-import org.openecomp.mso.bpmn.gamma.workflow.service.WorkflowContextHolder
-
-import groovy.json.JsonSlurper
-
-import org.openecomp.mso.rest.APIResponse;
-import org.openecomp.mso.rest.RESTClient
-import org.openecomp.mso.rest.RESTConfig
-
-import org.camunda.bpm.engine.variable.VariableMap;
-import org.camunda.bpm.engine.variable.Variables;
-import org.camunda.bpm.engine.variable.Variables.SerializationDataFormats;
-import org.w3c.dom.Node;
+import org.springframework.web.util.UriUtils
public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcessor {
public MsoUtils utils = new MsoUtils()
def encErrorMessage = errorMessage.replace("&", "&").replace("<", "<").replace(">", ">")
def content = """
- <aetgt:WorkflowException xmlns:aetgt="http://ecomp.att.com/mso/workflow/schema/v1">
+ <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
<aetgt:ErrorMessage>${encErrorMessage}</aetgt:ErrorMessage>
<aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode>
</aetgt:WorkflowException>
/**
- * Validates that the request exists and that the att-mso-request-id variable is set.
+ * Validates that the request exists and that the mso-request-id variable is set.
* Additional required variables may be checked by specifying their names.
- * NOTE: services requiring att-mso-service-instance-id must specify it explicitly!
+ * NOTE: services requiring mso-service-instance-id must specify it explicitly!
* If a problem is found, buildAndThrowWorkflowException builds a WorkflowException
* and throws an MSOWorkflowException. This method also sets up the log context for
* the workflow.
String serviceInstanceId = null
List<String> allRequiredVariables = new ArrayList<String>()
- allRequiredVariables.add("att-mso-request-id")
+ allRequiredVariables.add("mso-request-id")
if (requiredVariables != null) {
for (String variable : requiredVariables) {
" request was received with no '" + variable + "' variable")
}
- if ("att-mso-request-id".equals(variable)) {
+ if ("mso-request-id".equals(variable)) {
requestId = (String) value
- } else if ("att-mso-service-instance-id".equals(variable)) {
+ } else if ("mso-service-instance-id".equals(variable)) {
serviceInstanceId = (String) value
}
}
if (serviceInstanceId == null) {
- serviceInstanceId = (String) execution.getVariable("att-mso-service-instance-id")
+ serviceInstanceId = (String) execution.getVariable("mso-service-instance-id")
}
utils.logContext(requestId, serviceInstanceId)
String processKey = getProcessKey(execution);
def prefix = execution.getVariable("prefix")
- def requestId =getVariable(execution, "att-mso-request-id")
- def serviceInstanceId = getVariable(execution, "att-mso-service-instance-id")
+ def requestId =getVariable(execution, "mso-request-id")
+ def serviceInstanceId = getVariable(execution, "mso-service-instance-id")
if(requestId!=null && serviceInstanceId!=null){
utils.logContext(requestId, serviceInstanceId)
}
WorkflowContextHolder.getInstance().processCallback(
processKey,
execution.getProcessInstanceId(),
- execution.getVariable("att-mso-request-id"),
+ execution.getVariable("mso-request-id"),
callbackResponse)
execution.setVariable(processKey + "WorkflowResponseSent", "true");
}
/**
- * Returns the process definition key (i.e. the process name) from the
- * execution.
+ * Returns the process definition key (i.e. the process name) of the
+ * current process.
+ *
* @param execution the execution
*/
public String getProcessKey(Execution execution) {
.getProcessDefinition(execution.getProcessDefinitionId()).getKey()
}
+ /**
+ * Returns the process definition key (i.e. the process name) of the
+ * top-level process.
+ * @param execution the execution
+ */
+ public String getMainProcessKey(Execution execution) {
+ Execution exec = execution
+
+ while (true) {
+ Execution parent = exec.getSuperExecution()
+
+ if (parent == null) {
+ parent = exec.getParent()
+
+ if (parent == null) {
+ break
+ }
+ }
+
+ exec = parent
+ }
+
+ return execution.getProcessEngineServices().getRepositoryService()
+ .getProcessDefinition(exec.getProcessDefinitionId()).getKey()
+ }
+
/**
* Gets the node for the named element from the given xml. If the element
* does not exist in the xml or is empty, a WorkflowException is created
public void sendSyncError(Execution execution) {
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- String requestId = execution.getVariable("att-mso-request-id")
+ String requestId = execution.getVariable("mso-request-id")
logDebug('sendSyncError, requestId: ' + requestId, isDebugEnabled)
WorkflowException workflowExceptionObj = execution.getVariable("WorkflowException")
if (workflowExceptionObj != null) {
}
}
}
+
+ /**
+ *This method determines and adds the appropriate ending to come
+ *after a number (-st, -nd, -rd, or -th)
+ *
+ *@param int n
+ *
+ *@return String ending - number with suffix
+ */
+
+ public static String labelMaker(Object n) {
+ Integer num
+ if(n instanceof String){
+ num = Integer.parseInt(n)
+ }else{
+ num = n
+ }
+
+ String ending = ""; //the end to be added to the number
+ if(num != null){
+ if ((num % 10 == 1) && (num != 11)) {
+ ending = num + "st";
+ } else if ((num % 10 == 2) && (num != 12)) {
+ ending = num + "nd";
+ } else if ((num % 10 == 3) && (num != 13)) {
+ ending = num + "rd";
+ } else {
+ ending = num + "th";
+ }
+ }
+ return ending
+ }
+
+ /**
+ *
+ *This method gets and decodes SDNC Response's "RequestData".
+ *
+ *@param response - the sdnc response
+ *
+ *@return data - the response "RequestData" decoded
+ *
+ */
+ public String getRequestDataDecoded(String response){
+ String data = utils.getNodeText1(response, "RequestData")
+ if(data != null){
+ data = data.replaceAll("<", "<")
+ data = data.replaceAll(">", ">")
+ }
+
+ return data
+ }
+
+
+ /**
+ * Constructs a workflow message callback URL for the specified message type and correlator.
+ * @param messageType the message type (e.g. SDNCAResponse or VNFAResponse)
+ * @param correlator the correlator value (e.g. a request ID)
+ */
+ public String createCallbackURL(Execution execution, String messageType, String correlator) {
+ String endpoint = (String) execution.getVariable('URN_mso_workflow_message_endpoint')
+
+ if (endpoint == null || endpoint.isEmpty()) {
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2000,
+ 'mso:workflow:message:endpoint URN mapping is not set')
+ }
+
+ while (endpoint.endsWith('/')) {
+ endpoint = endpoint.substring(0, endpoint.length()-1)
+ }
+
+ return endpoint +
+ '/' + UriUtils.encodePathSegment(messageType, 'UTF-8') +
+ '/' + UriUtils.encodePathSegment(correlator, 'UTF-8')
+ }
}