You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2016/06/30 14:15:15 UTC
[06/40] incubator-taverna-common-activities git commit:
ToolDescriptionParser
ToolDescriptionParser
Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/commit/f9363a98
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/tree/f9363a98
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/diff/f9363a98
Branch: refs/heads/cwl-browse
Commit: f9363a98aebd26ca88e9bf9ffd46a9999c3ba054
Parents: 59a0dc1
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Wed May 4 01:08:42 2016 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed May 4 01:08:42 2016 +0100
----------------------------------------------------------------------
.../desc/ToolDescriptionParser.java | 111 +++++++++++++++++++
.../externaltool/desc/UseCaseEnumeration.java | 111 -------------------
2 files changed, 111 insertions(+), 111 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/f9363a98/taverna-external-tool-activity/src/main/java/org/apache/taverna/activities/externaltool/desc/ToolDescriptionParser.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/org/apache/taverna/activities/externaltool/desc/ToolDescriptionParser.java b/taverna-external-tool-activity/src/main/java/org/apache/taverna/activities/externaltool/desc/ToolDescriptionParser.java
new file mode 100644
index 0000000..cc48973
--- /dev/null
+++ b/taverna-external-tool-activity/src/main/java/org/apache/taverna/activities/externaltool/desc/ToolDescriptionParser.java
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+
+package org.apache.taverna.activities.externaltool.desc;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.taverna.workflowmodel.serialization.DeserializationException;
+
+import org.apache.log4j.Logger;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+
+public class ToolDescriptionParser {
+
+ private static Logger logger = Logger.getLogger(ToolDescriptionParser.class);
+
+ public static List<ToolDescription> readDescriptionsFromUrl(String xmlFileUrl) throws IOException {
+
+ List<ToolDescription> ret = new ArrayList<ToolDescription>();
+ URLConnection con = null;
+ try {
+ URL url = new URL(xmlFileUrl);
+
+ con = url.openConnection();
+ con.setConnectTimeout(4000);
+ ret = readDescriptionsFromStream(con.getInputStream());
+
+ } catch (IOException ioe) {
+ logger.error("Problem retrieving from " + xmlFileUrl);
+ logger.error(ioe);
+ throw ioe;
+ }
+ finally {
+
+ }
+
+ return ret;
+
+ }
+
+ public static List<ToolDescription> readDescriptionsFromStream(InputStream is) {
+
+ List<ToolDescription> ret = new ArrayList<ToolDescription>();
+
+ SAXBuilder builder = new SAXBuilder();
+ Document doc = null;
+ try {
+ doc = builder.build(is);
+ is.close();
+ } catch (JDOMException e1) {
+ logger.error(e1);
+ return ret;
+ } catch (IOException e1) {
+ logger.error(e1);
+ return ret;
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ logger.error(e);
+ }
+ }
+
+ Element usecases = doc.getRootElement();
+ for (Object ochild : usecases.getChildren()) {
+ Element child = (Element) ochild;
+ if (child.getName().equalsIgnoreCase("program")) {
+ try {
+ ret.add(new ToolDescription(child));
+ } catch (DeserializationException e) {
+ logger.error(e);
+ }
+ }
+ }
+ return ret;
+ }
+
+ public static ToolDescription readDescriptionFromUrl(
+ String repositoryUrl, String id) throws IOException {
+ List<ToolDescription> descriptions = readDescriptionsFromUrl(repositoryUrl);
+ for (ToolDescription usecase : descriptions) {
+ if (usecase.getUsecaseid().equals(id)) {
+ return usecase;
+ }
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/f9363a98/taverna-external-tool-activity/src/main/java/org/apache/taverna/activities/externaltool/desc/UseCaseEnumeration.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/org/apache/taverna/activities/externaltool/desc/UseCaseEnumeration.java b/taverna-external-tool-activity/src/main/java/org/apache/taverna/activities/externaltool/desc/UseCaseEnumeration.java
deleted file mode 100644
index 949ae93..0000000
--- a/taverna-external-tool-activity/src/main/java/org/apache/taverna/activities/externaltool/desc/UseCaseEnumeration.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.taverna.activities.externaltool.desc;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.taverna.workflowmodel.serialization.DeserializationException;
-
-import org.apache.log4j.Logger;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.input.SAXBuilder;
-
-public class UseCaseEnumeration {
-
- private static Logger logger = Logger.getLogger(UseCaseEnumeration.class);
-
- public static List<ToolDescription> readDescriptionsFromUrl(String xmlFileUrl) throws IOException {
-
- List<ToolDescription> ret = new ArrayList<ToolDescription>();
- URLConnection con = null;
- try {
- URL url = new URL(xmlFileUrl);
-
- con = url.openConnection();
- con.setConnectTimeout(4000);
- ret = readDescriptionsFromStream(con.getInputStream());
-
- } catch (IOException ioe) {
- logger.error("Problem retrieving from " + xmlFileUrl);
- logger.error(ioe);
- throw ioe;
- }
- finally {
-
- }
-
- return ret;
-
- }
-
- public static List<ToolDescription> readDescriptionsFromStream(InputStream is) {
-
- List<ToolDescription> ret = new ArrayList<ToolDescription>();
-
- SAXBuilder builder = new SAXBuilder();
- Document doc = null;
- try {
- doc = builder.build(is);
- is.close();
- } catch (JDOMException e1) {
- logger.error(e1);
- return ret;
- } catch (IOException e1) {
- logger.error(e1);
- return ret;
- } finally {
- try {
- is.close();
- } catch (IOException e) {
- logger.error(e);
- }
- }
-
- Element usecases = doc.getRootElement();
- for (Object ochild : usecases.getChildren()) {
- Element child = (Element) ochild;
- if (child.getName().equalsIgnoreCase("program")) {
- try {
- ret.add(new ToolDescription(child));
- } catch (DeserializationException e) {
- logger.error(e);
- }
- }
- }
- return ret;
- }
-
- public static ToolDescription readDescriptionFromUrl(
- String repositoryUrl, String id) throws IOException {
- List<ToolDescription> descriptions = readDescriptionsFromUrl(repositoryUrl);
- for (ToolDescription usecase : descriptions) {
- if (usecase.getUsecaseid().equals(id)) {
- return usecase;
- }
- }
- return null;
- }
-}