/** * parse a process definition from a process archive zip-stream. * * @throws org.jbpm.jpdl.JpdlException if parsing reported an error. */ public static ProcessDefinition parseParZipInputStream(ZipInputStream zipInputStream) throws IOException { return new ProcessArchive(zipInputStream).parseProcessDefinition(); }
public InputStream getEntryInputStream(String entryName) { return new ByteArrayInputStream(getEntry(entryName)); }
public ProcessDefinition readFromArchive(ProcessArchive processArchive, ProcessDefinition processDefinition) { processArchive.removeEntry("processdefinition.xml"); return null; } }
void convertPars() throws Exception { String[] files = indir.list(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".par"); } }); for (int i = 0; i < files.length; i++) { ZipInputStream zip = new ZipInputStream(new FileInputStream(indir.getPath() + "/" + files[i])); ProcessArchive pa = new ProcessArchive(zip); String xml = convertPar(pa); // Create new process archive in designated output directory ZipOutputStream zippo = new ZipOutputStream(new FileOutputStream(outdir.getPath() + "/" + files[i])); // Copy all non-pdl entries and insert new pdl for (Iterator iter = pa.getEntries().keySet().iterator(); iter.hasNext();) { String name = (String) iter.next(); zippo.putNextEntry(new ZipEntry(name)); if ("processdefinition.xml".equalsIgnoreCase(name)) { zippo.write(xml.getBytes()); } else { zippo.write(pa.getEntry(name)); } zippo.closeEntry(); } zippo.close(); System.out.println("Converted " + files[i]); } // process next PAR }
public ProcessDefinition parseProcessDefinition() { ProcessDefinition processDefinition = ProcessDefinition.createNewProcessDefinition(); for (Iterator iter = getParsers().iterator(); iter.hasNext();) { ProcessArchiveParser processArchiveParser = (ProcessArchiveParser) iter.next(); processDefinition = processArchiveParser.readFromArchive(this, processDefinition); } if (Problem.containsProblemsOfLevel(problems, Problem.LEVEL_ERROR)) { throw new JpdlException(problems); } return processDefinition; }
private static List getParsers() { String resource = Configs.getString("resource.parsers"); synchronized (parsersByResource) { List parsers = (List) parsersByResource.get(resource); if (parsers == null) { parsers = createParsers(resource); parsersByResource.put(resource, parsers); } return parsers; } }
public ProcessDefinition readFromArchive(ProcessArchive processArchive, ProcessDefinition processDefinition) { Map entries = processArchive.getEntries(); if (!entries.isEmpty()) { // get or create file definition FileDefinition fileDefinition = processDefinition.getFileDefinition(); if (fileDefinition == null) { fileDefinition = new FileDefinition(); processDefinition.addDefinition(fileDefinition); } // add file entries to definition for (Iterator iter = entries.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); fileDefinition.addFile((String) entry.getKey(), (byte[]) entry.getValue()); } } return processDefinition; }
void convertPars() throws Exception { File[] files = indir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".par"); } }); for (File inputFile: files) { ZipInputStream zip = new ZipInputStream(new BufferedInputStream(Files.newInputStream(inputFile.toPath()))); ProcessArchive pa = new ProcessArchive(zip); String xml = convertPar(pa); // Create new process archive in designated output directory File outputFile = new File(outdir, inputFile.getName()); ZipOutputStream zippo = new ZipOutputStream(new BufferedOutputStream(Files.newOutputStream(outputFile.toPath()))); // Copy all non-pdl entries and insert new pdl for (Iterator iter = pa.getEntries().keySet().iterator(); iter.hasNext();) { String name = (String) iter.next(); zippo.putNextEntry(new ZipEntry(name)); if ("processdefinition.xml".equalsIgnoreCase(name)) { zippo.write(xml.getBytes()); } else { zippo.write(pa.getEntry(name)); } zippo.closeEntry(); } zippo.close(); System.out.println("Converted " + inputFile.getName()); } // process next PAR }
public ProcessDefinition parseProcessDefinition() { ProcessDefinition processDefinition = ProcessDefinition.createNewProcessDefinition(); for (Iterator iter = getParsers().iterator(); iter.hasNext();) { ProcessArchiveParser processArchiveParser = (ProcessArchiveParser) iter.next(); processDefinition = processArchiveParser.readFromArchive(this, processDefinition); } if (Problem.containsProblemsOfLevel(problems, Problem.LEVEL_ERROR)) { throw new JpdlException(problems); } return processDefinition; }
private static List getParsers() { String resource = Configs.getString("resource.parsers"); synchronized (parsersByResource) { List parsers = (List) parsersByResource.get(resource); if (parsers == null) { parsers = createParsers(resource); parsersByResource.put(resource, parsers); } return parsers; } }
public ProcessDefinition readFromArchive(ProcessArchive processArchive, ProcessDefinition processDefinition) { Map entries = processArchive.getEntries(); if (!entries.isEmpty()) { // get or create file definition FileDefinition fileDefinition = processDefinition.getFileDefinition(); if (fileDefinition == null) { fileDefinition = new FileDefinition(); processDefinition.addDefinition(fileDefinition); } // add file entries to definition for (Iterator iter = entries.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); fileDefinition.addFile((String) entry.getKey(), (byte[]) entry.getValue()); } } return processDefinition; }
/** * parse a process definition from a process archive zip-stream. * * @throws org.jbpm.jpdl.JpdlException if parsing reported an error. */ public static ProcessDefinition parseParZipInputStream(ZipInputStream zipInputStream) throws IOException { return new ProcessArchive(zipInputStream).parseProcessDefinition(); }
public InputStream getEntryInputStream(String entryName) { return new ByteArrayInputStream(getEntry(entryName)); }
public ProcessDefinition readFromArchive(ProcessArchive processArchive, ProcessDefinition processDefinition) { processArchive.removeEntry("processdefinition.xml"); return null; } }
public ProcessDefinition readFromArchive(ProcessArchive processArchive, ProcessDefinition processDefinition) throws JpdlException { // getting the value byte[] processBytes = processArchive.getEntry("processdefinition.xml"); if (processBytes == null) { throw new JpdlException("no processdefinition.xml inside process archive"); } ByteArrayInputStream processStream = new ByteArrayInputStream(processBytes); JpdlXmlReader jpdlXmlReader = new JpdlXmlReader(new InputSource(processStream), processArchive); return jpdlXmlReader.readProcessDefinition(); } }
public InputStream removeEntryInputStream(String entryName) { return new ByteArrayInputStream(removeEntry(entryName)); }
public ProcessDefinition readFromArchive(ProcessArchive processArchive, ProcessDefinition processDefinition) throws JpdlException { // getting the value byte[] processBytes = processArchive.getEntry("processdefinition.xml"); if (processBytes == null) { throw new JpdlException("no processdefinition.xml inside process archive"); } ByteArrayInputStream processStream = new ByteArrayInputStream(processBytes); JpdlXmlReader jpdlXmlReader = new JpdlXmlReader(new InputSource(processStream), processArchive); return jpdlXmlReader.readProcessDefinition(); } }
public InputStream removeEntryInputStream(String entryName) { return new ByteArrayInputStream(removeEntry(entryName)); }
public String convertPar(ProcessArchive pa) { try { // Parse the process definition XML into a DOM document Document doc = DocumentHelper.parseText(new String(pa.getEntry("processdefinition.xml"))); // Convert from 2.0 to 3.0 PDL Document doc30 = convert(doc); // Serialize the resulting document as the result ByteArrayOutputStream bos = new ByteArrayOutputStream(); serializetoXML(bos, doc30); return bos.toString(); } catch (DocumentException de) { log.error("Conversion had trouble parsing the 2.0 process definition", de); } catch (Exception ex) { log.error("Unexpected error in conversion", ex); } // things did not go well return null; }
public String convertPar(ProcessArchive pa) { try { // Parse the process definition XML into a DOM document Document doc = DocumentHelper.parseText(new String(pa.getEntry("processdefinition.xml"))); // Convert from 2.0 to 3.0 PDL Document doc30 = convert(doc); // Serialize the resulting document as the result ByteArrayOutputStream bos = new ByteArrayOutputStream(); serializetoXML(bos, doc30); return bos.toString(); } catch (DocumentException de) { log.error("Conversion had trouble parsing the 2.0 process definition", de); } catch (Exception ex) { log.error("Unexpected error in conversion", ex); } // things did not go well return null; }