tag | e29f962b6bc0a070a2ffc5f7fe716b9e96879fee | |
---|---|---|
tagger | Stian Soiland-Reyes <soiland-reyes@cs.manchester.ac.uk> | Mon Feb 24 10:04:43 2014 +0000 |
object | 960150a4ee11636e6cf92b1194173d8df7dfc37d |
[maven-release-plugin] copy for tag 0.3.0
commit | 960150a4ee11636e6cf92b1194173d8df7dfc37d | [log] [tgz] |
---|---|---|
author | Stian Soiland-Reyes <soiland-reyes@cs.manchester.ac.uk> | Mon Feb 24 10:04:41 2014 +0000 |
committer | Stian Soiland-Reyes <soiland-reyes@cs.manchester.ac.uk> | Mon Feb 24 10:04:41 2014 +0000 |
tree | 5d721901373aee0a11b8fa05af2f13951934a2dd | |
parent | 6f723b8ba343c167bec301e5e2fd4bf14f8973c1 [diff] |
[maven-release-plugin] prepare release 0.3.0
API for building Wf4Ever RO bundles.
Work in progress.
This API is built on the Java 7 NIO Files and uses the Java 7 ZIP file provider to generate the RO Bundle.
The class org.purl.wf4ever.robundle.Bundles complements the Java 7 java.nio.Files API with more specific helper methods to work with RO Bundles.
This API is the basis for the Taverna Data Bundles API.
mvn clean install
should normally work, given a recent version of Maven 3 and Java 7 SDK.
myGrid's Jenkins installation has automated builds of robundle, which are deployed to myGrid's snapshot Maven repository.
Example in full is at org.purl.wf4ever.robundle.TestExample
// Create a new (temporary) RO bundle Bundle bundle = Bundles.createBundle(); // Get the inputs Path inputs = bundle.getRoot().resolve("inputs"); Files.createDirectory(inputs); // Get an input port: Path in1 = inputs.resolve("in1"); // Setting a string value for the input port: Bundles.setStringValue(in1, "Hello"); // And retrieving it if (Bundles.isValue(in1)) { System.out.println(Bundles.getStringValue(in1)); } // Or just use the regular Files methods: for (String line : Files.readAllLines(in1, Charset.forName("UTF-8"))) { System.out.println(line); } // Binaries and large files are done through the Files API try (OutputStream out = Files.newOutputStream(in1, StandardOpenOption.APPEND)) { out.write(32); } // Or Java 7 style Path localFile = Files.createTempFile("", ".txt"); Files.copy(in1, localFile, StandardCopyOption.REPLACE_EXISTING); System.out.println("Written to: " + localFile); Files.copy(localFile, bundle.getRoot().resolve("out1")); // Representing references URI ref = URI.create("http://example.com/external.txt"); Path out3 = bundle.getRoot().resolve("out3"); System.out.println(Bundles.setReference(out3, ref)); if (Bundles.isReference(out3)) { URI resolved = Bundles.getReference(out3); System.out.println(resolved); } // Saving a bundle: Path zip = Files.createTempFile("bundle", ".zip"); Bundles.closeAndSaveBundle(bundle, zip); // NOTE: From now "bundle" and its Path's are CLOSED // and can no longer be accessed System.out.println("Saved to " + zip); if (Desktop.isDesktopSupported()) { // Open ZIP file for browsing Desktop.getDesktop().open(zip.toFile()); } // Loading a bundle back from disk try (Bundle bundle2 = Bundles.openBundle(zip)) { assertEquals(zip, bundle2.getSource()); }