Sonar fixes and improvements 88/89488/3
authorr.bogacki <r.bogacki@samsung.com>
Thu, 6 Jun 2019 08:32:49 +0000 (10:32 +0200)
committerRobert Bogacki <r.bogacki@samsung.com>
Mon, 10 Jun 2019 07:15:04 +0000 (07:15 +0000)
General fixes and improvements according to the Sonar analysis.
-Fixed imports.
-Removed unnecessary variables.
-Added String constants.

Issue-ID: SO-1992
Signed-off-by: Robert Bogacki <r.bogacki@samsung.com>
Change-Id: I8b77def931e703c8a73929ec09324823a91721e3

bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java
bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/WorkflowExceptionPlugin.java
bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java

index 296ab64..251464a 100644 (file)
 
 package org.onap.so.bpmn.core.plugins;
 
-import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
 import org.camunda.bpm.engine.RepositoryService;
 import org.camunda.bpm.engine.delegate.DelegateExecution;
 import org.camunda.bpm.engine.delegate.ExecutionListener;
@@ -39,26 +31,15 @@ import org.camunda.bpm.engine.impl.bpmn.parser.AbstractBpmnParseListener;
 import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener;
 import org.camunda.bpm.engine.impl.cfg.AbstractProcessEnginePlugin;
 import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
-import org.camunda.bpm.engine.impl.context.Context;
-import org.camunda.bpm.engine.impl.interceptor.Command;
-import org.camunda.bpm.engine.impl.interceptor.CommandContext;
 import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity;
 import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl;
 import org.camunda.bpm.engine.impl.pvm.process.ScopeImpl;
 import org.camunda.bpm.engine.impl.pvm.process.TransitionImpl;
 import org.camunda.bpm.engine.impl.util.xml.Element;
 import org.camunda.bpm.engine.impl.variable.VariableDeclaration;
-import org.camunda.bpm.model.bpmn.impl.instance.FlowNodeImpl;
-import org.camunda.bpm.model.bpmn.instance.EndEvent;
-import org.camunda.bpm.model.bpmn.instance.FlowNode;
-import org.camunda.bpm.model.bpmn.instance.StartEvent;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.AbstractEnvironment;
-import org.springframework.core.env.Environment;
-import org.springframework.core.env.MapPropertySource;
-import org.springframework.core.env.PropertySource;
 import org.springframework.stereotype.Component;
 
 
index ab21c08..42c6ef0 100644 (file)
@@ -32,7 +32,6 @@ import org.camunda.bpm.engine.delegate.JavaDelegate;
 import org.camunda.bpm.engine.impl.bpmn.behavior.ClassDelegateActivityBehavior;
 import org.camunda.bpm.engine.impl.bpmn.parser.AbstractBpmnParseListener;
 import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener;
-import org.camunda.bpm.engine.impl.bpmn.parser.FieldDeclaration;
 import org.camunda.bpm.engine.impl.cfg.AbstractProcessEnginePlugin;
 import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
 import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity;
@@ -58,6 +57,8 @@ import org.slf4j.LoggerFactory;
 public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin {
     private static final Logger logger = LoggerFactory.getLogger(WorkflowExceptionPlugin.class);
 
+    private static final String WORKFLOW_EXCEPTION = "WorkflowException";
+
     @Override
     public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
         List<BpmnParseListener> preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners();
@@ -131,7 +132,7 @@ public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin {
      */
     public static class WorkflowExceptionResetListener implements ExecutionListener {
         public void notify(DelegateExecution execution) throws Exception {
-            Object workflowException = execution.getVariable("WorkflowException");
+            Object workflowException = execution.getVariable(WORKFLOW_EXCEPTION);
 
             if (workflowException instanceof WorkflowException) {
                 int index = 1;
@@ -140,10 +141,10 @@ public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin {
                     saveName = "SavedWorkflowException" + (++index);
                 }
 
-                logger.debug("WorkflowExceptionResetTask is moving WorkflowException to " + saveName);
+                logger.debug("WorkflowExceptionResetTask is moving WorkflowException to {}", saveName);
 
                 execution.setVariable(saveName, workflowException);
-                execution.setVariable("WorkflowException", null);
+                execution.setVariable(WORKFLOW_EXCEPTION, null);
             }
         }
     }
@@ -153,7 +154,7 @@ public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin {
      */
     public static class WorkflowExceptionTriggerTask implements JavaDelegate {
         public void execute(DelegateExecution execution) throws Exception {
-            if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
+            if (execution.getVariable(WORKFLOW_EXCEPTION) instanceof WorkflowException) {
                 logger.debug("WorkflowExceptionTriggerTask is generating a MSOWorkflowException event");
                 throw new BpmnError("MSOWorkflowException");
             }
index 2aa433b..5aae165 100644 (file)
@@ -124,7 +124,7 @@ public class MSOInfrastructureApplication {
         logger.debug("Attempting to deploy custom workflows");
         try {
             List<Workflow> workflows = catalogDbClient.findWorkflowBySource(SDC_SOURCE);
-            if (workflows != null && workflows.size() != 0) {
+            if (workflows != null && !workflows.isEmpty()) {
                 for (Workflow workflow : workflows) {
                     String workflowName = workflow.getName();
                     String workflowBody = workflow.getBody();