TAVERNA-971 Use our own jarcache.json as a workaround

and set Thread context class loader to the taverna-commandline-common
classloader.

contexts/bundle.jsonld copied from taverna-robundle


Project: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-commandline/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-commandline/commit/1f97dd0a
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-commandline/tree/1f97dd0a
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-taverna-commandline/diff/1f97dd0a

Branch: refs/heads/master
Commit: 1f97dd0a4ea24231c7405286baa6b2e309190045
Parents: 9786332
Author: Stian Soiland-Reyes <[email protected]>
Authored: Thu May 26 16:21:19 2016 +0100
Committer: Stian Soiland-Reyes <[email protected]>
Committed: Thu May 26 16:35:05 2016 +0100

----------------------------------------------------------------------
 .../taverna/commandline/CommandLineTool.java    |  83 ++++++-----
 .../src/main/resources/contexts/bundle.jsonld   | 140 +++++++++++++++++++
 .../src/main/resources/jarcache.json            |  11 ++
 3 files changed, 198 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-commandline/blob/1f97dd0a/taverna-commandline-common/src/main/java/org/apache/taverna/commandline/CommandLineTool.java
----------------------------------------------------------------------
diff --git 
a/taverna-commandline-common/src/main/java/org/apache/taverna/commandline/CommandLineTool.java
 
b/taverna-commandline-common/src/main/java/org/apache/taverna/commandline/CommandLineTool.java
index 5133f21..90a6d47 100644
--- 
a/taverna-commandline-common/src/main/java/org/apache/taverna/commandline/CommandLineTool.java
+++ 
b/taverna-commandline-common/src/main/java/org/apache/taverna/commandline/CommandLineTool.java
@@ -33,6 +33,12 @@ import java.util.Set;
 
 import javax.naming.NamingException;
 
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.log4j.RollingFileAppender;
 import org.apache.taverna.commandline.data.DatabaseConfigurationHandler;
 import org.apache.taverna.commandline.data.InputsHandler;
 import org.apache.taverna.commandline.data.SaveResultsHandler;
@@ -42,16 +48,19 @@ import 
org.apache.taverna.commandline.exceptions.InvalidOptionException;
 import org.apache.taverna.commandline.exceptions.OpenDataflowException;
 import org.apache.taverna.commandline.exceptions.ReadInputException;
 import org.apache.taverna.commandline.options.CommandLineOptions;
-import org.apache.taverna.security.credentialmanager.CMException;
-import org.apache.taverna.security.credentialmanager.CredentialManager;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.RollingFileAppender;
+import org.apache.taverna.configuration.database.DatabaseConfiguration;
+import org.apache.taverna.configuration.database.DatabaseManager;
 import org.apache.taverna.databundle.DataBundles;
+import org.apache.taverna.platform.execution.api.ExecutionEnvironment;
+import org.apache.taverna.platform.execution.api.InvalidExecutionIdException;
+import org.apache.taverna.platform.execution.api.InvalidWorkflowException;
+import org.apache.taverna.platform.report.State;
+import org.apache.taverna.platform.report.WorkflowReport;
+import org.apache.taverna.platform.run.api.InvalidRunIdException;
+import org.apache.taverna.platform.run.api.RunProfile;
+import org.apache.taverna.platform.run.api.RunProfileException;
+import org.apache.taverna.platform.run.api.RunService;
+import org.apache.taverna.platform.run.api.RunStateException;
 import org.apache.taverna.robundle.Bundle;
 import org.apache.taverna.scufl2.api.common.NamedSet;
 import org.apache.taverna.scufl2.api.container.WorkflowBundle;
@@ -65,19 +74,10 @@ import 
org.apache.taverna.scufl2.validation.correctness.CorrectnessValidator;
 import 
org.apache.taverna.scufl2.validation.correctness.ReportCorrectnessValidationListener;
 import 
org.apache.taverna.scufl2.validation.structural.ReportStructuralValidationListener;
 import org.apache.taverna.scufl2.validation.structural.StructuralValidator;
+import org.apache.taverna.security.credentialmanager.CMException;
+import org.apache.taverna.security.credentialmanager.CredentialManager;
 
-import org.apache.taverna.configuration.database.DatabaseConfiguration;
-import org.apache.taverna.configuration.database.DatabaseManager;
-import org.apache.taverna.platform.execution.api.ExecutionEnvironment;
-import org.apache.taverna.platform.execution.api.InvalidExecutionIdException;
-import org.apache.taverna.platform.execution.api.InvalidWorkflowException;
-import org.apache.taverna.platform.report.State;
-import org.apache.taverna.platform.report.WorkflowReport;
-import org.apache.taverna.platform.run.api.InvalidRunIdException;
-import org.apache.taverna.platform.run.api.RunProfile;
-import org.apache.taverna.platform.run.api.RunProfileException;
-import org.apache.taverna.platform.run.api.RunService;
-import org.apache.taverna.platform.run.api.RunStateException;
+import com.github.jsonldjava.utils.JsonUtils;
 
 /**
  * A utility class that wraps the process of executing a workflow, allowing 
workflows to be easily
@@ -87,6 +87,7 @@ import org.apache.taverna.platform.run.api.RunStateException;
  * @author Alex Nenadic
  */
 public class CommandLineTool {
+       private static final String BUNDLE_CONTEXT = 
"https://w3id.org/bundle/context";;
        private static boolean BOOTSTRAP_LOGGING = false;
        private static Logger logger = Logger.getLogger(CommandLineTool.class);
 
@@ -160,25 +161,22 @@ public class CommandLineTool {
                        }
                }
        }
-
+       
        public int setupAndExecute() throws InputMismatchException, 
InvalidOptionException,
                        CMException, OpenDataflowException, ReaderException, 
IOException, ValidationException,
                        ReadInputException, InvalidWorkflowException, 
RunProfileException,
                        InvalidRunIdException, RunStateException, 
InvalidExecutionIdException, DatabaseConfigurationException {
-
-               if (!commandLineOptions.askedForHelp()) {
+                               
+               if (commandLineOptions.askedForHelp()) {
+                       commandLineOptions.displayHelp();
+                       return 0;
+               }
                         setupDatabase(commandLineOptions);
-
+                        setupJarCache();
+                        
+                        
                        if (commandLineOptions.getWorkflow() != null) {
                                
-                               /* Set context class loader to us, 
-                                * so that things such as JSON-LD caching of
-                                * robundle works.
-                                */
-                               
-                               
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-                               
-                               
                                /*
                                 * Initialise Credential Manager and SSL stuff 
quite early as
                                 * parsing and validating the workflow may 
require it
@@ -309,9 +307,7 @@ public class CommandLineTool {
                                        System.out.println("Workflow 
completed.");
                                }
 
-                       }
-               } else {
-                       commandLineOptions.displayHelp();
+                       
                }
 
                // wait until user hits CTRL-C before exiting
@@ -329,6 +325,21 @@ public class CommandLineTool {
                return 0;
        }
 
+       private void setupJarCache() {
+               // TAVERNA-xx workaround - we'll have our own jarcache.json and
+               // our own bundle.jsonld
+               
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+               
+               // Verify:
+               try {
+                       JsonUtils.fromURL(new URL(BUNDLE_CONTEXT));
+               } catch (Exception e) {
+                       System.err.println("Can't load " + BUNDLE_CONTEXT + "");
+                       e.printStackTrace();
+                       
+               }
+       }
+
        private boolean workflowFinished(WorkflowReport report) {
                State state = report.getState();
                if (state == State.CANCELLED || state == State.COMPLETED || 
state == State.FAILED) {

http://git-wip-us.apache.org/repos/asf/incubator-taverna-commandline/blob/1f97dd0a/taverna-commandline-common/src/main/resources/contexts/bundle.jsonld
----------------------------------------------------------------------
diff --git 
a/taverna-commandline-common/src/main/resources/contexts/bundle.jsonld 
b/taverna-commandline-common/src/main/resources/contexts/bundle.jsonld
new file mode 100644
index 0000000..cadb9ff
--- /dev/null
+++ b/taverna-commandline-common/src/main/resources/contexts/bundle.jsonld
@@ -0,0 +1,140 @@
+{
+  "http://purl.org/dc/terms/license"; : 
+  "Licensed to the Apache Software Foundation (ASF) under one or more\n 
contributor license agreements.  See the NOTICE file distributed with\n this 
work for additional information regarding copyright ownership.\n The ASF 
licenses this file to You under the Apache License, Version 2.0\n (the 
\"License\"); you may not use this file except in compliance with\n the 
License.  You may obtain a copy of the License at\n \n 
http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable 
law or agreed to in writing, software\n distributed under the License is 
distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express or implied.\n See the License for the specific language 
governing permissions and\n limitations under the License.\n",
+  "@context": {
+    "ao": "http://purl.org/ao/";,
+    "oa": "http://www.w3.org/ns/oa#";,
+    "dc": "http://purl.org/dc/elements/1.1/";,
+    "dct": "http://purl.org/dc/terms/";,
+    "ore": "http://www.openarchives.org/ore/terms/";,
+    "ro": "http://purl.org/wf4ever/ro#";,
+    "roterms": "http://purl.org/wf4ever/roterms#";,
+    "bundle": "http://purl.org/wf4ever/bundle#";,
+    "prov": "http://www.w3.org/ns/prov#";,
+    "pav": "http://purl.org/pav/";,
+    "xsd": "http://www.w3.org/2001/XMLSchema#";,
+    "foaf": "http://xmlns.com/foaf/0.1/";,
+    "owl": "http://www.w3.org/2002/07/owl#";,
+
+    "uri": "@id",
+    "id": {
+      "@id": "owl:sameAs",
+      "@type": "@id" },
+    "file": {
+      "@id": "owl:sameAs",
+      "@type": "@id" },
+    "annotation": {
+      "@id": "owl:sameAs",
+      "@type": "@id" },
+
+    "manifest": {
+        "@id": "ore:isDescribedBy",
+        "@type": "@id"
+    },
+
+    "createdOn": {
+        "@id": "pav:createdOn",
+        "@type": "xsd:dateTime"
+    },
+    "createdBy": {
+        "@id": "pav:createdBy",
+        "@type": "@id"
+    },
+    "aggregatedOn": {
+        "@id": "pav:createdOn",
+        "@type": "xsd:dateTime"
+    },
+    "aggregatedBy": {
+        "@id": "pav:createdBy",
+        "@type": "@id"
+    },
+    "authoredOn": {
+        "@id": "pav:authoredOn",
+        "@type": "xsd:dateTime"
+    },
+    "authoredBy": {
+        "@id": "pav:authoredBy",
+        "@type": "@id"
+    },
+    "curatedOn": {
+        "@id": "pav:curatedOn",
+        "@type": "xsd:dateTime"
+    },
+    "curatedBy": {
+        "@id": "pav:curatedBy",
+        "@type": "@id"
+    },
+    "contributedOn": {
+        "@id": "pav:contributedOn",
+        "@type": "xsd:dateTime"
+    },
+    "contributedBy": {
+        "@id": "pav:contributedBy",
+        "@type": "@id"
+    },
+    "retrievedOn": {
+        "@id": "pav:retrievedOn",
+        "@type": "xsd:dateTime"
+    },
+    "retrievedBy": {
+        "@id": "pav:retrievedBy",
+        "@type": "@id"
+    },
+    "retrievedFrom": {
+        "@id": "pav:retrievedFrom",
+        "@type": "@id"
+    },
+    "name": {
+        "@id": "foaf:name"
+    },
+    "orcid": {
+        "@id": "roterms:orcid",
+        "@type": "@id"
+    },
+
+    "history": {
+        "@id": "prov:has_provenance",
+        "@type": "@id"
+    },
+    "aggregates": {
+      "@id": "ore:aggregates",
+      "@type": "@id"
+    },
+    "mediatype": {
+        "@id": "dc:format"
+    },
+    "folder": {
+      "@id": "bundle:inFolder",
+      "@type": "@id"
+    },
+    "filename": {
+        "@id": "ro:entryName"
+    },
+    "proxy": {
+      "@id": "bundle:hasProxy",
+      "@type": "@id"
+    },
+    "bundledAs": {
+        "@id": "bundle:bundledAs",
+        "@type": "@id"
+    },
+    "conformsTo": {
+        "@id": "dct:conformsTo",
+        "@type": "@id"
+    },
+    "annotations": {
+      "@id": "bundle:hasAnnotation",
+      "@type": "@id"
+    },
+    "content": {
+       "@id": "oa:hasBody",
+       "@type": "@id"
+    },
+    "about": {
+       "@id": "oa:hasTarget",
+       "@type": "@id"
+    }
+
+  },
+  "http://purl.org/pav/retrievedFrom": { "@id": 
"https://raw.githubusercontent.com/wf4ever/ro/61b563e7e9941485ff6e7b338875d4015d734b6f/bundle/draft/context.json";
 } 
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-commandline/blob/1f97dd0a/taverna-commandline-common/src/main/resources/jarcache.json
----------------------------------------------------------------------
diff --git a/taverna-commandline-common/src/main/resources/jarcache.json 
b/taverna-commandline-common/src/main/resources/jarcache.json
new file mode 100644
index 0000000..64aa4d3
--- /dev/null
+++ b/taverna-commandline-common/src/main/resources/jarcache.json
@@ -0,0 +1,11 @@
+[
+  {
+        "X-License" :
+         "Licensed to the Apache Software Foundation (ASF) under one or more\n 
contributor license agreements.  See the NOTICE file distributed with\n this 
work for additional information regarding copyright ownership.\n The ASF 
licenses this file to You under the Apache License, Version 2.0\n (the 
\"License\"); you may not use this file except in compliance with\n the 
License.  You may obtain a copy of the License at\n \n 
http://www.apache.org/licenses/LICENSE-2.0\n \n Unless required by applicable 
law or agreed to in writing, software\n distributed under the License is 
distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express or implied.\n See the License for the specific language 
governing permissions and\n limitations under the License.\n",
+
+       "Content-Location": "https://w3id.org/bundle/context";,
+       "X-Classpath": "contexts/bundle.jsonld",
+       "Content-Type": "application/ld+json"
+  }
+]
+

Reply via email to