public InputStream getEntryInputStream(String entryName) { return new ByteArrayInputStream(getEntry(entryName)); }
public InputStream getEntryInputStream(String entryName) { return new ByteArrayInputStream(getEntry(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 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(); } }
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 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; }
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 }