@Test public void transformSimpleTestBpmn() throws Exception { File file = new File("result.jar"); file.deleteOnExit(); FileOutputStream fos = new FileOutputStream(file); File bpmn = new File("src/test/resources/testprocess.bpmn"); transformer.transform(bpmn.toURI().toURL(), fos); JarInputStream jis = new JarInputStream(new FileInputStream(file)); Attributes attributes = jis.getManifest().getMainAttributes(); assertThat(attributes.getValue("Manifest-Version"), is("2")); assertThat(attributes.getValue(Constants.BUNDLE_VERSION), is("0.0.0")); assertThat(attributes.getValue(Constants.BUNDLE_SYMBOLICNAME), is("testprocess")); assertThat(attributes.getValue(Constants.BUNDLE_MANIFESTVERSION), is("2")); assertThat(attributes.getValue(BUNDLE_PROCESS_DEFINITIONS_HEADER), is(BUNDLE_PROCESS_DEFINTIONS_DEFAULT)); ZipEntry entry; while ((entry = jis.getNextEntry()) != null) { assertThat( entry.getName(), is(anyOf(is("OSGI-INF/"), is(BUNDLE_PROCESS_DEFINTIONS_DEFAULT), is(BUNDLE_PROCESS_DEFINTIONS_DEFAULT + "testprocess.bpmn")))); } jis.close(); }
public void transform(URL url, OutputStream os) throws Exception { Document doc = parse(url); String name = url.getPath(); int idx = name.lastIndexOf('/'); if (idx >= 0) { name = name.substring(idx + 1); } String[] str = NameVersionTypeExtractor.extractNameVersionType(name); Manifest m = new Manifest(); m.getMainAttributes().putValue("Manifest-Version", "2"); m.getMainAttributes().putValue(BUNDLE_MANIFESTVERSION, "2"); m.getMainAttributes().putValue(BUNDLE_SYMBOLICNAME, str[0]); m.getMainAttributes().putValue(BUNDLE_VERSION, str[1]); m.getMainAttributes().putValue(BUNDLE_PROCESS_DEFINITIONS_HEADER, BUNDLE_PROCESS_DEFINTIONS_DEFAULT); NodeList l = doc.getElementsByTagName("manifest"); if (l != null) { for (int i = 0; i < l.getLength(); i++) { Element e = (Element) l.item(i); String text = e.getTextContent(); Properties props = new Properties(); props.load(new ByteArrayInputStream(text.trim().getBytes())); Set<String> en = props.stringPropertyNames(); for (String k : en) { String v = props.getProperty(k); m.getMainAttributes().putValue(k, v); } e.getParentNode().removeChild(e); } } JarOutputStream out = new JarOutputStream(os); ZipEntry e = new ZipEntry(JarFile.MANIFEST_NAME); out.putNextEntry(e); m.write(out); out.closeEntry(); e = new ZipEntry("OSGI-INF/"); out.putNextEntry(e); String processDefDir = m.getMainAttributes().getValue(BUNDLE_PROCESS_DEFINITIONS_HEADER); e = new ZipEntry(processDefDir); out.putNextEntry(e); out.closeEntry(); e = new ZipEntry(processDefDir + name); out.putNextEntry(e); tf.newTransformer() .transform(new DOMSource(doc), new StreamResult(out)); out.closeEntry(); out.close(); }
BpmnTransformer { public void transform(URL url, OutputStream os) throws Exception { Document doc = parse(url); String name = url.getPath(); int idx = name.lastIndexOf('/'); if (idx >= 0) { name = name.substring(idx + 1); } String[] str = NameVersionTypeExtractor.extractNameVersionType(name); Manifest m = new Manifest(); m.getMainAttributes().putValue("Manifest-Version", "2"); m.getMainAttributes().putValue(BUNDLE_MANIFESTVERSION, "2"); m.getMainAttributes().putValue(BUNDLE_SYMBOLICNAME, str[0]); m.getMainAttributes().putValue(BUNDLE_VERSION, str[1]); m.getMainAttributes().putValue(BUNDLE_PROCESS_DEFINITIONS_HEADER, BUNDLE_PROCESS_DEFINTIONS_DEFAULT); NodeList l = doc.getElementsByTagName("manifest"); if (l != null) { for (int i = 0; i < l.getLength(); i++) { Element e = (Element) l.item(i); String text = e.getTextContent(); Properties props = new Properties(); props.load(new ByteArrayInputStream(text.trim().getBytes())); Set<String> en = props.stringPropertyNames(); for (String k : en) { String v = props.getProperty(k); m.getMainAttributes().putValue(k, v); } e.getParentNode().removeChild(e); } } JarOutputStream out = new JarOutputStream(os); ZipEntry e = new ZipEntry(JarFile.MANIFEST_NAME); out.putNextEntry(e); m.write(out); out.closeEntry(); e = new ZipEntry("OSGI-INF/"); out.putNextEntry(e); String processDefDir = m.getMainAttributes().getValue(BUNDLE_PROCESS_DEFINITIONS_HEADER); e = new ZipEntry(processDefDir); out.putNextEntry(e); out.closeEntry(); e = new ZipEntry(processDefDir + name); out.putNextEntry(e); tf.newTransformer() .transform(new DOMSource(doc), new StreamResult(out)); out.closeEntry(); out.close(); } }
BpmnTransformer { public void transform(URL url, OutputStream os) throws Exception { Document doc = parse(url); String name = url.getPath(); int idx = name.lastIndexOf('/'); if (idx >= 0) { name = name.substring(idx + 1); } String[] str = NameVersionTypeExtractor.extractNameVersionType(name); Manifest m = new Manifest(); m.getMainAttributes().putValue("Manifest-Version", "2"); m.getMainAttributes().putValue(BUNDLE_MANIFESTVERSION, "2"); m.getMainAttributes().putValue(BUNDLE_SYMBOLICNAME, str[0]); m.getMainAttributes().putValue(BUNDLE_VERSION, str[1]); m.getMainAttributes().putValue(BUNDLE_PROCESS_DEFINITIONS_HEADER, BUNDLE_PROCESS_DEFINTIONS_DEFAULT); NodeList l = doc.getElementsByTagName("manifest"); if (l != null) { for (int i = 0; i < l.getLength(); i++) { Element e = (Element) l.item(i); String text = e.getTextContent(); Properties props = new Properties(); props.load(new ByteArrayInputStream(text.trim().getBytes())); Set<String> en = props.stringPropertyNames(); for (String k : en) { String v = props.getProperty(k); m.getMainAttributes().putValue(k, v); } e.getParentNode().removeChild(e); } } JarOutputStream out = new JarOutputStream(os); ZipEntry e = new ZipEntry(JarFile.MANIFEST_NAME); out.putNextEntry(e); m.write(out); out.closeEntry(); e = new ZipEntry("OSGI-INF/"); out.putNextEntry(e); String processDefDir = m.getMainAttributes().getValue(BUNDLE_PROCESS_DEFINITIONS_HEADER); e = new ZipEntry(processDefDir); out.putNextEntry(e); out.closeEntry(); e = new ZipEntry(processDefDir + name); out.putNextEntry(e); tf.newTransformer() .transform(new DOMSource(doc), new StreamResult(out)); out.closeEntry(); out.close(); }  }
BpmnTransformer { public void transform(URL url, OutputStream os) throws Exception { Document doc = parse(url); String name = url.getPath(); int idx = name.lastIndexOf('/'); if (idx >= 0) { name = name.substring(idx + 1); } String[] str = NameVersionTypeExtractor.extractNameVersionType(name); Manifest m = new Manifest(); m.getMainAttributes().putValue("Manifest-Version", "2"); m.getMainAttributes().putValue(BUNDLE_MANIFESTVERSION, "2"); m.getMainAttributes().putValue(BUNDLE_SYMBOLICNAME, str[0]); m.getMainAttributes().putValue(BUNDLE_VERSION, str[1]); m.getMainAttributes().putValue(BUNDLE_PROCESS_DEFINITIONS_HEADER, BUNDLE_PROCESS_DEFINTIONS_DEFAULT); NodeList l = doc.getElementsByTagName("manifest"); if (l != null) { for (int i = 0; i < l.getLength(); i++) { Element e = (Element) l.item(i); String text = e.getTextContent(); Properties props = new Properties(); props.load(new ByteArrayInputStream(text.trim().getBytes())); Set<String> en = props.stringPropertyNames(); for (String k : en) { String v = props.getProperty(k); m.getMainAttributes().putValue(k, v); } e.getParentNode().removeChild(e); } } JarOutputStream out = new JarOutputStream(os); ZipEntry e = new ZipEntry(JarFile.MANIFEST_NAME); out.putNextEntry(e); m.write(out); out.closeEntry(); e = new ZipEntry("OSGI-INF/"); out.putNextEntry(e); String processDefDir = m.getMainAttributes().getValue(BUNDLE_PROCESS_DEFINITIONS_HEADER); e = new ZipEntry(processDefDir); out.putNextEntry(e); out.closeEntry(); e = new ZipEntry(processDefDir + name); out.putNextEntry(e); tf.newTransformer() .transform(new DOMSource(doc), new StreamResult(out)); out.closeEntry(); out.close(); }  void transform(URL url, OutputStream os); }
BpmnTransformer { public void transform(URL url, OutputStream os) throws Exception { Document doc = parse(url); String name = url.getPath(); int idx = name.lastIndexOf('/'); if (idx >= 0) { name = name.substring(idx + 1); } String[] str = NameVersionTypeExtractor.extractNameVersionType(name); Manifest m = new Manifest(); m.getMainAttributes().putValue("Manifest-Version", "2"); m.getMainAttributes().putValue(BUNDLE_MANIFESTVERSION, "2"); m.getMainAttributes().putValue(BUNDLE_SYMBOLICNAME, str[0]); m.getMainAttributes().putValue(BUNDLE_VERSION, str[1]); m.getMainAttributes().putValue(BUNDLE_PROCESS_DEFINITIONS_HEADER, BUNDLE_PROCESS_DEFINTIONS_DEFAULT); NodeList l = doc.getElementsByTagName("manifest"); if (l != null) { for (int i = 0; i < l.getLength(); i++) { Element e = (Element) l.item(i); String text = e.getTextContent(); Properties props = new Properties(); props.load(new ByteArrayInputStream(text.trim().getBytes())); Set<String> en = props.stringPropertyNames(); for (String k : en) { String v = props.getProperty(k); m.getMainAttributes().putValue(k, v); } e.getParentNode().removeChild(e); } } JarOutputStream out = new JarOutputStream(os); ZipEntry e = new ZipEntry(JarFile.MANIFEST_NAME); out.putNextEntry(e); m.write(out); out.closeEntry(); e = new ZipEntry("OSGI-INF/"); out.putNextEntry(e); String processDefDir = m.getMainAttributes().getValue(BUNDLE_PROCESS_DEFINITIONS_HEADER); e = new ZipEntry(processDefDir); out.putNextEntry(e); out.closeEntry(); e = new ZipEntry(processDefDir + name); out.putNextEntry(e); tf.newTransformer() .transform(new DOMSource(doc), new StreamResult(out)); out.closeEntry(); out.close(); }  void transform(URL url, OutputStream os);  }