/** Register Process Definition */ public static void registerProcessDefinition(InputStream is) throws WorkflowException, ParseException, IOException { log.debug("registerProcessDefinition({})", is); JbpmContext jbpmContext = JBPMUtils.getConfig().createJbpmContext(); InputStream isForms = null; ZipInputStream zis = null; if (Config.SYSTEM_READONLY) { throw new WorkflowException("System is in read-only mode"); } try { zis = new ZipInputStream(is); org.jbpm.graph.def.ProcessDefinition processDefinition = org.jbpm.graph.def.ProcessDefinition.parseParZipInputStream(zis); // Check xml form definition FileDefinition fileDef = processDefinition.getFileDefinition(); isForms = fileDef.getInputStream("forms.xml"); FormUtils.parseWorkflowForms(isForms); // If it is ok, deploy it jbpmContext.deployProcessDefinition(processDefinition); } catch (JbpmException e) { throw new WorkflowException(e.getMessage(), e); } finally { IOUtils.closeQuietly(isForms); IOUtils.closeQuietly(zis); jbpmContext.close(); } log.debug("registerProcessDefinition: void"); }
/** Get Process Definition Forms */ public static Map<String, List<FormElement>> getProcessDefinitionForms(long processDefinitionId) throws ParseException { log.debug("getProcessDefinitionForms({})", processDefinitionId); JbpmContext jbpmContext = JBPMUtils.getConfig().createJbpmContext(); Map<String, List<FormElement>> forms = new HashMap<String, List<FormElement>>(); InputStream is = null; try { GraphSession graphSession = jbpmContext.getGraphSession(); org.jbpm.graph.def.ProcessDefinition pd = graphSession.getProcessDefinition(processDefinitionId); FileDefinition fileDef = pd.getFileDefinition(); is = fileDef.getInputStream("forms.xml"); if (is != null) { forms = FormUtils.parseWorkflowForms(is); } else { log.warn("Process definition '{}' has no forms.xml file", processDefinitionId); } } finally { IOUtils.closeQuietly(is); jbpmContext.close(); } log.debug("getProcessDefinitionForms: {}", forms); return forms; }