diff --git a/pom.xml b/pom.xml
index d3842f60..a791d3eb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -183,18 +183,10 @@
ca.mcgill.sable
soot
- 3.0.0-SNAPSHOT
+ 3.2.0
-
-
- soot-snapshot
- soot snapshots
- https://soot-build.cs.uni-paderborn.de/nexus/repository/soot-snapshot/
-
-
-
release-sign-artifacts
@@ -342,7 +334,7 @@
org.owasp
dependency-check-maven
- 3.3.4
+ 4.0.2
owasp-dependency-check-suppressions.xml
diff --git a/src/main/java/de/viadee/bpm/vPAV/BpmnScanner.java b/src/main/java/de/viadee/bpm/vPAV/BpmnScanner.java
index bb2f0a71..fd807f09 100644
--- a/src/main/java/de/viadee/bpm/vPAV/BpmnScanner.java
+++ b/src/main/java/de/viadee/bpm/vPAV/BpmnScanner.java
@@ -31,23 +31,17 @@
*/
package de.viadee.bpm.vPAV;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
+import de.viadee.bpm.vPAV.constants.BpmnConstants;
+import org.w3c.dom.*;
+import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-import de.viadee.bpm.vPAV.constants.BpmnConstants;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
public class BpmnScanner {
diff --git a/src/main/java/de/viadee/bpm/vPAV/FileScanner.java b/src/main/java/de/viadee/bpm/vPAV/FileScanner.java
index afa82569..972354c6 100644
--- a/src/main/java/de/viadee/bpm/vPAV/FileScanner.java
+++ b/src/main/java/de/viadee/bpm/vPAV/FileScanner.java
@@ -31,22 +31,11 @@
*/
package de.viadee.bpm.vPAV;
-import java.io.File;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
+import de.viadee.bpm.vPAV.config.model.Rule;
+import de.viadee.bpm.vPAV.config.model.Setting;
+import de.viadee.bpm.vPAV.constants.ConfigConstants;
+import de.viadee.bpm.vPAV.processing.ConfigItemNotFoundException;
+import de.viadee.bpm.vPAV.processing.checker.VersioningChecker;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.DirectoryFileFilter;
import org.apache.commons.io.filefilter.TrueFileFilter;
@@ -60,11 +49,14 @@
import org.camunda.bpm.model.dmn.DmnModelInstance;
import org.camunda.bpm.model.dmn.instance.Decision;
-import de.viadee.bpm.vPAV.config.model.Rule;
-import de.viadee.bpm.vPAV.config.model.Setting;
-import de.viadee.bpm.vPAV.constants.ConfigConstants;
-import de.viadee.bpm.vPAV.processing.ConfigItemNotFoundException;
-import de.viadee.bpm.vPAV.processing.checker.VersioningChecker;
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* scans maven project for files, which are necessary for the later analysis
diff --git a/src/main/java/de/viadee/bpm/vPAV/OuterProcessVariablesScanner.java b/src/main/java/de/viadee/bpm/vPAV/OuterProcessVariablesScanner.java
deleted file mode 100644
index 715ce0dc..00000000
--- a/src/main/java/de/viadee/bpm/vPAV/OuterProcessVariablesScanner.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/**
- * BSD 3-Clause License
- *
- * Copyright © 2018, viadee Unternehmensberatung AG
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of the copyright holder nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package de.viadee.bpm.vPAV;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.tools.ant.DirectoryScanner;
-import org.apache.tools.ant.types.Resource;
-
-import de.viadee.bpm.vPAV.constants.ConfigConstants;
-import groovyjarjarasm.asm.ClassReader;
-import groovyjarjarasm.asm.ClassVisitor;
-import groovyjarjarasm.asm.FieldVisitor;
-import groovyjarjarasm.asm.Opcodes;
-
-/**
- * scan process variables, which are set in outer java classes
- *
- */
-public class OuterProcessVariablesScanner {
-
- private Set javaResources;
-
- private Map> messageIdToVariableMap = new HashMap>();
-
- private Map> processIdToVariableMap = new HashMap>();
-
- private Collection initialProcessVariables = new ArrayList();
-
- private Collection initialProcessVariablesLocation = new ArrayList();
-
- public OuterProcessVariablesScanner(final Set javaResources) {
- this.javaResources = javaResources;
- }
-
- /**
- * scan variables
- *
- * @throws IOException
- * possible exception if filepath can not be resolved
- */
- public void scanProcessVariables() throws IOException {
- for (final String filePath : javaResources) {
- if (!filePath.startsWith("javax")) {
- final String content = readResourceFile(filePath);
- if (content != null) {
- final Collection initialProcessVariablesInFilePath = readVariablesOfInnerClassInitialProcessVariables(
- filePath);
- if (!initialProcessVariablesInFilePath.isEmpty()) {
- initialProcessVariables.addAll(initialProcessVariablesInFilePath);
- initialProcessVariablesLocation.add(filePath);
- // if correlateMessage and startProcessInstanceByMessage called
- // together in one class take the intersection to avoid duplicates
- final Set messageIds = new HashSet();
- messageIds.addAll(checkStartProcessByMessageIdPattern(content));
- messageIds.addAll(checkStartProcessByMessageAndProcessDefinitionId(content));
- messageIds.addAll(checkCorrelateMessagePattern(content));
- for (final String messageId : messageIds) {
- if (messageIdToVariableMap.containsKey(messageId)) {
- // if messageId is already set, create intersection of variables and overwrite map
- // item
- final Collection existingProcessVariables = messageIdToVariableMap
- .get(messageId);
- final List intersectionProcessVariables = existingProcessVariables.stream()
- .filter(initialProcessVariablesInFilePath::contains)
- .collect(Collectors.toList());
-
- messageIdToVariableMap.put(messageId, intersectionProcessVariables);
- } else {
- messageIdToVariableMap.put(messageId, initialProcessVariablesInFilePath);
- }
- }
-
- final Set processIds = new HashSet();
- processIds.addAll(checkStartProcessByKeyPattern(content));
- processIds.addAll(checkStartProcessByIdPattern(content));
-
- for (final String processId : processIds) {
- processIdToVariableMap.put(processId, initialProcessVariablesInFilePath);
- }
- }
- }
- }
- }
- }
-
-
- /**
- * get list of locations where initial process variables have been found
- *
- * @return returns list of locations
- */
- public Collection getInitialProcessVariablesLocation() {
- return initialProcessVariablesLocation;
- }
-
-
- /**
- * get mapping for message id
- *
- * @return messageIdToVariableMap returns messageIdToVariableMap
- */
- public Map> getMessageIdToVariableMap() {
- return messageIdToVariableMap;
- }
-
- /**
- * get mapping for process id
- *
- * @return processIdToVariableMap returns processIdToVariableMap
- */
- public Map> getProcessIdToVariableMap() {
- return processIdToVariableMap;
- }
-
- /**
- * read resource file
- *
- * @param filePath
- * path of the file
- * @return methodBody returns methodBody
- */
- private String readResourceFile(final String filePath) {
- String methodBody = "";
-
- if (filePath != null && filePath.trim().length() > 0) {
- try {
- final DirectoryScanner scanner = new DirectoryScanner();
-
- if (RuntimeConfig.getInstance().isTest()) {
- scanner.setBasedir(ConfigConstants.TEST_JAVAPATH);
- } else {
- scanner.setBasedir(ConfigConstants.JAVAPATH);
- }
-
- Resource s = scanner.getResource(filePath);
-
- if (s.isExists()) {
-
- InputStreamReader resource = new InputStreamReader(new FileInputStream(s.toString()));
-
- methodBody = IOUtils.toString(resource);
-
- } else {
-
- }
- } catch (final IOException ex) {
- throw new RuntimeException(
- "resource '" + filePath + "' could not be read: " + ex.getMessage());
- }
-
- }
-
- return methodBody;
-
- }
-
- /**
- * check pattern for startProcessInstanceByMessage
- *
- * @param code
- * @return message ids
- */
- private Collection checkStartProcessByMessageIdPattern(final String code) {
-
- // remove special characters from code
- final String FILTER_PATTERN = "'|\"| ";
- final String cleanedCode = code.replaceAll(FILTER_PATTERN, "");
-
- // search locations where variables are read
- final Pattern pattern = Pattern.compile("\\.(startProcessInstanceByMessage)(\\()([a-z0-9_.]+)(,.?)*(\\n?)([a-z0-9_.()])*(,?)([a-z0-9_.()])*\\)", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
- final Matcher matcher = pattern.matcher(cleanedCode);
-
- final Collection messageIds = new ArrayList();
- while (matcher.find()) {
- final String match = matcher.group(3);
- messageIds.add(match);
- }
-
- return messageIds;
- }
-
- /**
- * check pattern for startProcessInstanceById
- *
- * @param code
- * @return message ids
- */
- private Collection checkStartProcessByIdPattern(final String code) {
-
- // remove special characters from code
- final String FILTER_PATTERN = "'|\"| ";
- final String cleanedCode = code.replaceAll(FILTER_PATTERN, "");
-
- // search locations where variables are read
- final Pattern pattern = Pattern.compile("\\.(startProcessInstanceById)(\\()([a-z0-9_.]+)(,.?)*(\\n?)([a-z0-9_.()])*(,?)([a-z0-9_.()])*\\)", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
- final Matcher matcher = pattern.matcher(cleanedCode);
-
- final Collection processIds = new ArrayList();
- while (matcher.find()) {
- final String match = matcher.group(3);
- processIds.add(match);
- }
-
- return processIds;
- }
-
-
- /**
- * check pattern for startProcessInstanceByMessageAndProcessDefinitionId
- *
- * @param code
- * @return message ids
- */
- private Collection checkStartProcessByMessageAndProcessDefinitionId(final String code) {
-
- // remove special characters from code
- final String FILTER_PATTERN = "'|\"| ";
- final String cleanedCode = code.replaceAll(FILTER_PATTERN, "");
-
- // search locations where variables are read
- final Pattern pattern = Pattern.compile("\\.(startProcessInstanceByMessageAndProcessDefinitionId)(\\()([a-z0-9_.]+)(,.?)*(\\n?)([a-z0-9_.()])*(,?)([a-z0-9_.()])*\\)", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
- final Matcher matcher = pattern.matcher(cleanedCode);
-
- final Collection messageAndProcessIds = new ArrayList();
- while (matcher.find()) {
- final String match = matcher.group(3);
- messageAndProcessIds.add(match);
- }
-
- return messageAndProcessIds;
- }
-
- /**
- * check pattern for startProcessInstanceByKey
- *
- * @param code
- * @return process keys
- */
- private Collection checkStartProcessByKeyPattern(final String code) {
-
- // remove special characters from code
- final String FILTER_PATTERN = "'|\"| ";
- final String cleanedCode = code.replaceAll(FILTER_PATTERN, "");
-
- // search locations where variables are read
- final Pattern pattern = Pattern.compile("\\.(startProcessInstanceByKey)(\\()([a-z0-9_.]+)(,.?)*(\\n?)([a-z0-9_.()])*(,?)([a-z0-9_.()])*\\)", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
- final Matcher matcher = pattern.matcher(cleanedCode);
-
- final Collection processIds = new ArrayList();
- while (matcher.find()) {
- final String match = matcher.group(3);
- processIds.add(match);
- }
-
- return processIds;
- }
-
- /**
- * check pattern for correlateMessage
- *
- * @param code
- * @return message ids
- */
- private Collection checkCorrelateMessagePattern(final String code) {
-
- // remove special characters from code
- final String FILTER_PATTERN = "'|\"| ";
- final String cleanedCode = code.replaceAll(FILTER_PATTERN, "");
-
- // search locations where variables are read
- final Pattern pattern = Pattern.compile("\\.correlateMessage\\((\\w+),(.*)");
- final Matcher matcher = pattern.matcher(cleanedCode);
-
- final Collection messageIds = new ArrayList();
- while (matcher.find()) {
- final String match = matcher.group(1);
- messageIds.add(match);
- }
-
- return messageIds;
- }
-
- /**
- * For given filePath returns fields of class InitialProcessVariables (either separate or inner class). This class is used to initialize the
- * process
- *
- * @param filePath
- * @return
- * @throws IOException
- */
- private Collection readVariablesOfInnerClassInitialProcessVariables(final String filePath)
- throws IOException {
-
- final Collection processVariables = new ArrayList();
-
- if (filePath != null) {
- final String[] splittedFilePath = filePath.split("\\.");
- if (splittedFilePath.length > 0) {
- ClassVisitor cl = new ClassVisitor(Opcodes.ASM4) {
-
- @Override
- public FieldVisitor visitField(int access, String name, String desc, String signature,
- Object value) {
- if (!name.startsWith("this")) {
- processVariables.add(name);
- }
- super.visitField(access, name, desc, signature, value);
- return null;
- }
- };
-
- InputStream in = null;
- if (splittedFilePath[0].contains(ConfigConstants.INITIAL_VARIABLES)) {
- in = RuntimeConfig.getInstance().getClassLoader().getResourceAsStream(filePath.replace(".java", ".class"));
- } else {
- in = RuntimeConfig.getInstance().getClassLoader()
- .getResourceAsStream(splittedFilePath[0] + "$InitialProcessVariables.class");
- }
-
- if (in != null) {
- ClassReader classReader = new ClassReader(in);
- classReader.accept(cl, 0);
- }
- }
- }
- return processVariables;
- }
-
-
- public Collection getInitialProcessVariables() {
- return initialProcessVariables;
- }
-}
diff --git a/src/main/java/de/viadee/bpm/vPAV/ProcessApplicationValidator.java b/src/main/java/de/viadee/bpm/vPAV/ProcessApplicationValidator.java
index a600a235..43a56764 100644
--- a/src/main/java/de/viadee/bpm/vPAV/ProcessApplicationValidator.java
+++ b/src/main/java/de/viadee/bpm/vPAV/ProcessApplicationValidator.java
@@ -31,16 +31,15 @@
*/
package de.viadee.bpm.vPAV;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import de.viadee.bpm.vPAV.processing.dataflow.DataFlowRule;
-import org.springframework.context.ApplicationContext;
-
import de.viadee.bpm.vPAV.beans.BeanMappingGenerator;
import de.viadee.bpm.vPAV.constants.ConfigConstants;
+import de.viadee.bpm.vPAV.processing.dataflow.DataFlowRule;
import de.viadee.bpm.vPAV.processing.model.data.CheckerIssue;
import de.viadee.bpm.vPAV.processing.model.data.CriticalityEnum;
+import org.springframework.context.ApplicationContext;
+
+import java.util.ArrayList;
+import java.util.Collection;
public class ProcessApplicationValidator {
diff --git a/src/main/java/de/viadee/bpm/vPAV/ProcessApplicationVariableParser.java b/src/main/java/de/viadee/bpm/vPAV/ProcessApplicationVariableParser.java
index 63c88aa0..c6c30d23 100644
--- a/src/main/java/de/viadee/bpm/vPAV/ProcessApplicationVariableParser.java
+++ b/src/main/java/de/viadee/bpm/vPAV/ProcessApplicationVariableParser.java
@@ -31,25 +31,24 @@
*/
package de.viadee.bpm.vPAV;
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.camunda.bpm.model.bpmn.Bpmn;
-import org.camunda.bpm.model.bpmn.BpmnModelInstance;
-import org.camunda.bpm.model.bpmn.instance.BaseElement;
-import org.springframework.context.ApplicationContext;
-import org.xml.sax.SAXException;
-
import de.viadee.bpm.vPAV.beans.BeanMappingGenerator;
import de.viadee.bpm.vPAV.constants.ConfigConstants;
import de.viadee.bpm.vPAV.processing.BpmnModelDispatcher;
import de.viadee.bpm.vPAV.processing.ElementGraphBuilder;
+import de.viadee.bpm.vPAV.processing.ProcessVariablesScanner;
import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
import de.viadee.bpm.vPAV.processing.model.data.ProcessVariable;
+import org.camunda.bpm.model.bpmn.Bpmn;
+import org.camunda.bpm.model.bpmn.BpmnModelInstance;
+import org.camunda.bpm.model.bpmn.instance.BaseElement;
+import org.springframework.context.ApplicationContext;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
public class ProcessApplicationVariableParser {
@@ -60,7 +59,7 @@ public static Collection parseProcessVariables(File modelFile,
FileScanner fileScanner = new FileScanner(new HashMap<>(), ConfigConstants.JAVAPATH);
- OuterProcessVariablesScanner variableScanner = readOuterProcessVariables(fileScanner);
+ ProcessVariablesScanner variableScanner = readOuterProcessVariables(fileScanner);
BpmnScanner bpmnScanner = createScanner(modelFile);
final BpmnModelInstance modelInstance = Bpmn.readModelFromFile(modelFile);
@@ -86,9 +85,9 @@ public static Collection parseProcessVariables(File modelFile,
* @param fileScanner
* FileScanner
*/
- private static OuterProcessVariablesScanner readOuterProcessVariables(final FileScanner fileScanner) throws RuntimeException {
+ private static ProcessVariablesScanner readOuterProcessVariables(final FileScanner fileScanner) throws RuntimeException {
try {
- OuterProcessVariablesScanner variableScanner = new OuterProcessVariablesScanner(fileScanner.getJavaResourcesFileInputStream());
+ ProcessVariablesScanner variableScanner = new ProcessVariablesScanner(fileScanner.getJavaResourcesFileInputStream());
variableScanner.scanProcessVariables();
return variableScanner;
} catch (final IOException e) {
diff --git a/src/main/java/de/viadee/bpm/vPAV/Runner.java b/src/main/java/de/viadee/bpm/vPAV/Runner.java
index d9ddf128..3573a0b5 100644
--- a/src/main/java/de/viadee/bpm/vPAV/Runner.java
+++ b/src/main/java/de/viadee/bpm/vPAV/Runner.java
@@ -31,51 +31,36 @@
*/
package de.viadee.bpm.vPAV;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Logger;
-
import de.viadee.bpm.vPAV.config.model.Rule;
import de.viadee.bpm.vPAV.config.reader.ConfigReaderException;
import de.viadee.bpm.vPAV.config.reader.XmlConfigReader;
import de.viadee.bpm.vPAV.constants.ConfigConstants;
-import de.viadee.bpm.vPAV.output.IssueOutputWriter;
-import de.viadee.bpm.vPAV.output.JsOutputWriter;
-import de.viadee.bpm.vPAV.output.JsonOutputWriter;
-import de.viadee.bpm.vPAV.output.OutputWriterException;
-import de.viadee.bpm.vPAV.output.RuleSetOutputWriter;
-import de.viadee.bpm.vPAV.output.XmlOutputWriter;
+import de.viadee.bpm.vPAV.output.*;
import de.viadee.bpm.vPAV.processing.BpmnModelDispatcher;
import de.viadee.bpm.vPAV.processing.ConfigItemNotFoundException;
+import de.viadee.bpm.vPAV.processing.ProcessVariablesScanner;
import de.viadee.bpm.vPAV.processing.dataflow.DataFlowRule;
import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
import de.viadee.bpm.vPAV.processing.model.data.CheckerIssue;
import de.viadee.bpm.vPAV.processing.model.data.ModelDispatchResult;
import de.viadee.bpm.vPAV.processing.model.data.ProcessVariable;
+import java.io.*;
+import java.net.MalformedURLException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.*;
+import java.util.logging.Logger;
+
public class Runner {
private static Logger logger = Logger.getLogger(Runner.class.getName());
private FileScanner fileScanner;
- private OuterProcessVariablesScanner variableScanner;
+ private ProcessVariablesScanner variableScanner;
private Collection issues;
@@ -230,7 +215,7 @@ private void getProcessVariables(final Map rules) {
if (rules.get("ProcessVariablesModelChecker").isActive()
|| rules.get("ProcessVariablesNameConventionChecker").isActive()
|| rules.get("DataFlowChecker").isActive()) {
- variableScanner = new OuterProcessVariablesScanner(getFileScanner().getJavaResourcesFileInputStream());
+ variableScanner = new ProcessVariablesScanner(getFileScanner().getJavaResourcesFileInputStream());
readOuterProcessVariables(variableScanner);
setCheckProcessVariables(true);
} else {
@@ -320,10 +305,7 @@ private void createvPAVFolder() {
}
/**
- * Delete files from destinations
- *
- * @param destinations
- * List of destinations who will be deleted
+ * Delete files from validation folder
*/
private void deleteFiles() {
File index = new File(ConfigConstants.VALIDATION_FOLDER);
@@ -586,7 +568,7 @@ private FileReader createFileReader(final String filePath) {
* ConfigItem not found
*/
private Collection checkModels(final Map rules, final FileScanner fileScanner,
- final OuterProcessVariablesScanner variableScanner, Collection dataFlowRules)
+ final ProcessVariablesScanner variableScanner, Collection dataFlowRules)
throws RuntimeException {
final Collection issues = new ArrayList();
@@ -601,8 +583,6 @@ private Collection checkModels(final Map rules, fina
*
* @param rules
* all rules of ruleSet.xml
- * @param beanMapping
- * beanMapping if spring context is available
* @param processdef
* processdefintion
* @param fileScanner
@@ -612,7 +592,7 @@ private Collection checkModels(final Map rules, fina
* @return modelIssues
*/
private Collection checkModel(final Map rules, final String processdef,
- final FileScanner fileScanner, final OuterProcessVariablesScanner variableScanner,
+ final FileScanner fileScanner, final ProcessVariablesScanner variableScanner,
Collection dataFlowRules) {
BpmnModelDispatcher bpmnModelDispatcher = new BpmnModelDispatcher();
ModelDispatchResult dispatchResult;
@@ -641,7 +621,7 @@ private Collection checkModel(final Map rules, final
* @throws IOException
* Outer process variables couldn't be read
*/
- private void readOuterProcessVariables(final OuterProcessVariablesScanner scanner) throws RuntimeException {
+ private void readOuterProcessVariables(final ProcessVariablesScanner scanner) throws RuntimeException {
try {
scanner.scanProcessVariables();
} catch (final IOException e) {
diff --git a/src/main/java/de/viadee/bpm/vPAV/RuntimeConfig.java b/src/main/java/de/viadee/bpm/vPAV/RuntimeConfig.java
index 246b2e47..d9e95600 100644
--- a/src/main/java/de/viadee/bpm/vPAV/RuntimeConfig.java
+++ b/src/main/java/de/viadee/bpm/vPAV/RuntimeConfig.java
@@ -31,22 +31,17 @@
*/
package de.viadee.bpm.vPAV;
+import de.viadee.bpm.vPAV.config.model.Rule;
+import de.viadee.bpm.vPAV.config.model.Setting;
+import de.viadee.bpm.vPAV.constants.ConfigConstants;
+import org.springframework.context.ApplicationContext;
+
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
+import java.util.*;
import java.util.logging.Logger;
-import org.springframework.context.ApplicationContext;
-
-import de.viadee.bpm.vPAV.config.model.Rule;
-import de.viadee.bpm.vPAV.config.model.Setting;
-import de.viadee.bpm.vPAV.constants.ConfigConstants;
-
public class RuntimeConfig {
private static RuntimeConfig instance;
diff --git a/src/main/java/de/viadee/bpm/vPAV/beans/BeanMappingGenerator.java b/src/main/java/de/viadee/bpm/vPAV/beans/BeanMappingGenerator.java
index 3c807890..ce492930 100644
--- a/src/main/java/de/viadee/bpm/vPAV/beans/BeanMappingGenerator.java
+++ b/src/main/java/de/viadee/bpm/vPAV/beans/BeanMappingGenerator.java
@@ -31,11 +31,11 @@
*/
package de.viadee.bpm.vPAV.beans;
+import org.springframework.context.ApplicationContext;
+
import java.util.HashMap;
import java.util.Map;
-import org.springframework.context.ApplicationContext;
-
/**
* Helper methods for Maven Plugin CamundaStaticValidator
*/
diff --git a/src/main/java/de/viadee/bpm/vPAV/config/reader/ConfigReader.java b/src/main/java/de/viadee/bpm/vPAV/config/reader/ConfigReader.java
index 052ef7df..485338d9 100644
--- a/src/main/java/de/viadee/bpm/vPAV/config/reader/ConfigReader.java
+++ b/src/main/java/de/viadee/bpm/vPAV/config/reader/ConfigReader.java
@@ -1,41 +1,41 @@
-/**
- * BSD 3-Clause License
- *
- * Copyright © 2018, viadee Unternehmensberatung AG
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of the copyright holder nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package de.viadee.bpm.vPAV.config.reader;
-
-import java.util.Map;
-
-import de.viadee.bpm.vPAV.config.model.Rule;
-
-public interface ConfigReader {
-
- Map read(final String file) throws ConfigReaderException;
-}
+/**
+ * BSD 3-Clause License
+ *
+ * Copyright © 2018, viadee Unternehmensberatung AG
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package de.viadee.bpm.vPAV.config.reader;
+
+import de.viadee.bpm.vPAV.config.model.Rule;
+
+import java.util.Map;
+
+public interface ConfigReader {
+
+ Map read(final String file) throws ConfigReaderException;
+}
diff --git a/src/main/java/de/viadee/bpm/vPAV/config/reader/XmlConfigReader.java b/src/main/java/de/viadee/bpm/vPAV/config/reader/XmlConfigReader.java
index bfb19010..15cc3d06 100644
--- a/src/main/java/de/viadee/bpm/vPAV/config/reader/XmlConfigReader.java
+++ b/src/main/java/de/viadee/bpm/vPAV/config/reader/XmlConfigReader.java
@@ -1,179 +1,174 @@
-/**
- * BSD 3-Clause License
- *
- * Copyright © 2018, viadee Unternehmensberatung AG
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of the copyright holder nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package de.viadee.bpm.vPAV.config.reader;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-
-import de.viadee.bpm.vPAV.RuntimeConfig;
-import de.viadee.bpm.vPAV.config.model.ElementConvention;
-import de.viadee.bpm.vPAV.config.model.ElementFieldTypes;
-import de.viadee.bpm.vPAV.config.model.ModelConvention;
-import de.viadee.bpm.vPAV.config.model.Rule;
-import de.viadee.bpm.vPAV.config.model.Setting;
-
-/**
- * Used to read the config file (ruleSet.xml) and extract the configured rules
- * Requirements: Exisiting ruleSet.xml in src/test/resources
- */
-public final class XmlConfigReader implements ConfigReader {
-
- /**
- * @throws ConfigReaderException
- * If file can not be found in classpath
- */
- @Override
- public Map read(final String file) throws ConfigReaderException {
-
- try {
- final JAXBContext jaxbContext = JAXBContext.newInstance(XmlRuleSet.class);
- final Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
-
- InputStream fRuleSet = RuntimeConfig.getInstance().getClassLoader().getResourceAsStream(file);
-
- if (fRuleSet != null) {
- final XmlRuleSet ruleSet = (XmlRuleSet) jaxbUnmarshaller.unmarshal(fRuleSet);
- return transformFromXmlDatastructues(ruleSet);
- } else {
- throw new ConfigReaderException("ConfigFile could not be found");
- }
- } catch (JAXBException e) {
- throw new ConfigReaderException(e);
- }
- }
-
- /**
- * Retrieves all rules, by default deactivated
- *
- * @return rules
- */
- public Map getDeactivatedRuleSet() {
- final Map rules = new HashMap();
-
- for (String name : RuntimeConfig.getInstance().getViadeeRules()) {
- if (name.equals("CreateOutputHTML")) {
- rules.put(name, new Rule(name, true, null, new HashMap(),
- new ArrayList(), new ArrayList()));
- } else {
- rules.put(name, new Rule(name, false, null, new HashMap(),
- new ArrayList(), new ArrayList()));
- }
- }
-
- return rules;
- }
-
- /**
- * Transforms XmlRuleSet to rules
- *
- * @param ruleSet
- * @return rules
- * @throws ConfigReaderException
- * If file could not be read properly
- */
- private static Map transformFromXmlDatastructues(final XmlRuleSet ruleSet)
- throws ConfigReaderException {
- final Map rules = new HashMap();
-
- final Collection xmlRules = ruleSet.getRules();
- for (final XmlRule rule : xmlRules) {
- final String name = rule.getName();
- if (name == null)
- throw new ConfigReaderException("rule name is not set");
- final boolean state = rule.isState();
- final String ruleDescription = rule.getDescription();
- final Collection xmlElementConventions = rule.getElementConventions();
- final ArrayList elementConventions = new ArrayList();
- if (xmlElementConventions != null) {
- for (final XmlElementConvention xmlElementConvention : xmlElementConventions) {
- final XmlElementFieldTypes xmlElementFieldTypes = xmlElementConvention.getElementFieldTypes();
- ElementFieldTypes elementFieldTypes = null;
- if (xmlElementFieldTypes != null) {
- elementFieldTypes = new ElementFieldTypes(xmlElementFieldTypes.getElementFieldTypes(),
- xmlElementFieldTypes.isExcluded());
- }
- if (!checkRegEx(xmlElementConvention.getPattern()))
- throw new ConfigReaderException("RegEx (" + xmlElementConvention.getPattern() + ") of " + name
- + " (" + xmlElementConvention.getName() + ") is incorrect");
- elementConventions.add(new ElementConvention(xmlElementConvention.getName(), elementFieldTypes,
- xmlElementConvention.getDescription(), xmlElementConvention.getPattern()));
- }
- }
- final Collection xmlModelConventions = rule.getModelConventions();
- final ArrayList modelConventions = new ArrayList();
- if (xmlModelConventions != null) {
- for (final XmlModelConvention xmlModelConvention : xmlModelConventions) {
- modelConventions.add(new ModelConvention(xmlModelConvention.getType()));
- }
- }
- final Collection xmlSettings = rule.getSettings();
- final Map settings = new HashMap();
- if (xmlSettings != null) {
- for (final XmlSetting xmlSetting : xmlSettings) {
- if (!settings.containsKey(xmlSetting.getName())) {
- settings.put(xmlSetting.getName(),
- new Setting(xmlSetting.getName(), xmlSetting.getScript(), xmlSetting.getType(),
- xmlSetting.getId(), xmlSetting.getRequired(), xmlSetting.getValue()));
- } else {
- settings.get(xmlSetting.getName()).addScriptPlace(xmlSetting.getScript());
- }
- }
- }
- rules.put(name, new Rule(name, state, ruleDescription, settings, elementConventions, modelConventions));
- }
-
- return rules;
- }
-
- private static boolean checkRegEx(String regEx) {
- boolean correct = false;
-
- if (regEx.isEmpty())
- return correct;
-
- try {
- Pattern.compile(regEx);
- correct = true;
- } catch (PatternSyntaxException e) {
- }
- return correct;
- }
-}
+/**
+ * BSD 3-Clause License
+ *
+ * Copyright © 2018, viadee Unternehmensberatung AG
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package de.viadee.bpm.vPAV.config.reader;
+
+import de.viadee.bpm.vPAV.RuntimeConfig;
+import de.viadee.bpm.vPAV.config.model.*;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+/**
+ * Used to read the config file (ruleSet.xml) and extract the configured rules
+ * Requirements: Exisiting ruleSet.xml in src/test/resources
+ */
+public final class XmlConfigReader implements ConfigReader {
+
+ /**
+ * @throws ConfigReaderException
+ * If file can not be found in classpath
+ */
+ @Override
+ public Map read(final String file) throws ConfigReaderException {
+
+ try {
+ final JAXBContext jaxbContext = JAXBContext.newInstance(XmlRuleSet.class);
+ final Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
+
+ InputStream fRuleSet = RuntimeConfig.getInstance().getClassLoader().getResourceAsStream(file);
+
+ if (fRuleSet != null) {
+ final XmlRuleSet ruleSet = (XmlRuleSet) jaxbUnmarshaller.unmarshal(fRuleSet);
+ return transformFromXmlDatastructues(ruleSet);
+ } else {
+ throw new ConfigReaderException("ConfigFile could not be found");
+ }
+ } catch (JAXBException e) {
+ throw new ConfigReaderException(e);
+ }
+ }
+
+ /**
+ * Retrieves all rules, by default deactivated
+ *
+ * @return rules
+ */
+ public Map getDeactivatedRuleSet() {
+ final Map rules = new HashMap();
+
+ for (String name : RuntimeConfig.getInstance().getViadeeRules()) {
+ if (name.equals("CreateOutputHTML")) {
+ rules.put(name, new Rule(name, true, null, new HashMap(),
+ new ArrayList(), new ArrayList()));
+ } else {
+ rules.put(name, new Rule(name, false, null, new HashMap(),
+ new ArrayList(), new ArrayList()));
+ }
+ }
+
+ return rules;
+ }
+
+ /**
+ * Transforms XmlRuleSet to rules
+ *
+ * @param ruleSet
+ * @return rules
+ * @throws ConfigReaderException
+ * If file could not be read properly
+ */
+ private static Map transformFromXmlDatastructues(final XmlRuleSet ruleSet)
+ throws ConfigReaderException {
+ final Map rules = new HashMap();
+
+ final Collection xmlRules = ruleSet.getRules();
+ for (final XmlRule rule : xmlRules) {
+ final String name = rule.getName();
+ if (name == null)
+ throw new ConfigReaderException("rule name is not set");
+ final boolean state = rule.isState();
+ final String ruleDescription = rule.getDescription();
+ final Collection xmlElementConventions = rule.getElementConventions();
+ final ArrayList elementConventions = new ArrayList();
+ if (xmlElementConventions != null) {
+ for (final XmlElementConvention xmlElementConvention : xmlElementConventions) {
+ final XmlElementFieldTypes xmlElementFieldTypes = xmlElementConvention.getElementFieldTypes();
+ ElementFieldTypes elementFieldTypes = null;
+ if (xmlElementFieldTypes != null) {
+ elementFieldTypes = new ElementFieldTypes(xmlElementFieldTypes.getElementFieldTypes(),
+ xmlElementFieldTypes.isExcluded());
+ }
+ if (!checkRegEx(xmlElementConvention.getPattern()))
+ throw new ConfigReaderException("RegEx (" + xmlElementConvention.getPattern() + ") of " + name
+ + " (" + xmlElementConvention.getName() + ") is incorrect");
+ elementConventions.add(new ElementConvention(xmlElementConvention.getName(), elementFieldTypes,
+ xmlElementConvention.getDescription(), xmlElementConvention.getPattern()));
+ }
+ }
+ final Collection xmlModelConventions = rule.getModelConventions();
+ final ArrayList modelConventions = new ArrayList();
+ if (xmlModelConventions != null) {
+ for (final XmlModelConvention xmlModelConvention : xmlModelConventions) {
+ modelConventions.add(new ModelConvention(xmlModelConvention.getType()));
+ }
+ }
+ final Collection xmlSettings = rule.getSettings();
+ final Map settings = new HashMap();
+ if (xmlSettings != null) {
+ for (final XmlSetting xmlSetting : xmlSettings) {
+ if (!settings.containsKey(xmlSetting.getName())) {
+ settings.put(xmlSetting.getName(),
+ new Setting(xmlSetting.getName(), xmlSetting.getScript(), xmlSetting.getType(),
+ xmlSetting.getId(), xmlSetting.getRequired(), xmlSetting.getValue()));
+ } else {
+ settings.get(xmlSetting.getName()).addScriptPlace(xmlSetting.getScript());
+ }
+ }
+ }
+ rules.put(name, new Rule(name, state, ruleDescription, settings, elementConventions, modelConventions));
+ }
+
+ return rules;
+ }
+
+ private static boolean checkRegEx(String regEx) {
+ boolean correct = false;
+
+ if (regEx.isEmpty())
+ return correct;
+
+ try {
+ Pattern.compile(regEx);
+ correct = true;
+ } catch (PatternSyntaxException e) {
+ }
+ return correct;
+ }
+}
diff --git a/src/main/java/de/viadee/bpm/vPAV/config/reader/XmlElementFieldTypes.java b/src/main/java/de/viadee/bpm/vPAV/config/reader/XmlElementFieldTypes.java
index 8171c7a3..e580beb7 100644
--- a/src/main/java/de/viadee/bpm/vPAV/config/reader/XmlElementFieldTypes.java
+++ b/src/main/java/de/viadee/bpm/vPAV/config/reader/XmlElementFieldTypes.java
@@ -31,12 +31,11 @@
*/
package de.viadee.bpm.vPAV.config.reader;
-import java.util.Collection;
-
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import java.util.Collection;
@XmlRootElement(name = "elementFieldTypes")
@XmlType(propOrder = { "elementFieldTypes", "excluded" })
diff --git a/src/main/java/de/viadee/bpm/vPAV/config/reader/XmlRule.java b/src/main/java/de/viadee/bpm/vPAV/config/reader/XmlRule.java
index 124c3016..92f4db8f 100644
--- a/src/main/java/de/viadee/bpm/vPAV/config/reader/XmlRule.java
+++ b/src/main/java/de/viadee/bpm/vPAV/config/reader/XmlRule.java
@@ -31,12 +31,11 @@
*/
package de.viadee.bpm.vPAV.config.reader;
-import java.util.Collection;
-
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import java.util.Collection;
@XmlRootElement(name = "rule")
@XmlType(propOrder = { "name", "state", "description", "settings", "elementConventions", "modelConventions" })
diff --git a/src/main/java/de/viadee/bpm/vPAV/config/reader/XmlRuleSet.java b/src/main/java/de/viadee/bpm/vPAV/config/reader/XmlRuleSet.java
index 7e1abf0e..5afa0ed3 100644
--- a/src/main/java/de/viadee/bpm/vPAV/config/reader/XmlRuleSet.java
+++ b/src/main/java/de/viadee/bpm/vPAV/config/reader/XmlRuleSet.java
@@ -31,10 +31,9 @@
*/
package de.viadee.bpm.vPAV.config.reader;
-import java.util.Collection;
-
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import java.util.Collection;
@XmlRootElement(name = "ruleSet")
public class XmlRuleSet {
diff --git a/src/main/java/de/viadee/bpm/vPAV/constants/CamundaMethodServices.java b/src/main/java/de/viadee/bpm/vPAV/constants/CamundaMethodServices.java
index 8c0a3138..07256022 100644
--- a/src/main/java/de/viadee/bpm/vPAV/constants/CamundaMethodServices.java
+++ b/src/main/java/de/viadee/bpm/vPAV/constants/CamundaMethodServices.java
@@ -42,5 +42,17 @@ public class CamundaMethodServices {
public static final String SCOPE = "org.camunda.bpm.engine.delegate.VariableScope";
public static final String VARIABLE_MAP = "org.camunda.bpm.engine.variable.VariableMap";
+
+ public static final String START_PROCESS_INSTANCE_BY_MESSAGE = "startProcessInstanceByMessage";
+
+ public static final String START_PROCESS_INSTANCE_BY_ID = "startProcessInstanceById";
+
+ public static final String START_PROCESS_INSTANCE_BY_MESSAGE_AND_PROCESS_DEF = "startProcessInstanceByMessageAndProcessDefinitionId";
+
+ public static final String START_PROCESS_INSTANCE_BY_KEY = "startProcessInstanceByKey";
+
+ public static final String CORRELATE_MESSAGE = "createMessageCorrelation";
+
+
}
diff --git a/src/main/java/de/viadee/bpm/vPAV/output/IssueOutputWriter.java b/src/main/java/de/viadee/bpm/vPAV/output/IssueOutputWriter.java
index d5f67a5b..37825e15 100644
--- a/src/main/java/de/viadee/bpm/vPAV/output/IssueOutputWriter.java
+++ b/src/main/java/de/viadee/bpm/vPAV/output/IssueOutputWriter.java
@@ -31,10 +31,10 @@
*/
package de.viadee.bpm.vPAV.output;
-import java.util.Collection;
-
import de.viadee.bpm.vPAV.processing.model.data.CheckerIssue;
+import java.util.Collection;
+
public interface IssueOutputWriter {
void write(final Collection issues) throws OutputWriterException;
diff --git a/src/main/java/de/viadee/bpm/vPAV/output/IssueWriter.java b/src/main/java/de/viadee/bpm/vPAV/output/IssueWriter.java
index 36dc6638..417827ae 100644
--- a/src/main/java/de/viadee/bpm/vPAV/output/IssueWriter.java
+++ b/src/main/java/de/viadee/bpm/vPAV/output/IssueWriter.java
@@ -31,20 +31,18 @@
*/
package de.viadee.bpm.vPAV.output;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map.Entry;
-
+import de.viadee.bpm.vPAV.config.model.ElementConvention;
+import de.viadee.bpm.vPAV.config.model.Rule;
import de.viadee.bpm.vPAV.processing.model.data.*;
+import de.viadee.bpm.vPAV.processing.model.graph.Path;
import org.camunda.bpm.model.bpmn.impl.BpmnModelConstants;
import org.camunda.bpm.model.bpmn.instance.BaseElement;
import org.w3c.dom.Element;
-import de.viadee.bpm.vPAV.config.model.ElementConvention;
-import de.viadee.bpm.vPAV.config.model.Rule;
-import de.viadee.bpm.vPAV.processing.model.data.ProcessVariableOperation;
-import de.viadee.bpm.vPAV.processing.model.graph.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map.Entry;
public class IssueWriter {
diff --git a/src/main/java/de/viadee/bpm/vPAV/output/JsOutputWriter.java b/src/main/java/de/viadee/bpm/vPAV/output/JsOutputWriter.java
index 176588a1..05e41a17 100644
--- a/src/main/java/de/viadee/bpm/vPAV/output/JsOutputWriter.java
+++ b/src/main/java/de/viadee/bpm/vPAV/output/JsOutputWriter.java
@@ -31,36 +31,23 @@
*/
package de.viadee.bpm.vPAV.output;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.function.Function;
-import java.util.logging.Logger;
-
-import de.viadee.bpm.vPAV.processing.model.data.ProcessVariable;
-import de.viadee.bpm.vPAV.processing.model.data.*;
-
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
-
import de.viadee.bpm.vPAV.RuntimeConfig;
import de.viadee.bpm.vPAV.constants.BpmnConstants;
import de.viadee.bpm.vPAV.constants.ConfigConstants;
+import de.viadee.bpm.vPAV.processing.model.data.*;
import de.viadee.bpm.vPAV.processing.model.graph.Path;
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.*;
+import java.util.function.Function;
+import java.util.logging.Logger;
+
/**
* Create the JavaScript file for HTML-output; Needs: issues and bpmnFile names
*/
diff --git a/src/main/java/de/viadee/bpm/vPAV/output/JsonOutputWriter.java b/src/main/java/de/viadee/bpm/vPAV/output/JsonOutputWriter.java
index d5232f19..c7b526e3 100644
--- a/src/main/java/de/viadee/bpm/vPAV/output/JsonOutputWriter.java
+++ b/src/main/java/de/viadee/bpm/vPAV/output/JsonOutputWriter.java
@@ -31,23 +31,22 @@
*/
package de.viadee.bpm.vPAV.output;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.nio.charset.StandardCharsets;
-import java.util.Collection;
-import java.util.List;
-
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
-
import de.viadee.bpm.vPAV.constants.BpmnConstants;
import de.viadee.bpm.vPAV.constants.ConfigConstants;
import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
import de.viadee.bpm.vPAV.processing.model.data.CheckerIssue;
import de.viadee.bpm.vPAV.processing.model.graph.Path;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
+import java.util.Collection;
+import java.util.List;
+
public class JsonOutputWriter implements IssueOutputWriter {
/**
diff --git a/src/main/java/de/viadee/bpm/vPAV/output/RuleSetOutputWriter.java b/src/main/java/de/viadee/bpm/vPAV/output/RuleSetOutputWriter.java
index 6604a75a..e233562d 100644
--- a/src/main/java/de/viadee/bpm/vPAV/output/RuleSetOutputWriter.java
+++ b/src/main/java/de/viadee/bpm/vPAV/output/RuleSetOutputWriter.java
@@ -31,35 +31,20 @@
*/
package de.viadee.bpm.vPAV.output;
-import java.io.BufferedWriter;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
+import de.viadee.bpm.vPAV.config.model.*;
+import de.viadee.bpm.vPAV.config.reader.*;
+import de.viadee.bpm.vPAV.constants.ConfigConstants;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-
-import de.viadee.bpm.vPAV.config.model.ElementConvention;
-import de.viadee.bpm.vPAV.config.model.ElementFieldTypes;
-import de.viadee.bpm.vPAV.config.model.ModelConvention;
-import de.viadee.bpm.vPAV.config.model.Rule;
-import de.viadee.bpm.vPAV.config.model.Setting;
-import de.viadee.bpm.vPAV.config.reader.XmlElementConvention;
-import de.viadee.bpm.vPAV.config.reader.XmlElementFieldTypes;
-import de.viadee.bpm.vPAV.config.reader.XmlModelConvention;
-import de.viadee.bpm.vPAV.config.reader.XmlRule;
-import de.viadee.bpm.vPAV.config.reader.XmlRuleSet;
-import de.viadee.bpm.vPAV.config.reader.XmlSetting;
-import de.viadee.bpm.vPAV.constants.ConfigConstants;
-
/**
* Ergebnisse aus dem Checker in ein definiertes XML-Format schreiben
*
diff --git a/src/main/java/de/viadee/bpm/vPAV/output/XmlCheckerIssue.java b/src/main/java/de/viadee/bpm/vPAV/output/XmlCheckerIssue.java
index 82f877fe..ab31fdba 100644
--- a/src/main/java/de/viadee/bpm/vPAV/output/XmlCheckerIssue.java
+++ b/src/main/java/de/viadee/bpm/vPAV/output/XmlCheckerIssue.java
@@ -31,12 +31,11 @@
*/
package de.viadee.bpm.vPAV.output;
-import java.util.List;
-
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import java.util.List;
@XmlRootElement(name = "issue")
@XmlType(propOrder = { "id", "ruleName", "ruleDescription", "bpmnFile", "resourceFile", "classification", "elementId",
diff --git a/src/main/java/de/viadee/bpm/vPAV/output/XmlCheckerIssues.java b/src/main/java/de/viadee/bpm/vPAV/output/XmlCheckerIssues.java
index 9d7d3b86..b4475b37 100644
--- a/src/main/java/de/viadee/bpm/vPAV/output/XmlCheckerIssues.java
+++ b/src/main/java/de/viadee/bpm/vPAV/output/XmlCheckerIssues.java
@@ -31,13 +31,12 @@
*/
package de.viadee.bpm.vPAV.output;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
@XmlRootElement(name = "issues")
public class XmlCheckerIssues {
diff --git a/src/main/java/de/viadee/bpm/vPAV/output/XmlOutputWriter.java b/src/main/java/de/viadee/bpm/vPAV/output/XmlOutputWriter.java
index 5d609c23..de36a2f4 100644
--- a/src/main/java/de/viadee/bpm/vPAV/output/XmlOutputWriter.java
+++ b/src/main/java/de/viadee/bpm/vPAV/output/XmlOutputWriter.java
@@ -31,26 +31,20 @@
*/
package de.viadee.bpm.vPAV.output;
-import java.io.BufferedWriter;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-
import de.viadee.bpm.vPAV.constants.BpmnConstants;
import de.viadee.bpm.vPAV.constants.ConfigConstants;
import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
import de.viadee.bpm.vPAV.processing.model.data.CheckerIssue;
import de.viadee.bpm.vPAV.processing.model.graph.Path;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
/**
* Ergebnisse aus dem Checker in ein definiertes XML-Format schreiben
*
diff --git a/src/main/java/de/viadee/bpm/vPAV/output/XmlPath.java b/src/main/java/de/viadee/bpm/vPAV/output/XmlPath.java
index 5ab54de2..62a84ca4 100644
--- a/src/main/java/de/viadee/bpm/vPAV/output/XmlPath.java
+++ b/src/main/java/de/viadee/bpm/vPAV/output/XmlPath.java
@@ -31,10 +31,9 @@
*/
package de.viadee.bpm.vPAV.output;
-import java.util.Collection;
-
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import java.util.Collection;
@XmlRootElement(name = "path")
public class XmlPath {
diff --git a/src/main/java/de/viadee/bpm/vPAV/processing/BpmnModelDispatcher.java b/src/main/java/de/viadee/bpm/vPAV/processing/BpmnModelDispatcher.java
index a5b2ded8..d9a68fe1 100644
--- a/src/main/java/de/viadee/bpm/vPAV/processing/BpmnModelDispatcher.java
+++ b/src/main/java/de/viadee/bpm/vPAV/processing/BpmnModelDispatcher.java
@@ -31,43 +31,26 @@
*/
package de.viadee.bpm.vPAV.processing;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-import de.viadee.bpm.vPAV.OuterProcessVariablesScanner;
-import org.camunda.bpm.model.bpmn.Bpmn;
-import org.camunda.bpm.model.bpmn.BpmnModelInstance;
-import org.camunda.bpm.model.bpmn.instance.BaseElement;
-import org.xml.sax.SAXException;
-
import de.viadee.bpm.vPAV.BpmnScanner;
import de.viadee.bpm.vPAV.FileScanner;
import de.viadee.bpm.vPAV.config.model.Rule;
import de.viadee.bpm.vPAV.config.model.Setting;
import de.viadee.bpm.vPAV.constants.BpmnConstants;
import de.viadee.bpm.vPAV.constants.ConfigConstants;
-import de.viadee.bpm.vPAV.processing.checker.CheckerFactory;
-import de.viadee.bpm.vPAV.processing.checker.DataFlowChecker;
-import de.viadee.bpm.vPAV.processing.checker.ElementChecker;
-import de.viadee.bpm.vPAV.processing.checker.ModelChecker;
-import de.viadee.bpm.vPAV.processing.checker.ProcessVariablesModelChecker;
+import de.viadee.bpm.vPAV.processing.checker.*;
import de.viadee.bpm.vPAV.processing.dataflow.DataFlowRule;
-import de.viadee.bpm.vPAV.processing.model.data.AnomalyContainer;
-import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
-import de.viadee.bpm.vPAV.processing.model.data.CheckerIssue;
-import de.viadee.bpm.vPAV.processing.model.data.ModelDispatchResult;
-import de.viadee.bpm.vPAV.processing.model.data.ProcessVariable;
-import de.viadee.bpm.vPAV.processing.model.data.ProcessVariableOperation;
+import de.viadee.bpm.vPAV.processing.model.data.*;
import de.viadee.bpm.vPAV.processing.model.graph.IGraph;
import de.viadee.bpm.vPAV.processing.model.graph.Path;
+import org.camunda.bpm.model.bpmn.Bpmn;
+import org.camunda.bpm.model.bpmn.BpmnModelInstance;
+import org.camunda.bpm.model.bpmn.instance.BaseElement;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
/**
* Calls model and element checkers for a concrete bpmn processdefinition
@@ -102,7 +85,7 @@ public class BpmnModelDispatcher {
*/
public ModelDispatchResult dispatchWithVariables(final FileScanner fileScanner, final File processdefinition,
final Map decisionRefToPathMap, final Map processIdToPathMap,
- final OuterProcessVariablesScanner scanner, final Collection dataFlowRules,
+ final ProcessVariablesScanner scanner, final Collection dataFlowRules,
final Collection resourcesNewestVersions, final Map conf) {
final BpmnScanner bpmnScanner = createScanner(processdefinition);
diff --git a/src/main/java/de/viadee/bpm/vPAV/processing/CheckName.java b/src/main/java/de/viadee/bpm/vPAV/processing/CheckName.java
index 8ed2ffbb..d29eaa71 100644
--- a/src/main/java/de/viadee/bpm/vPAV/processing/CheckName.java
+++ b/src/main/java/de/viadee/bpm/vPAV/processing/CheckName.java
@@ -31,11 +31,10 @@
*/
package de.viadee.bpm.vPAV.processing;
+import de.viadee.bpm.vPAV.constants.BpmnConstants;
import org.camunda.bpm.model.bpmn.instance.BaseElement;
import org.w3c.dom.Element;
-import de.viadee.bpm.vPAV.constants.BpmnConstants;
-
/**
*
* Utility class to check names and return names/ids
diff --git a/src/main/java/de/viadee/bpm/vPAV/processing/ElementGraphBuilder.java b/src/main/java/de/viadee/bpm/vPAV/processing/ElementGraphBuilder.java
index cd556bb0..fe347a2b 100644
--- a/src/main/java/de/viadee/bpm/vPAV/processing/ElementGraphBuilder.java
+++ b/src/main/java/de/viadee/bpm/vPAV/processing/ElementGraphBuilder.java
@@ -33,16 +33,16 @@
import de.viadee.bpm.vPAV.BpmnScanner;
import de.viadee.bpm.vPAV.FileScanner;
-import de.viadee.bpm.vPAV.OuterProcessVariablesScanner;
import de.viadee.bpm.vPAV.constants.BpmnConstants;
-import de.viadee.bpm.vPAV.processing.model.data.*;
+import de.viadee.bpm.vPAV.processing.model.data.AnomalyContainer;
+import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
+import de.viadee.bpm.vPAV.processing.model.data.ProcessVariableOperation;
import de.viadee.bpm.vPAV.processing.model.graph.Edge;
import de.viadee.bpm.vPAV.processing.model.graph.Graph;
import de.viadee.bpm.vPAV.processing.model.graph.IGraph;
import de.viadee.bpm.vPAV.processing.model.graph.Path;
import org.camunda.bpm.model.bpmn.Bpmn;
import org.camunda.bpm.model.bpmn.BpmnModelInstance;
-import org.camunda.bpm.model.bpmn.impl.BpmnModelConstants;
import org.camunda.bpm.model.bpmn.instance.*;
import org.camunda.bpm.model.bpmn.instance.Process;
import org.camunda.bpm.model.bpmn.instance.camunda.CamundaIn;
@@ -109,7 +109,7 @@ public ElementGraphBuilder(final Map decisionRefToPathMap,
*/
public Collection createProcessGraph(final JavaReaderContext context, final FileScanner fileScanner,
final BpmnModelInstance modelInstance, final String processdefinition,
- final Collection calledElementHierarchy, final OuterProcessVariablesScanner scanner) {
+ final Collection calledElementHierarchy, final ProcessVariablesScanner scanner) {
final Collection graphCollection = new ArrayList();
@@ -141,33 +141,35 @@ public Collection createProcessGraph(final JavaReaderContext context, fi
processdefinition);
}
+ // Ordered map to hold operations in correct order
+ final LinkedHashMap variables = new LinkedHashMap<>();
+
// initialize element
final BpmnElement node = new BpmnElement(processdefinition, element);
+
+ // retrieve initial variable operation (should be WRITE)
+ if (element.getElementType().getTypeName().equals(BpmnConstants.STARTEVENT)) {
+ // add process variables for start event, which set by call
+ // startProcessInstanceByKey
+ for (Map.Entry> entry : scanner.getEntryPoints().entrySet()) {
+ for (Map.Entry innerEntry : entry.getValue().entrySet()) {
+ variables.putAll(checkInitialVariableOperations(innerEntry.getValue(), context, scanner, node, processdefinition, variables, entry));
+ }
+ }
+
+ node.setProcessVariables(variables);
+ graph.addStartNode(node);
+ }
+
// examine process variables and save it with access operation
- final LinkedHashMap variables = new ProcessVariableReader(
- decisionRefToPathMap, bpmnScanner).getVariablesFromElement(context, fileScanner, node);
+ final ProcessVariableReader reader = new ProcessVariableReader(decisionRefToPathMap, bpmnScanner);
+ variables.putAll(reader.getVariablesFromElement(context, fileScanner, node, variables));
// examine process variables for element and set it
node.setProcessVariables(variables);
// mention element
elementMap.put(element.getId(), node);
- if (element.getElementType().getBaseType().getBaseType().getTypeName()
- .equals(BpmnModelConstants.BPMN_ELEMENT_EVENT)) {
- // add variables for message event (set by outer class)
- addProcessVariablesForMessageName(element, node, context, scanner, processdefinition);
- }
- if (element.getElementType().getTypeName().equals(BpmnConstants.STARTEVENT)) {
- // add process variables for start event, which set by call
- // startProcessInstanceByKey
- checkInitialVariableOperations(context, scanner, node, processdefinition);
-
- final String processId = node.getBaseElement().getParentElement()
- .getAttributeValue(BpmnConstants.ATTR_ID);
- addProcessVariablesByStartForProcessId(node, processId);
-
- graph.addStartNode(node);
- }
if (element.getElementType().getTypeName().equals(BpmnConstants.ENDEVENT)) {
graph.addEndNode(node);
}
@@ -197,76 +199,12 @@ public Collection createProcessGraph(final JavaReaderContext context, fi
* @param scanner
* OuterProcessVariableScanner
*/
- private void checkInitialVariableOperations(final JavaReaderContext jvc, final OuterProcessVariablesScanner scanner,
- final BpmnElement element, final String resourceFilePath) {
- for (final String clazz : scanner.getInitialProcessVariablesLocation()) {
- jvc.readClass(clazz, scanner, element, resourceFilePath);
- }
- }
-
- /**
- * Add process variables on start event for a specific process id
- *
- * @param node
- * Current BPMN Element
- * @param processId
- * Current Process ID
- */
- private void addProcessVariablesByStartForProcessId(final BpmnElement node, final String processId) {
- if (processIdToVariables != null && processId != null) {
- final Collection outerVariables = processIdToVariables.get(processId);
- // add variables
- if (outerVariables != null) {
- for (final String varName : outerVariables) {
- node.setProcessVariable(varName,
- new ProcessVariableOperation(varName, node, ElementChapter.OutstandingVariable,
- KnownElementFieldType.Class, null, VariableOperation.WRITE, ""));
- }
- }
- }
+ private LinkedHashMap checkInitialVariableOperations(final String clazz, final JavaReaderContext jvc, final ProcessVariablesScanner scanner,
+ final BpmnElement element, final String resourceFilePath, final LinkedHashMap variables, final Map.Entry> entry) {
+ variables.putAll(jvc.readClass(clazz, scanner, element, resourceFilePath, entry));
+ return variables;
}
- /**
- * Add process variables on event for a specific message name
- *
- * @param element
- * FlowElement
- * @param node
- * BpmnElement
- */
- private void addProcessVariablesForMessageName(final FlowElement element, final BpmnElement node,
- final JavaReaderContext jvc, final OuterProcessVariablesScanner scanner, final String resourceFilePath) {
- if (messageIdToVariables != null) {
- if (element instanceof Event) {
- final Event event = (Event) element;
- final Collection messageEventDefinitions = event
- .getChildElementsByType(MessageEventDefinition.class);
- if (messageEventDefinitions != null) {
- for (MessageEventDefinition eventDef : messageEventDefinitions) {
- if (eventDef != null) {
- final Message message = eventDef.getMessage();
- if (message != null) {
- final String messageName = message.getName();
- final Collection outerVariables = messageIdToVariables.get(messageName);
- if (outerVariables != null) {
- for (final String varName : outerVariables) {
- // Check which outerVariables have been written
-
- checkInitialVariableOperations(jvc, scanner, node, resourceFilePath);
-
- node.setProcessVariable(varName,
- new ProcessVariableOperation(varName, node,
- ElementChapter.OutstandingVariable, KnownElementFieldType.Class,
- null, VariableOperation.WRITE, ""));
- }
- }
- }
- }
- }
- }
- }
- }
- }
public BpmnElement getElement(final String id) {
return elementMap.get(id);
@@ -402,8 +340,9 @@ private void addElementsSubprocess(final JavaReaderContext context, final FileSc
// add elements of the sub process as nodes
final BpmnElement node = new BpmnElement(processdefinitionPath, subElement);
// determine process variables with operations
- final LinkedHashMap variables = new ProcessVariableReader(
- decisionRefToPathMap, bpmnScanner).getVariablesFromElement(context, fileScanner, node);
+ final LinkedHashMap variables = new LinkedHashMap<>();
+ variables.putAll(
+ new ProcessVariableReader(decisionRefToPathMap, bpmnScanner).getVariablesFromElement(context, fileScanner, node, variables));
// set process variables for the node
node.setProcessVariables(variables);
// mention the element
@@ -436,7 +375,7 @@ private void addElementsSubprocess(final JavaReaderContext context, final FileSc
private void integrateCallActivityFlow(final JavaReaderContext context, final FileScanner fileScanner,
final String processdefinition, final BpmnModelInstance modelInstance, final CallActivity callActivity,
final IGraph graph, final Collection calledElementHierarchy,
- final OuterProcessVariablesScanner scanner) {
+ final ProcessVariablesScanner scanner) {
final String calledElement = callActivity.getCalledElement();
@@ -592,7 +531,7 @@ private void connectParallelGatewaysWithSubDataFlow(final IGraph graph, final Co
*/
private Collection createSubDataFlowsFromCallActivity(final JavaReaderContext context,
FileScanner fileScanner, final Collection calledElementHierarchy, final String callActivityPath,
- final OuterProcessVariablesScanner scanner) {
+ final ProcessVariablesScanner scanner) {
// read called process
final BpmnModelInstance submodel = Bpmn.readModelFromFile(new File(callActivityPath));
diff --git a/src/main/java/de/viadee/bpm/vPAV/processing/JavaReader.java b/src/main/java/de/viadee/bpm/vPAV/processing/JavaReader.java
index 4e4c7da2..39701327 100644
--- a/src/main/java/de/viadee/bpm/vPAV/processing/JavaReader.java
+++ b/src/main/java/de/viadee/bpm/vPAV/processing/JavaReader.java
@@ -31,21 +31,22 @@
*/
package de.viadee.bpm.vPAV.processing;
-import java.util.*;
-
import de.viadee.bpm.vPAV.FileScanner;
-import de.viadee.bpm.vPAV.OuterProcessVariablesScanner;
import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
import de.viadee.bpm.vPAV.processing.model.data.ElementChapter;
import de.viadee.bpm.vPAV.processing.model.data.KnownElementFieldType;
import de.viadee.bpm.vPAV.processing.model.data.ProcessVariableOperation;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
public interface JavaReader {
- LinkedHashMap getVariablesFromJavaDelegate(final FileScanner fileScanner, final String classFile,
- final BpmnElement element, final ElementChapter chapter, final KnownElementFieldType fieldType,
- final String scopeId);
+ LinkedHashMap getVariablesFromJavaDelegate(final FileScanner fileScanner,
+ final String classFile, final BpmnElement element, final ElementChapter chapter,
+ final KnownElementFieldType fieldType, final String scopeId);
- LinkedHashMap getVariablesFromClass(final String className, final OuterProcessVariablesScanner scanner,
- final BpmnElement element, final String resourceFilePath);
+ LinkedHashMap getVariablesFromClass(final String className,
+ final ProcessVariablesScanner scanner, final BpmnElement element, final String resourceFilePath,
+ final Map.Entry> entry);
}
diff --git a/src/main/java/de/viadee/bpm/vPAV/processing/JavaReaderContext.java b/src/main/java/de/viadee/bpm/vPAV/processing/JavaReaderContext.java
index 5330bbaa..055f9802 100644
--- a/src/main/java/de/viadee/bpm/vPAV/processing/JavaReaderContext.java
+++ b/src/main/java/de/viadee/bpm/vPAV/processing/JavaReaderContext.java
@@ -31,14 +31,15 @@
*/
package de.viadee.bpm.vPAV.processing;
-import java.util.*;
import de.viadee.bpm.vPAV.FileScanner;
-import de.viadee.bpm.vPAV.OuterProcessVariablesScanner;
import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
import de.viadee.bpm.vPAV.processing.model.data.ElementChapter;
import de.viadee.bpm.vPAV.processing.model.data.KnownElementFieldType;
import de.viadee.bpm.vPAV.processing.model.data.ProcessVariableOperation;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
public class JavaReaderContext {
private JavaReader javaReaderStrategy;
@@ -52,8 +53,8 @@ public LinkedHashMap readJavaDelegate(final Fi
return javaReaderStrategy.getVariablesFromJavaDelegate(fileScanner, classFile, element, chapter, fieldType, scopeId);
}
- public LinkedHashMap readClass(final String className, final OuterProcessVariablesScanner scanner, final BpmnElement element, final String resourceFilePath){
- return javaReaderStrategy.getVariablesFromClass(className, scanner, element, resourceFilePath);
+ public LinkedHashMap readClass(final String className, final ProcessVariablesScanner scanner, final BpmnElement element, final String resourceFilePath, final Map.Entry> entry){
+ return javaReaderStrategy.getVariablesFromClass(className, scanner, element, resourceFilePath, entry);
}
diff --git a/src/main/java/de/viadee/bpm/vPAV/processing/JavaReaderRegex.java b/src/main/java/de/viadee/bpm/vPAV/processing/JavaReaderRegex.java
index a430703a..fc8110de 100644
--- a/src/main/java/de/viadee/bpm/vPAV/processing/JavaReaderRegex.java
+++ b/src/main/java/de/viadee/bpm/vPAV/processing/JavaReaderRegex.java
@@ -31,16 +31,16 @@
*/
package de.viadee.bpm.vPAV.processing;
-import java.util.LinkedHashMap;
-import java.util.logging.Logger;
-
import de.viadee.bpm.vPAV.FileScanner;
-import de.viadee.bpm.vPAV.OuterProcessVariablesScanner;
import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
import de.viadee.bpm.vPAV.processing.model.data.ElementChapter;
import de.viadee.bpm.vPAV.processing.model.data.KnownElementFieldType;
import de.viadee.bpm.vPAV.processing.model.data.ProcessVariableOperation;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.logging.Logger;
+
public class JavaReaderRegex implements JavaReader {
public static final Logger LOGGER = Logger.getLogger(JavaReaderRegex.class.getName());
@@ -81,23 +81,12 @@ public LinkedHashMap getVariablesFromJavaDeleg
}
/**
- *
* Unused implementation
- *
- * @param className
- * Class name to be scanned
- * @param scanner
- * OuterProcessVariableScanner
- * @param element
- * BpmnElement
- * @param resourceFilePath
- * Path of the BPMN model
- *
- * @return Process Variables
*/
@Override
public LinkedHashMap getVariablesFromClass(final String className,
- final OuterProcessVariablesScanner scanner, final BpmnElement element, final String resourceFilePath) {
+ final ProcessVariablesScanner scanner, final BpmnElement element, final String resourceFilePath,
+ final Map.Entry> entry) {
// TODO Auto-generated method stub
return null;
}
diff --git a/src/main/java/de/viadee/bpm/vPAV/processing/JavaReaderStatic.java b/src/main/java/de/viadee/bpm/vPAV/processing/JavaReaderStatic.java
index 41fd9290..617aef29 100644
--- a/src/main/java/de/viadee/bpm/vPAV/processing/JavaReaderStatic.java
+++ b/src/main/java/de/viadee/bpm/vPAV/processing/JavaReaderStatic.java
@@ -31,37 +31,15 @@
*/
package de.viadee.bpm.vPAV.processing;
-import java.util.*;
-import java.util.logging.Logger;
-
import de.viadee.bpm.vPAV.FileScanner;
-import de.viadee.bpm.vPAV.OuterProcessVariablesScanner;
-import de.viadee.bpm.vPAV.processing.model.data.Anomaly;
-import de.viadee.bpm.vPAV.processing.model.data.AnomalyContainer;
-import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
-import de.viadee.bpm.vPAV.processing.model.data.CamundaProcessVariableFunctions;
-import de.viadee.bpm.vPAV.processing.model.data.ElementChapter;
-import de.viadee.bpm.vPAV.processing.model.data.KnownElementFieldType;
-import de.viadee.bpm.vPAV.processing.model.data.OutSetCFG;
-import de.viadee.bpm.vPAV.processing.model.data.ProcessVariableOperation;
-import de.viadee.bpm.vPAV.processing.model.data.VariableBlock;
-import de.viadee.bpm.vPAV.processing.model.data.VariableOperation;
-import soot.Body;
-import soot.G;
-import soot.PackManager;
-import soot.PatchingChain;
-import soot.RefType;
-import soot.Scene;
-import soot.SootClass;
-import soot.SootMethod;
-import soot.Type;
-import soot.Unit;
-import soot.VoidType;
+import de.viadee.bpm.vPAV.constants.CamundaMethodServices;
+import de.viadee.bpm.vPAV.processing.model.data.*;
+import org.camunda.bpm.engine.variable.VariableMap;
+import soot.*;
import soot.jimple.AssignStmt;
import soot.jimple.InvokeStmt;
import soot.jimple.StringConstant;
import soot.jimple.internal.JInterfaceInvokeExpr;
-import soot.jimple.internal.JVirtualInvokeExpr;
import soot.jimple.toolkits.callgraph.CallGraph;
import soot.jimple.toolkits.callgraph.Edge;
import soot.options.Options;
@@ -69,6 +47,9 @@
import soot.toolkits.graph.BlockGraph;
import soot.toolkits.graph.ClassicCompleteBlockGraph;
+import java.util.*;
+import java.util.logging.Logger;
+
public class JavaReaderStatic implements JavaReader {
public static final Logger LOGGER = Logger.getLogger(JavaReaderStatic.class.getName());
@@ -137,7 +118,8 @@ public LinkedHashMap getVariablesFromJavaDeleg
* @return Map of process variable operations
*/
public LinkedHashMap getVariablesFromClass(String className,
- final OuterProcessVariablesScanner scanner, final BpmnElement element, final String resourceFilePath) {
+ final ProcessVariablesScanner scanner, final BpmnElement element, final String resourceFilePath,
+ final Map.Entry> map) {
final LinkedHashMap initialOperations = new LinkedHashMap<>();
@@ -156,12 +138,15 @@ public LinkedHashMap getVariablesFromClass(Str
sootClass.setApplicationClass();
Scene.v().loadNecessaryClasses();
for (SootMethod method : sootClass.getMethods()) {
- final Body body = method.retrieveActiveBody();
- initialOperations.putAll(checkWriteAccess(body, scanner, element, resourceFilePath));
+ for (Map.Entry entry : map.getValue().entrySet()) {
+ if (method.getName().equals(entry.getKey())) {
+ final Body body = method.retrieveActiveBody();
+ initialOperations.putAll(checkWriteAccess(body, element, resourceFilePath, map));
+ }
+ }
}
}
}
-
return initialOperations;
}
@@ -171,71 +156,89 @@ public LinkedHashMap getVariablesFromClass(Str
*
* @param body
* Soot representation of a method's body
- * @param scanner
- * OuterProcessVariableScanner
* @param element
* BpmnElement
* @param resourceFilePath
* Path of the BPMN model
* @return Map of process variable operations
*/
- private Map checkWriteAccess(final Body body,
- final OuterProcessVariablesScanner scanner, final BpmnElement element, final String resourceFilePath) {
-
- final Map initialOperations = new HashMap<>();
-
- for (String location : scanner.getInitialProcessVariablesLocation()) {
- location = cleanString(location, true);
- location = "new " + location.replace(".java", "") + "$InitialProcessVariables";
-
- String assignment = "";
- String invoke = "";
-
- final PatchingChain pc = body.getUnits();
- for (Unit unit : pc) {
- if (unit instanceof AssignStmt) {
- final String rightBox = ((AssignStmt) unit).getRightOpBox().getValue().toString();
- final String leftBox = ((AssignStmt) unit).getLeftOpBox().getValue().toString();
+ private Map checkWriteAccess(final Body body, final BpmnElement element,
+ final String resourceFilePath, final Map.Entry> map) {
- if (rightBox.equals(location)) {
- assignment = leftBox;
- }
-
- if (rightBox.equals(assignment)) {
- invoke = leftBox;
- }
+ final LinkedHashMap initialOperations = new LinkedHashMap<>();
- if (leftBox.contains(location.replace("new ", "")) && leftBox.contains(invoke)) {
- if (scanner.getInitialProcessVariables()
- .contains(((AssignStmt) unit).getFieldRef().getFieldRef().name())) {
- final String name = ((AssignStmt) unit).getFieldRef().getFieldRef().name();
- initialOperations.put(name,
- new ProcessVariableOperation(name, element, ElementChapter.Code,
- KnownElementFieldType.Initial, resourceFilePath, VariableOperation.WRITE,
- element.getBaseElement().getId()));
+ for (Map.Entry entry : map.getValue().entrySet()) {
+ if (body.getMethod().getName().equals(entry.getKey())) {
+ final PatchingChain pc = body.getUnits();
+ String assignment = "";
+ String invoke = "";
+
+ for (Unit unit : pc) {
+ if (unit instanceof AssignStmt) {
+ final String rightBox = ((AssignStmt) unit).getRightOpBox().getValue().toString();
+ final String leftBox = ((AssignStmt) unit).getLeftOpBox().getValue().toString();
+
+ if (rightBox.contains(CamundaMethodServices.VARIABLE_MAP + " createVariables()")) {
+ assignment = leftBox;
+ }
+
+ if (rightBox.contains(map.getKey()) && rightBox.contains(invoke)) {
+ return initialOperations;
+ }
+
+ if (((AssignStmt) unit).getRightOpBox().getValue() instanceof JInterfaceInvokeExpr) {
+ final JInterfaceInvokeExpr expr = (JInterfaceInvokeExpr) ((AssignStmt) unit)
+ .getRightOpBox().getValue();
+ if (expr != null) {
+ if (expr.getMethodRef().getDeclaringClass().equals(Scene.v()
+ .forceResolve(VariableMap.class.getName(), SootClass.SIGNATURES))) {
+ initialOperations.putAll(parseInitialExpression(expr, element, resourceFilePath));
+ invoke = leftBox;
+ }
+ if (checkArgBoxes(map, assignment, invoke, expr)) return initialOperations;
+ }
}
- }
-
- if (((AssignStmt) unit).getRightOpBox().getValue() instanceof JVirtualInvokeExpr) {
-
- final JVirtualInvokeExpr expr = (JVirtualInvokeExpr) ((AssignStmt) unit).getRightOpBox()
- .getValue();
-
- if (expr != null) {
- String functionName = expr.getMethodRef().name();
- if (functionName.equals("createVariableMap")) {
- return initialOperations;
- }
+ }
+ if (unit instanceof InvokeStmt) {
+ if (((InvokeStmt) unit).getInvokeExprBox().getValue() instanceof JInterfaceInvokeExpr) {
+ final JInterfaceInvokeExpr expr = (JInterfaceInvokeExpr) ((InvokeStmt) unit)
+ .getInvokeExprBox().getValue();
+ if (expr != null) {
+ if (checkArgBoxes(map, assignment, invoke, expr)) return initialOperations;
+ }
}
}
}
}
- }
-
+ }
return initialOperations;
}
- /**
+ /**
+ *
+ * Check whether or not the second or third argument contain a reference to the variable map
+ *
+ * @param map Current entry
+ * @param assignment Current assigned variable
+ * @param invoke Current invocation
+ * @param expr Current expression
+ * @return True/False based on whether the second or third argument refers to the variable map
+ */
+ private boolean checkArgBoxes(Map.Entry> map, String assignment, String invoke, JInterfaceInvokeExpr expr) {
+ if (expr.getMethodRef().getName().equals(map.getKey())) {
+ if (!assignment.isEmpty()) {
+ if (expr.getArgBox(1).getValue().toString().equals(invoke)) {
+ return true;
+ }
+ if (expr.getArgBox(2).getValue().toString().equals(invoke)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
*
* Starting by the main JavaDelegate, statically analyses the classes
* implemented for the bpmn element.
@@ -267,7 +270,7 @@ public Map classFetcher(final Set clas
OutSetCFG outSet = new OutSetCFG(new ArrayList());
classFetcherRecursive(classPaths, className, methodName, classFile, element, chapter, fieldType, scopeId,
- outSet, null, new ArrayList());
+ outSet, null);
processVariables.putAll(outSet.getAllProcessVariables());
@@ -305,75 +308,69 @@ public Map classFetcher(final Set clas
* Callgraph information
* @param originalBlock
* VariableBlock
- * @param visitedClasses
- * List to hold information which class has been visited (avoid
- * circular references that lead to a StackOverflow)
* @return OutSetCFG which contains data flow information
*/
public OutSetCFG classFetcherRecursive(final Set classPaths, String className, final String methodName,
final String classFile, final BpmnElement element, final ElementChapter chapter,
final KnownElementFieldType fieldType, final String scopeId, OutSetCFG outSet,
- final VariableBlock originalBlock, final ArrayList visitedClasses) {
-
- if (!visitedClasses.contains(className)) {
- className = cleanString(className, true);
-
- Options.v().set_whole_program(true);
- Options.v().set_allow_phantom_refs(true);
-
- SootClass sootClass = Scene.v().forceResolve(className, SootClass.SIGNATURES);
-
- if (sootClass != null) {
-
- sootClass.setApplicationClass();
- Scene.v().loadNecessaryClasses();
-
- // Retrieve the method and its body based on the used interface
- List parameterTypes = new ArrayList();
- RefType delegateExecutionType = RefType.v("org.camunda.bpm.engine.delegate.DelegateExecution");
- RefType delegateTaskType = RefType.v("org.camunda.bpm.engine.delegate.DelegateTask");
- RefType mapVariablesType = RefType.v("org.camunda.bpm.engine.variable.VariableMap");
- VoidType returnType = VoidType.v();
-
- switch (methodName) {
- case "execute":
- parameterTypes.add((Type) delegateExecutionType);
- outSet = retrieveMethod(classPaths, className, methodName, classFile, element, chapter, fieldType,
- scopeId, outSet, originalBlock, sootClass, parameterTypes, returnType, visitedClasses);
- break;
- case "notify":
- for (SootClass clazz : sootClass.getInterfaces()) {
- if (clazz.getName().equals("org.camunda.bpm.engine.delegate.TaskListener")) {
- parameterTypes.add((Type) delegateTaskType);
- } else if (clazz.getName().equals("org.camunda.bpm.engine.delegate.ExecutionListener")) {
- parameterTypes.add((Type) delegateExecutionType);
- }
+ final VariableBlock originalBlock) {
+
+ className = cleanString(className, true);
+
+ Options.v().set_whole_program(true);
+ Options.v().set_allow_phantom_refs(true);
+
+ SootClass sootClass = Scene.v().forceResolve(className, SootClass.SIGNATURES);
+
+ if (sootClass != null) {
+
+ sootClass.setApplicationClass();
+ Scene.v().loadNecessaryClasses();
+
+ // Retrieve the method and its body based on the used interface
+ List parameterTypes = new ArrayList();
+ RefType delegateExecutionType = RefType.v("org.camunda.bpm.engine.delegate.DelegateExecution");
+ RefType delegateTaskType = RefType.v("org.camunda.bpm.engine.delegate.DelegateTask");
+ RefType mapVariablesType = RefType.v("org.camunda.bpm.engine.variable.VariableMap");
+ VoidType returnType = VoidType.v();
+
+ switch (methodName) {
+ case "execute":
+ parameterTypes.add((Type) delegateExecutionType);
+ outSet = retrieveMethod(classPaths, className, methodName, classFile, element, chapter, fieldType,
+ scopeId, outSet, originalBlock, sootClass, parameterTypes, returnType);
+ break;
+ case "notify":
+ for (SootClass clazz : sootClass.getInterfaces()) {
+ if (clazz.getName().equals("org.camunda.bpm.engine.delegate.TaskListener")) {
+ parameterTypes.add((Type) delegateTaskType);
+ } else if (clazz.getName().equals("org.camunda.bpm.engine.delegate.ExecutionListener")) {
+ parameterTypes.add((Type) delegateExecutionType);
}
- outSet = retrieveMethod(classPaths, className, methodName, classFile, element, chapter, fieldType,
- scopeId, outSet, originalBlock, sootClass, parameterTypes, returnType, visitedClasses);
- break;
- case "mapInputVariables":
- parameterTypes.add((Type) delegateExecutionType);
- parameterTypes.add((Type) mapVariablesType);
- outSet = retrieveMethod(classPaths, className, methodName, classFile, element, chapter, fieldType,
- scopeId, outSet, originalBlock, sootClass, parameterTypes, returnType, visitedClasses);
- break;
- case "mapOutputVariables":
- parameterTypes.add((Type) delegateExecutionType);
- parameterTypes.add((Type) mapVariablesType);
- outSet = retrieveMethod(classPaths, className, methodName, classFile, element, chapter, fieldType,
- scopeId, outSet, originalBlock, sootClass, parameterTypes, returnType, visitedClasses);
- break;
- default:
- visitedClasses.add(className);
- outSet = retrieveCustomMethod(sootClass, classPaths, className, methodName, classFile, element,
- chapter, fieldType, scopeId, outSet, originalBlock, visitedClasses);
- break;
}
-
- } else {
- LOGGER.warning("Class " + classFile + " was not found by Soot");
+ outSet = retrieveMethod(classPaths, className, methodName, classFile, element, chapter, fieldType,
+ scopeId, outSet, originalBlock, sootClass, parameterTypes, returnType);
+ break;
+ case "mapInputVariables":
+ parameterTypes.add((Type) delegateExecutionType);
+ parameterTypes.add((Type) mapVariablesType);
+ outSet = retrieveMethod(classPaths, className, methodName, classFile, element, chapter, fieldType,
+ scopeId, outSet, originalBlock, sootClass, parameterTypes, returnType);
+ break;
+ case "mapOutputVariables":
+ parameterTypes.add((Type) delegateExecutionType);
+ parameterTypes.add((Type) mapVariablesType);
+ outSet = retrieveMethod(classPaths, className, methodName, classFile, element, chapter, fieldType,
+ scopeId, outSet, originalBlock, sootClass, parameterTypes, returnType);
+ break;
+ default:
+ outSet = retrieveCustomMethod(sootClass, classPaths, className, methodName, classFile, element, chapter,
+ fieldType, scopeId, outSet, originalBlock);
+ break;
}
+
+ } else {
+ LOGGER.warning("Class " + classFile + " was not found by Soot");
}
return outSet;
@@ -411,26 +408,24 @@ public OutSetCFG classFetcherRecursive(final Set classPaths, String clas
* Soot representation of parameters
* @param returnType
* Soot Representation of return type
- * @param visitedClasses
- * List of visited classes to avoid circular references
* @return OutSetCFG which contains data flow information
*/
private OutSetCFG retrieveMethod(final Set classPaths, String className, final String methodName,
final String classFile, final BpmnElement element, final ElementChapter chapter,
final KnownElementFieldType fieldType, final String scopeId, OutSetCFG outSet,
final VariableBlock originalBlock, final SootClass sootClass, final List parameterTypes,
- final VoidType returnType, final ArrayList visitedClasses) {
+ final VoidType returnType) {
- SootMethod method = sootClass.getMethodUnsafe(methodName, parameterTypes, (Type) returnType);
+ SootMethod method = sootClass.getMethodUnsafe(methodName, parameterTypes, returnType);
if (method != null) {
- outSet = fetchMethodBody(classPaths, className, methodName, classFile, element, chapter, fieldType, scopeId,
- outSet, originalBlock, method, visitedClasses);
+ outSet = fetchMethodBody(classPaths, className, classFile, element, chapter, fieldType, scopeId,
+ outSet, originalBlock, method);
} else {
method = sootClass.getMethodByNameUnsafe(methodName);
if (method != null) {
- outSet = fetchMethodBody(classPaths, className, methodName, classFile, element, chapter, fieldType,
- scopeId, outSet, originalBlock, method, visitedClasses);
+ outSet = fetchMethodBody(classPaths, className, classFile, element, chapter, fieldType,
+ scopeId, outSet, originalBlock, method);
} else {
LOGGER.warning("In class " + classFile + " - " + methodName + " method was not found by Soot");
}
@@ -465,19 +460,17 @@ private OutSetCFG retrieveMethod(final Set classPaths, String className,
* VariableBlock
* @param sootClass
* Soot representation of given class
- * @param visitedClasses
- * List of visited classes to avoid circular references
* @return OutSetCFG which contains data flow information
*/
private OutSetCFG retrieveCustomMethod(final SootClass sootClass, final Set classPaths, String className,
final String methodName, final String classFile, final BpmnElement element, final ElementChapter chapter,
final KnownElementFieldType fieldType, final String scopeId, OutSetCFG outSet,
- final VariableBlock originalBlock, final ArrayList visitedClasses) {
+ final VariableBlock originalBlock) {
for (SootMethod method : sootClass.getMethods()) {
if (method.getName().equals(methodName)) {
- outSet = fetchMethodBody(classPaths, className, methodName, classFile, element, chapter, fieldType,
- scopeId, outSet, originalBlock, method, visitedClasses);
+ outSet = fetchMethodBody(classPaths, className, classFile, element, chapter, fieldType,
+ scopeId, outSet, originalBlock, method);
}
}
return outSet;
@@ -492,8 +485,6 @@ private OutSetCFG retrieveCustomMethod(final SootClass sootClass, final Set classPaths, final String className, final String methodName,
+ private OutSetCFG fetchMethodBody(final Set classPaths, final String className,
final String classFile, final BpmnElement element, final ElementChapter chapter,
final KnownElementFieldType fieldType, final String scopeId, OutSetCFG outSet,
- final VariableBlock originalBlock, final SootMethod method, final ArrayList visitedClasses) {
+ final VariableBlock originalBlock, final SootMethod method) {
final Body body = method.retrieveActiveBody();
@@ -532,11 +521,10 @@ private OutSetCFG fetchMethodBody(final Set classPaths, final String cla
CallGraph cg = Scene.v().getCallGraph();
final List graphHeads = graph.getHeads();
- final List graphTails = graph.getTails();
for (Block head : graphHeads) {
- outSet = graphIterator(classPaths, cg, graph, head, graphTails, outSet, element, chapter, fieldType,
- classFile, scopeId, originalBlock, className, visitedClasses);
+ outSet = graphIterator(classPaths, cg, graph, outSet, element, chapter, fieldType,
+ classFile, scopeId, originalBlock, className);
}
return outSet;
@@ -552,10 +540,6 @@ private OutSetCFG fetchMethodBody(final Set classPaths, final String cla
* Soot CallGraph
* @param graph
* Control Flow graph of method
- * @param head
- * Starting Block of the CFG
- * @param blockTails
- * List of End Blocks of CFG
* @param outSet
* OUT set of CFG
* @param element
@@ -572,14 +556,12 @@ private OutSetCFG fetchMethodBody(final Set classPaths, final String cla
* VariableBlock
* @param oldClassName
* Classname
- * @param visitedClasses
- * List of visited classes to avoid circular references
* @return OutSetCFG which contains data flow information
*/
- private OutSetCFG graphIterator(final Set classPaths, CallGraph cg, BlockGraph graph, Block head,
- List blockTails, OutSetCFG outSet, final BpmnElement element, final ElementChapter chapter,
+ private OutSetCFG graphIterator(final Set classPaths, CallGraph cg, BlockGraph graph,
+ OutSetCFG outSet, final BpmnElement element, final ElementChapter chapter,
final KnownElementFieldType fieldType, final String filePath, final String scopeId,
- VariableBlock originalBlock, String oldClassName, final ArrayList visitedClasses) {
+ VariableBlock originalBlock, String oldClassName) {
final Iterator graphIterator = graph.iterator();
@@ -589,7 +571,7 @@ private OutSetCFG graphIterator(final Set classPaths, CallGraph cg, Bloc
// Collect the functions Unit by Unit via the blockIterator
final VariableBlock vb = blockIterator(classPaths, cg, block, outSet, element, chapter, fieldType, filePath,
- scopeId, originalBlock, oldClassName, visitedClasses);
+ scopeId, originalBlock, oldClassName);
// depending if outset already has that Block, only add varibles,
// if not, then add the whole vb
@@ -630,14 +612,12 @@ private OutSetCFG graphIterator(final Set classPaths, CallGraph cg, Bloc
* VariableBlock
* @param oldClassName
* Classname
- * @param visitedClasses
- * List of visited classes to avoid circular references
* @return VariableBlock
*/
private VariableBlock blockIterator(final Set classPaths, final CallGraph cg, final Block block,
OutSetCFG outSet, final BpmnElement element, final ElementChapter chapter,
final KnownElementFieldType fieldType, final String filePath, final String scopeId,
- VariableBlock variableBlock, String oldClassName, final ArrayList visitedClasses) {
+ VariableBlock variableBlock, String oldClassName) {
if (variableBlock == null) {
variableBlock = new VariableBlock(block, new ArrayList());
@@ -655,7 +635,7 @@ private VariableBlock blockIterator(final Set classPaths, final CallGrap
Edge src;
while (sources.hasNext()) {
- src = (Edge) sources.next();
+ src = sources.next();
String methodName = src.tgt().getName();
String className = src.tgt().getDeclaringClass().getName();
className = cleanString(className, false);
@@ -668,7 +648,7 @@ private VariableBlock blockIterator(final Set classPaths, final CallGrap
if (classPaths.contains(className) || className.contains("$")) {
G.reset();
classFetcherRecursive(classPaths, className, methodName, className, element, chapter, fieldType,
- scopeId, outSet, variableBlock, visitedClasses);
+ scopeId, outSet, variableBlock);
}
}
@@ -725,7 +705,7 @@ private VariableBlock blockIterator(final Set classPaths, final CallGrap
private void parseExpression(JInterfaceInvokeExpr expr, VariableBlock variableBlock, BpmnElement element,
ElementChapter chapter, KnownElementFieldType fieldType, String filePath, String scopeId) {
- String functionName = expr.getMethodRef().name();
+ String functionName = expr.getMethodRef().getName();
int numberOfArg = expr.getArgCount();
String baseBox = expr.getBaseBox().getValue().getType().toString();
@@ -748,6 +728,45 @@ private void parseExpression(JInterfaceInvokeExpr expr, VariableBlock variableBl
}
}
+ /**
+ *
+ * Parsing of initially discovered statements to find Process Variable
+ * operations.
+ *
+ * @param expr
+ * Expression Unit from Statement
+ * @param element
+ * Current BPMN Element
+ * @param resourceFilePath
+ * Filepath of model
+ * @return inital operations
+ */
+ private Map parseInitialExpression(final JInterfaceInvokeExpr expr, final BpmnElement element,
+ final String resourceFilePath) {
+
+ final LinkedHashMap initialOperations = new LinkedHashMap<>();
+
+ final String functionName = expr.getMethodRef().getName();
+ final int numberOfArg = expr.getArgCount();
+ final String baseBox = expr.getBaseBox().getValue().getType().toString();
+
+ final CamundaProcessVariableFunctions foundMethod = CamundaProcessVariableFunctions
+ .findByNameAndNumberOfBoxes(functionName, baseBox, numberOfArg);
+
+ if (foundMethod != null) {
+ final int location = foundMethod.getLocation() - 1;
+ final VariableOperation type = foundMethod.getOperationType();
+ if (expr.getArgBox(location).getValue() instanceof StringConstant) {
+ final StringConstant variableName = (StringConstant) expr.getArgBox(location).getValue();
+ final String name = variableName.value;
+ initialOperations.put(name, new ProcessVariableOperation(expr.getArg(0).toString(), element,
+ ElementChapter.Code, KnownElementFieldType.Initial, resourceFilePath, type,
+ element.getBaseElement().getId()));
+ }
+ }
+ return initialOperations;
+ }
+
/**
*
* Find anomalies inside a Bpmn element as well.
@@ -952,30 +971,8 @@ private boolean duSourceCode(final ProcessVariableOperation prev, final ProcessV
* @return cleaned String
*/
private String cleanString(String className, boolean dot) {
- final String replaceDot = ".";
- final String replaceEmpty = "";
- final String replaceSingleBackSlash = "\\";
- final String replaceSingleForwardSlash = "/";
- final String replaceDotJava = ".java";
-
- if (dot) {
- if (System.getProperty("os.name").startsWith("Windows")) {
- className = className.replace(replaceSingleBackSlash, replaceDot).replace(replaceDotJava, replaceEmpty);
- } else {
- className = className.replace(replaceSingleForwardSlash, replaceDot).replace(replaceDotJava,
- replaceEmpty);
- }
- } else {
- if (System.getProperty("os.name").startsWith("Windows")) {
- className = className.replace(replaceDot, replaceSingleBackSlash);
- className = className.concat(replaceDotJava);
- } else {
- className = className.replace(replaceDot, replaceSingleForwardSlash);
- className = className.concat(replaceDotJava);
- }
- }
+ className = ProcessVariablesScanner.cleanString(className, dot);
return className;
-
}
}
diff --git a/src/main/java/de/viadee/bpm/vPAV/processing/ProcessVariableReader.java b/src/main/java/de/viadee/bpm/vPAV/processing/ProcessVariableReader.java
index 6d02879b..eeebec44 100644
--- a/src/main/java/de/viadee/bpm/vPAV/processing/ProcessVariableReader.java
+++ b/src/main/java/de/viadee/bpm/vPAV/processing/ProcessVariableReader.java
@@ -31,47 +31,20 @@
*/
package de.viadee.bpm.vPAV.processing;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.el.ELException;
-
+import de.viadee.bpm.vPAV.BpmnScanner;
+import de.viadee.bpm.vPAV.FileScanner;
+import de.viadee.bpm.vPAV.RuntimeConfig;
+import de.viadee.bpm.vPAV.constants.BpmnConstants;
+import de.viadee.bpm.vPAV.constants.ConfigConstants;
+import de.viadee.bpm.vPAV.processing.model.data.*;
import org.camunda.bpm.engine.impl.juel.Builder;
import org.camunda.bpm.engine.impl.juel.IdentifierNode;
import org.camunda.bpm.engine.impl.juel.Tree;
import org.camunda.bpm.engine.impl.juel.TreeBuilder;
import org.camunda.bpm.model.bpmn.Query;
import org.camunda.bpm.model.bpmn.impl.BpmnModelConstants;
-import org.camunda.bpm.model.bpmn.instance.BaseElement;
-import org.camunda.bpm.model.bpmn.instance.BpmnModelElementInstance;
-import org.camunda.bpm.model.bpmn.instance.BusinessRuleTask;
-import org.camunda.bpm.model.bpmn.instance.CallActivity;
-import org.camunda.bpm.model.bpmn.instance.CompletionCondition;
-import org.camunda.bpm.model.bpmn.instance.ConditionExpression;
-import org.camunda.bpm.model.bpmn.instance.ExtensionElements;
-import org.camunda.bpm.model.bpmn.instance.LoopCardinality;
-import org.camunda.bpm.model.bpmn.instance.LoopCharacteristics;
-import org.camunda.bpm.model.bpmn.instance.Script;
-import org.camunda.bpm.model.bpmn.instance.ScriptTask;
-import org.camunda.bpm.model.bpmn.instance.SendTask;
-import org.camunda.bpm.model.bpmn.instance.SequenceFlow;
-import org.camunda.bpm.model.bpmn.instance.ServiceTask;
-import org.camunda.bpm.model.bpmn.instance.UserTask;
-import org.camunda.bpm.model.bpmn.instance.camunda.CamundaExecutionListener;
-import org.camunda.bpm.model.bpmn.instance.camunda.CamundaFormData;
-import org.camunda.bpm.model.bpmn.instance.camunda.CamundaFormField;
-import org.camunda.bpm.model.bpmn.instance.camunda.CamundaIn;
-import org.camunda.bpm.model.bpmn.instance.camunda.CamundaOut;
-import org.camunda.bpm.model.bpmn.instance.camunda.CamundaScript;
-import org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener;
+import org.camunda.bpm.model.bpmn.instance.*;
+import org.camunda.bpm.model.bpmn.instance.camunda.*;
import org.camunda.bpm.model.dmn.Dmn;
import org.camunda.bpm.model.dmn.DmnModelInstance;
import org.camunda.bpm.model.dmn.instance.Decision;
@@ -80,16 +53,12 @@
import org.camunda.bpm.model.dmn.instance.Text;
import org.camunda.bpm.model.xml.instance.ModelElementInstance;
-import de.viadee.bpm.vPAV.BpmnScanner;
-import de.viadee.bpm.vPAV.FileScanner;
-import de.viadee.bpm.vPAV.RuntimeConfig;
-import de.viadee.bpm.vPAV.constants.BpmnConstants;
-import de.viadee.bpm.vPAV.constants.ConfigConstants;
-import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
-import de.viadee.bpm.vPAV.processing.model.data.ElementChapter;
-import de.viadee.bpm.vPAV.processing.model.data.KnownElementFieldType;
-import de.viadee.bpm.vPAV.processing.model.data.ProcessVariableOperation;
-import de.viadee.bpm.vPAV.processing.model.data.VariableOperation;
+import javax.el.ELException;
+import java.io.InputStream;
+import java.util.*;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* search process variables for an bpmn element
@@ -117,12 +86,13 @@ public ProcessVariableReader(final Map decisionRefToPathMap, Bpm
* FileScanner
* @param element
* BpmnElement
- * @return processVariables returns processVariables
+ * @param processVariables
+ * process variable operation
+ * @return returns processVariables
*/
public LinkedHashMap getVariablesFromElement(final JavaReaderContext context,
- final FileScanner fileScanner, final BpmnElement element) {
-
- final LinkedHashMap processVariables = new LinkedHashMap();
+ final FileScanner fileScanner, final BpmnElement element,
+ final LinkedHashMap processVariables) {
// 1) Search variables in task
processVariables.putAll(getVariablesFromTask(context, fileScanner, element));
diff --git a/src/main/java/de/viadee/bpm/vPAV/processing/ProcessVariablesScanner.java b/src/main/java/de/viadee/bpm/vPAV/processing/ProcessVariablesScanner.java
new file mode 100644
index 00000000..9be90c51
--- /dev/null
+++ b/src/main/java/de/viadee/bpm/vPAV/processing/ProcessVariablesScanner.java
@@ -0,0 +1,184 @@
+/**
+ * BSD 3-Clause License
+ *
+ * Copyright © 2018, viadee Unternehmensberatung AG
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package de.viadee.bpm.vPAV.processing;
+
+import de.viadee.bpm.vPAV.FileScanner;
+import de.viadee.bpm.vPAV.constants.CamundaMethodServices;
+import soot.Body;
+import soot.Scene;
+import soot.SootClass;
+import soot.SootMethod;
+import soot.options.Options;
+
+import java.io.IOException;
+import java.util.*;
+
+public class ProcessVariablesScanner {
+
+ private Set javaResources;
+
+ private Map> messageIdToVariableMap = new HashMap>();
+
+ private Map> processIdToVariableMap = new HashMap>();
+
+ private Map> entryPoints = new HashMap>();
+
+ private Set camundaProcessEntryPoints = new HashSet();
+
+ public ProcessVariablesScanner(final Set javaResources) {
+ this.javaResources = javaResources;
+ camundaProcessEntryPoints.add(CamundaMethodServices.START_PROCESS_INSTANCE_BY_ID);
+ camundaProcessEntryPoints.add(CamundaMethodServices.START_PROCESS_INSTANCE_BY_KEY);
+ camundaProcessEntryPoints.add(CamundaMethodServices.START_PROCESS_INSTANCE_BY_MESSAGE);
+ camundaProcessEntryPoints.add(CamundaMethodServices.START_PROCESS_INSTANCE_BY_MESSAGE_AND_PROCESS_DEF);
+ }
+
+ /**
+ * scan java resources for variables and retrieve important information such as
+ * message ids and entrypoints
+ *
+ * @throws IOException
+ * possible exception if filepath can not be resolved
+ */
+ public void scanProcessVariables() throws IOException {
+ for (final String filePath : javaResources) {
+ if (!filePath.startsWith("javax")) {
+ final Set messageIds = new HashSet();
+ final Set processIds = new HashSet();
+ retrieveMethod(filePath, messageIds, processIds);
+ }
+ }
+ }
+
+ /**
+ * Retrieve the method name which contains the entrypoint (e.g.
+ * "startProcessByXYZ")
+ *
+ * @param filePath
+ * fully qualified path to the java class
+ * @return
+ */
+ private void retrieveMethod(final String filePath, final Set messageIds, final Set processIds) {
+ final String sootPath = FileScanner.getSootPath();
+ System.setProperty("soot.class.path", sootPath);
+
+ Options.v().set_whole_program(true);
+ Options.v().set_allow_phantom_refs(true);
+
+ SootClass sootClass = Scene.v().forceResolve(cleanString(filePath, true), SootClass.SIGNATURES);
+
+ if (sootClass != null && !sootClass.isInterface()) {
+ sootClass.setApplicationClass();
+ Scene.v().loadNecessaryClasses();
+ for (SootMethod method : sootClass.getMethods()) {
+// if (method.hasActiveBody()) {
+ final Body body = method.retrieveActiveBody();
+ for (String entryPoint : camundaProcessEntryPoints) {
+ if (body.toString().contains(entryPoint)) {
+ final Map innerMap = new HashMap();
+ innerMap.put(method.getName(), filePath);
+ entryPoints.put(entryPoint, innerMap);
+ messageIds.add(entryPoint);
+ }
+ if (body.toString().contains(CamundaMethodServices.CORRELATE_MESSAGE)) {
+ processIds.add(entryPoint);
+ }
+ }
+// }
+ }
+ }
+ }
+
+ /**
+ * Strips unnecessary characters and returns cleaned name
+ *
+ * @param className
+ * Classname to be stripped of unused chars
+ * @param dot
+ * Replace dots
+ * @return cleaned String
+ */
+ static String cleanString(String className, boolean dot) {
+ final String replaceDot = ".";
+ final String replaceEmpty = "";
+ final String replaceSingleBackSlash = "\\";
+ final String replaceSingleForwardSlash = "/";
+ final String replaceDotJava = ".java";
+
+ if (dot) {
+ if (System.getProperty("os.name").startsWith("Windows")) {
+ className = className.replace(replaceSingleBackSlash, replaceDot).replace(replaceDotJava, replaceEmpty);
+ } else {
+ className = className.replace(replaceSingleForwardSlash, replaceDot).replace(replaceDotJava,
+ replaceEmpty);
+ }
+ } else {
+ if (System.getProperty("os.name").startsWith("Windows")) {
+ className = className.replace(replaceDot, replaceSingleBackSlash);
+ className = className.concat(replaceDotJava);
+ } else {
+ className = className.replace(replaceDot, replaceSingleForwardSlash);
+ className = className.concat(replaceDotJava);
+ }
+ }
+ return className;
+ }
+
+ /**
+ * get list of entrypoints (process message, method) where process variables
+ * have been found
+ *
+ * @return returns list of locations
+ */
+ public Map> getEntryPoints() {
+ return entryPoints;
+ }
+
+ /**
+ * get mapping for message id
+ *
+ * @return messageIdToVariableMap returns messageIdToVariableMap
+ */
+ public Map> getMessageIdToVariableMap() {
+ return messageIdToVariableMap;
+ }
+
+ /**
+ * get mapping for process id
+ *
+ * @return processIdToVariableMap returns processIdToVariableMap
+ */
+ public Map> getProcessIdToVariableMap() {
+ return processIdToVariableMap;
+ }
+
+}
diff --git a/src/main/java/de/viadee/bpm/vPAV/processing/ResourceFileReader.java b/src/main/java/de/viadee/bpm/vPAV/processing/ResourceFileReader.java
index 6035c6a6..88de0a6a 100644
--- a/src/main/java/de/viadee/bpm/vPAV/processing/ResourceFileReader.java
+++ b/src/main/java/de/viadee/bpm/vPAV/processing/ResourceFileReader.java
@@ -31,6 +31,13 @@
*/
package de.viadee.bpm.vPAV.processing;
+import de.viadee.bpm.vPAV.RuntimeConfig;
+import de.viadee.bpm.vPAV.constants.ConfigConstants;
+import de.viadee.bpm.vPAV.processing.model.data.*;
+import org.apache.commons.io.IOUtils;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.types.Resource;
+
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -39,18 +46,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.io.IOUtils;
-import org.apache.tools.ant.DirectoryScanner;
-import org.apache.tools.ant.types.Resource;
-
-import de.viadee.bpm.vPAV.RuntimeConfig;
-import de.viadee.bpm.vPAV.constants.ConfigConstants;
-import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
-import de.viadee.bpm.vPAV.processing.model.data.ElementChapter;
-import de.viadee.bpm.vPAV.processing.model.data.KnownElementFieldType;
-import de.viadee.bpm.vPAV.processing.model.data.ProcessVariableOperation;
-import de.viadee.bpm.vPAV.processing.model.data.VariableOperation;
-
public class ResourceFileReader {
public static final Logger LOGGER = Logger.getLogger(ResourceFileReader.class.getName());
diff --git a/src/main/java/de/viadee/bpm/vPAV/processing/checker/BoundaryErrorChecker.java b/src/main/java/de/viadee/bpm/vPAV/processing/checker/BoundaryErrorChecker.java
index cf5e4058..3a89540d 100644
--- a/src/main/java/de/viadee/bpm/vPAV/processing/checker/BoundaryErrorChecker.java
+++ b/src/main/java/de/viadee/bpm/vPAV/processing/checker/BoundaryErrorChecker.java
@@ -1,304 +1,303 @@
-/**
- * BSD 3-Clause License
- *
- * Copyright © 2018, viadee Unternehmensberatung AG
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of the copyright holder nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package de.viadee.bpm.vPAV.processing.checker;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.tools.ant.DirectoryScanner;
-import org.apache.tools.ant.types.Resource;
-import org.camunda.bpm.model.bpmn.impl.BpmnModelConstants;
-import org.camunda.bpm.model.bpmn.instance.BaseElement;
-
-import de.odysseus.el.tree.IdentifierNode;
-import de.odysseus.el.tree.Tree;
-import de.odysseus.el.tree.TreeBuilder;
-import de.odysseus.el.tree.impl.Builder;
-import de.viadee.bpm.vPAV.BpmnScanner;
-import de.viadee.bpm.vPAV.Messages;
-import de.viadee.bpm.vPAV.RuntimeConfig;
-import de.viadee.bpm.vPAV.config.model.Rule;
-import de.viadee.bpm.vPAV.constants.BpmnConstants;
-import de.viadee.bpm.vPAV.constants.ConfigConstants;
-import de.viadee.bpm.vPAV.output.IssueWriter;
-import de.viadee.bpm.vPAV.processing.CheckName;
-import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
-import de.viadee.bpm.vPAV.processing.model.data.CheckerIssue;
-import de.viadee.bpm.vPAV.processing.model.data.CriticalityEnum;
-
-public class BoundaryErrorChecker extends AbstractElementChecker {
-
- private static Logger logger = Logger.getLogger(BoundaryErrorChecker.class.getName());
-
- public BoundaryErrorChecker(final Rule rule, BpmnScanner bpmnScanner) {
- super(rule, bpmnScanner);
- }
-
- @Override
- public Collection check(BpmnElement element) {
-
- final Collection issues = new ArrayList();
- final BaseElement bpmnElement = element.getBaseElement();
-
- String mappedTaskId = null;
- String implementation = null;
- String implementationRef = null;
-
- // Grab only boundaryEvents
- if (bpmnElement.getElementType().getTypeName().equals(BpmnModelConstants.BPMN_ELEMENT_BOUNDARY_EVENT)) {
-
- // Map errorEventDef -> "errorRef" , "camunda:errorMessageVariable"
- final Map errorEventDef = bpmnScanner.getErrorEvent(bpmnElement.getId());
-
- // Check if boundaryEvent consists of an errorEventDefinition
- if (errorEventDef.size() != 0) {
- mappedTaskId = bpmnScanner.getErrorEventMapping(bpmnElement.getId());
- implementation = bpmnScanner.getImplementation(mappedTaskId);
- implementationRef = bpmnScanner.getImplementationReference(mappedTaskId,
- implementation);
-
- // No error has been referenced
- if (errorEventDef.entrySet().iterator().next().getKey() == null
- || errorEventDef.entrySet().iterator().next().getKey().isEmpty()) {
- final String errorCode = bpmnScanner.getErrorCodeVar(bpmnElement.getId());
- if (errorCode == null || errorCode.isEmpty()) {
- issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.ERROR, element,
- String.format(Messages.getString("BoundaryErrorChecker.0"), //$NON-NLS-1$
- CheckName.checkName(bpmnElement))));
- } else {
- issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.ERROR, element,
- String.format(Messages.getString("BoundaryErrorChecker.1"), //$NON-NLS-1$
- CheckName.checkName(bpmnElement))));
- }
- } else {
-
- // Error reference could be resolved, retrieve errorDefinition
- final Map errorDef = bpmnScanner
- .getErrorDef(errorEventDef.entrySet().iterator().next().getKey());
-
- // No errorCode has been specified
- if (errorDef.entrySet().iterator().next().getValue() == null
- || errorDef.entrySet().iterator().next().getValue().isEmpty()) {
- issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.WARNING, element,
- String.format(Messages.getString("BoundaryErrorChecker.2"), //$NON-NLS-1$
- CheckName.checkName(bpmnElement))));
-
- } else {
- if (implementation != null) {
- // Check the BeanMapping to resolve delegate expression
- if (implementation.equals(BpmnConstants.CAMUNDA_DEXPRESSION)) {
- checkBeanMapping(element, issues, bpmnElement,
- errorDef.entrySet().iterator().next().getValue(), implementationRef);
-
- // Check the directly referenced class
- } else if (implementation.equals(BpmnConstants.CAMUNDA_CLASS)) {
- if (!readResourceFile(implementationRef,
- errorDef.entrySet().iterator().next().getValue())) {
- issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.ERROR, element,
- String.format(
- Messages.getString("BoundaryErrorChecker.3"), //$NON-NLS-1$
- CheckName.checkName(bpmnElement), implementationRef)));
-
- }
- }
- }
- }
-
- // No errorName has been specified
- if (errorDef.entrySet().iterator().next().getKey() == null
- || errorDef.entrySet().iterator().next().getKey().isEmpty()) {
- issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.WARNING, element,
- String.format(Messages.getString("BoundaryErrorChecker.4"), //$NON-NLS-1$
- CheckName.checkName(bpmnElement))));
- }
-
- // No ErrorMessageVariable has been specified
- if (errorEventDef.entrySet().iterator().next().getValue() == null
- || errorEventDef.entrySet().iterator().next().getValue().isEmpty()) {
- issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.WARNING, element,
- String.format(Messages.getString("BoundaryErrorChecker.5"), //$NON-NLS-1$
- CheckName.checkName(bpmnElement))));
- }
- }
- }
- }
- return issues;
- }
-
- /**
- * In case a bean mapping exists, we check for validity of a bean, so the event can be mapped against the respective
- * task If the class or bean can be resolved, the ErrorCode gets validated
- *
- * @param element
- * @param issues
- * @param bpmnElement
- * @param errorDefEntry
- * @param implementationRef
- */
- private void checkBeanMapping(BpmnElement element, final Collection issues,
- final BaseElement bpmnElement, final String errorDefEntry, final String implementationRef) {
- if (RuntimeConfig.getInstance().getBeanMapping() != null) {
- final TreeBuilder treeBuilder = new Builder();
- final Tree tree = treeBuilder.build(implementationRef);
- final Iterable identifierNodes = tree.getIdentifierNodes();
- // if beanMapping ${...} reference
- if (identifierNodes.iterator().hasNext()) {
- for (final IdentifierNode node : identifierNodes) {
- final String classFile = RuntimeConfig.getInstance().getBeanMapping()
- .get(node.getName());
- // correct beanmapping was found -> check if class exists
- if (classFile != null && classFile.trim().length() > 0) {
- if (checkClassFile(classFile)) {
- if (!readResourceFile(classFile, errorDefEntry)) {
- issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.ERROR, element,
- String.format(
- Messages.getString("BoundaryErrorChecker.6"), //$NON-NLS-1$
- CheckName.checkName(bpmnElement), node.getName())));
- }
- } else {
- issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.ERROR, element,
- Messages.getString("BoundaryErrorChecker.7"))); //$NON-NLS-1$
- }
- } else {
- // incorrect beanmapping
- issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.ERROR, element, String.format(
- Messages.getString("BoundaryErrorChecker.8"), //$NON-NLS-1$
- implementationRef)));
- }
- }
- }
- } else {
- if (!checkClassFile(implementationRef)) {
- issues.addAll(
- IssueWriter.createIssue(rule, CriticalityEnum.ERROR, element,
- String.format(
- Messages.getString("BoundaryErrorChecker.9"), //$NON-NLS-1$
- implementationRef, CheckName.checkName(bpmnElement))));
- }
- }
- }
-
- /**
- * Reads a resource and retrieves content as String
- *
- * @param className
- * @param errorCode
- * @return boolean
- */
- private boolean readResourceFile(final String className, final String errorCode) {
-
- final String fileName = className.replaceAll("\\.", "/") + ".java"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- boolean matchingErrorCode = false;
-
- if (fileName != null && fileName.trim().length() > 0) {
- try {
- final DirectoryScanner scanner = new DirectoryScanner();
-
- if (RuntimeConfig.getInstance().isTest()) {
- if (fileName.endsWith(".java")) //$NON-NLS-1$
- scanner.setBasedir(ConfigConstants.TEST_JAVAPATH);
- else
- scanner.setBasedir(ConfigConstants.TEST_BASEPATH);
- } else {
- if (fileName.endsWith(".java")) //$NON-NLS-1$
- scanner.setBasedir(ConfigConstants.JAVAPATH);
- else
- scanner.setBasedir(ConfigConstants.BASEPATH);
- }
-
- Resource s = scanner.getResource(fileName);
-
- if (s.isExists()) {
- InputStreamReader resource = new InputStreamReader(new FileInputStream(s.toString()));
- final String methodBody = IOUtils.toString(resource);
- return validateContent(methodBody, errorCode);
- } else {
- logger.warning("Class " + fileName + " could not be read or does not exist"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- } catch (final IOException ex) {
- logger.warning("Resource '" + fileName + "' could not be read: " + ex.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- return matchingErrorCode;
- }
-
- /**
- * Check methodBody for content and return true if a "throw new BpmnError.." declaration is found
- *
- * @param errorCode
- * @param methodBody
- * @return boolean
- */
- private boolean validateContent(final String methodBody, final String errorCode) {
-
- if (methodBody != null && !methodBody.isEmpty()) {
- if (methodBody.contains("throw new BpmnError")) { //$NON-NLS-1$
- String temp = methodBody.substring(methodBody.indexOf("throw new BpmnError")); //$NON-NLS-1$
- temp = temp.substring(0, temp.indexOf(";") + 1); //$NON-NLS-1$
-
- final String delErrorCode = temp.substring(temp.indexOf("\"") + 1, temp.lastIndexOf("\"")); //$NON-NLS-1$ //$NON-NLS-2$
- if (delErrorCode.equals(errorCode)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Check if class reference for a given element exists
- *
- * @param className
- * @return boolean
- */
- private boolean checkClassFile(final String className) {
-
- @SuppressWarnings("unused")
- final String classPath = className.replaceAll("\\.", "/") + ".java"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- try {
- RuntimeConfig.getInstance().getClassLoader().loadClass(className);
- } catch (final ClassNotFoundException e) {
- return false;
- }
- return true;
- }
-
-}
+/**
+ * BSD 3-Clause License
+ *
+ * Copyright © 2018, viadee Unternehmensberatung AG
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package de.viadee.bpm.vPAV.processing.checker;
+
+import de.odysseus.el.tree.IdentifierNode;
+import de.odysseus.el.tree.Tree;
+import de.odysseus.el.tree.TreeBuilder;
+import de.odysseus.el.tree.impl.Builder;
+import de.viadee.bpm.vPAV.BpmnScanner;
+import de.viadee.bpm.vPAV.Messages;
+import de.viadee.bpm.vPAV.RuntimeConfig;
+import de.viadee.bpm.vPAV.config.model.Rule;
+import de.viadee.bpm.vPAV.constants.BpmnConstants;
+import de.viadee.bpm.vPAV.constants.ConfigConstants;
+import de.viadee.bpm.vPAV.output.IssueWriter;
+import de.viadee.bpm.vPAV.processing.CheckName;
+import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
+import de.viadee.bpm.vPAV.processing.model.data.CheckerIssue;
+import de.viadee.bpm.vPAV.processing.model.data.CriticalityEnum;
+import org.apache.commons.io.IOUtils;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.types.Resource;
+import org.camunda.bpm.model.bpmn.impl.BpmnModelConstants;
+import org.camunda.bpm.model.bpmn.instance.BaseElement;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.logging.Logger;
+
+public class BoundaryErrorChecker extends AbstractElementChecker {
+
+ private static Logger logger = Logger.getLogger(BoundaryErrorChecker.class.getName());
+
+ public BoundaryErrorChecker(final Rule rule, BpmnScanner bpmnScanner) {
+ super(rule, bpmnScanner);
+ }
+
+ @Override
+ public Collection check(BpmnElement element) {
+
+ final Collection issues = new ArrayList();
+ final BaseElement bpmnElement = element.getBaseElement();
+
+ String mappedTaskId = null;
+ String implementation = null;
+ String implementationRef = null;
+
+ // Grab only boundaryEvents
+ if (bpmnElement.getElementType().getTypeName().equals(BpmnModelConstants.BPMN_ELEMENT_BOUNDARY_EVENT)) {
+
+ // Map errorEventDef -> "errorRef" , "camunda:errorMessageVariable"
+ final Map errorEventDef = bpmnScanner.getErrorEvent(bpmnElement.getId());
+
+ // Check if boundaryEvent consists of an errorEventDefinition
+ if (errorEventDef.size() != 0) {
+ mappedTaskId = bpmnScanner.getErrorEventMapping(bpmnElement.getId());
+ implementation = bpmnScanner.getImplementation(mappedTaskId);
+ implementationRef = bpmnScanner.getImplementationReference(mappedTaskId,
+ implementation);
+
+ // No error has been referenced
+ if (errorEventDef.entrySet().iterator().next().getKey() == null
+ || errorEventDef.entrySet().iterator().next().getKey().isEmpty()) {
+ final String errorCode = bpmnScanner.getErrorCodeVar(bpmnElement.getId());
+ if (errorCode == null || errorCode.isEmpty()) {
+ issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.ERROR, element,
+ String.format(Messages.getString("BoundaryErrorChecker.0"), //$NON-NLS-1$
+ CheckName.checkName(bpmnElement))));
+ } else {
+ issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.ERROR, element,
+ String.format(Messages.getString("BoundaryErrorChecker.1"), //$NON-NLS-1$
+ CheckName.checkName(bpmnElement))));
+ }
+ } else {
+
+ // Error reference could be resolved, retrieve errorDefinition
+ final Map errorDef = bpmnScanner
+ .getErrorDef(errorEventDef.entrySet().iterator().next().getKey());
+
+ // No errorCode has been specified
+ if (errorDef.entrySet().iterator().next().getValue() == null
+ || errorDef.entrySet().iterator().next().getValue().isEmpty()) {
+ issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.WARNING, element,
+ String.format(Messages.getString("BoundaryErrorChecker.2"), //$NON-NLS-1$
+ CheckName.checkName(bpmnElement))));
+
+ } else {
+ if (implementation != null) {
+ // Check the BeanMapping to resolve delegate expression
+ if (implementation.equals(BpmnConstants.CAMUNDA_DEXPRESSION)) {
+ checkBeanMapping(element, issues, bpmnElement,
+ errorDef.entrySet().iterator().next().getValue(), implementationRef);
+
+ // Check the directly referenced class
+ } else if (implementation.equals(BpmnConstants.CAMUNDA_CLASS)) {
+ if (!readResourceFile(implementationRef,
+ errorDef.entrySet().iterator().next().getValue())) {
+ issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.ERROR, element,
+ String.format(
+ Messages.getString("BoundaryErrorChecker.3"), //$NON-NLS-1$
+ CheckName.checkName(bpmnElement), implementationRef)));
+
+ }
+ }
+ }
+ }
+
+ // No errorName has been specified
+ if (errorDef.entrySet().iterator().next().getKey() == null
+ || errorDef.entrySet().iterator().next().getKey().isEmpty()) {
+ issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.WARNING, element,
+ String.format(Messages.getString("BoundaryErrorChecker.4"), //$NON-NLS-1$
+ CheckName.checkName(bpmnElement))));
+ }
+
+ // No ErrorMessageVariable has been specified
+ if (errorEventDef.entrySet().iterator().next().getValue() == null
+ || errorEventDef.entrySet().iterator().next().getValue().isEmpty()) {
+ issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.WARNING, element,
+ String.format(Messages.getString("BoundaryErrorChecker.5"), //$NON-NLS-1$
+ CheckName.checkName(bpmnElement))));
+ }
+ }
+ }
+ }
+ return issues;
+ }
+
+ /**
+ * In case a bean mapping exists, we check for validity of a bean, so the event can be mapped against the respective
+ * task If the class or bean can be resolved, the ErrorCode gets validated
+ *
+ * @param element
+ * @param issues
+ * @param bpmnElement
+ * @param errorDefEntry
+ * @param implementationRef
+ */
+ private void checkBeanMapping(BpmnElement element, final Collection issues,
+ final BaseElement bpmnElement, final String errorDefEntry, final String implementationRef) {
+ if (RuntimeConfig.getInstance().getBeanMapping() != null) {
+ final TreeBuilder treeBuilder = new Builder();
+ final Tree tree = treeBuilder.build(implementationRef);
+ final Iterable identifierNodes = tree.getIdentifierNodes();
+ // if beanMapping ${...} reference
+ if (identifierNodes.iterator().hasNext()) {
+ for (final IdentifierNode node : identifierNodes) {
+ final String classFile = RuntimeConfig.getInstance().getBeanMapping()
+ .get(node.getName());
+ // correct beanmapping was found -> check if class exists
+ if (classFile != null && classFile.trim().length() > 0) {
+ if (checkClassFile(classFile)) {
+ if (!readResourceFile(classFile, errorDefEntry)) {
+ issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.ERROR, element,
+ String.format(
+ Messages.getString("BoundaryErrorChecker.6"), //$NON-NLS-1$
+ CheckName.checkName(bpmnElement), node.getName())));
+ }
+ } else {
+ issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.ERROR, element,
+ Messages.getString("BoundaryErrorChecker.7"))); //$NON-NLS-1$
+ }
+ } else {
+ // incorrect beanmapping
+ issues.addAll(IssueWriter.createIssue(rule, CriticalityEnum.ERROR, element, String.format(
+ Messages.getString("BoundaryErrorChecker.8"), //$NON-NLS-1$
+ implementationRef)));
+ }
+ }
+ }
+ } else {
+ if (!checkClassFile(implementationRef)) {
+ issues.addAll(
+ IssueWriter.createIssue(rule, CriticalityEnum.ERROR, element,
+ String.format(
+ Messages.getString("BoundaryErrorChecker.9"), //$NON-NLS-1$
+ implementationRef, CheckName.checkName(bpmnElement))));
+ }
+ }
+ }
+
+ /**
+ * Reads a resource and retrieves content as String
+ *
+ * @param className
+ * @param errorCode
+ * @return boolean
+ */
+ private boolean readResourceFile(final String className, final String errorCode) {
+
+ final String fileName = className.replaceAll("\\.", "/") + ".java"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ boolean matchingErrorCode = false;
+
+ if (fileName != null && fileName.trim().length() > 0) {
+ try {
+ final DirectoryScanner scanner = new DirectoryScanner();
+
+ if (RuntimeConfig.getInstance().isTest()) {
+ if (fileName.endsWith(".java")) //$NON-NLS-1$
+ scanner.setBasedir(ConfigConstants.TEST_JAVAPATH);
+ else
+ scanner.setBasedir(ConfigConstants.TEST_BASEPATH);
+ } else {
+ if (fileName.endsWith(".java")) //$NON-NLS-1$
+ scanner.setBasedir(ConfigConstants.JAVAPATH);
+ else
+ scanner.setBasedir(ConfigConstants.BASEPATH);
+ }
+
+ Resource s = scanner.getResource(fileName);
+
+ if (s.isExists()) {
+ InputStreamReader resource = new InputStreamReader(new FileInputStream(s.toString()));
+ final String methodBody = IOUtils.toString(resource);
+ return validateContent(methodBody, errorCode);
+ } else {
+ logger.warning("Class " + fileName + " could not be read or does not exist"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } catch (final IOException ex) {
+ logger.warning("Resource '" + fileName + "' could not be read: " + ex.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ return matchingErrorCode;
+ }
+
+ /**
+ * Check methodBody for content and return true if a "throw new BpmnError.." declaration is found
+ *
+ * @param errorCode
+ * @param methodBody
+ * @return boolean
+ */
+ private boolean validateContent(final String methodBody, final String errorCode) {
+
+ if (methodBody != null && !methodBody.isEmpty()) {
+ if (methodBody.contains("throw new BpmnError")) { //$NON-NLS-1$
+ String temp = methodBody.substring(methodBody.indexOf("throw new BpmnError")); //$NON-NLS-1$
+ temp = temp.substring(0, temp.indexOf(";") + 1); //$NON-NLS-1$
+
+ final String delErrorCode = temp.substring(temp.indexOf("\"") + 1, temp.lastIndexOf("\"")); //$NON-NLS-1$ //$NON-NLS-2$
+ if (delErrorCode.equals(errorCode)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check if class reference for a given element exists
+ *
+ * @param className
+ * @return boolean
+ */
+ private boolean checkClassFile(final String className) {
+
+ @SuppressWarnings("unused")
+ final String classPath = className.replaceAll("\\.", "/") + ".java"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ try {
+ RuntimeConfig.getInstance().getClassLoader().loadClass(className);
+ } catch (final ClassNotFoundException e) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/src/main/java/de/viadee/bpm/vPAV/processing/checker/CheckerFactory.java b/src/main/java/de/viadee/bpm/vPAV/processing/checker/CheckerFactory.java
index 8f176b31..04bd7dff 100644
--- a/src/main/java/de/viadee/bpm/vPAV/processing/checker/CheckerFactory.java
+++ b/src/main/java/de/viadee/bpm/vPAV/processing/checker/CheckerFactory.java
@@ -31,15 +31,6 @@
*/
package de.viadee.bpm.vPAV.processing.checker;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Logger;
-
import de.viadee.bpm.vPAV.BpmnScanner;
import de.viadee.bpm.vPAV.Messages;
import de.viadee.bpm.vPAV.RuntimeConfig;
@@ -47,6 +38,11 @@
import de.viadee.bpm.vPAV.constants.BpmnConstants;
import de.viadee.bpm.vPAV.constants.ConfigConstants;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.*;
+import java.util.logging.Logger;
+
/**
* Factory decides which Checkers will be used in defined situations
*
diff --git a/src/main/java/de/viadee/bpm/vPAV/processing/checker/DataFlowChecker.java b/src/main/java/de/viadee/bpm/vPAV/processing/checker/DataFlowChecker.java
index 4eea51ce..86770848 100644
--- a/src/main/java/de/viadee/bpm/vPAV/processing/checker/DataFlowChecker.java
+++ b/src/main/java/de/viadee/bpm/vPAV/processing/checker/DataFlowChecker.java
@@ -34,8 +34,8 @@
import de.viadee.bpm.vPAV.config.model.Rule;
import de.viadee.bpm.vPAV.output.IssueWriter;
import de.viadee.bpm.vPAV.processing.dataflow.DataFlowRule;
-import de.viadee.bpm.vPAV.processing.model.data.ProcessVariable;
import de.viadee.bpm.vPAV.processing.model.data.CheckerIssue;
+import de.viadee.bpm.vPAV.processing.model.data.ProcessVariable;
import org.camunda.bpm.model.bpmn.BpmnModelInstance;
import java.util.ArrayList;
diff --git a/src/main/java/de/viadee/bpm/vPAV/processing/checker/DmnTaskChecker.java b/src/main/java/de/viadee/bpm/vPAV/processing/checker/DmnTaskChecker.java
index e41fb6b3..37304d7c 100644
--- a/src/main/java/de/viadee/bpm/vPAV/processing/checker/DmnTaskChecker.java
+++ b/src/main/java/de/viadee/bpm/vPAV/processing/checker/DmnTaskChecker.java
@@ -31,14 +31,6 @@
*/
package de.viadee.bpm.vPAV.processing.checker;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.camunda.bpm.model.bpmn.impl.BpmnModelConstants;
-import org.camunda.bpm.model.bpmn.instance.BaseElement;
-import org.camunda.bpm.model.bpmn.instance.BusinessRuleTask;
-
import de.viadee.bpm.vPAV.BpmnScanner;
import de.viadee.bpm.vPAV.Messages;
import de.viadee.bpm.vPAV.RuntimeConfig;
@@ -49,6 +41,13 @@
import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
import de.viadee.bpm.vPAV.processing.model.data.CheckerIssue;
import de.viadee.bpm.vPAV.processing.model.data.CriticalityEnum;
+import org.camunda.bpm.model.bpmn.impl.BpmnModelConstants;
+import org.camunda.bpm.model.bpmn.instance.BaseElement;
+import org.camunda.bpm.model.bpmn.instance.BusinessRuleTask;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
/**
* Checks, whether a business rule task with dmn implementation is valid
diff --git a/src/main/java/de/viadee/bpm/vPAV/processing/checker/ElementChecker.java b/src/main/java/de/viadee/bpm/vPAV/processing/checker/ElementChecker.java
index c5aee336..be92d717 100644
--- a/src/main/java/de/viadee/bpm/vPAV/processing/checker/ElementChecker.java
+++ b/src/main/java/de/viadee/bpm/vPAV/processing/checker/ElementChecker.java
@@ -31,11 +31,11 @@
*/
package de.viadee.bpm.vPAV.processing.checker;
-import java.util.Collection;
-
import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
import de.viadee.bpm.vPAV.processing.model.data.CheckerIssue;
+import java.util.Collection;
+
/**
* Checks bpmn models for defined characteristics
*/
diff --git a/src/main/java/de/viadee/bpm/vPAV/processing/checker/ElementIdConventionChecker.java b/src/main/java/de/viadee/bpm/vPAV/processing/checker/ElementIdConventionChecker.java
index be72d229..cf71b7b1 100644
--- a/src/main/java/de/viadee/bpm/vPAV/processing/checker/ElementIdConventionChecker.java
+++ b/src/main/java/de/viadee/bpm/vPAV/processing/checker/ElementIdConventionChecker.java
@@ -1,87 +1,86 @@
-/**
- * BSD 3-Clause License
- *
- * Copyright © 2018, viadee Unternehmensberatung AG
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of the copyright holder nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package de.viadee.bpm.vPAV.processing.checker;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.camunda.bpm.model.bpmn.impl.BpmnModelConstants;
-import org.camunda.bpm.model.bpmn.instance.BaseElement;
-
-import de.viadee.bpm.vPAV.BpmnScanner;
-import de.viadee.bpm.vPAV.Messages;
-import de.viadee.bpm.vPAV.config.model.ElementConvention;
-import de.viadee.bpm.vPAV.config.model.Rule;
-import de.viadee.bpm.vPAV.output.IssueWriter;
-import de.viadee.bpm.vPAV.processing.model.data.BpmnElement;
-import de.viadee.bpm.vPAV.processing.model.data.CheckerIssue;
-import de.viadee.bpm.vPAV.processing.model.data.CriticalityEnum;
-
-public class ElementIdConventionChecker extends AbstractElementChecker {
-
- public ElementIdConventionChecker(final Rule rule, final BpmnScanner bpmnScanner) {
- super(rule, bpmnScanner);
- }
-
- /**
- * Check if an element follows a configurable pattern
- *
- * @return issues
- */
- @Override
- public Collection check(final BpmnElement element) {
- final Collection