3 Replies Latest reply on Aug 22, 2005 3:55 PM by aguizar

    Should the JpdlArchiveParser throw the JpdlException?

      Hi, all.
      I'm testing the validation in the process definition files again.
      In this case, my process definition has the next code:

      <process-definition name="Prueba Error">.....
      ...........<start-state name="start"/>
       <transition name="tr1" to="TaskNode1"></transition>
       </start-state>............
      </process-definition>

      As you can see, the "start-state" element has a syntax error: it ends the tag (it must be
      <start-state name="start">
      instead
      <start-state name="start"/>
      The slash character isn't wanted in this case ;-)
      The issue is that when my application tries to read the xml file with the JpdlXmlReader, it throws a JpdlException. That's right.
      But, the JpdlArchiveParser has a try/catch and although the JpdlException occurs, my application that call the JpdlArchiveParser doesn't know it.
      My question is:
      should the JpdlArchiveParser throws the JpdlException to facilitate the calling code to know that an or more errors have happened in the process-definition.xml validation?
      This is the try/catch piece of code in JpdlArchiveParser
      try {
       // pump the problems from the jpdlReader over to the processArchive
       processDefinition = jpdlReader.readProcessDefinition();
       } catch (JpdlException e) {
       e.printStackTrace();
       // pump the problems from the jpdlReader over to the processArchive
       processArchive.getProblems().addAll(e.getProblems());
       }
      

      Thanks in advance.
      Regards
      Juanjo

        • 1. Re: Should the JpdlArchiveParser throw the JpdlException?
          kukeltje

          Eventually there will also be a validation against the schema. Once the WTP reaches final state. This validation will probably be done fist and *in* the editor as well as jBPM core. So many of these issues will not arise.

          As mentioned in your other post, please file things like this in the jira

          • 2. Re: Should the JpdlArchiveParser throw the JpdlException?
            aguizar

            As you can see in the try/catch block, the problem details are added to the process archive. If you instantiate a ProcessArchive and then invoke its parseProcessDefinition() method directly, instead of ProcessDefinition.parseParXXX(), you could later call ProcessArchive.getProblems() to see whether any problems have occurred.

            However, the ProcessDefinition.parseXmlXXX() methods do throw a JpdlException with the list of problems that occurred. Conversely, ProcessDefinition.parseParXXX() have no way of notifying the caller of problems that might have ocurred.

            How about changing method ProcessDefinition.parseParZipInputStream() from:

            try {
             return new ProcessArchive(zipInputStream).parseProcessDefinition();
             } catch (IOException e) {
             throw new RuntimeException("couldn't parse par zip file zipInputStream", e);
             }

            to:
            try {
             ProcessArchive archive = new ProcessArchive(zipInputStream);
             ProcessDefinition definition = archive.parseProcessDefinition();
             List problems = archive.getProblems();
             if (!problems.isEmpty()) throw new JpdlException(problems);
             return definition;
             } catch (IOException e) {
             throw new RuntimeException("couldn't parse par zip file zipInputStream", e);
             }


            ProcessDefinition.parseParResource() delegates to the previous method, so it gets fixed for free.

            • 3. Re: Should the JpdlArchiveParser throw the JpdlException?
              aguizar

              Opened http://jira.jboss.org/jira/browse/JBPM-322 to track this issue.