diff options
Diffstat (limited to 'bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java')
-rw-r--r-- | bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java | 510 |
1 files changed, 255 insertions, 255 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java index 3eed14bc30..296ab64df3 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java @@ -32,7 +32,6 @@ 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; @@ -53,8 +52,6 @@ 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; @@ -72,256 +69,259 @@ import org.springframework.stereotype.Component; @Component public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { - @Autowired - private LoggingParseListener loggingParseListener; - - @Override - public void preInit( - ProcessEngineConfigurationImpl processEngineConfiguration) { - List<BpmnParseListener> preParseListeners = processEngineConfiguration - .getCustomPreBPMNParseListeners(); - if (preParseListeners == null) { - preParseListeners = new ArrayList<>(); - processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners); - } - preParseListeners.add(loggingParseListener); - } - - /** - * Called when a process flow is parsed so we can inject listeners. - */ - @Component - public class LoggingParseListener extends AbstractBpmnParseListener { - - - private void injectLogExecutionListener(ActivityImpl activity) { - activity.addListener( - ExecutionListener.EVENTNAME_END, - new LoggingExecutionListener("END")); - - activity.addListener( - ExecutionListener.EVENTNAME_START, - new LoggingExecutionListener("START")); - - activity.addListener( - ExecutionListener.EVENTNAME_TAKE, - new LoggingExecutionListener("TAKE")); - } - - @Override - public void parseProcess(Element processElement, ProcessDefinitionEntity processDefinition) { - } - - @Override - public void parseStartEvent(Element startEventElement, ScopeImpl scope, ActivityImpl startEventActivity) { - // Inject these listeners only on the main start event for the flow, not on any embedded subflow start events - - injectLogExecutionListener(startEventActivity); - } - - @Override - public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseExclusiveGateway(Element exclusiveGwElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseInclusiveGateway(Element inclusiveGwElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseParallelGateway(Element parallelGwElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseScriptTask(Element scriptTaskElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseBusinessRuleTask(Element businessRuleTaskElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseTask(Element taskElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseManualTask(Element manualTaskElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseEndEvent(Element endEventElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseBoundaryTimerEventDefinition(Element timerEventDefinition, boolean interrupting, ActivityImpl timerActivity) { - injectLogExecutionListener(timerActivity); - } - - @Override - public void parseBoundaryErrorEventDefinition(Element errorEventDefinition, boolean interrupting, ActivityImpl activity, ActivityImpl nestedErrorEventActivity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseSubProcess(Element subProcessElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseCallActivity(Element callActivityElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseProperty(Element propertyElement, VariableDeclaration variableDeclaration, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) { - //injectLogExecutionListener(activity); - } - - @Override - public void parseSendTask(Element sendTaskElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseMultiInstanceLoopCharacteristics(Element activityElement, Element multiInstanceLoopCharacteristicsElement, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseIntermediateTimerEventDefinition(Element timerEventDefinition, ActivityImpl timerActivity) { - injectLogExecutionListener(timerActivity); - } - - @Override - public void parseRootElement(Element rootElement, List<ProcessDefinitionEntity> processDefinitions) { - - } - - @Override - public void parseReceiveTask(Element receiveTaskElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseIntermediateSignalCatchEventDefinition(Element signalEventDefinition, ActivityImpl signalActivity) { - injectLogExecutionListener(signalActivity); - } - - @Override - public void parseBoundarySignalEventDefinition(Element signalEventDefinition, boolean interrupting, ActivityImpl signalActivity) { - injectLogExecutionListener(signalActivity); - } - - @Override - public void parseEventBasedGateway(Element eventBasedGwElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseTransaction(Element transactionElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseCompensateEventDefinition(Element compensateEventDefinition, ActivityImpl compensationActivity) { - injectLogExecutionListener(compensationActivity); - } - - @Override - public void parseIntermediateThrowEvent(Element intermediateEventElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseIntermediateCatchEvent(Element intermediateEventElement, ScopeImpl scope, ActivityImpl activity) { - injectLogExecutionListener(activity); - } - - @Override - public void parseBoundaryEvent(Element boundaryEventElement, ScopeImpl scopeElement, ActivityImpl nestedActivity) { - injectLogExecutionListener(nestedActivity); - } - - @Override - public void parseIntermediateMessageCatchEventDefinition(Element messageEventDefinition, ActivityImpl nestedActivity) { - injectLogExecutionListener(nestedActivity); - } - - @Override - public void parseBoundaryMessageEventDefinition(Element element, boolean interrupting, ActivityImpl messageActivity) { - injectLogExecutionListener(messageActivity); - } - } - - /** - * Logs details about the current activity. - */ - public class LoggingExecutionListener implements ExecutionListener { - private final Logger logger = LoggerFactory.getLogger(LoggingExecutionListener.class); - - private String event; - - public LoggingExecutionListener() { - this.event = ""; - } - - public LoggingExecutionListener(String event) { - this.event = event; - } - - public String getEvent() { - return event; - } - - @Override - public void notify(DelegateExecution execution) throws Exception { - //required for legacy groovy processing in camunda - execution.setVariable("isDebugLogEnabled", "true"); - if (!isBlank(execution.getCurrentActivityName())) { - try { - - String id = execution.getId(); - if (id != null ) { - RepositoryService repositoryService = execution.getProcessEngineServices().getRepositoryService(); - String processName = repositoryService.createProcessDefinitionQuery() - .processDefinitionId(execution.getProcessDefinitionId()) - .singleResult() - .getName(); - - - String requestId = (String) execution.getVariable("mso-request-id"); - String svcid = (String) execution.getVariable("mso-service-instance-id"); - } - } catch(Exception e) { - logger.error("Exception occurred", e); - } - } - } - - private boolean isBlank(Object object) { - return object == null || "".equals(object.toString().trim()); - } - } + @Autowired + private LoggingParseListener loggingParseListener; + + @Override + public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) { + List<BpmnParseListener> preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners(); + if (preParseListeners == null) { + preParseListeners = new ArrayList<>(); + processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners); + } + preParseListeners.add(loggingParseListener); + } + + /** + * Called when a process flow is parsed so we can inject listeners. + */ + @Component + public class LoggingParseListener extends AbstractBpmnParseListener { + + + private void injectLogExecutionListener(ActivityImpl activity) { + activity.addListener(ExecutionListener.EVENTNAME_END, new LoggingExecutionListener("END")); + + activity.addListener(ExecutionListener.EVENTNAME_START, new LoggingExecutionListener("START")); + + activity.addListener(ExecutionListener.EVENTNAME_TAKE, new LoggingExecutionListener("TAKE")); + } + + @Override + public void parseProcess(Element processElement, ProcessDefinitionEntity processDefinition) {} + + @Override + public void parseStartEvent(Element startEventElement, ScopeImpl scope, ActivityImpl startEventActivity) { + // Inject these listeners only on the main start event for the flow, not on any embedded subflow start + // events + + injectLogExecutionListener(startEventActivity); + } + + @Override + public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseExclusiveGateway(Element exclusiveGwElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseInclusiveGateway(Element inclusiveGwElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseParallelGateway(Element parallelGwElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseScriptTask(Element scriptTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseBusinessRuleTask(Element businessRuleTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseTask(Element taskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseManualTask(Element manualTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseEndEvent(Element endEventElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseBoundaryTimerEventDefinition(Element timerEventDefinition, boolean interrupting, + ActivityImpl timerActivity) { + injectLogExecutionListener(timerActivity); + } + + @Override + public void parseBoundaryErrorEventDefinition(Element errorEventDefinition, boolean interrupting, + ActivityImpl activity, ActivityImpl nestedErrorEventActivity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseSubProcess(Element subProcessElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseCallActivity(Element callActivityElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseProperty(Element propertyElement, VariableDeclaration variableDeclaration, + ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) { + // injectLogExecutionListener(activity); + } + + @Override + public void parseSendTask(Element sendTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseMultiInstanceLoopCharacteristics(Element activityElement, + Element multiInstanceLoopCharacteristicsElement, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseIntermediateTimerEventDefinition(Element timerEventDefinition, ActivityImpl timerActivity) { + injectLogExecutionListener(timerActivity); + } + + @Override + public void parseRootElement(Element rootElement, List<ProcessDefinitionEntity> processDefinitions) { + + } + + @Override + public void parseReceiveTask(Element receiveTaskElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseIntermediateSignalCatchEventDefinition(Element signalEventDefinition, + ActivityImpl signalActivity) { + injectLogExecutionListener(signalActivity); + } + + @Override + public void parseBoundarySignalEventDefinition(Element signalEventDefinition, boolean interrupting, + ActivityImpl signalActivity) { + injectLogExecutionListener(signalActivity); + } + + @Override + public void parseEventBasedGateway(Element eventBasedGwElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseTransaction(Element transactionElement, ScopeImpl scope, ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseCompensateEventDefinition(Element compensateEventDefinition, + ActivityImpl compensationActivity) { + injectLogExecutionListener(compensationActivity); + } + + @Override + public void parseIntermediateThrowEvent(Element intermediateEventElement, ScopeImpl scope, + ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseIntermediateCatchEvent(Element intermediateEventElement, ScopeImpl scope, + ActivityImpl activity) { + injectLogExecutionListener(activity); + } + + @Override + public void parseBoundaryEvent(Element boundaryEventElement, ScopeImpl scopeElement, + ActivityImpl nestedActivity) { + injectLogExecutionListener(nestedActivity); + } + + @Override + public void parseIntermediateMessageCatchEventDefinition(Element messageEventDefinition, + ActivityImpl nestedActivity) { + injectLogExecutionListener(nestedActivity); + } + + @Override + public void parseBoundaryMessageEventDefinition(Element element, boolean interrupting, + ActivityImpl messageActivity) { + injectLogExecutionListener(messageActivity); + } + } + + /** + * Logs details about the current activity. + */ + public class LoggingExecutionListener implements ExecutionListener { + private final Logger logger = LoggerFactory.getLogger(LoggingExecutionListener.class); + + private String event; + + public LoggingExecutionListener() { + this.event = ""; + } + + public LoggingExecutionListener(String event) { + this.event = event; + } + + public String getEvent() { + return event; + } + + @Override + public void notify(DelegateExecution execution) throws Exception { + // required for legacy groovy processing in camunda + execution.setVariable("isDebugLogEnabled", "true"); + if (!isBlank(execution.getCurrentActivityName())) { + try { + + String id = execution.getId(); + if (id != null) { + RepositoryService repositoryService = + execution.getProcessEngineServices().getRepositoryService(); + String processName = repositoryService.createProcessDefinitionQuery() + .processDefinitionId(execution.getProcessDefinitionId()).singleResult().getName(); + + + String requestId = (String) execution.getVariable("mso-request-id"); + String svcid = (String) execution.getVariable("mso-service-instance-id"); + } + } catch (Exception e) { + logger.error("Exception occurred", e); + } + } + } + + private boolean isBlank(Object object) { + return object == null || "".equals(object.toString().trim()); + } + } } |