http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/316e4a8a/taverna-baclava-language/src/main/resources/xsd/xscufl.xsd ---------------------------------------------------------------------- diff --git a/taverna-baclava-language/src/main/resources/xsd/xscufl.xsd b/taverna-baclava-language/src/main/resources/xsd/xscufl.xsd deleted file mode 100644 index 75d51b3..0000000 --- a/taverna-baclava-language/src/main/resources/xsd/xscufl.xsd +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> -<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://org.embl.ebi.escience/xscufl/0.1alpha" xmlns:s="http://org.embl.ebi.escience/xscufl/0.1alpha" elementFormDefault="qualified"> - - <complexType name="MimeTypesType"> - <sequence> - <element ref="s:mimeType" minOccurs="0" maxOccurs="unbounded"></element> - </sequence> - </complexType> - - <element name="metadata" type="s:MetadataType"></element> - - <complexType name="MetadataType"> - <sequence> - <element ref="s:mimeTypes" minOccurs="1" maxOccurs="1"></element> - </sequence> - </complexType> - - <element name="mimeTypes" type="s:MimeTypesType"></element> - - - <element name="mimeType" type="string"></element> - -</schema> \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/316e4a8a/taverna-baclava-language/src/test/java/org/apache/taverna/baclava/TestExample1.java ---------------------------------------------------------------------- diff --git a/taverna-baclava-language/src/test/java/org/apache/taverna/baclava/TestExample1.java b/taverna-baclava-language/src/test/java/org/apache/taverna/baclava/TestExample1.java deleted file mode 100644 index c27dea1..0000000 --- a/taverna-baclava-language/src/test/java/org/apache/taverna/baclava/TestExample1.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.apache.taverna.baclava; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.util.List; - -import javax.xml.bind.JAXBException; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -public class TestExample1 { - - private static DataThingMapType dt; - - private static String[] expectedKeys = new String[] {"status", "proteinIDs", "output"}; - - private static String[] expectedMimeTypes = new String[] {"text/plain", "text/plain", "application/octet-stream"}; - - @BeforeClass - public static void setUpClass() throws FileNotFoundException, JAXBException { - ClassLoader classLoader = TestExample1.class.getClassLoader(); - File file = new File(classLoader.getResource("example1.xml").getFile()); - dt = BaclavaReader.readBaclava(new FileReader(file)); - } - - @Test - public void checkRead() { - Assert.assertNotNull("Unable to parse example1.xml", dt); - } - - @Test - public void checkNumberOfDataThings() { - Assert.assertEquals("There should be three data things", 3, dt.getDataThing().size()); - } - - @Test - public void checkDataThingKeys() { - for (String k : expectedKeys) { - Assert.assertNotNull(k + " should be there", getDataThingTypeByKey(k)); - } - } - - @Test - public void checkDataThingMimeTypes() { - for (int i = 0; i < expectedKeys.length; i++) { - String k = expectedKeys[i]; - DataThingType d = getDataThingTypeByKey(k); - MyGridDataDocumentType doc = d.getMyGridDataDocument(); - Assert.assertNotNull("myGridDataDocument of " + k + " is missing", doc); - MetadataType meta = doc.getMetadata(); - Assert.assertNotNull("metadata of " + k + " is missing", meta); - MimeTypesType types = meta.getMimeTypes(); - Assert.assertNotNull("mimetypes of " + k + " is missing", types); - List<String> mimeTypes = types.getMimeType(); - Assert.assertNotNull("mimetypes of " + k + " is null", mimeTypes); - Assert.assertNotEquals("mimetypes of " + k + " is empty", 0, mimeTypes); - String firstMimeType = mimeTypes.get(0); - Assert.assertEquals("mimetype of " + k + " is wrong", expectedMimeTypes[i], firstMimeType); - } - } - - private DataThingType getDataThingTypeByKey(String key) { - DataThingType result = null; - for (DataThingType d : dt.getDataThing()) { - if (d.getKey().equals(key)) { - result = d; - break; - } - } - return result; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/316e4a8a/taverna-baclava-language/src/test/java/org/apache/taverna/baclava/TestRoundTrip.java ---------------------------------------------------------------------- diff --git a/taverna-baclava-language/src/test/java/org/apache/taverna/baclava/TestRoundTrip.java b/taverna-baclava-language/src/test/java/org/apache/taverna/baclava/TestRoundTrip.java deleted file mode 100644 index 613a252..0000000 --- a/taverna-baclava-language/src/test/java/org/apache/taverna/baclava/TestRoundTrip.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.apache.taverna.baclava; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.StringReader; -import java.io.StringWriter; - -import javax.xml.bind.JAXBException; - -import org.junit.Assert; -import org.junit.Test; - -public class TestRoundTrip { - - private static String[] fileNames = new String[] {"example1.xml", "example2.xml"}; - - @Test - public void testRoundTrips() throws JAXBException, FileNotFoundException { - for (String fileName : fileNames) { - ClassLoader classLoader = getClass().getClassLoader(); - File file = new File(classLoader.getResource(fileName).getFile()); - DataThingMapType o = BaclavaReader.readBaclava(new FileReader(file)); - - StringWriter initialWriter = new StringWriter(); - BaclavaWriter.writeBaclava(o, initialWriter); - String initialString = initialWriter.toString(); - - DataThingMapType reread = BaclavaReader.readBaclava(new StringReader(initialString)); - StringWriter rewriteWriter = new StringWriter(); - BaclavaWriter.writeBaclava(reread, rewriteWriter); - String rewrittenString = rewriteWriter.toString(); - Assert.assertEquals(initialString, rewrittenString); - } - - } - - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/316e4a8a/taverna-baclava-language/src/test/resources/example1.xml ---------------------------------------------------------------------- diff --git a/taverna-baclava-language/src/test/resources/example1.xml b/taverna-baclava-language/src/test/resources/example1.xml deleted file mode 100644 index c39e73c..0000000 --- a/taverna-baclava-language/src/test/resources/example1.xml +++ /dev/null @@ -1,74 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<b:dataThingMap xmlns:b="http://org.embl.ebi.escience/baclava/0.1alpha"> - <b:dataThing key="status"> - <b:myGridDataDocument lsid="" syntactictype="l('text/plain')"> - <s:metadata xmlns:s="http://org.embl.ebi.escience/xscufl/0.1alpha"> - <s:mimeTypes> - <s:mimeType>text/plain</s:mimeType> - </s:mimeTypes> - </s:metadata> - <b:partialOrder lsid="" type="list"> - <b:relationList /> - <b:itemList> - <b:dataElement lsid="" index="0"> - <b:dataElementData>RklOSVNIRUQ=</b:dataElementData> - </b:dataElement> - </b:itemList> - </b:partialOrder> - </b:myGridDataDocument> - </b:dataThing> - <b:dataThing key="proteinIDs"> - <b:myGridDataDocument lsid="" syntactictype="'text/plain'"> - <s:metadata xmlns:s="http://org.embl.ebi.escience/xscufl/0.1alpha"> - <s:mimeTypes> - <s:mimeType>text/plain</s:mimeType> - </s:mimeTypes> - </s:metadata> - <b:dataElement lsid=""> - <b:dataElementData>UDE1MDE4</b:dataElementData> - </b:dataElement> - </b:myGridDataDocument> - </b:dataThing> - <b:dataThing key="output"> - <b:myGridDataDocument lsid="" syntactictype="l('application/octet-stream')"> - <s:metadata xmlns:s="http://org.embl.ebi.escience/xscufl/0.1alpha"> - <s:mimeTypes> - <s:mimeType>application/octet-stream</s:mimeType> - </s:mimeTypes> - </s:metadata> - <b:partialOrder lsid="" type="list"> - <b:relationList /> - <b:itemList> - <b:dataElement lsid="" index="0"> - <b:dataElementData>SUQgICBnaXwxMjYyNzl8c3B8UDE1MDE4LjF8TElGX0hVTUFOCkZUICAgU0lHTkFMICAgICAgICAx -ICAgICAzMiAgICAgICAKRlQgICBET01BSU4gICAgICAgIDEgICAgICAyICAgICAgIE4tUkVHSU9O -LgpGVCAgIERPTUFJTiAgICAgICAgMyAgICAgMTQgICAgICAgSC1SRUdJT04uCkZUICAgRE9NQUlO -ICAgICAgIDE1ICAgICAzMiAgICAgICBDLVJFR0lPTi4KRlQgICBET01BSU4gICAgICAgMzMgICAg -MjAyICAgICAgIE5PTiBDWVRPUExBU01JQy4KLy8K</b:dataElementData> - </b:dataElement> - </b:itemList> - </b:partialOrder> - </b:myGridDataDocument> - </b:dataThing> -</b:dataThingMap> - http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/316e4a8a/taverna-baclava-language/src/test/resources/example2.xml ---------------------------------------------------------------------- diff --git a/taverna-baclava-language/src/test/resources/example2.xml b/taverna-baclava-language/src/test/resources/example2.xml deleted file mode 100644 index ff05414..0000000 --- a/taverna-baclava-language/src/test/resources/example2.xml +++ /dev/null @@ -1,370 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<b:dataThingMap xmlns:b="http://org.embl.ebi.escience/baclava/0.1alpha"> - <b:dataThing key="strings"> - <b:myGridDataDocument lsid="" syntactictype="l(l('text/plain'))"> - <s:metadata xmlns:s="http://org.embl.ebi.escience/xscufl/0.1alpha"> - <s:mimeTypes> - <s:mimeType>text/plain</s:mimeType> - </s:mimeTypes> - </s:metadata> - <b:partialOrder lsid="" type="list"> - <b:relationList> - <b:relation parent="0" child="1" /> - </b:relationList> - <b:itemList> - <b:partialOrder lsid="" type="list" index="0"> - <b:relationList> - <b:relation parent="0" child="1" /> - <b:relation parent="1" child="2" /> - <b:relation parent="2" child="3" /> - <b:relation parent="3" child="4" /> - <b:relation parent="4" child="5" /> - <b:relation parent="5" child="6" /> - <b:relation parent="6" child="7" /> - <b:relation parent="7" child="8" /> - <b:relation parent="8" child="9" /> - <b:relation parent="9" child="10" /> - <b:relation parent="10" child="11" /> - <b:relation parent="11" child="12" /> - <b:relation parent="12" child="13" /> - <b:relation parent="13" child="14" /> - <b:relation parent="14" child="15" /> - <b:relation parent="15" child="16" /> - <b:relation parent="16" child="17" /> - <b:relation parent="17" child="18" /> - <b:relation parent="18" child="19" /> - <b:relation parent="19" child="20" /> - <b:relation parent="20" child="21" /> - <b:relation parent="21" child="22" /> - <b:relation parent="22" child="23" /> - <b:relation parent="23" child="24" /> - <b:relation parent="24" child="25" /> - <b:relation parent="25" child="26" /> - <b:relation parent="26" child="27" /> - <b:relation parent="27" child="28" /> - <b:relation parent="28" child="29" /> - <b:relation parent="29" child="30" /> - <b:relation parent="30" child="31" /> - <b:relation parent="31" child="32" /> - <b:relation parent="32" child="33" /> - <b:relation parent="33" child="34" /> - <b:relation parent="34" child="35" /> - <b:relation parent="35" child="36" /> - <b:relation parent="36" child="37" /> - <b:relation parent="37" child="38" /> - <b:relation parent="38" child="39" /> - </b:relationList> - <b:itemList> - <b:dataElement lsid="" index="0"> - <b:dataElementData>U3RyaW5nMA==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="1"> - <b:dataElementData>U3RyaW5nMQ==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="2"> - <b:dataElementData>U3RyaW5nMg==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="3"> - <b:dataElementData>U3RyaW5nMw==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="4"> - <b:dataElementData>U3RyaW5nNA==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="5"> - <b:dataElementData>U3RyaW5nNQ==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="6"> - <b:dataElementData>U3RyaW5nNg==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="7"> - <b:dataElementData>U3RyaW5nNw==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="8"> - <b:dataElementData>U3RyaW5nOA==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="9"> - <b:dataElementData>U3RyaW5nOQ==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="10"> - <b:dataElementData>U3RyaW5nMTA=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="11"> - <b:dataElementData>U3RyaW5nMTE=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="12"> - <b:dataElementData>U3RyaW5nMTI=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="13"> - <b:dataElementData>U3RyaW5nMTM=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="14"> - <b:dataElementData>U3RyaW5nMTQ=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="15"> - <b:dataElementData>U3RyaW5nMTU=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="16"> - <b:dataElementData>U3RyaW5nMTY=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="17"> - <b:dataElementData>U3RyaW5nMTc=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="18"> - <b:dataElementData>U3RyaW5nMTg=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="19"> - <b:dataElementData>U3RyaW5nMTk=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="20"> - <b:dataElementData>U3RyaW5nMjA=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="21"> - <b:dataElementData>U3RyaW5nMjE=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="22"> - <b:dataElementData>U3RyaW5nMjI=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="23"> - <b:dataElementData>U3RyaW5nMjM=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="24"> - <b:dataElementData>U3RyaW5nMjQ=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="25"> - <b:dataElementData>U3RyaW5nMjU=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="26"> - <b:dataElementData>U3RyaW5nMjY=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="27"> - <b:dataElementData>U3RyaW5nMjc=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="28"> - <b:dataElementData>U3RyaW5nMjg=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="29"> - <b:dataElementData>U3RyaW5nMjk=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="30"> - <b:dataElementData>U3RyaW5nMzA=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="31"> - <b:dataElementData>U3RyaW5nMzE=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="32"> - <b:dataElementData>U3RyaW5nMzI=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="33"> - <b:dataElementData>U3RyaW5nMzM=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="34"> - <b:dataElementData>U3RyaW5nMzQ=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="35"> - <b:dataElementData>U3RyaW5nMzU=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="36"> - <b:dataElementData>U3RyaW5nMzY=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="37"> - <b:dataElementData>U3RyaW5nMzc=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="38"> - <b:dataElementData>U3RyaW5nMzg=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="39"> - <b:dataElementData>U3RyaW5nMzk=</b:dataElementData> - </b:dataElement> - </b:itemList> - </b:partialOrder> - <b:partialOrder lsid="" type="list" index="1"> - <b:relationList> - <b:relation parent="0" child="1" /> - <b:relation parent="1" child="2" /> - <b:relation parent="2" child="3" /> - <b:relation parent="3" child="4" /> - <b:relation parent="4" child="5" /> - <b:relation parent="5" child="6" /> - <b:relation parent="6" child="7" /> - <b:relation parent="7" child="8" /> - <b:relation parent="8" child="9" /> - <b:relation parent="9" child="10" /> - <b:relation parent="10" child="11" /> - <b:relation parent="11" child="12" /> - <b:relation parent="12" child="13" /> - <b:relation parent="13" child="14" /> - <b:relation parent="14" child="15" /> - <b:relation parent="15" child="16" /> - <b:relation parent="16" child="17" /> - <b:relation parent="17" child="18" /> - <b:relation parent="18" child="19" /> - <b:relation parent="19" child="20" /> - <b:relation parent="20" child="21" /> - <b:relation parent="21" child="22" /> - <b:relation parent="22" child="23" /> - <b:relation parent="23" child="24" /> - <b:relation parent="24" child="25" /> - <b:relation parent="25" child="26" /> - <b:relation parent="26" child="27" /> - <b:relation parent="27" child="28" /> - <b:relation parent="28" child="29" /> - <b:relation parent="29" child="30" /> - <b:relation parent="30" child="31" /> - <b:relation parent="31" child="32" /> - <b:relation parent="32" child="33" /> - <b:relation parent="33" child="34" /> - <b:relation parent="34" child="35" /> - <b:relation parent="35" child="36" /> - <b:relation parent="36" child="37" /> - <b:relation parent="37" child="38" /> - <b:relation parent="38" child="39" /> - </b:relationList> - <b:itemList> - <b:dataElement lsid="" index="0"> - <b:dataElementData>U3RyaW5nMA==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="1"> - <b:dataElementData>U3RyaW5nMQ==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="2"> - <b:dataElementData>U3RyaW5nMg==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="3"> - <b:dataElementData>U3RyaW5nMw==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="4"> - <b:dataElementData>U3RyaW5nNA==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="5"> - <b:dataElementData>U3RyaW5nNQ==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="6"> - <b:dataElementData>U3RyaW5nNg==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="7"> - <b:dataElementData>U3RyaW5nNw==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="8"> - <b:dataElementData>U3RyaW5nOA==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="9"> - <b:dataElementData>U3RyaW5nOQ==</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="10"> - <b:dataElementData>U3RyaW5nMTA=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="11"> - <b:dataElementData>U3RyaW5nMTE=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="12"> - <b:dataElementData>U3RyaW5nMTI=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="13"> - <b:dataElementData>U3RyaW5nMTM=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="14"> - <b:dataElementData>U3RyaW5nMTQ=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="15"> - <b:dataElementData>U3RyaW5nMTU=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="16"> - <b:dataElementData>U3RyaW5nMTY=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="17"> - <b:dataElementData>U3RyaW5nMTc=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="18"> - <b:dataElementData>U3RyaW5nMTg=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="19"> - <b:dataElementData>U3RyaW5nMTk=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="20"> - <b:dataElementData>U3RyaW5nMjA=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="21"> - <b:dataElementData>U3RyaW5nMjE=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="22"> - <b:dataElementData>U3RyaW5nMjI=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="23"> - <b:dataElementData>U3RyaW5nMjM=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="24"> - <b:dataElementData>U3RyaW5nMjQ=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="25"> - <b:dataElementData>U3RyaW5nMjU=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="26"> - <b:dataElementData>U3RyaW5nMjY=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="27"> - <b:dataElementData>U3RyaW5nMjc=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="28"> - <b:dataElementData>U3RyaW5nMjg=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="29"> - <b:dataElementData>U3RyaW5nMjk=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="30"> - <b:dataElementData>U3RyaW5nMzA=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="31"> - <b:dataElementData>U3RyaW5nMzE=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="32"> - <b:dataElementData>U3RyaW5nMzI=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="33"> - <b:dataElementData>U3RyaW5nMzM=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="34"> - <b:dataElementData>U3RyaW5nMzQ=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="35"> - <b:dataElementData>U3RyaW5nMzU=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="36"> - <b:dataElementData>U3RyaW5nMzY=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="37"> - <b:dataElementData>U3RyaW5nMzc=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="38"> - <b:dataElementData>U3RyaW5nMzg=</b:dataElementData> - </b:dataElement> - <b:dataElement lsid="" index="39"> - <b:dataElementData>U3RyaW5nMzk=</b:dataElementData> - </b:dataElement> - </b:itemList> - </b:partialOrder> - </b:itemList> - </b:partialOrder> - </b:myGridDataDocument> - </b:dataThing> -</b:dataThingMap> - http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/316e4a8a/taverna-databundle/README.md ---------------------------------------------------------------------- diff --git a/taverna-databundle/README.md b/taverna-databundle/README.md deleted file mode 100644 index dab38b6..0000000 --- a/taverna-databundle/README.md +++ /dev/null @@ -1,172 +0,0 @@ -Data bundles API -================ - -API for Taverna Data Bundles - -[![Build Status](https://travis-ci.org/taverna/taverna-databundle.svg?branch=master)](https://travis-ci.org/taverna/taverna-databundle) - -See [Data bundle requirements](http://dev.mygrid.org.uk/wiki/display/TAVOSGI/2013-02+Data+bundle+requirements) -and [TestDataBundles.java](src/test/java/uk/org/taverna/databundle/TestDataBundles.java) - -This API is built on the Java 7 NIO Files and the [RO Bundle API](https://github.com/wf4ever/robundle), which -uses the [Java 7 ZIP file provider](http://docs.oracle.com/javase/7/docs/technotes/guides/io/fsp/zipfilesystemprovider.html) to generate the Data Bundle. - - -The class [org.apache.taverna.databundle.DataBundles](src/main/java/uk/org/taverna/databundle/DataBundles.java) -complements the Java 7 [java.nio.Files](http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html) -API with more specific helper methods to work with Data Bundles. - - -Building --------- -```mvn clean install``` - -should normally work, given a recent version of [Maven 3](http://maven.apache.org/download.cgi) and -[Java 7 SDK](http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html). - -[myGrid's Jenkins installation](http://build.mygrid.org.uk/ci/) has automated -builds of both [databundles](http://build.mygrid.org.uk/ci/job/databundles/) -and [robundle](http://build.mygrid.org.uk/ci/job/robundle/), which snapshots are deployed to -[myGrid's snapshot repository](http://build.mygrid.org.uk/maven/snapshot-repository/uk/org/taverna/databundle/databundle/). - -Maven should download the latest snapshot of [robundle](https://github.com/wf4ever/robundle) -from [myGrid's snapshot repository](http://build.mygrid.org.uk/maven/snapshot-repository/org/purl/wf4ever/robundle/robundle/), -but in some cases you might have to build robundle locally before building this project. - - -Example of use --------------- - -Example in full is at [org.apache.taverna.databundle.TestExample](src/test/java/uk/org/taverna/databundle/TestExample.java) - - -Create a new (temporary) data bundle: -```java - Bundle dataBundle = DataBundles.createBundle(); -``` - -Get the input ports and the port "in1": -```java - Path inputs = DataBundles.getInputs(dataBundle); - Path portIn1 = DataBundles.getPort(inputs, "in1"); -``` - -Setting a string value for the input port: -```java - DataBundles.setStringValue(portIn1, "Hello"); -``` - -And retrieving it: -```java - if (DataBundles.isValue(portIn1)) { - System.out.println(DataBundles.getStringValue(portIn1)); - } -``` -``` -Hello -``` - - -Alternatively, use the regular Files methods: -```java - for (String line : Files - .readAllLines(portIn1, Charset.forName("UTF-8"))) { - System.out.println(line); - } -``` - - -Binaries and large files are done through the Files API -```java - try (OutputStream out = Files.newOutputStream(portIn1, - StandardOpenOption.APPEND)) { - out.write(32); - } -``` - -Or Java 7 style: -```java - Path localFile = Files.createTempFile("", ".txt"); - Files.copy(portIn1, localFile, StandardCopyOption.REPLACE_EXISTING); - System.out.println("Written to: " + localFile); -``` -``` -Written to: C:\Users\stain\AppData\Local\Temp\2009921746200670789.txt -``` - -Either direction of copy works, of course: -```java - Files.copy(localFile, - DataBundles.getPort(DataBundles.getOutputs(dataBundle), "out1")); -``` - - -When you get a port, it can become either a value or a list: -```java - Path port2 = DataBundles.getPort(inputs, "port2"); - DataBundles.createList(port2); // empty list - List<Path> list = DataBundles.getList(port2); - assertTrue(list.isEmpty()); -``` - -Adding items sequentially: -```java - Path item0 = DataBundles.newListItem(port2); - DataBundles.setStringValue(item0, "item 0"); - DataBundles.setStringValue(DataBundles.newListItem(port2), "item 1"); - DataBundles.setStringValue(DataBundles.newListItem(port2), "item 2"); -``` - -Set and get by explicit position: -```java - DataBundles.setStringValue(DataBundles.getListItem(port2, 12), "item 12"); - System.out.println(DataBundles.getStringValue(DataBundles.getListItem(port2, 2))); -``` -``` -item 2 -``` - -The list is sorted numerically (e.g. 2, 5, 10) and will contain nulls for empty slots: -```java - System.out.println(DataBundles.getList(port2)); -``` -``` -[/inputs/port2/0, /inputs/port2/1, /inputs/port2/2, null, null, null, null, null, - null, null, null, null, /inputs/port2/12] -``` - -Ports can be browsed as a map by port name: -```java - NavigableMap<String, Path> ports = DataBundles.getPorts(inputs); - System.out.println(ports.keySet()); -``` -``` -[in1, port2] -``` - -Saving a data bundle: -```java - Path zip = Files.createTempFile("databundle", ".zip"); - DataBundles.closeAndSaveBundle(dataBundle, zip); - // NOTE: From now dataBundle and its Path's are CLOSED - // and can no longer be accessed - System.out.println("Saved to " + zip); -``` -``` -Saved to C:\Users\stain\AppData\Local\Temp\databundle6905894602121718151.zip -``` - -Inspecting the zip: -```java - if (Desktop.isDesktopSupported()) { - // Open ZIP file for browsing - Desktop.getDesktop().open(zip.toFile()); - } -``` - -Loading a data bundle back from disk: -```java - try (Bundle dataBundle2 = DataBundles.openBundle(zip)) { - // Any modifications here will be saved on (here automatic) close - } -``` http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/316e4a8a/taverna-databundle/pom.xml ---------------------------------------------------------------------- diff --git a/taverna-databundle/pom.xml b/taverna-databundle/pom.xml deleted file mode 100644 index e7ff46e..0000000 --- a/taverna-databundle/pom.xml +++ /dev/null @@ -1,109 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.taverna.language</groupId> - <artifactId>taverna-language</artifactId> - <version>0.16.1-incubating-SNAPSHOT</version> - </parent> - <artifactId>taverna-databundle</artifactId> - <name>Apache Taverna Databundle API</name> - <description>API for dealing with Data Bundles</description> - <dependencies> - <dependency> - <groupId>org.apache.jena</groupId> - <artifactId>jena-arq</artifactId> - <version>${jena.version}</version> - </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>taverna-scufl2-rdfxml</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>taverna-scufl2-t2flow</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>taverna-scufl2-wfdesc</artifactId> - <version>${project.version}</version> - <optional>true</optional> - </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>taverna-robundle</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>${junit.version}</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>${commons.io.version}</version> - <scope>test</scope> - </dependency> - - - <dependency> - <groupId>commons-configuration</groupId> - <artifactId>commons-configuration</artifactId> - <version>${commons.configuration.version}</version> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>2.3.2</version> - <configuration> - <source>1.7</source> - <target>1.7</target> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - </plugin> - <plugin> - <groupId>org.apache.rat</groupId> - <artifactId>apache-rat-plugin</artifactId> - </plugin> - </plugins> - <pluginManagement> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <version>2.3.7</version> - </plugin> - </plugins> - </pluginManagement> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/316e4a8a/taverna-databundle/src/main/java/org/apache/taverna/databundle/DataBundles.java ---------------------------------------------------------------------- diff --git a/taverna-databundle/src/main/java/org/apache/taverna/databundle/DataBundles.java b/taverna-databundle/src/main/java/org/apache/taverna/databundle/DataBundles.java deleted file mode 100644 index 750a23e..0000000 --- a/taverna-databundle/src/main/java/org/apache/taverna/databundle/DataBundles.java +++ /dev/null @@ -1,454 +0,0 @@ -package org.apache.taverna.databundle; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - - -import static java.nio.file.Files.createDirectories; -import static java.nio.file.Files.delete; -import static java.nio.file.Files.isDirectory; -import static java.nio.file.Files.isRegularFile; -import static java.nio.file.Files.newDirectoryStream; -import static java.nio.file.Files.newInputStream; -import static java.nio.file.Files.newOutputStream; -import static java.nio.file.Files.readAllLines; -import static java.nio.file.Files.write; -import static java.nio.file.StandardOpenOption.CREATE; -import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; -import java.nio.charset.Charset; -import java.nio.file.DirectoryIteratorException; -import java.nio.file.DirectoryStream; -import java.nio.file.DirectoryStream.Filter; -import java.nio.file.FileAlreadyExistsException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.NavigableMap; -import java.util.TreeMap; -import java.util.UUID; - -import org.apache.log4j.Logger; -import org.apache.taverna.scufl2.api.container.WorkflowBundle; -import org.apache.taverna.scufl2.api.io.ReaderException; -import org.apache.taverna.scufl2.api.io.WorkflowBundleIO; -import org.apache.taverna.scufl2.api.io.WriterException; -import org.apache.taverna.robundle.Bundle; -import org.apache.taverna.robundle.Bundles; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * Utility functions for dealing with data bundles. - * <p> - * The style of using this class is similar to that of {@link Files}. In fact, a - * data bundle is implemented as a set of {@link Path}s. - * - * @author Stian Soiland-Reyes - */ -public class DataBundles extends Bundles { - private static final class OBJECT_MAPPER { - // Lazy initialization of singleton - private static final ObjectMapper instance = new ObjectMapper(); - } - - protected static final class ExtensionIgnoringFilter implements - Filter<Path> { - private final String fname; - - private ExtensionIgnoringFilter(Path file) { - this.fname = filenameWithoutExtension(file); - } - - @Override - public boolean accept(Path entry) throws IOException { - return fname.equals(filenameWithoutExtension(entry)); - } - } - - private static WorkflowBundleIO wfBundleIO; - - private static Logger logger = Logger.getLogger(DataBundles.class); - - private static final String WFBUNDLE_CONTENT_TYPE = "application/vnd.taverna.scufl2.workflow-bundle"; - private static final String WFDESC_TURTLE = "text/vnd.wf4ever.wfdesc+turtle"; - private static final String WORKFLOW = "workflow"; - private static final String DOT_WFDESC_TTL = ".wfdesc.ttl"; - private static final String DOT_WFBUNDLE = ".wfbundle"; - private static final String WORKFLOWRUN_PROV_TTL = "workflowrun.prov.ttl"; - private static final String WORKFLOWRUN_JSON = "workflowrun.json"; - private static final String DOT_ERR = ".err"; - private static final String INPUTS = "inputs"; - private static final String INTERMEDIATES = "intermediates"; - private static final String OUTPUTS = "outputs"; - private static final Charset UTF8 = Charset.forName("UTF-8"); - - private static Path anyExtension(Path path) throws IOException { - return anyExtension(path.getParent(), path.getFileName().toString()); - } - - private static Path anyExtension(Path directory, String fileName) - throws IOException { - Path path = directory.resolve(fileName); - - // Prefer the fileName as it is - if (Files.exists(path)) - return path; - // Strip any existing extension - String fileNameNoExt = filenameWithoutExtension(path); - Path withoutExt = path.resolveSibling(fileNameNoExt); - if (Files.exists(withoutExt)) - return withoutExt; - - // Check directory for path.* - for (Path p : newDirectoryStream(directory, fileNameNoExt + ".*")) - /* - * We'll just return the first one - * - * TODO: Should we fail if there's more than one? - */ - return p; - - /* - * Nothing? Then let's give the existing one; perhaps it is to be - * created. - */ - return path; - } - - private static void checkExistingAnyExtension(Path path) - throws IOException, FileAlreadyExistsException { - Path existing = anyExtension(path); - if (!path.equals(existing)) - throw new FileAlreadyExistsException(existing.toString()); - } - - public static void createList(Path path) throws IOException { - checkExistingAnyExtension(path); - Files.createDirectories(path); - } - - public static void deleteAllExtensions(final Path file) throws IOException { - Filter<Path> filter = new ExtensionIgnoringFilter(file); - try (DirectoryStream<Path> ds = newDirectoryStream(file.getParent(), - filter)) { - for (Path p : ds) - deleteRecursively(p); - } - } - - protected static String filenameWithoutExtension(Path entry) { - String fileName = entry.getFileName().toString(); - int lastDot = fileName.lastIndexOf("."); - if (lastDot < 0) - return fileName.replace("/", ""); - return fileName.substring(0, lastDot); - } - - public static ErrorDocument getError(Path path) throws IOException { - if (path == null) - return null; - - Path errorPath = withExtension(path, DOT_ERR); - List<String> errorList = readAllLines(errorPath, UTF8); - int split = errorList.indexOf(""); - if (split == -1 || errorList.size() <= split) - throw new IOException("Invalid error document: " + errorPath); - - ErrorDocument errorDoc = new ErrorDocument(); - - for (String cause : errorList.subList(0, split)) - errorDoc.getCausedBy().add(path.resolveSibling(cause)); - - errorDoc.setMessage(errorList.get(split + 1)); - - StringBuilder errorTrace = new StringBuilder(); - for (String line : errorList.subList(split + 2, errorList.size())) { - errorTrace.append(line); - errorTrace.append("\n"); - } - if (errorTrace.length() > 0) - // Delete last \n - errorTrace.deleteCharAt(errorTrace.length() - 1); - errorDoc.setTrace(errorTrace.toString()); - return errorDoc; - } - - public static Path getInputs(Bundle dataBundle) throws IOException { - Path inputs = dataBundle.getRoot().resolve(INPUTS); - createDirectories(inputs); - return inputs; - } - - private static long getEntryNumber(Path entry) throws NumberFormatException { - String name = filenameWithoutExtension(entry); - return Long.parseLong(name); - } - - public static List<Path> getList(Path list) throws IOException { - if (list == null) - return null; - List<Path> paths = new ArrayList<>(); - try (DirectoryStream<Path> ds = newDirectoryStream(list)) { - for (Path entry : ds) - try { - long entryNum = getEntryNumber(entry); - while (paths.size() <= entryNum) - // Fill any gaps - paths.add(null); - // NOTE: Don't use add() as these could come in any order! - paths.set((int) entryNum, entry); - } catch (NumberFormatException ex) { - } - } catch (DirectoryIteratorException ex) { - throw ex.getCause(); - } - return paths; - } - - public static Path getListItem(Path list, long position) throws IOException { - if (position < 0) - throw new IllegalArgumentException( - "Position must be 0 or more, not: " + position); - return anyExtension(list, Long.toString(position)); - } - - public static Path getOutputs(Bundle dataBundle) throws IOException { - Path inputs = dataBundle.getRoot().resolve(OUTPUTS); - createDirectories(inputs); - return inputs; - } - - public static Path getPort(Path map, String portName) throws IOException { - Files.createDirectories(map); - return anyExtension(map, portName); - } - - public static NavigableMap<String, Path> getPorts(Path path) - throws IOException { - NavigableMap<String, Path> ports = new TreeMap<>(); - try (DirectoryStream<Path> ds = newDirectoryStream(path)) { - for (Path p : ds) - ports.put(filenameWithoutExtension(p), p); - } - return ports; - } - - public static boolean hasInputs(Bundle dataBundle) { - Path inputs = dataBundle.getRoot().resolve(INPUTS); - return isDirectory(inputs); - } - - public static boolean hasOutputs(Bundle dataBundle) { - Path outputs = dataBundle.getRoot().resolve(OUTPUTS); - return isDirectory(outputs); - } - - public static boolean isError(Path path) { - return isRegularFile(withExtension(path, DOT_ERR)); - } - - public static boolean isList(Path path) { - return isDirectory(path); - } - - public static boolean isMissing(Path item) { - return Bundles.isMissing(item) && !isError(item); - } - - public static boolean isValue(Path item) { - return !isError(item) && Bundles.isValue(item); - } - - public static Path newListItem(Path list) throws IOException { - createList(list); - return list.resolve(Long.toString(getListSize(list))); - } - - public static Path setError(Path path, ErrorDocument error) - throws IOException { - return setError(path, error.getMessage(), error.getTrace(), error - .getCausedBy().toArray(new Path[error.getCausedBy().size()])); - } - - public static Path setError(Path errorPath, String message, String trace, - Path... causedBy) throws IOException { - errorPath = withExtension(errorPath, DOT_ERR); - // Silly \n-based format - List<String> errorDoc = new ArrayList<>(); - for (Path cause : causedBy) { - Path relCause = errorPath.getParent().relativize(cause); - errorDoc.add(relCause.toString()); - } - errorDoc.add(""); // Our magic separator - errorDoc.add(message); - errorDoc.add(trace); - checkExistingAnyExtension(errorPath); - write(errorPath, errorDoc, UTF8, TRUNCATE_EXISTING, CREATE); - return errorPath; - } - - public static Path setReference(Path path, URI reference) - throws IOException { - path = withExtension(path, DOT_URL); - checkExistingAnyExtension(path); - return Bundles.setReference(path, reference); - } - - public static void setStringValue(Path path, String string) - throws IOException { - checkExistingAnyExtension(path); - Bundles.setStringValue(path, string); - } - - protected static Path withExtension(Path path, String extension) { - String filename = path.getFileName().toString(); - return path.resolveSibling(withExtensionFilename(filename, extension)); - } - - protected static String withExtensionFilename(String filename, - String extension) { - if (!extension.isEmpty() && !extension.startsWith(".")) - throw new IllegalArgumentException( - "Extension must be empty or start with ."); - if (!extension.isEmpty() - && filename.toLowerCase().endsWith(extension.toLowerCase())) - return filename; - // Everything after the last . - or just the end - return filename.replaceFirst("(\\.[^.]*)?$", extension); - } - - public static Path getWorkflowRunProvenance(Bundle dataBundle) { - return dataBundle.getRoot().resolve(WORKFLOWRUN_PROV_TTL); - } - - public static Path getWorkflowRunReport(Bundle dataBundle) { - return dataBundle.getRoot().resolve(WORKFLOWRUN_JSON); - } - - public static JsonNode getWorkflowRunReportAsJson(Bundle dataBundle) - throws IOException { - Path path = getWorkflowRunReport(dataBundle); - try (InputStream jsonIn = newInputStream(path)) { - return OBJECT_MAPPER.instance.readTree(jsonIn); - } - } - - public static void setWorkflowRunReport(Bundle dataBundle, - JsonNode workflowRunReport) throws IOException { - Path path = getWorkflowRunReport(dataBundle); - try (OutputStream out = newOutputStream(path)) { - OBJECT_MAPPER.instance.writeValue(out, workflowRunReport); - } - } - - public static Path getWorkflow(Bundle dataBundle) throws IOException { - return anyExtension(dataBundle.getRoot(), WORKFLOW); - } - - public static Path getWorkflowDescription(Bundle dataBundle) - throws IOException { - Path annotations = getAnnotations(dataBundle); - return annotations.resolve(WORKFLOW + DOT_WFDESC_TTL); - } - - public static void setWorkflowBundle(Bundle dataBundle, - WorkflowBundle wfBundle) throws IOException { - Path bundlePath = withExtension(getWorkflow(dataBundle), DOT_WFBUNDLE); - checkExistingAnyExtension(bundlePath); - - // TODO: Save as nested folder? - try (OutputStream outputStream = newOutputStream(bundlePath)) { - getWfBundleIO().writeBundle(wfBundle, outputStream, - WFBUNDLE_CONTENT_TYPE); - } catch (WriterException e) { - throw new IOException("Can't write workflow bundle to: " - + bundlePath, e); - } - - // wfdesc - Path wfdescPath = getWorkflowDescription(dataBundle); - try (OutputStream outputStream = newOutputStream(wfdescPath)) { - getWfBundleIO().writeBundle(wfBundle, outputStream, WFDESC_TURTLE); - } catch (IllegalArgumentException | WriterException e) { - logger.warn("Can't write wfdesc to: " + bundlePath, e); - delete(wfdescPath); - // throw new IOException("Can't write wfdesc to: " + bundlePath, e); - } - } - - public static WorkflowBundle getWorkflowBundle(Bundle dataBundle) - throws ReaderException, IOException { - Path wf = getWorkflow(dataBundle); - // String type = Files.probeContentType(wf); - return wfBundleIO.readBundle(newInputStream(wf), null); - } - - public static Path getIntermediates(Bundle dataBundle) throws IOException { - Path intermediates = dataBundle.getRoot().resolve(INTERMEDIATES); - createDirectories(intermediates); - return intermediates; - } - - public static Path getIntermediate(Bundle dataBundle, UUID uuid) - throws IOException { - String fileName = uuid.toString(); - Path intermediates = getIntermediates(dataBundle); - // Folder is named after first 2 characters of UUID - Path folder = intermediates.resolve(fileName.substring(0, 2)); - createDirectories(folder); - return anyExtension(folder, fileName); - } - - public static long getListSize(Path list) throws IOException { - // Should fail if list is not a directory - try (DirectoryStream<Path> ds = newDirectoryStream(list)) { - long max = -1L; - for (Path entry : ds) - try { - long entryNum = getEntryNumber(entry); - if (entryNum > max) - max = entryNum; - } catch (NumberFormatException ex) { - } - return max + 1; - } catch (DirectoryIteratorException ex) { - throw ex.getCause(); - } - } - - public static WorkflowBundleIO getWfBundleIO() { - if (wfBundleIO == null) - wfBundleIO = new WorkflowBundleIO(); - return wfBundleIO; - } - - public static void setWfBundleIO(WorkflowBundleIO wfBundleIO) { - if (wfBundleIO == null) - throw new NullPointerException(); - DataBundles.wfBundleIO = wfBundleIO; - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/316e4a8a/taverna-databundle/src/main/java/org/apache/taverna/databundle/ErrorDocument.java ---------------------------------------------------------------------- diff --git a/taverna-databundle/src/main/java/org/apache/taverna/databundle/ErrorDocument.java b/taverna-databundle/src/main/java/org/apache/taverna/databundle/ErrorDocument.java deleted file mode 100644 index ec551b8..0000000 --- a/taverna-databundle/src/main/java/org/apache/taverna/databundle/ErrorDocument.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.taverna.databundle; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - - -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; - -public class ErrorDocument { - private List<Path> causedBy = new ArrayList<>(); - private String message = ""; - private String trace = ""; - - public List<Path> getCausedBy() { - return causedBy; - } - - public String getMessage() { - return message; - } - - public String getTrace() { - return trace; - } - - public void setCausedBy(List<Path> causedBy) { - this.causedBy.clear(); - if (causedBy != null) - this.causedBy.addAll(causedBy); - } - - public void setMessage(String message) { - if (message == null) - message = ""; - this.message = message; - } - - public void setTrace(String trace) { - if (trace == null) - trace = ""; - this.trace = trace; - } -}