Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / mso-infrastructure-bpmn / src / main / java / org / onap / so / bpmn / common / workflow / service / WorkflowProcessor.java
index b106296..4e9e9fd 100644 (file)
@@ -26,7 +26,6 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
 import java.util.UUID;
-
 import org.camunda.bpm.engine.RuntimeService;
 import org.camunda.bpm.engine.runtime.ProcessInstance;
 import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
@@ -39,65 +38,64 @@ import org.springframework.stereotype.Service;
 
 @Service
 public class WorkflowProcessor extends ProcessEngineAwareService {
-       
-       private static final Logger logger = LoggerFactory.getLogger(WorkflowProcessor.class);
-       protected static final String logMarker = "[WRKFLOW-RESOURCE]";
-       
-       @Async
-       public void startProcess( String processKey, VariableMapImpl variableMap)
-       {
-               
-               long startTime = System.currentTimeMillis();
-               Map<String, Object> inputVariables = null;
-               String processInstanceId = null;
-               try {
-                       inputVariables = getInputVariables(variableMap);
-                       // This variable indicates that the flow was invoked asynchronously
-                       inputVariables.put("isAsyncProcess", "true");
 
-                       // Note: this creates a random businessKey if it wasn't specified.
-                       String businessKey = getBusinessKey(inputVariables);
+    private static final Logger logger = LoggerFactory.getLogger(WorkflowProcessor.class);
+    protected static final String logMarker = "[WRKFLOW-RESOURCE]";
+
+    @Async
+    public void startProcess(String processKey, VariableMapImpl variableMap) {
+
+        long startTime = System.currentTimeMillis();
+        Map<String, Object> inputVariables = null;
+        String processInstanceId = null;
+        try {
+            inputVariables = getInputVariables(variableMap);
+            // This variable indicates that the flow was invoked asynchronously
+            inputVariables.put("isAsyncProcess", "true");
 
-                       logger.debug("***Received MSO startProcessInstanceByKey with processKey: {} and variables: {}", processKey,
-                               inputVariables);
+            // Note: this creates a random businessKey if it wasn't specified.
+            String businessKey = getBusinessKey(inputVariables);
 
-                       RuntimeService runtimeService = getProcessEngineServices().getRuntimeService();
-                       ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processKey, businessKey,
-                                       inputVariables);
-                       processInstanceId = processInstance.getId();
+            logger.debug("***Received MSO startProcessInstanceByKey with processKey: {} and variables: {}", processKey,
+                    inputVariables);
 
-                       logger.debug(logMarker + "Process " + processKey + ":" + processInstanceId + " "
-                                       + (processInstance.isEnded() ? "ENDED" : "RUNNING"));
-               } catch (Exception e) {
-                       WorkflowResponse workflowResponse = new WorkflowResponse();
-                       workflowResponse.setResponse("Error occurred while executing the process: " + e);
-                       workflowResponse.setProcessInstanceID(processInstanceId);
-                       workflowResponse.setMessageCode(500);
-                       workflowResponse.setMessage("Fail");
-                       throw new WorkflowProcessorException(workflowResponse);
-               }
-       }
+            RuntimeService runtimeService = getProcessEngineServices().getRuntimeService();
+            ProcessInstance processInstance =
+                    runtimeService.startProcessInstanceByKey(processKey, businessKey, inputVariables);
+            processInstanceId = processInstance.getId();
+
+            logger.debug(logMarker + "Process " + processKey + ":" + processInstanceId + " "
+                    + (processInstance.isEnded() ? "ENDED" : "RUNNING"));
+        } catch (Exception e) {
+            WorkflowResponse workflowResponse = new WorkflowResponse();
+            workflowResponse.setResponse("Error occurred while executing the process: " + e);
+            workflowResponse.setProcessInstanceID(processInstanceId);
+            workflowResponse.setMessageCode(500);
+            workflowResponse.setMessage("Fail");
+            throw new WorkflowProcessorException(workflowResponse);
+        }
+    }
 
-       // Note: the business key is used to identify the process in unit tests
-       protected static String getBusinessKey(Map<String, Object> inputVariables) {
+    // Note: the business key is used to identify the process in unit tests
+    protected static String getBusinessKey(Map<String, Object> inputVariables) {
         return getOrCreate(inputVariables, "mso-business-key");
-       }
+    }
+
+
+    protected static Map<String, Object> getInputVariables(VariableMapImpl variableMap) {
+        Map<String, Object> inputVariables = new HashMap<>();
+        @SuppressWarnings("unchecked")
+        Map<String, Object> vMap = (Map<String, Object>) variableMap.get("variables");
+        for (Map.Entry<String, Object> entry : vMap.entrySet()) {
+            String vName = entry.getKey();
+            Object value = entry.getValue();
+            @SuppressWarnings("unchecked")
+            Map<String, Object> valueMap = (Map<String, Object>) value; // value, type
+            inputVariables.put(vName, valueMap.get("value"));
+        }
+        return inputVariables;
+    }
 
-       
-       protected static Map<String, Object> getInputVariables(VariableMapImpl variableMap) {
-               Map<String, Object> inputVariables = new HashMap<>();
-               @SuppressWarnings("unchecked")
-               Map<String, Object> vMap = (Map<String, Object>) variableMap.get("variables");
-               for (Map.Entry<String, Object> entry : vMap.entrySet()) {
-                       String vName = entry.getKey();
-                       Object value = entry.getValue();
-                       @SuppressWarnings("unchecked")
-                       Map<String, Object> valueMap = (Map<String,Object>)value; // value, type
-                       inputVariables.put(vName, valueMap.get("value"));
-               }
-               return inputVariables;
-       }
-       
     protected static String getOrCreate(Map<String, Object> inputVariables, String key) {
         String value = Objects.toString(inputVariables.get(key), null);
         if (value == null) {