[jbpm-commits] JBoss JBPM SVN: r3847 - in jbpm3/trunk/modules/core: scripts and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Feb 12 02:33:12 EST 2009


Author: thomas.diesler at jboss.com
Date: 2009-02-12 02:33:12 -0500 (Thu, 12 Feb 2009)
New Revision: 3847

Added:
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1686/
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1686/JBPM1686Test.java
Modified:
   jbpm3/trunk/modules/core/pom.xml
   jbpm3/trunk/modules/core/scripts/antrun-jbpm-config.xml
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Node.java
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java
Log:
[JBPM-1686] NPE when reading a process definition with a decision name which contains the / character

Modified: jbpm3/trunk/modules/core/pom.xml
===================================================================
--- jbpm3/trunk/modules/core/pom.xml	2009-02-12 06:54:41 UTC (rev 3846)
+++ jbpm3/trunk/modules/core/pom.xml	2009-02-12 07:33:12 UTC (rev 3847)
@@ -182,7 +182,7 @@
             <configuration>
               <tasks>
                 <property name="database" value="${database}" />
-                <ant antfile="scripts/antrun-jbpm-config.xml" target="concat" />
+                <ant antfile="scripts/antrun-jbpm-config.xml" target="generate-hibernate-cfg" />
               </tasks>
             </configuration>
           </execution>
@@ -225,8 +225,7 @@
                   <configuration>
                     <tasks>
                       <property name="database" value="${database}" />
-                      <ant antfile="scripts/antrun-jbpm-config.xml" target="concat" />
-                      <ant antfile="scripts/antrun-jbpm-config.xml" target="jbpm-cfg-xml-soa" />
+                      <ant antfile="scripts/antrun-jbpm-config.xml" target="generate-jbpm-cfg-soa" />
                     </tasks>
                   </configuration>
                 </execution>

Modified: jbpm3/trunk/modules/core/scripts/antrun-jbpm-config.xml
===================================================================
--- jbpm3/trunk/modules/core/scripts/antrun-jbpm-config.xml	2009-02-12 06:54:41 UTC (rev 3846)
+++ jbpm3/trunk/modules/core/scripts/antrun-jbpm-config.xml	2009-02-12 07:33:12 UTC (rev 3847)
@@ -11,7 +11,7 @@
 
 <!-- $Id$ -->
 
-<project default="concat">
+<project>
 
   <property name="project.build.directory" value="${basedir}/target"/>
   <property name="build.resources.directory" value="${basedir}/target/classes"/>
@@ -80,7 +80,7 @@
   </macrodef>
 
   <!-- Concatenates the hibernate config scripts -->	
-  <target name="concat" >
+  <target name="generate-hibernate-cfg" >
     <macro-database-cfg database="db2" />
     <macro-database-cfg database="derby" />
     <macro-database-cfg database="firebird" />
@@ -105,7 +105,7 @@
   </target>
  
   <!-- Generate the custom jbpm.cfg.xml for the SOA platform -->	
-  <target name="jbpm-cfg-xml-soa" >
+  <target name="generate-jbpm-cfg-soa" depends="generate-hibernate-cfg">
     <echo message="Generate the custom jbpm.cfg.xml for the SOA platform" />
     <macro-disable section="Logging Service" file="${project.build.directory}/classes/org/jbpm/default.jbpm.cfg.xml"/>
   </target>

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Node.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Node.java	2009-02-12 06:54:41 UTC (rev 3846)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Node.java	2009-02-12 07:33:12 UTC (rev 3847)
@@ -500,6 +500,9 @@
    */
   public void setName(String name)
   {
+    if (name == null || name.contains("/"))
+      throw new IllegalArgumentException("Invalid node name: " + name);
+    
     if (isDifferent(this.name, name))
     {
       String oldName = this.name;

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java	2009-02-12 06:54:41 UTC (rev 3846)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java	2009-02-12 07:33:12 UTC (rev 3847)
@@ -59,8 +59,9 @@
 import org.jbpm.taskmgmt.def.TaskMgmtDefinition;
 import org.xml.sax.InputSource;
 
-public class JpdlXmlReader implements ProblemListener {
-  
+public class JpdlXmlReader implements ProblemListener
+{
+
   private static final long serialVersionUID = 1L;
 
   protected InputSource inputSource = null;
@@ -71,32 +72,37 @@
   protected Collection<Object[]> unresolvedTransitionDestinations = null;
   protected Collection<Object[]> unresolvedActionReferences = null;
 
-  /**
+  /*
    * the parsed process definition as DOM tree (available after readProcessDefinition)
    */
   protected Document document;
 
-  /** for autonumbering anonymous timers. */
+  /*  for autonumbering anonymous timers. */
   private int timerNumber;
 
-  public JpdlXmlReader(InputSource inputSource) {
+  public JpdlXmlReader(InputSource inputSource)
+  {
     this.inputSource = inputSource;
   }
-  
-  public JpdlXmlReader(InputSource inputSource, ProblemListener problemListener) {
+
+  public JpdlXmlReader(InputSource inputSource, ProblemListener problemListener)
+  {
     this.inputSource = inputSource;
     this.problemListener = problemListener;
   }
-  
-  public JpdlXmlReader(Reader reader) {
+
+  public JpdlXmlReader(Reader reader)
+  {
     this(new InputSource(reader));
   }
 
-  public void close() throws IOException {
+  public void close() throws IOException
+  {
     InputStream byteStream = inputSource.getByteStream();
-    if (byteStream != null) 
+    if (byteStream != null)
       byteStream.close();
-    else {
+    else
+    {
       Reader charStream = inputSource.getCharacterStream();
       if (charStream != null)
         charStream.close();
@@ -104,31 +110,38 @@
     document = null;
   }
 
-  public ProcessDefinition getProcessDefinition() {
+  public ProcessDefinition getProcessDefinition()
+  {
     return processDefinition;
   }
 
-  public void addProblem(Problem problem) {
+  public void addProblem(Problem problem)
+  {
     problems.add(problem);
-    if (problemListener!=null) problemListener.addProblem(problem);
+    if (problemListener != null)
+      problemListener.addProblem(problem);
   }
-  
-  public void addError(String description) {
-    log.error("invalid process xml: "+description);
+
+  public void addError(String description)
+  {
+    log.error("invalid process xml: " + description);
     addProblem(new Problem(Problem.LEVEL_ERROR, description));
   }
 
-  public void addError(String description, Throwable exception) {
-    log.error("invalid process xml: "+description, exception);
+  public void addError(String description, Throwable exception)
+  {
+    log.error("invalid process xml: " + description, exception);
     addProblem(new Problem(Problem.LEVEL_ERROR, description, exception));
   }
 
-  public void addWarning(String description) {
-    log.warn("process xml warning: "+description);
+  public void addWarning(String description)
+  {
+    log.warn("process xml warning: " + description);
     addProblem(new Problem(Problem.LEVEL_WARNING, description));
   }
 
-  public ProcessDefinition readProcessDefinition() {
+  public ProcessDefinition readProcessDefinition()
+  {
     // create a new definition
     processDefinition = ProcessDefinition.createNewProcessDefinition();
 
@@ -136,18 +149,20 @@
     problems = new ArrayList<Problem>();
     unresolvedTransitionDestinations = new ArrayList<Object[]>();
     unresolvedActionReferences = new ArrayList<Object[]>();
-		
-    try {
+
+    try
+    {
       // parse the document into a dom tree
       document = JpdlParser.parse(inputSource, this);
       Element root = document.getRootElement();
-            
+
       // read the process name
       parseProcessDefinitionAttributes(root);
-      
-      // get the process description 
+
+      // get the process description
       String description = root.elementTextTrim("description");
-      if (description!=null) {
+      if (description != null)
+      {
         processDefinition.setDescription(description);
       }
 
@@ -164,59 +179,73 @@
       resolveActionReferences();
       verifySwimlaneAssignments();
 
-    } catch (Exception e) {
+    }
+    catch (Exception e)
+    {
       log.error("couldn't parse process definition", e);
       addProblem(new Problem(Problem.LEVEL_ERROR, "couldn't parse process definition", e));
     }
-    
-    if (Problem.containsProblemsOfLevel(problems, Problem.LEVEL_ERROR)) {
+
+    if (Problem.containsProblemsOfLevel(problems, Problem.LEVEL_ERROR))
+    {
       throw new JpdlException(problems);
     }
-    
-    if (problems!=null) {
-      for (Problem problem : problems) {
-        log.warn("process parse warning: "+problem.getDescription());        
+
+    if (problems != null)
+    {
+      for (Problem problem : problems)
+      {
+        log.warn("process parse warning: " + problem.getDescription());
       }
     }
-    
+
     return processDefinition;
   }
 
-  protected void parseProcessDefinitionAttributes(Element root) {
+  protected void parseProcessDefinitionAttributes(Element root)
+  {
     processDefinition.setName(root.attributeValue("name"));
     initialNodeName = root.attributeValue("initial");
   }
-  
-  protected void readSwimlanes(Element processDefinitionElement) {
+
+  protected void readSwimlanes(Element processDefinitionElement)
+  {
     Iterator<?> iter = processDefinitionElement.elementIterator("swimlane");
     TaskMgmtDefinition taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
-    while (iter.hasNext()) {
-      Element swimlaneElement = (Element) iter.next();
+    while (iter.hasNext())
+    {
+      Element swimlaneElement = (Element)iter.next();
       String swimlaneName = swimlaneElement.attributeValue("name");
-      if (swimlaneName==null) {
+      if (swimlaneName == null)
+      {
         addWarning("there's a swimlane without a name");
-      } else {
+      }
+      else
+      {
         Swimlane swimlane = new Swimlane(swimlaneName);
         Element assignmentElement = swimlaneElement.element("assignment");
 
-        if (assignmentElement!=null) {
-          
-          if ( (assignmentElement.attribute("actor-id")!=null)
-              || (assignmentElement.attribute("pooled-actors")!=null)
-            ) {
+        if (assignmentElement != null)
+        {
+
+          if ((assignmentElement.attribute("actor-id") != null) || (assignmentElement.attribute("pooled-actors") != null))
+          {
             swimlane.setActorIdExpression(assignmentElement.attributeValue("actor-id"));
             swimlane.setPooledActorsExpression(assignmentElement.attributeValue("pooled-actors"));
-           
-          } else {
+
+          }
+          else
+          {
             Delegation assignmentDelegation = readAssignmentDelegation(assignmentElement);
             swimlane.setAssignmentDelegation(assignmentDelegation);
           }
-        } else {
+        }
+        else
+        {
           Task startTask = taskMgmtDefinition.getStartTask();
-          if ( (startTask==null)
-               || (startTask.getSwimlane()!=swimlane)
-             ) {
-            addWarning("swimlane '"+swimlaneName+"' does not have an assignment");
+          if ((startTask == null) || (startTask.getSwimlane() != swimlane))
+          {
+            addWarning("swimlane '" + swimlaneName + "' does not have an assignment");
           }
         }
         taskMgmtDefinition.addSwimlane(swimlane);
@@ -224,90 +253,111 @@
     }
   }
 
-  public void readNodes(Element element, NodeCollection nodeCollection) {
+  public void readNodes(Element element, NodeCollection nodeCollection)
+  {
     Iterator<?> nodeElementIter = element.elementIterator();
-    while (nodeElementIter.hasNext()) {
-      Element nodeElement = (Element) nodeElementIter.next();
+    while (nodeElementIter.hasNext())
+    {
+      Element nodeElement = (Element)nodeElementIter.next();
       String nodeName = nodeElement.getName();
       // get the node type
       Class<?> nodeType = NodeTypes.getNodeType(nodeName);
-      if (nodeType!=null) {
+      if (nodeType != null)
+      {
 
         Node node = null;
-        try {
+        try
+        {
           // create a new instance
-          node = (Node) nodeType.newInstance();
-        } catch (Exception e) {
-          log.error("couldn't instantiate node '"+nodeName+"', of type '"+nodeType.getName()+"'", e);
+          node = (Node)nodeType.newInstance();
+        }
+        catch (Exception e)
+        {
+          log.error("couldn't instantiate node '" + nodeName + "', of type '" + nodeType.getName() + "'", e);
           continue;
         }
-        
+
         node.setProcessDefinition(processDefinition);
-        
+
         // check for duplicate start-states
-        if ( (node instanceof StartState)
-             && (processDefinition.getStartState()!=null)
-           ) {
+        if ((node instanceof StartState) && (processDefinition.getStartState() != null))
+        {
           addError("max one start-state allowed in a process");
-          
-        } else {
+
+        }
+        else
+        {
           // read the common node parts of the element
           readNode(nodeElement, node, nodeCollection);
-        
-          // if the node is parsable 
-          // (meaning: if the node has special configuration to parse, other then the 
-          //  common node data)
+
+          // if the node is parsable
+          // (meaning: if the node has special configuration to parse, other then the
+          // common node data)
           node.read(nodeElement, this);
         }
       }
     }
   }
 
-  public void readTasks(Element element, TaskNode taskNode) {
+  public void readTasks(Element element, TaskNode taskNode)
+  {
     List<?> elements = element.elements("task");
-    TaskMgmtDefinition tmd = processDefinition.getTaskMgmtDefinition(); 
-    if (elements.size()>0) {
-      if (tmd==null) {
+    TaskMgmtDefinition tmd = processDefinition.getTaskMgmtDefinition();
+    if (elements.size() > 0)
+    {
+      if (tmd == null)
+      {
         tmd = new TaskMgmtDefinition();
       }
       processDefinition.addDefinition(tmd);
 
-      for (Object taskElement : elements) {
-        readTask((Element) taskElement, tmd, taskNode);        
+      for (Object taskElement : elements)
+      {
+        readTask((Element)taskElement, tmd, taskNode);
       }
     }
   }
 
-  public Task readTask(Element taskElement, TaskMgmtDefinition taskMgmtDefinition, TaskNode taskNode) {
+  public Task readTask(Element taskElement, TaskMgmtDefinition taskMgmtDefinition, TaskNode taskNode)
+  {
     Task task = new Task();
     task.setProcessDefinition(processDefinition);
-    
+
     // get the task name
     String name = taskElement.attributeValue("name");
-    if (name!=null) {
+    if (name != null)
+    {
       task.setName(name);
       taskMgmtDefinition.addTask(task);
-    } else if (taskNode!=null) {
+    }
+    else if (taskNode != null)
+    {
       task.setName(taskNode.getName());
       taskMgmtDefinition.addTask(task);
     }
-    
-    // get the task description 
+
+    // get the task description
     String description = taskElement.elementTextTrim("description");
-    if (description!=null) {
+    if (description != null)
+    {
       task.setDescription(description);
-    } else {
+    }
+    else
+    {
       task.setDescription(taskElement.attributeValue("description"));
     }
-    
-    // get the condition 
+
+    // get the condition
     String condition = taskElement.elementTextTrim("condition");
-    if (condition!=null) {
+    if (condition != null)
+    {
       task.setCondition(condition);
-    } else {
+    }
+    else
+    {
       task.setCondition(taskElement.attributeValue("condition"));
     }
-    
+
     // parse common subelements
     readTaskTimers(taskElement, task);
     readEvents(taskElement, task);
@@ -315,83 +365,93 @@
 
     // duedate and priority
     String duedateText = taskElement.attributeValue("duedate");
-    if (duedateText==null) {
+    if (duedateText == null)
+    {
       duedateText = taskElement.attributeValue("dueDate");
     }
     task.setDueDate(duedateText);
     String priorityText = taskElement.attributeValue("priority");
-    if (priorityText!=null) {
+    if (priorityText != null)
+    {
       task.setPriority(Task.parsePriority(priorityText));
     }
-    
+
     // if this task is in the context of a taskNode, associate them
-    if (taskNode!=null) {
+    if (taskNode != null)
+    {
       taskNode.addTask(task);
     }
 
     // blocking
     String blockingText = taskElement.attributeValue("blocking");
-    if (blockingText!=null) {
-      if ( ("true".equalsIgnoreCase(blockingText))
-           || ("yes".equalsIgnoreCase(blockingText))
-           || ("on".equalsIgnoreCase(blockingText)) ) {
+    if (blockingText != null)
+    {
+      if (("true".equalsIgnoreCase(blockingText)) || ("yes".equalsIgnoreCase(blockingText)) || ("on".equalsIgnoreCase(blockingText)))
+      {
         task.setBlocking(true);
       }
     }
-    
+
     // signalling
     String signallingText = taskElement.attributeValue("signalling");
-    if (signallingText!=null) {
-      if ( ("false".equalsIgnoreCase(signallingText))
-           || ("no".equalsIgnoreCase(signallingText))
-           || ("off".equalsIgnoreCase(signallingText)) ) {
+    if (signallingText != null)
+    {
+      if (("false".equalsIgnoreCase(signallingText)) || ("no".equalsIgnoreCase(signallingText)) || ("off".equalsIgnoreCase(signallingText)))
+      {
         task.setSignalling(false);
       }
     }
-    
+
     // assignment
     String swimlaneName = taskElement.attributeValue("swimlane");
     Element assignmentElement = taskElement.element("assignment");
 
     // if there is a swimlane attribute specified
-    if (swimlaneName!=null) {
+    if (swimlaneName != null)
+    {
       Swimlane swimlane = taskMgmtDefinition.getSwimlane(swimlaneName);
-      if (swimlane==null) {
-        addWarning("task references unknown swimlane '"+swimlaneName+"':"+taskElement.asXML());
-      } else {
+      if (swimlane == null)
+      {
+        addWarning("task references unknown swimlane '" + swimlaneName + "':" + taskElement.asXML());
+      }
+      else
+      {
         task.setSwimlane(swimlane);
       }
 
-    // else if there is a direct assignment specified
-    } else if (assignmentElement!=null) {
-      if ( (assignmentElement.attribute("actor-id")!=null)
-           || (assignmentElement.attribute("pooled-actors")!=null)
-         ) {
+      // else if there is a direct assignment specified
+    }
+    else if (assignmentElement != null)
+    {
+      if ((assignmentElement.attribute("actor-id") != null) || (assignmentElement.attribute("pooled-actors") != null))
+      {
         task.setActorIdExpression(assignmentElement.attributeValue("actor-id"));
         task.setPooledActorsExpression(assignmentElement.attributeValue("pooled-actors"));
-        
-      } else {
+
+      }
+      else
+      {
         Delegation assignmentDelegation = readAssignmentDelegation(assignmentElement);
         task.setAssignmentDelegation(assignmentDelegation);
       }
 
-    // if no assignment or swimlane is specified
-    } else {
-        // the user has to manage assignment manually, so we better inform him/her.
-        log.info("process xml information: no swimlane or assignment specified for task '"+taskElement.asXML()+"'");
+      // if no assignment or swimlane is specified
     }
+    else
+    {
+      // the user has to manage assignment manually, so we better inform him/her.
+      log.info("process xml information: no swimlane or assignment specified for task '" + taskElement.asXML() + "'");
+    }
 
     // notify
     String notificationsText = taskElement.attributeValue("notify");
-    if ( notificationsText!=null
-         && ("true".equalsIgnoreCase(notificationsText)
-             ||  "on".equalsIgnoreCase(notificationsText)
-             || "yes".equalsIgnoreCase(notificationsText)
-            )
-       ) {
+    if (notificationsText != null
+        && ("true".equalsIgnoreCase(notificationsText) || "on".equalsIgnoreCase(notificationsText) || "yes".equalsIgnoreCase(notificationsText)))
+    {
       String notificationEvent = Event.EVENTTYPE_TASK_ASSIGN;
       Event event = task.getEvent(notificationEvent);
-      if (event==null) {
+      if (event == null)
+      {
         event = new Event(notificationEvent);
         task.addEvent(event);
       }
@@ -404,119 +464,140 @@
 
     // task controller
     Element taskControllerElement = taskElement.element("controller");
-    if (taskControllerElement!=null) {
+    if (taskControllerElement != null)
+    {
       task.setTaskController(readTaskController(taskControllerElement));
     }
-    
+
     return task;
   }
 
-  protected Delegation readAssignmentDelegation(Element assignmentElement) {
+  protected Delegation readAssignmentDelegation(Element assignmentElement)
+  {
     Delegation assignmentDelegation = new Delegation();
     String expression = assignmentElement.attributeValue("expression");
     String actorId = assignmentElement.attributeValue("actor-id");
     String pooledActors = assignmentElement.attributeValue("pooled-actors");
-    
-    if (expression!=null){
+
+    if (expression != null)
+    {
       assignmentDelegation.setProcessDefinition(processDefinition);
       assignmentDelegation.setClassName("org.jbpm.identity.assignment.ExpressionAssignmentHandler");
-      assignmentDelegation.setConfiguration("<expression>"+expression+"</expression>");
-      
-    } else if ( (actorId!=null)
-                || (pooledActors!=null) 
-              ) {
+      assignmentDelegation.setConfiguration("<expression>" + expression + "</expression>");
+
+    }
+    else if ((actorId != null) || (pooledActors != null))
+    {
       assignmentDelegation.setProcessDefinition(processDefinition);
       assignmentDelegation.setClassName("org.jbpm.taskmgmt.assignment.ActorAssignmentHandler");
       String configuration = "";
-      if (actorId!=null) {
-        configuration += "<actorId>"+actorId+"</actorId>";
+      if (actorId != null)
+      {
+        configuration += "<actorId>" + actorId + "</actorId>";
       }
-      if (pooledActors!=null) {
-        configuration += "<pooledActors>"+pooledActors+"</pooledActors>";
+      if (pooledActors != null)
+      {
+        configuration += "<pooledActors>" + pooledActors + "</pooledActors>";
       }
       assignmentDelegation.setConfiguration(configuration);
-      
-    } else {
+
+    }
+    else
+    {
       assignmentDelegation = new Delegation();
       assignmentDelegation.read(assignmentElement, this);
     }
-    
+
     return assignmentDelegation;
   }
 
-  protected TaskController readTaskController(Element taskControllerElement) {
+  protected TaskController readTaskController(Element taskControllerElement)
+  {
     TaskController taskController = new TaskController();
 
-    if (taskControllerElement.attributeValue("class")!=null) {
+    if (taskControllerElement.attributeValue("class") != null)
+    {
       Delegation taskControllerDelegation = new Delegation();
       taskControllerDelegation.read(taskControllerElement, this);
       taskController.setTaskControllerDelegation(taskControllerDelegation);
 
-    } else {
+    }
+    else
+    {
       List<VariableAccess> variableAccesses = readVariableAccesses(taskControllerElement);
       taskController.setVariableAccesses(variableAccesses);
     }
     return taskController;
   }
-  
-  public List<VariableAccess> readVariableAccesses(Element element) {
+
+  public List<VariableAccess> readVariableAccesses(Element element)
+  {
     List<VariableAccess> variableAccesses = new ArrayList<VariableAccess>();
     Iterator<?> iter = element.elementIterator("variable");
-    while (iter.hasNext()) {
-      Element variableElement = (Element) iter.next();
-      
+    while (iter.hasNext())
+    {
+      Element variableElement = (Element)iter.next();
+
       String variableName = variableElement.attributeValue("name");
-      if (variableName==null) {
-        addProblem(new Problem(Problem.LEVEL_WARNING, "the name attribute of a variable element is required: "+variableElement.asXML()));
+      if (variableName == null)
+      {
+        addProblem(new Problem(Problem.LEVEL_WARNING, "the name attribute of a variable element is required: " + variableElement.asXML()));
       }
       String access = variableElement.attributeValue("access", "read,write");
       String mappedName = variableElement.attributeValue("mapped-name");
-      
+
       variableAccesses.add(new VariableAccess(variableName, access, mappedName));
     }
     return variableAccesses;
   }
 
-  public void readStartStateTask(Element startTaskElement, StartState startState) {
+  public void readStartStateTask(Element startTaskElement, StartState startState)
+  {
     TaskMgmtDefinition taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
     Task startTask = readTask(startTaskElement, taskMgmtDefinition, null);
     startTask.setStartState(startState);
-    if (startTask.getName()==null) {
+    if (startTask.getName() == null)
+    {
       startTask.setName(startState.getName());
     }
     taskMgmtDefinition.setStartTask(startTask);
   }
 
-  public void readNode(Element nodeElement, Node node, NodeCollection nodeCollection) {
+  public void readNode(Element nodeElement, Node node, NodeCollection nodeCollection)
+  {
 
-    // first put the node in its collection.  this is done so that the 
-    // setName later on will be able to differentiate between nodes contained in 
+    // first put the node in its collection. this is done so that the
+    // setName later on will be able to differentiate between nodes contained in
     // processDefinitions and nodes contained in superstates
     nodeCollection.addNode(node);
 
     // get the node name
     String name = nodeElement.attributeValue("name");
-    if (name!=null) {
+    if (name != null)
+    {
       node.setName(name);
 
       // check if this is the initial node
-      if ( (initialNodeName!=null)
-           && (initialNodeName.equals(node.getFullyQualifiedName()))
-         ) {
+      if ((initialNodeName != null) && (initialNodeName.equals(node.getFullyQualifiedName())))
+      {
         processDefinition.setStartState(node);
       }
     }
 
-    // get the node description 
+    // get the node description
     String description = nodeElement.elementTextTrim("description");
-    if (description!=null) {
+    if (description != null)
+    {
       node.setDescription(description);
     }
 
     String asyncText = nodeElement.attributeValue("async");
-    if ("true".equalsIgnoreCase(asyncText)) {
+    if ("true".equalsIgnoreCase(asyncText))
+    {
       node.setAsync(true);
-    } else if ("exclusive".equalsIgnoreCase(asyncText)) {
+    }
+    else if ("exclusive".equalsIgnoreCase(asyncText))
+    {
       node.setAsync(true);
       node.setAsyncExclusive(true);
     }
@@ -530,94 +611,109 @@
     addUnresolvedTransitionDestination(nodeElement, node);
   }
 
-  protected void readNodeTimers(Element nodeElement, Node node) {
+  protected void readNodeTimers(Element nodeElement, Node node)
+  {
     Iterator<?> iter = nodeElement.elementIterator("timer");
-    while (iter.hasNext()) {
-      Element timerElement = (Element) iter.next();
+    while (iter.hasNext())
+    {
+      Element timerElement = (Element)iter.next();
       readNodeTimer(timerElement, node);
     }
   }
 
-  protected void readNodeTimer(Element timerElement, Node node) {
+  protected void readNodeTimer(Element timerElement, Node node)
+  {
     String name = timerElement.attributeValue("name", node.getName());
-    if (name == null) name = generateTimerName();
-    
+    if (name == null)
+      name = generateTimerName();
+
     CreateTimerAction createTimerAction = instantiateCreateTimerAction();
     createTimerAction.read(timerElement, this);
     createTimerAction.setTimerName(name);
     createTimerAction.setTimerAction(readSingleAction(timerElement));
     addAction(node, Event.EVENTTYPE_NODE_ENTER, createTimerAction);
-    
+
     CancelTimerAction cancelTimerAction = instantiateCancelTimerAction();
     cancelTimerAction.setTimerName(name);
     addAction(node, Event.EVENTTYPE_NODE_LEAVE, cancelTimerAction);
   }
 
-  /**
-   * instantiate {@link CreateTimerAction} object from configured
-   * class in action.types.xml (if configured). If not the default
-   * jbpm class is used.
+  /*
+   * instantiate {@link CreateTimerAction} object from configured class in action.types.xml (if configured). If not the default jbpm class is used.
    */
   private CreateTimerAction instantiateCreateTimerAction()
   {
-    if (ActionTypes.hasActionName("create-timer")) {
+    if (ActionTypes.hasActionName("create-timer"))
+    {
       Class actionType = ActionTypes.getActionType("create-timer");
-      try {
+      try
+      {
         return (CreateTimerAction)actionType.newInstance();
-      } catch (Exception e) {
-        log.error("couldn't instantiate 'create-timer' action of type '"+actionType.getName()+"'. Using default CreateTimerAction.", e);
       }
+      catch (Exception e)
+      {
+        log.error("couldn't instantiate 'create-timer' action of type '" + actionType.getName() + "'. Using default CreateTimerAction.", e);
+      }
     }
     // default
-    return new CreateTimerAction();      
+    return new CreateTimerAction();
   }
 
-  /**
-   * instantiate {@link CancelTimerAction} object from configured
-   * class in action.types.xml (if configured). If not the default
-   * jbpm class is used.
+  /*
+   * instantiate {@link CancelTimerAction} object from configured class in action.types.xml (if configured). If not the default jbpm class is used.
    */
   private CancelTimerAction instantiateCancelTimerAction()
   {
-    if (ActionTypes.hasActionName("cancel-timer")) {
+    if (ActionTypes.hasActionName("cancel-timer"))
+    {
       Class actionType = ActionTypes.getActionType("cancel-timer");
-      try {
+      try
+      {
         return (CancelTimerAction)actionType.newInstance();
-      } catch (Exception e) {
-        log.error("couldn't instantiate 'cancel-timer' action of type '"+actionType.getName()+"'. Using default CancelTimerAction.", e);
       }
+      catch (Exception e)
+      {
+        log.error("couldn't instantiate 'cancel-timer' action of type '" + actionType.getName() + "'. Using default CancelTimerAction.", e);
+      }
     }
     // default
-    return new CancelTimerAction();      
+    return new CancelTimerAction();
   }
 
-  private String generateTimerName() {
-    return "timer-" + (timerNumber++); 
+  private String generateTimerName()
+  {
+    return "timer-" + (timerNumber++);
   }
 
-  protected void readTaskTimers(Element taskElement, Task task) {
+  protected void readTaskTimers(Element taskElement, Task task)
+  {
     Iterator<?> iter = taskElement.elementIterator();
-    while (iter.hasNext()) {
-      Element element = (Element) iter.next();
-      if ( ("timer".equals(element.getName()))
-           || ("reminder".equals(element.getName()))
-         ) {
+    while (iter.hasNext())
+    {
+      Element element = (Element)iter.next();
+      if (("timer".equals(element.getName())) || ("reminder".equals(element.getName())))
+      {
         readTaskTimer(element, task);
       }
     }
   }
 
-  protected void readTaskTimer(Element timerElement, Task task) {
+  protected void readTaskTimer(Element timerElement, Task task)
+  {
     String name = timerElement.attributeValue("name", task.getName());
-    if (name==null) name = generateTimerName();
+    if (name == null)
+      name = generateTimerName();
 
     CreateTimerAction createTimerAction = instantiateCreateTimerAction();
     createTimerAction.read(timerElement, this);
     createTimerAction.setTimerName(name);
     Action action = null;
-    if ("timer".equals(timerElement.getName())) {
+    if ("timer".equals(timerElement.getName()))
+    {
       action = readSingleAction(timerElement);
-    } else {
+    }
+    else
+    {
       Delegation delegation = createMailDelegation("task-reminder", null, null, null, null);
       action = new Action(delegation);
     }
@@ -628,47 +724,57 @@
     Collection<String> cancelEventTypes = new ArrayList<String>();
 
     String cancelEventTypeText = timerElement.attributeValue("cancel-event");
-    if (cancelEventTypeText!=null) {
+    if (cancelEventTypeText != null)
+    {
       // cancel-event is a comma separated list of events
       StringTokenizer tokenizer = new StringTokenizer(cancelEventTypeText, ",");
-      while (tokenizer.hasMoreTokens()) {
+      while (tokenizer.hasMoreTokens())
+      {
         cancelEventTypes.add(tokenizer.nextToken().trim());
       }
-    } else {
+    }
+    else
+    {
       // set the default
       cancelEventTypes.add(Event.EVENTTYPE_TASK_END);
     }
 
-    for (String cancelEventType : cancelEventTypes) {      
+    for (String cancelEventType : cancelEventTypes)
+    {
       CancelTimerAction cancelTimerAction = instantiateCancelTimerAction();
       cancelTimerAction.setTimerName(name);
       addAction(task, cancelEventType, cancelTimerAction);
     }
   }
-  
-  protected void readEvents(Element parentElement, GraphElement graphElement) {
+
+  protected void readEvents(Element parentElement, GraphElement graphElement)
+  {
     Iterator<?> iter = parentElement.elementIterator("event");
-    while (iter.hasNext()) {
-      Element eventElement = (Element) iter.next();
+    while (iter.hasNext())
+    {
+      Element eventElement = (Element)iter.next();
       String eventType = eventElement.attributeValue("type");
-      if (!graphElement.hasEvent(eventType)) {
+      if (!graphElement.hasEvent(eventType))
+      {
         graphElement.addEvent(new Event(eventType));
       }
       readActions(eventElement, graphElement, eventType);
     }
   }
 
-  public void readActions(Element eventElement, GraphElement graphElement, String eventType) {
+  public void readActions(Element eventElement, GraphElement graphElement, String eventType)
+  {
     // for all the elements in the event element
     Iterator<?> nodeElementIter = eventElement.elementIterator();
-    while (nodeElementIter.hasNext()) {
-      Element actionElement = (Element) nodeElementIter.next();
+    while (nodeElementIter.hasNext())
+    {
+      Element actionElement = (Element)nodeElementIter.next();
       String actionName = actionElement.getName();
-      if (ActionTypes.hasActionName(actionName)) {
+      if (ActionTypes.hasActionName(actionName))
+      {
         Action action = createAction(actionElement);
-        if ( (graphElement!=null)
-             && (eventType!=null)
-           ) {
+        if ((graphElement != null) && (eventType != null))
+        {
           // add the action to the event
           addAction(graphElement, eventType, action);
         }
@@ -676,22 +782,27 @@
     }
   }
 
-  protected void addAction(GraphElement graphElement, String eventType, Action action) {
+  protected void addAction(GraphElement graphElement, String eventType, Action action)
+  {
     Event event = graphElement.getEvent(eventType);
-    if (event==null) {
-      event = new Event(eventType); 
+    if (event == null)
+    {
+      event = new Event(eventType);
       graphElement.addEvent(event);
     }
     event.addAction(action);
   }
-  
-  public Action readSingleAction(Element nodeElement) {
+
+  public Action readSingleAction(Element nodeElement)
+  {
     Action action = null;
     // search for the first action element in the node
     Iterator<?> iter = nodeElement.elementIterator();
-    while (iter.hasNext() && (action==null)) {
-      Element candidate = (Element) iter.next();
-      if (ActionTypes.hasActionName(candidate.getName())) {
+    while (iter.hasNext() && (action == null))
+    {
+      Element candidate = (Element)iter.next();
+      if (ActionTypes.hasActionName(candidate.getName()))
+      {
         // parse the action and assign it to this node
         action = createAction(candidate);
       }
@@ -699,46 +810,55 @@
     return action;
   }
 
-  public Action createAction(Element actionElement) {
+  public Action createAction(Element actionElement)
+  {
     // create a new instance of the action
     Action action = null;
     String actionName = actionElement.getName();
     Class<? extends Action> actionType = ActionTypes.getActionType(actionName);
-    try {
+    try
+    {
       action = actionType.newInstance();
-    } catch (Exception e) {
-      log.error("couldn't instantiate action '"+actionName+"', of type '"+actionType.getName()+"'", e);
     }
+    catch (Exception e)
+    {
+      log.error("couldn't instantiate action '" + actionName + "', of type '" + actionType.getName() + "'", e);
+    }
 
     // read the common node parts of the action
     readAction(actionElement, action);
-    
+
     return action;
   }
 
-  public void readAction(Element element, Action action) {
+  public void readAction(Element element, Action action)
+  {
     // if a name is specified for this action
     String actionName = element.attributeValue("name");
-    if (actionName!=null) {
+    if (actionName != null)
+    {
       action.setName(actionName);
-      // add the action to the named process action repository 
+      // add the action to the named process action repository
       processDefinition.addAction(action);
     }
 
-    // if the action is parsable 
+    // if the action is parsable
     // (meaning: if the action has special configuration to parse, other then the common node data)
     action.read(element, this);
   }
 
-  protected void readExceptionHandlers(Element graphElementElement, GraphElement graphElement) {
+  protected void readExceptionHandlers(Element graphElementElement, GraphElement graphElement)
+  {
     Iterator<?> iter = graphElementElement.elementIterator("exception-handler");
-    while (iter.hasNext()) {
-      Element exceptionHandlerElement = (Element) iter.next();
+    while (iter.hasNext())
+    {
+      Element exceptionHandlerElement = (Element)iter.next();
       readExceptionHandler(exceptionHandlerElement, graphElement);
     }
   }
 
-  protected void readExceptionHandler(Element exceptionHandlerElement, GraphElement graphElement) {
+  protected void readExceptionHandler(Element exceptionHandlerElement, GraphElement graphElement)
+  {
     // create the exception handler
     ExceptionHandler exceptionHandler = new ExceptionHandler();
     exceptionHandler.setExceptionClassName(exceptionHandlerElement.attributeValue("exception-class"));
@@ -747,9 +867,11 @@
 
     // read the actions in the body of the exception-handler element
     Iterator<?> iter = exceptionHandlerElement.elementIterator();
-    while (iter.hasNext()) {
-      Element childElement = (Element) iter.next();
-      if (ActionTypes.hasActionName(childElement.getName())) {
+    while (iter.hasNext())
+    {
+      Element childElement = (Element)iter.next();
+      if (ActionTypes.hasActionName(childElement.getName()))
+      {
         Action action = createAction(childElement);
         exceptionHandler.addAction(action);
       }
@@ -757,32 +879,36 @@
   }
 
   // transition destinations are parsed in a second pass //////////////////////
-  
-  public void addUnresolvedTransitionDestination(Element nodeElement, Node node) {
-    unresolvedTransitionDestinations.add(new Object[]{nodeElement, node});
+
+  public void addUnresolvedTransitionDestination(Element nodeElement, Node node)
+  {
+    unresolvedTransitionDestinations.add(new Object[] { nodeElement, node });
   }
 
-  public void resolveTransitionDestinations() {
-    for (Object[] unresolvedTransition : unresolvedTransitionDestinations) {
-      Element nodeElement = (Element) unresolvedTransition[0];
-      Node node = (Node) unresolvedTransition[1];
+  public void resolveTransitionDestinations()
+  {
+    for (Object[] unresolvedTransition : unresolvedTransitionDestinations)
+    {
+      Element nodeElement = (Element)unresolvedTransition[0];
+      Node node = (Node)unresolvedTransition[1];
       resolveTransitionDestinations(nodeElement.elements("transition"), node);
     }
   }
 
-  public void resolveTransitionDestinations(List<?> transitionElements, Node node) {
-    for (Object transitionElement : transitionElements) {
-      resolveTransitionDestination((Element) transitionElement, node);
+  public void resolveTransitionDestinations(List<?> transitionElements, Node node)
+  {
+    for (Object transitionElement : transitionElements)
+    {
+      resolveTransitionDestination((Element)transitionElement, node);
     }
   }
 
-  /**
+  /*
    * creates the transition object and configures it by the read attributes
-   * @return the created <code>org.jbpm.graph.def.Transition</code> object
-   *         (useful, if you want to override this method
-   *         to read additional configuration properties)
+   * @return the created <code>org.jbpm.graph.def.Transition</code> object (useful, if you want to override this method to read additional configuration properties)
    */
-  public Transition resolveTransitionDestination(Element transitionElement, Node node) {
+  public Transition resolveTransitionDestination(Element transitionElement, Node node)
+  {
     Transition transition = new Transition();
     transition.setProcessDefinition(processDefinition);
 
@@ -790,14 +916,15 @@
     transition.setDescription(transitionElement.elementTextTrim("description"));
 
     String condition = transitionElement.attributeValue("condition");
-    if (condition==null) {
+    if (condition == null)
+    {
       Element conditionElement = transitionElement.element("condition");
-      if (conditionElement!=null) {
+      if (conditionElement != null)
+      {
         condition = conditionElement.getTextTrim();
         // for backwards compatibility
-        if ( (condition==null)
-             || (condition.length()==0)
-           ) {
+        if ((condition == null) || (condition.length() == 0))
+        {
           condition = conditionElement.attributeValue("expression");
         }
       }
@@ -809,58 +936,68 @@
 
     // set destinationNode of the transition
     String toName = transitionElement.attributeValue("to");
-    if (toName==null) {
-      addWarning("node '"+node.getFullyQualifiedName()+"' has a transition without a 'to'-attribute to specify its destinationNode");
-    } else {
+    if (toName == null)
+    {
+      addWarning("node '" + node.getFullyQualifiedName() + "' has a transition without a 'to'-attribute to specify its destinationNode");
+    }
+    else
+    {
       Node to = ((NodeCollection)node.getParent()).findNode(toName);
-      if (to==null) {
-        addWarning("transition to='"+toName+"' on node '"+node.getFullyQualifiedName()+"' cannot be resolved");
-      } else {
+      if (to == null)
+      {
+        addWarning("transition to='" + toName + "' on node '" + node.getFullyQualifiedName() + "' cannot be resolved");
+      }
+      else
+      {
         to.addArrivingTransition(transition);
       }
     }
-    
+
     // read the actions
     readActions(transitionElement, transition, Event.EVENTTYPE_TRANSITION);
-    
+
     readExceptionHandlers(transitionElement, transition);
-    
+
     return transition;
   }
-  
+
   // action references are parsed in a second pass ////////////////////////////
 
-  public void addUnresolvedActionReference(Element actionElement, Action action) {
-    unresolvedActionReferences.add(new Object[]{actionElement, action});
+  public void addUnresolvedActionReference(Element actionElement, Action action)
+  {
+    unresolvedActionReferences.add(new Object[] { actionElement, action });
   }
 
-  public void resolveActionReferences() {
-    for (Object[] unresolvedActionReference : unresolvedActionReferences) {
-      Element actionElement = (Element) unresolvedActionReference[0];
-      Action action = (Action) unresolvedActionReference[1];
+  public void resolveActionReferences()
+  {
+    for (Object[] unresolvedActionReference : unresolvedActionReferences)
+    {
+      Element actionElement = (Element)unresolvedActionReference[0];
+      Action action = (Action)unresolvedActionReference[1];
       String referencedActionName = actionElement.attributeValue("ref-name");
       Action referencedAction = processDefinition.getAction(referencedActionName);
-      if (referencedAction==null) {
-        addWarning("couldn't resolve action reference in "+actionElement.asXML());
+      if (referencedAction == null)
+      {
+        addWarning("couldn't resolve action reference in " + actionElement.asXML());
       }
       action.setReferencedAction(referencedAction);
     }
   }
 
   // verify swimlane assignments in second pass ///////////////////////////////
-  public void verifySwimlaneAssignments() {
+  public void verifySwimlaneAssignments()
+  {
     TaskMgmtDefinition taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
-    if ( (taskMgmtDefinition!=null)
-         && (taskMgmtDefinition.getSwimlanes()!=null)
-       ) {
-      for (Swimlane swimlane : taskMgmtDefinition.getSwimlanes().values()) {
+    if ((taskMgmtDefinition != null) && (taskMgmtDefinition.getSwimlanes() != null))
+    {
+      for (Swimlane swimlane : taskMgmtDefinition.getSwimlanes().values())
+      {
         Task startTask = taskMgmtDefinition.getStartTask();
-        Swimlane startTaskSwimlane = (startTask!=null ? startTask.getSwimlane() : null);
-        
-        if ( (swimlane.getAssignmentDelegation()==null)
-            && (swimlane!=startTaskSwimlane) 
-        ) {
-          addWarning("swimlane '"+swimlane.getName()+"' does not have an assignment");
+        Swimlane startTaskSwimlane = (startTask != null ? startTask.getSwimlane() : null);
+
+        if ((swimlane.getAssignmentDelegation() == null) && (swimlane != startTaskSwimlane))
+        {
+          addWarning("swimlane '" + swimlane.getName() + "' does not have an assignment");
         }
       }
     }
@@ -868,42 +1005,47 @@
 
   // mail delegations /////////////////////////////////////////////////////////
 
-  public Delegation createMailDelegation(String template,
-                                         String actors,
-                                         String to,
-                                         String subject,
-                                         String text) {
+  public Delegation createMailDelegation(String template, String actors, String to, String subject, String text)
+  {
     StringBuffer config = new StringBuffer();
-    if (template!=null) {
+    if (template != null)
+    {
       config.append("<template>");
       config.append(template);
       config.append("</template>");
     }
-    if (actors!=null) {
+    if (actors != null)
+    {
       config.append("<actors>");
       config.append(actors);
       config.append("</actors>");
     }
-    if (to!=null) {
+    if (to != null)
+    {
       config.append("<to>");
       config.append(to);
       config.append("</to>");
     }
-    if (subject!=null) {
+    if (subject != null)
+    {
       config.append("<subject>");
       config.append(subject);
       config.append("</subject>");
     }
-    if (text!=null) {
+    if (text != null)
+    {
       config.append("<text>");
       config.append(text);
       config.append("</text>");
     }
 
     String mailClassName = Mail.class.getName();
-    if (JbpmConfiguration.Configs.hasObject("jbpm.mail.class.name")) {
+    if (JbpmConfiguration.Configs.hasObject("jbpm.mail.class.name"))
+    {
       mailClassName = JbpmConfiguration.Configs.getString("jbpm.mail.class.name");
-    } else if (JbpmConfiguration.Configs.hasObject("mail.class.name")) {
+    }
+    else if (JbpmConfiguration.Configs.hasObject("mail.class.name"))
+    {
       mailClassName = JbpmConfiguration.Configs.getString("mail.class.name");
     }
 
@@ -913,11 +1055,14 @@
     return delegation;
   }
 
-  public String getProperty(String property, Element element) {
+  public String getProperty(String property, Element element)
+  {
     String value = element.attributeValue(property);
-    if (value==null) {
+    if (value == null)
+    {
       Element propertyElement = element.element(property);
-      if (propertyElement!=null) {
+      if (propertyElement != null)
+      {
         value = propertyElement.getText();
       }
     }

Added: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1686/JBPM1686Test.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1686/JBPM1686Test.java	                        (rev 0)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1686/JBPM1686Test.java	2009-02-12 07:33:12 UTC (rev 3847)
@@ -0,0 +1,45 @@
+package org.jbpm.jbpm1686;
+
+import org.jbpm.AbstractJbpmTestCase;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.jpdl.JpdlException;
+
+/**
+ * NPE when reading a process definition with a decision name which contains the "/" character
+ * 
+ * https://jira.jboss.org/jira/browse/JBPM-1686
+ * 
+ * @author Thomas.Diesler at jboss.com
+ * @since 12-Feb-2009
+ */
+public class JBPM1686Test extends AbstractJbpmTestCase
+{
+  public void testProcessDefinition()
+  {
+    try
+    {
+      ProcessDefinition.parseXmlString(
+          "<process-definition>" +
+          "  <start-state>" +
+          "    <transition to='d/e' />" +
+          "  </start-state>" +
+          "  <decision name='d/e'>" +
+          "    <transition name='one' to='a'>" +
+          "      <condition>#{a == 1}</condition>" +
+          "    </transition>" +
+          "    <transition name='three' to='c'>" +
+          "      <condition>#{a == 3}</condition>" +
+          "    </transition>" +
+          "  </decision>" +
+          "  <state name='a' />" +
+          "  <state name='c' />" +
+          "</process-definition>");
+      
+      fail("JpdlException expected");
+    }
+    catch (JpdlException ex)
+    {
+      // expected
+    }
+  }
+}


Property changes on: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1686/JBPM1686Test.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jbpm-commits mailing list