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/05/04 02:01:11 UTC
[5/7] incubator-taverna-common-activities git commit: TAVERNA-963
package taverna.externaltool.*
TAVERNA-963 package taverna.externaltool.*
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/98468d30
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/tree/98468d30
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/diff/98468d30
Branch: refs/heads/master
Commit: 98468d304f297b53fc73e80befba8787adabdf53
Parents: 142667c
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Wed May 4 00:53:18 2016 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Wed May 4 01:00:29 2016 +0100
----------------------------------------------------------------------
.../inb/knowarc/gui/AskUserForPwPopup.java | 74 --
.../inb/knowarc/gui/PleaseWaitDialog.java | 73 --
.../knowarc/usecases/RuntimeEnvironment.java | 251 ------
.../usecases/RuntimeEnvironmentConstraint.java | 160 ----
.../inb/knowarc/usecases/ScriptInput.java | 134 ---
.../inb/knowarc/usecases/ScriptInputStatic.java | 73 --
.../inb/knowarc/usecases/ScriptInputUser.java | 99 --
.../inb/knowarc/usecases/ScriptOutput.java | 88 --
.../knowarc/usecases/UseCaseDescription.java | 897 -------------------
.../knowarc/usecases/UseCaseEnumeration.java | 111 ---
.../usecases/invocation/AskUserForPw.java | 32 -
.../invocation/InvocationException.java | 36 -
.../usecases/invocation/UseCaseInvocation.java | 322 -------
.../local/LocalUseCaseInvocation.java | 561 ------------
.../ssh/SshAutoLoginTrustEveryone.java | 70 --
.../usecases/invocation/ssh/SshNode.java | 157 ----
.../usecases/invocation/ssh/SshNodeFactory.java | 66 --
.../usecases/invocation/ssh/SshPool.java | 158 ----
.../usecases/invocation/ssh/SshReference.java | 222 -----
.../knowarc/usecases/invocation/ssh/SshUrl.java | 163 ----
.../invocation/ssh/SshUrlToSshReference.java | 54 --
.../invocation/ssh/SshUseCaseInvocation.java | 561 ------------
.../externaltool/ExternalToolActivity.java | 13 +-
.../ExternalToolActivityConfigurationBean.java | 2 +-
.../ExternalToolActivityMimeTypeChecker.java | 5 +-
.../externaltool/InvocationCreator.java | 5 +-
.../externaltool/RetrieveLoginFromTaverna.java | 2 +-
.../externaltool/desc/RuntimeEnvironment.java | 251 ++++++
.../desc/RuntimeEnvironmentConstraint.java | 160 ++++
.../externaltool/desc/ScriptInput.java | 134 +++
.../externaltool/desc/ScriptInputStatic.java | 73 ++
.../externaltool/desc/ScriptInputUser.java | 99 ++
.../externaltool/desc/ScriptOutput.java | 88 ++
.../externaltool/desc/UseCaseDescription.java | 897 +++++++++++++++++++
.../externaltool/desc/UseCaseEnumeration.java | 111 +++
.../externaltool/gui/AskUserForPwPopup.java | 74 ++
.../externaltool/gui/PleaseWaitDialog.java | 73 ++
.../externaltool/invocation/AskUserForPw.java | 32 +
.../invocation/InvocationException.java | 36 +
.../invocation/UseCaseInvocation.java | 321 +++++++
.../ExternalToolLocalInvocationMechanism.java | 2 -
.../local/LocalInvocationCreator.java | 6 +-
.../local/LocalInvocationPersister.java | 2 -
.../local/LocalMechanismCreator.java | 2 -
.../local/LocalUseCaseInvocation.java | 560 ++++++++++++
.../ssh/ExternalToolSshInvocationMechanism.java | 5 -
.../ssh/SshAutoLoginTrustEveryone.java | 69 ++
.../externaltool/ssh/SshInvocationCreator.java | 11 +-
.../ssh/SshInvocationPersister.java | 4 +-
.../externaltool/ssh/SshMechanismCreator.java | 4 -
.../activities/externaltool/ssh/SshNode.java | 157 ++++
.../externaltool/ssh/SshNodeFactory.java | 66 ++
.../activities/externaltool/ssh/SshPool.java | 157 ++++
.../externaltool/ssh/SshReference.java | 222 +++++
.../activities/externaltool/ssh/SshUrl.java | 163 ++++
.../externaltool/ssh/SshUrlToSshReference.java | 54 ++
.../externaltool/ssh/SshUseCaseInvocation.java | 560 ++++++++++++
...pache.taverna.reference.ExternalReferenceSPI | 2 +-
...verna.reference.ValueToReferenceConverterSPI | 2 +-
.../spring/external-tool-activity-context.xml | 4 +-
.../invocation/ssh/SshReference.hbm.xml | 2 +-
61 files changed, 4379 insertions(+), 4413 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/98468d30/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/gui/AskUserForPwPopup.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/gui/AskUserForPwPopup.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/gui/AskUserForPwPopup.java
deleted file mode 100644
index 0ce0460..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/gui/AskUserForPwPopup.java
+++ /dev/null
@@ -1,74 +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 de.uni_luebeck.inb.knowarc.gui;
-
-import javax.swing.JOptionPane;
-
-import de.uni_luebeck.inb.knowarc.usecases.invocation.AskUserForPw;
-import de.uni_luebeck.inb.knowarc.usecases.invocation.ssh.SshNode;
-
-public final class AskUserForPwPopup implements AskUserForPw {
- private SshNode ret;
- private String pw, pp, kf, us;
-
- public static String ask(String message, String title) {
- return (String) JOptionPane.showInputDialog(null, message, title, JOptionPane.QUESTION_MESSAGE, null, null, "");
- }
-
- public static boolean askYN(String message, String title) {
- return JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION;
- }
-
- public String getPassword() {
- getUsername();
- if (pw != null)
- return pw;
- pw = ask("Please enter your password for " + us + " @ " + ret.getHost(), us + " @ " + ret.getHost());
- return pw;
- }
-
- public String getPassphrase() {
- getUsername();
- if (pp != null)
- return pp;
- pp = ask("Please enter your passphrase for " + kf + " used for " + us + " @ " + ret.getHost(), us + " @ " + ret.getHost());
- return pp;
- }
-
- public String getKeyfile() {
- getUsername();
- if (kf != null)
- return kf;
- kf = ask("Please enter the keyfile for " + us + " @ " + ret.getHost(), us + " @ " + ret.getHost());
- return kf;
- }
-
- public String getUsername() {
- if (us != null)
- return us;
- us = ask("Please enter the username for " + ret.getHost(), "Username for " + ret.getHost());
- return us;
- }
-
- public void setSshNode(SshNode sshNode) {
- this.ret = sshNode;
- }
-
- public void authenticationSucceeded() {
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/98468d30/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/gui/PleaseWaitDialog.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/gui/PleaseWaitDialog.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/gui/PleaseWaitDialog.java
deleted file mode 100755
index 2a643eb..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/gui/PleaseWaitDialog.java
+++ /dev/null
@@ -1,73 +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 de.uni_luebeck.inb.knowarc.gui;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.swing.JDialog;
-import javax.swing.JLabel;
-
-public class PleaseWaitDialog extends JDialog {
- private static final long serialVersionUID = 1L;
-
- static PleaseWaitDialog instance = new PleaseWaitDialog();
-
- public class WaitMessage{
- public WaitMessage() {
- }
-
- String str;
- public void set(String newstr) {
- synchronized (PleaseWaitDialog.instance) {
- if(this.str != null && this.str.equals(newstr)) return;
- if(this.str != null) messages.remove(this.str);
- this.str = newstr;
- if(this.str != null) messages.add(this.str);
- }
- updateDialog();
- }
- public void done() {
- set(null);
- }
- }
-
- private void updateDialog() {
- synchronized (PleaseWaitDialog.instance) {
- if(messages.size() > 0) this.setVisible(true);
- else this.setVisible(false);
- String t = "";
- for (String cur : messages) {
- t += cur + "<br>";
- }
- l.setText("<html>"+t+"</html>");
- }
- }
-
- List<String> messages = new ArrayList<String>();
-
- JLabel l;
- private PleaseWaitDialog() {
- this.setAlwaysOnTop(true);
- this.setTitle("Please wait");
- l = new JLabel("");
- this.add(l);
- this.setSize(400, 100);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/98468d30/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/RuntimeEnvironment.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/RuntimeEnvironment.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/RuntimeEnvironment.java
deleted file mode 100644
index c7fd889..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/RuntimeEnvironment.java
+++ /dev/null
@@ -1,251 +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 de.uni_luebeck.inb.knowarc.usecases;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-/**
- * Representation of information about a single runtime environment. It is used
- * to decide if one runtime environment is possibly compatible with another one
- * for the selection of queues to commit to.
- *
- * To experiment/test these functions, run the following java -cp
- * target/taverna-knowarc-processor-0.1.7.jar
- * de.uni_luebeck.janitor.ldap.RuntimeEnvironment compare bla-1 foo-1 java -cp
- * target/taverna-knowarc-processor-0.1.7.jar
- * de.uni_luebeck.janitor.ldap.RuntimeEnvironment compare bla-1 bla-2 java -cp
- * target/taverna-knowarc-processor-0.1.7.jar
- * de.uni_luebeck.janitor.ldap.RuntimeEnvironment compare bla-1.2 bla-1
- *
- * @author Steffen Moeller
- */
-@SuppressWarnings("unchecked")
-public class RuntimeEnvironment implements Comparable {
-
- private static Logger logger = Logger.getLogger(RuntimeEnvironment.class);
-
-
- /**
- * Unique identification of the runtime environment - the full name
- */
- protected String id;
-
- /**
- * Accessor function for the complete identifier of the runtime environment
- */
- public String getID() {
- return id;
- }
-
- protected String name;
-
- /**
- * Accessor function for the RE's name
- */
- public String getName() {
- return name;
- }
-
- protected String version;
-
- /**
- * Accessfor function for the version
- */
- public String getVersion() {
- return version;
- }
-
- /**
- * for those busy fellows who don't have the time to convert the String into
- * a RuntimeEnvironment object.
- *
- * @author Steffen Moeller
- */
- public boolean atLeastAsCapableAs(String s) {
- RuntimeEnvironment tmpRE = new RuntimeEnvironment(s);
- return this.atLeastAsCapableAs(tmpRE);
- }
-
- /**
- * Indicates if a runtime environment has the same name, and if so, if the
- * given RE has the same or a later version.
- *
- * @author Steffen Moeller
- */
- public boolean atLeastAsCapableAs(RuntimeEnvironment re) {
- if (!name.equals(re.name))
- return false;
- int c = compareVersions(getVersion(), re.getVersion());
- if (c >= 0) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Indicates if this runtimeEnvironment is the same version or later as any
- * in that list.
- *
- * @author Steffen Moeller
- */
- public boolean atLeastAsCapableAsAnyOf(Iterable<RuntimeEnvironment> res) {
- boolean compatibleOneFound = false;
- Iterator<RuntimeEnvironment> i = res.iterator();
- while (i.hasNext() && !compatibleOneFound) {
- RuntimeEnvironment r = i.next();
- compatibleOneFound = atLeastAsCapableAs(r);
- }
- return compatibleOneFound;
- }
-
- /**
- * Indicates if any of the runtime environments listed is the same version
- * as this or later.
- *
- * @author Steffen Moeller
- */
- public boolean isInferiorToAtLeastOneIn(Iterable<RuntimeEnvironment> res) {
- boolean compatibleOneFound = false;
- Iterator<RuntimeEnvironment> i = res.iterator();
- while (i.hasNext() && !compatibleOneFound) {
- RuntimeEnvironment r = i.next();
- compatibleOneFound = r.atLeastAsCapableAs(this);
- }
- return compatibleOneFound;
- }
-
- /**
- * Parses a string as commonly presented by the infosystem
- *
- * @author Steffen Moeller
- */
- public RuntimeEnvironment(String raw) {
- id = raw;
- int dashpos = raw.indexOf("-");
- if (-1 == dashpos) {
- version = "";
- name = raw;
- } else {
- name = raw.substring(0, dashpos);
- if (dashpos + 1 <= raw.length()) {
- version = raw.substring(dashpos + 1, raw.length());
- } else {
- version = "";
- }
- }
- }
-
- /**
- * to make it behave like a string at time, as it was originally implemented
- */
- @Override
- public String toString() {
- return id;
- }
-
- /**
- * Implementation of Comparable interface. It comes handy albeit this
- * function says nothing about the compatibility of two runtime environments
- * unless their names are identical and the relation of the constraint was
- * taken into account. It just sorts them in lists.
- */
- public int compareTo(Object o) throws ClassCastException {
- RuntimeEnvironment r = (RuntimeEnvironment) o;
- if (getName().equals(r.getName())) {
- return RuntimeEnvironment.compareVersions(getVersion(), r.getVersion());
- } else {
- return id.compareTo(r.getID());
- }
- }
-
- /**
- * FIXME: For the sake of simplicity, this implementation makes an error in
- * treating . and - in the versions equally. Versions, if numerical, are
- * treated numerically. Otherwise it is lexicographical, which is error
- * prone, though. Should the 'Scanner' class should be tapped into?
- *
- * @author Steffen Moeller
- */
- public static int compareVersions(String a, String b) {
-
- // null pointer exceptions are not risked .. we are nice
- if (null == a)
- a = "";
- if (null == b)
- b = "";
-
- // catching the dumb case first
- if (a.equals(b))
- return 0;
-
- List as = Arrays.asList(a.split("[.-]"));
- List bs = Arrays.asList(b.split("[.-]"));
-
- // both lists have the empty element as members at least
- Iterator aIterator = as.iterator();
- Iterator bIterator = bs.iterator();
-
- while (aIterator.hasNext()) {
- String aa = (String) aIterator.next();
- if (!bIterator.hasNext()) {
- // a is longer while equal so far
- return 1; // a > b
- }
- String bb = (String) bIterator.next();
- if (!aa.equals(bb)) {
- // a and b differ
- try {
- Integer aInt = Integer.parseInt(aa);
- Integer bInt = Integer.parseInt(bb);
- return aInt.compareTo(bInt);
- } catch (Exception e) {
- return aa.compareTo(bb);
- }
- }
- }
- if (bIterator.hasNext()) {
- // b is longer while equal so far
- return -1; // a < b
- }
- return 0; // a == b
- }
-
- /**
- * For testing purposes
- */
- public static void main(String argv[]) {
- if ("compare".equals(argv[0])) {
- RuntimeEnvironment r1 = new RuntimeEnvironment(argv[1]);
- RuntimeEnvironment r2 = new RuntimeEnvironment(argv[2]);
- logger.info("r1.getName(): " + r1.getName());
- logger.info("r1.getVersion(): " + r1.getVersion());
- logger.info("r2.getName(): " + r2.getName());
- logger.info("r2.getVersion(): " + r2.getVersion());
- logger.info("r1.atLeastAsCapableAs(r2): " + String.valueOf(r1.atLeastAsCapableAs(r2)));
- } else {
- logger.info("Don't know how to '" + argv[0] + "'");
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/98468d30/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/RuntimeEnvironmentConstraint.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/RuntimeEnvironmentConstraint.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/RuntimeEnvironmentConstraint.java
deleted file mode 100644
index ce7e055..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/RuntimeEnvironmentConstraint.java
+++ /dev/null
@@ -1,160 +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 de.uni_luebeck.inb.knowarc.usecases;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.apache.log4j.Logger;
-
-
-/**
- * When use cases present a runtime environment, then they don't want to express
- * that these would provide such, but that these request such, i.e. they constrain
- * lists of potentially eligible queues.
- * @author Steffen Moeller
- * @since 2008
- */
-public class RuntimeEnvironmentConstraint extends RuntimeEnvironment {
-
- private static Logger logger = Logger.getLogger(RuntimeEnvironmentConstraint.class);
-
- private static String[] ACCEPTED_RELATIONS = new String[] {"=", ">=", "<=", ">", "<"};
- /**
- * If there is no relation specified, presume >=
- */
- private static String DEFAULT_RELATION = ">=";
-
- public static String[] getAcceptedRelations() {
- return ACCEPTED_RELATIONS;
- }
-
- public static String getDefaultRelation() {
- return DEFAULT_RELATION;
- }
-
- /**
- * Identifies the relation between runtime environments to be tested
- */
- protected String relation;
-
- /**
- * Accessor function for relation
- */
- public String getRelation() {
- return this.relation;
- }
-
- /**
- * Tests of a relation is supported
- * @param relation
- * @return true iff in <, > , <=, >=, =
- */
- public static boolean acceptedRelation(String relation) {
- if ((null == relation) || relation.equals("")) {
- return false;
- }
- return relation.equals("=")||relation.equals(">=")||relation.equals("<=")||relation.equals(">")||relation.equals("<");
- }
-
- /**
- * Constructor
- * @param id - expects the name of the runtime environment together with the version to which the
- * @param relation - relates to (">","<","=",">=","<=")
- */
- public RuntimeEnvironmentConstraint(String id, String relation) {
- super(id);
- if (null == relation || relation.equals("")) {
- relation=RuntimeEnvironmentConstraint.getDefaultRelation();
- }
- if (relation.equals("==")) {
- relation="=";
- }
- else if (relation.equals("=<")) {
- relation="<=";
- }
- else if (!RuntimeEnvironmentConstraint.acceptedRelation(relation)) {
- logger.warn("Unknown relation '"+relation+"', presuming '"+RuntimeEnvironmentConstraint.getDefaultRelation()+"'");
- relation=RuntimeEnvironmentConstraint.getDefaultRelation();
- }
- this.relation=relation;
- }
-
- /**
- * Perfoms test if the RuntimeEnvironment (RE) passed as argument fulfills the requirements set by the constraint.
- * @param re - RE to test
- * @return true iff the RE fulfills this REconstraint.
- */
- public boolean isFulfilledBy(RuntimeEnvironment re) {
- logger.info(re.getID()+" " + this.getRelation() + " "+this.getID() + " ?");
- if (this.getRelation().equals("=")) {
- logger.info("=");
- return re.getID().equals(this.getID());
- }
- if (!re.getName().equals(this.getName())) {
- logger.warn("Name match failed");
- return false;
- }
- int c = RuntimeEnvironment.compareVersions(re.getVersion(),this.getVersion());
- logger.info("c="+c);
- if (this.getRelation().equals(">")) return c>0;
- if (this.getRelation().equals(">=")) return c>=0;
- if (this.getRelation().equals("<=")) return c<=0;
- if (this.getRelation().equals("<")) return c<0;
- throw new RuntimeException("Unknown/untreated releation '"+this.getRelation()+"'");
- }
-
- /**
- * Iterates over all the RuntimeEnvironments passed as argument.
- * @param REs - list of RuntimeEnvironments, mostly those offered at a particular queue
- * @return true iff any RE among the REs passed as argument are fulfilling the constraint
- */
- public boolean isFulfilledByAtLeastOneIn(Collection<RuntimeEnvironment> REs) {
- boolean fulfilled = false;
- Iterator<RuntimeEnvironment> i = REs.iterator();
- while(i.hasNext() && !fulfilled) {
- RuntimeEnvironment r = i.next();
- fulfilled = this.isFulfilledBy(r);
- }
- return fulfilled;
- }
- /**
- * For testing purposes
- */
- public static void main(String argv[]) {
- try {
- if (argv[0].equals("--help") || argv.length != 3) {
- logger.error("Expecting arguments (<|>|=|<=|>=) runtime1-version runtime2-version");
- }
- else {
- RuntimeEnvironmentConstraint r1 = new RuntimeEnvironmentConstraint(argv[1], argv[0]);
- RuntimeEnvironment r2 = new RuntimeEnvironment(argv[2]);
- logger.info("r1.getName(): "+r1.getName());
- logger.info("r1.getVersion(): "+r1.getVersion());
- logger.info("r1.getRelation(): "+r1.getRelation());
- logger.info("r2.getName(): "+r2.getName());
- logger.info("r2.getVersion(): "+r2.getVersion());
- logger.info("r1.isFulfilledBy(r2): "+String.valueOf(r1.isFulfilledBy(r2)));
- }
- }
- catch (Exception e) {
- logger.error(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/98468d30/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInput.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInput.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInput.java
deleted file mode 100644
index 50747b5..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInput.java
+++ /dev/null
@@ -1,134 +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 de.uni_luebeck.inb.knowarc.usecases;
-
-import java.nio.charset.Charset;
-
-import org.apache.taverna.activities.externaltool.ExternalToolActivity;
-import org.apache.taverna.workflowmodel.processor.config.ConfigurationBean;
-import org.apache.taverna.workflowmodel.processor.config.ConfigurationProperty;
-
-/**
- * Integrates inputs to the grid that come from the use case descriptions
- * with those that are fed through the workflow.
- *
- * this class controls name and data storage of one input,
- * no matter where the data comes from
- */
-@ConfigurationBean(uri = ExternalToolActivity.URI + "#AbstractScriptInput")
-public abstract class ScriptInput {
- /**
- * This input can be referenced under the name 'tag'.
- */
- private String tag = null;
- /**
- * In most cases, the data will be stored under a specific
- * filename.
- */
- private boolean file = false;
- /**
- * Set, if the name of the file to be executed is not
- * explicitly set but prepared by some automatism and referenced
- * via the tagging principle.
- */
- private boolean tempFile = false;
- /**
- * True if (!) the data is binary. (Text otherwise)
- */
- private boolean binary = false;
-
- private String charsetName = Charset.defaultCharset().name();
- private boolean forceCopy = false;
-
- /**
- * @return the tag
- */
- public final String getTag() {
- return tag;
- }
- /**
- * @param tag the tag to set
- */
- @ConfigurationProperty(name = "tag", label = "Tag")
- public final void setTag(String tag) {
- this.tag = tag;
- }
- /**
- * @return the file
- */
- public final boolean isFile() {
- return file;
- }
- /**
- * @param file the file to set
- */
- @ConfigurationProperty(name = "file", label = "File")
- public final void setFile(boolean file) {
- this.file = file;
- }
- /**
- * @return the tempFile
- */
- public final boolean isTempFile() {
- return tempFile;
- }
- /**
- * @param tempFile the tempFile to set
- */
- @ConfigurationProperty(name = "tempFile", label = "Temporary File")
- public final void setTempFile(boolean tempFile) {
- this.tempFile = tempFile;
- }
- /**
- * @return the binary
- */
- public final boolean isBinary() {
- return binary;
- }
- /**
- * @param binary the binary to set
- */
- @ConfigurationProperty(name = "binary", label = "Binary")
- public final void setBinary(boolean binary) {
- this.binary = binary;
- }
-
- public String getCharsetName() {
- return this.charsetName;
- }
- /**
- * @param charsetName the charsetName to set
- */
- @ConfigurationProperty(name = "charsetName", label = "Chararter Set")
- public void setCharsetName(String charsetName) {
- this.charsetName = charsetName;
- }
-
- @ConfigurationProperty(name = "forceCopy", label = "Force Copy")
- public final void setForceCopy(boolean forceCopy) {
- this.forceCopy = forceCopy;
-
- }
- /**
- * @return the forceCopy
- */
- public boolean isForceCopy() {
- return forceCopy;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/98468d30/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputStatic.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputStatic.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputStatic.java
deleted file mode 100644
index 749e104..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputStatic.java
+++ /dev/null
@@ -1,73 +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 de.uni_luebeck.inb.knowarc.usecases;
-
-import org.apache.taverna.activities.externaltool.ExternalToolActivity;
-import org.apache.taverna.workflowmodel.processor.config.ConfigurationBean;
-import org.apache.taverna.workflowmodel.processor.config.ConfigurationProperty;
-
-/**
- * This subclass of script input is used to manage static content
- * which is embedded into the use case description.
- */
-@ConfigurationBean(uri = ExternalToolActivity.URI + "#ScriptInputStatic")
-public class ScriptInputStatic extends ScriptInput {
-
- public ScriptInputStatic() {
- }
-
- private String url = null; //if this is set, load content from remote URL
- private String content = null;
-
- @Override
- public String toString() {
- return "InputStatic[tag: " +
- getTag() + (isFile() ? ", file" : "") + (isTempFile() ? ", tempfile" : "") + (isBinary() ? ", binary" : "") + ", content: " + content + "]";
- }
-
- /**
- * @return the url
- */
- public final String getUrl() {
- return url;
- }
-
- /**
- * @param url the url to set
- */
- @ConfigurationProperty(name = "url", label = "URL", required=false)
- public final void setUrl(String url) {
- this.url = url;
- }
-
- /**
- * @return the content
- */
- public final String getContent() {
- return content;
- }
-
- /**
- * @param content the content to set
- */
- @ConfigurationProperty(name = "content", label = "Content", required=false)
- public final void setContent(String content) {
- this.content = content;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/98468d30/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputUser.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputUser.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputUser.java
deleted file mode 100644
index 715c13e..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputUser.java
+++ /dev/null
@@ -1,99 +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 de.uni_luebeck.inb.knowarc.usecases;
-import java.util.ArrayList;
-
-import org.apache.taverna.activities.externaltool.ExternalToolActivity;
-import org.apache.taverna.workflowmodel.processor.config.ConfigurationBean;
-import org.apache.taverna.workflowmodel.processor.config.ConfigurationProperty;
-
-/**
- * Internal description of output
- */
-@ConfigurationBean(uri = ExternalToolActivity.URI + "#ScriptInput")
-public class ScriptInputUser extends ScriptInput {
-
- /**
- * This input may be fed from multiple ouputs.
- */
- private boolean list = false;
- /**
- * True if the data from a list input in taverna is concatenated into one single input file.
- */
- private boolean concatenate = false;
-
- private ArrayList<String> mime = new ArrayList<String>();
-
- @Override
- public String toString() {
- return "Input[tag: " + getTag() + (isFile() ? ", file" : "")
- + (isTempFile() ? ", tempfile" : "")
- + (isBinary() ? ", binary" : "") + (list ? ", list" : "")
- + (concatenate ? ", concatenate" : "")
- + " mime: " + mime.toString() + "]";
- }
-
- /**
- * @return the list
- */
- public final boolean isList() {
- return list;
- }
-
- /**
- * @param list the list to set
- */
- @ConfigurationProperty(name = "list", label = "List")
- public final void setList(boolean list) {
- this.list = list;
- }
-
- /**
- * @return the concatenate
- */
- public final boolean isConcatenate() {
- return concatenate;
- }
-
- /**
- * @param concatenate the concatenate to set
- */
- @ConfigurationProperty(name = "concatenate", label = "Concatenate")
- public final void setConcatenate(boolean concatenate) {
- this.concatenate = concatenate;
- }
-
- /**
- * @return the mime
- */
- public final ArrayList<String> getMime() {
- if (mime == null) {
- mime = new ArrayList<String>();
- }
- return mime;
- }
-
- /**
- * @param mime the mime to set
- */
- @ConfigurationProperty(name = "mime", label = "Mime Types", required=false)
- public final void setMime(ArrayList<String> mime) {
- this.mime = mime;
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/98468d30/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptOutput.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptOutput.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptOutput.java
deleted file mode 100644
index d824ad4..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptOutput.java
+++ /dev/null
@@ -1,88 +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 de.uni_luebeck.inb.knowarc.usecases;
-import java.util.ArrayList;
-
-import org.apache.taverna.activities.externaltool.ExternalToolActivity;
-import org.apache.taverna.workflowmodel.processor.config.ConfigurationBean;
-import org.apache.taverna.workflowmodel.processor.config.ConfigurationProperty;
-
-/**
- * Internal description of input
- */
-@ConfigurationBean(uri = ExternalToolActivity.URI + "#ScriptOutput")
-public class ScriptOutput {
- private String path;
- private boolean binary;
- private ArrayList<String> mime = new ArrayList<String>();
-
- @Override
- public String toString() {
- return "Output[path: " + path + (binary ? ", binary" : "")
- + " mime: " + mime.toString() + "]";
- }
-
- /**
- * @return the path
- */
- public final String getPath() {
- return path;
- }
-
- /**
- * @param path the path to set
- */
- @ConfigurationProperty(name = "path", label = "Path")
- public final void setPath(String path) {
- this.path = path;
- }
-
- /**
- * @return the binary
- */
- public final boolean isBinary() {
- return binary;
- }
-
- /**
- * @param binary the binary to set
- */
- @ConfigurationProperty(name = "binary", label = "Binary")
- public final void setBinary(boolean binary) {
- this.binary = binary;
- }
-
- /**
- * @return the mime
- */
- public final ArrayList<String> getMime() {
- if (mime == null) {
- mime = new ArrayList<String>();
- }
- return mime;
- }
-
- /**
- * @param mime the mime to set
- */
- @ConfigurationProperty(name = "mime", label = "Mime Types", required=false)
- public final void setMime(ArrayList<String> mime) {
- this.mime = mime;
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/98468d30/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseDescription.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseDescription.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseDescription.java
deleted file mode 100644
index 1c5914e..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseDescription.java
+++ /dev/null
@@ -1,897 +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 de.uni_luebeck.inb.knowarc.usecases;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import javax.swing.ImageIcon;
-
-import org.apache.taverna.activities.externaltool.ExternalToolActivity;
-import org.apache.taverna.workflowmodel.processor.config.ConfigurationBean;
-import org.apache.taverna.workflowmodel.processor.config.ConfigurationProperty;
-import org.apache.taverna.workflowmodel.processor.config.ConfigurationProperty.OrderPolicy;
-import org.apache.taverna.workflowmodel.serialization.DeserializationException;
-import org.apache.taverna.workflowmodel.utils.Tools;
-
-import org.apache.log4j.Logger;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.input.SAXBuilder;
-
-import org.apache.commons.lang.StringUtils;
-
-/**
- * Class representation of XML-description of UseCases
- */
-@ConfigurationBean(uri = ExternalToolActivity.URI + "#ToolDescription")
-public class UseCaseDescription {
-
- private static Logger logger = Logger.getLogger(UseCaseDescription.class);
-
- /**
- * Identifier for the retrieval of this UseCase in the sharedRepository
- * database, respectively its XML export.
- */
- private String usecaseid = "";
- /**
- * Workflow Elements now can get a group identifier. There may be subgroups
- * divided by :
- */
- private String group = "";
- /**
- * Textual description of the use case itself. This description is very
- * short to fit on the single line that is prepared for such descriptions in
- * the Taverna workflow element list.
- */
- private String description = "";
- /**
- * What is actually executed on the shell.
- */
- private String command = "";
-
- /**
- * Accessor function of command
- *
- * @return shell-executable series of commands
- */
- public String getCommand() {
- if (null == command) {
- // FIXME: Is this possible?
- return "";
- } else {
- return command;
- }
- }
-
- /**
- * Routine that may be executed as a first check if the program is indeed
- * installed.
- */
- private String test_local = null;
-
- /**
- * URL of an icon that would help users to recognise the use case
- */
- private String icon_url = null;
-
- private int preparingTimeoutInSeconds = 20 * 60; // 20 minutes
- private int executionTimeoutInSeconds = 30 * 60; // 30 minutes
-
- private List<String> tags = new ArrayList<String>();
- private List<RuntimeEnvironmentConstraint> REs = new ArrayList<RuntimeEnvironmentConstraint>();
- private ArrayList<String> queue_preferred = new ArrayList<String>();
- private ArrayList<String> queue_deny = new ArrayList<String>();
-
- private List<ScriptInputStatic> static_inputs = new ArrayList<ScriptInputStatic>();
- private Map<String, ScriptInput> inputs = new HashMap<String, ScriptInput>();
- private Map<String, ScriptOutput> outputs = new HashMap<String, ScriptOutput>();
-
- private boolean includeStdIn = false;
- private boolean includeStdOut = true;
- private boolean includeStdErr = true;
-
- private List<Integer> validReturnCodes = new ArrayList<Integer>();
-
- /**
- * Default constructor to make xstream happy
- */
- public UseCaseDescription() {
-
- }
-
- /**
- * Constructor, for special purpose usecases.
- *
- * @param usecaseid
- */
- public UseCaseDescription(String usecaseid) {
- this.setUsecaseid(usecaseid);
- }
-
- /**
- * Constructor, expects an input stream containing the xml. for example, use
- * getClass().getClassLoader().getResourceAsStream("..") to load a usecase
- * from your program jar
- */
- public UseCaseDescription(InputStream programAsStream) throws DeserializationException {
- SAXBuilder builder = new SAXBuilder();
- Document doc;
- try {
- doc = builder.build(programAsStream);
- programAsStream.close();
- } catch (JDOMException e) {
- throw new DeserializationException("Error deserializing usecase", e);
- } catch (IOException e) {
- throw new DeserializationException("Error deserializing usecase", e);
- }
- readFromXmlElement(doc.getRootElement());
- }
-
- /**
- * Constructor, expects an XML-root to dissect.
- */
- public UseCaseDescription(Element programNode) throws DeserializationException {
- readFromXmlElement(programNode);
- }
-
-/**
- * Produce an XML description of the UseCaseDescription
- */
- public Element writeToXMLElement() {
- Element programNode = new Element("program");
- programNode.setAttribute("name", getUsecaseid());
- programNode.setAttribute("description", getDescription());
- // Always use element version of command
-// programNode.setAttribute("command", getCommand());
- Element commandNode = new Element("command");
- commandNode.addContent(getCommand());
- programNode.addContent(commandNode);
- programNode.setAttribute("timeout", Integer.toString(getExecutionTimeoutInSeconds()));
- programNode.setAttribute("preparing_timeout", Integer.toString(getPreparingTimeoutInSeconds()));
- programNode.setAttribute("includeStdIn", Boolean.toString(isIncludeStdIn()));
- programNode.setAttribute("includeStdOut", Boolean.toString(isIncludeStdOut()));
- programNode.setAttribute("includeStdErr", Boolean.toString(isIncludeStdErr()));
- for (ScriptInputStatic si : getStatic_inputs()) {
- Element staticNode = new Element("static");
- if (si.isBinary()) {
- staticNode.setAttribute("binary", "true");
- }
- if (si.isForceCopy()) {
- staticNode.setAttribute("forceCopy", "true");
- }
- if (si.isFile()) {
- Element fileNode = new Element("file");
- fileNode.setAttribute("path", si.getTag());
- staticNode.addContent(fileNode);
- } else if (si.isTempFile()) {
- Element tempfileNode = new Element("tempfile");
- tempfileNode.setAttribute("tag", si.getTag());
- staticNode.addContent(tempfileNode);
- } else {
- Element replaceNode = new Element("replace");
- replaceNode.setAttribute("tag", si.getTag());
- staticNode.addContent(replaceNode);
- }
- if (si.getUrl() != null) {
- Element contentNode = new Element("content");
- contentNode.setAttribute("url", si.getUrl());
- staticNode.addContent(contentNode);
- } else {
- Element contentNode = new Element("content");
- contentNode.addContent((String) si.getContent());
- staticNode.addContent(contentNode);
- }
- programNode.addContent(staticNode);
- }
- for (Entry<String, ScriptInput> entry : getInputs().entrySet()) {
- String name = entry.getKey();
- ScriptInputUser si = (ScriptInputUser) entry.getValue();
- Element inputNode = new Element("input");
- inputNode.setAttribute("name", name);
- if (si.isBinary()) {
- inputNode.setAttribute("binary", "true");
- }
- if (si.isForceCopy()) {
- inputNode.setAttribute("forceCopy", "true");
- }
- if (si.isConcatenate()) {
- inputNode.setAttribute("concatenate", "true");
- }
- if (si.isList()) {
- inputNode.setAttribute("list", "true");
- }
- if (si.isFile()) {
- Element fileNode = new Element("file");
- fileNode.setAttribute("path", si.getTag());
- inputNode.addContent(fileNode);
- } else if (si.isTempFile()) {
- Element tempfileNode = new Element("tempfile");
- tempfileNode.setAttribute("tag", si.getTag());
- inputNode.addContent(tempfileNode);
- } else {
- Element replaceNode = new Element("replace");
- replaceNode.setAttribute("tag", si.getTag());
- inputNode.addContent(replaceNode);
- }
- for (String mime : si.getMime()) {
- Element mimeNode = new Element("mime");
- mimeNode.setAttribute("type", mime);
- inputNode.addContent(mimeNode);
- }
- programNode.addContent(inputNode);
- }
- for (Entry<String, ScriptOutput> entry : getOutputs().entrySet()) {
- String name = entry.getKey();
- ScriptOutput so = entry.getValue();
- Element outputNode = new Element("output");
- outputNode.setAttribute("name", name);
- if (so.isBinary()) {
- outputNode.setAttribute("binary", "true");
- }
- Element fromfileNode = new Element("fromfile");
- fromfileNode.setAttribute("path", so.getPath());
- outputNode.addContent(fromfileNode);
- for (String mime : so.getMime()) {
- Element mimeNode = new Element("mime");
- mimeNode.setAttribute("type", mime);
- outputNode.addContent(mimeNode);
- }
- programNode.addContent(outputNode);
- }
- for (RuntimeEnvironmentConstraint rec : getREs()) {
- Element rteNode = new Element("rte");
- rteNode.setAttribute("name", rec.getID());
- rteNode.setAttribute("relation", rec.getRelation());
- programNode.addContent(rteNode);
- }
- if ((group != null) && !group.isEmpty()) {
- Element groupNode = new Element("group");
- groupNode.setAttribute("name", group);
- programNode.addContent(groupNode);
- }
- if ((test_local != null) && !test_local.isEmpty()) {
- Element testNode = new Element("test");
- testNode.setAttribute("local", test_local);
- programNode.addContent(testNode);
- }
- if ((icon_url != null) && !icon_url.isEmpty()) {
- Element iconNode = new Element("icon");
- iconNode.setAttribute("url", icon_url);
- programNode.addContent(iconNode);
- }
- if (!getQueue_preferred().isEmpty() || !getQueue_deny().isEmpty()) {
- Element queueNode = new Element("queue");
- for (String url : getQueue_preferred()) {
- Element preferredNode = new Element("prefer");
- preferredNode.setAttribute("url", url);
- queueNode.addContent(preferredNode);
- }
- for (String url : getQueue_deny()) {
- Element denyNode = new Element("deny");
- denyNode.setAttribute("url", url);
- queueNode.addContent(denyNode);
- }
- programNode.addContent(queueNode);
- }
- Element validReturnCodesNode = new Element("validReturnCodes");
- validReturnCodesNode.setAttribute("codes", getReturnCodesAsText());
- programNode.addContent(validReturnCodesNode);
-
- return programNode;
- }
- /**
- * Specifies the UseCaseDescription from the root of an XML description
- * which is accessible online.
- *
- * @param programNode
- * @throws DeserializationException
- */
- private void readFromXmlElement(Element programNode) throws DeserializationException {
- if (programNode.getName().compareToIgnoreCase("program") != 0)
- throw new DeserializationException("Expected <program>, read '" + programNode.getName() + "'");
-
- setUsecaseid(programNode.getAttributeValue("name"));
- setDescription(programNode.getAttributeValue("description"));
- setCommand(programNode.getAttributeValue("command"));
- String timeoutStr = programNode.getAttributeValue("timeout");
- if (timeoutStr != null)
- setExecutionTimeoutInSeconds(Integer.parseInt(timeoutStr));
- timeoutStr = programNode.getAttributeValue("preparing_timeout");
- if (timeoutStr != null)
- setPreparingTimeoutInSeconds(Integer.parseInt(timeoutStr));
-
- String includeStdInStr = programNode.getAttributeValue("includeStdIn");
- if (includeStdInStr != null && !includeStdInStr.isEmpty()) {
- setIncludeStdIn(includeStdInStr.equals("true"));
- }
-
- String includeStdOutStr = programNode.getAttributeValue("includeStdOut");
- if (includeStdOutStr != null && !includeStdOutStr.isEmpty()) {
- setIncludeStdOut(includeStdOutStr.equals("true"));
- }
-
- String includeStdErrStr = programNode.getAttributeValue("includeStdErr");
- if (includeStdErrStr != null && !includeStdErrStr.isEmpty()) {
- setIncludeStdErr(includeStdErrStr.equals("true"));
- }
-
- for (Object cur_ob : programNode.getChildren()) {
- Element cur = (Element) cur_ob;
-
- String name = cur.getAttributeValue("name");
-
- String type = cur.getName();
- boolean binary = false;
- if (null != cur.getAttributeValue("binary") && cur.getAttributeValue("binary").equalsIgnoreCase("true")) {
- binary = true;
- }
- boolean list = false;
- if (null != cur.getAttributeValue("list") && cur.getAttributeValue("list").equalsIgnoreCase("true")) {
- list = true;
- }
- boolean concatenate = false;
- if (null != cur.getAttributeValue("concatenate") && cur.getAttributeValue("concatenate").equalsIgnoreCase("true")) {
- concatenate = true;
- }
- boolean forceCopy = false;
- if (null != cur.getAttributeValue("forceCopy") && cur.getAttributeValue("forceCopy").equalsIgnoreCase("true")) {
- forceCopy = true;
- }
-
- Element inner = null;
- String innerType = null, tag = null, path = null;
- if (cur.getChildren().size() > 0) {
- inner = (Element) cur.getChildren().get(0);
- innerType = inner.getName();
- tag = inner.getAttributeValue("tag");
- path = inner.getAttributeValue("path");
- }
- // build mime type declaration list
- ArrayList<String> mime = new ArrayList<String>();
- for (Object child : cur.getChildren()) {
- Element curChild = (Element) child;
- if (curChild.getName().equalsIgnoreCase("mime")) {
- mime.add(curChild.getAttributeValue("type"));
- }
- }
- if (type.equalsIgnoreCase("static")) {
- ScriptInputStatic si = new ScriptInputStatic();
- Element content = cur.getChild("content");
- if (content == null)
- throw new DeserializationException("FIXME: script tag without embedded content tag");
- si.setUrl(content.getAttributeValue("url"));
- if (si.getUrl() == null)
- si.setContent(content.getText());
- fillInputDescription(si, binary, forceCopy, innerType, tag, path);
- getStatic_inputs().add(si);
- } else if (type.equalsIgnoreCase("input")) {
- ScriptInputUser indesc = new ScriptInputUser();
- indesc.setList(list);
- indesc.setMime(mime);
- indesc.setConcatenate(concatenate);
- fillInputDescription(indesc, binary, forceCopy, innerType, tag, path);
- getInputs().put(Tools.sanitiseName(name), indesc);
- } else if (type.equalsIgnoreCase("output")) {
- ScriptOutput outdesc = new ScriptOutput();
- outdesc.setMime(mime);
-
- boolean ok = true;
- if (null == innerType) {
- // don't know what to do
- throw new DeserializationException("FIXME: Found null == innerType for output, is this the bug?");
- } else if (innerType.equalsIgnoreCase("fromfile")) {
- outdesc.setPath(path);
- outdesc.setBinary(binary);
- } else {
- throw new DeserializationException("Problem reading output port: unknown innerType '" + innerType + "'");
- }
- if (ok) {
- getOutputs().put(Tools.sanitiseName(name), outdesc);
- }
- } else if (type.equalsIgnoreCase("rte") || type.equalsIgnoreCase("re")) {
- getREs().add(new RuntimeEnvironmentConstraint(name, cur.getAttributeValue("relation")));
- } else if (type.equalsIgnoreCase("group")) {
- group = name;
- } else if (type.equalsIgnoreCase("test")) {
- test_local = cur.getAttributeValue("local");
- } else if (type.equalsIgnoreCase("icon")) {
- icon_url = cur.getAttributeValue("url");
- } else if (type.equalsIgnoreCase("queue")) {
- for (Object child_ob : cur.getChildren()) {
- Element child = (Element) child_ob;
- if (child.getName().equalsIgnoreCase("prefer"))
- getQueue_preferred().add(child.getAttributeValue("url"));
- else if (child.getName().equalsIgnoreCase("deny"))
- getQueue_deny().add(child.getAttributeValue("url"));
- else
- throw new DeserializationException("Error while reading usecase " + this.getUsecaseid() + ": invalid queue entry");
- }
- } else if (type.equalsIgnoreCase("command")) {
- // i like to have the ability to inject complete shell script
- // fragments into the use case,
- // so this should be replace and should allow multiple lines
- if ((getCommand() != null) && !getCommand().isEmpty()) {
- throw new DeserializationException("You have specified both command attribute and command tag.");
- }
- setCommand(cur.getText());
- } else if (type.equalsIgnoreCase("validReturnCodes")) {
- String codeString = cur.getAttributeValue("codes");
- if (codeString != null) {
- setReturnCodesAsText(codeString);
- }
- }
- else {
- throw new DeserializationException("Unexpected and uninterpreted attribute " + type);
- }
- }
- }
-
- private void fillInputDescription(ScriptInput fillMe, boolean binary, boolean forceCopy, String innerType, String tag, String path) throws DeserializationException {
- fillMe.setBinary(binary);
- fillMe.setForceCopy(forceCopy);
- if (null == innerType) {
- // don't know what to do
- throw new DeserializationException("FIXME: Found null == innerType for input, is this the bug?");
- } else if (innerType.equalsIgnoreCase("replace")) {
- fillMe.setTag(tag);
- fillMe.setTempFile(false);
- fillMe.setFile(false);
- getTags().add(tag);
- } else if (innerType.equalsIgnoreCase("tempfile")) {
- fillMe.setTag(tag);
- fillMe.setTempFile(true);
- fillMe.setFile(false);
- getTags().add(tag);
- } else if (innerType.equalsIgnoreCase("file")) {
- fillMe.setTag(path);
- fillMe.setTempFile(false);
- fillMe.setFile(true);
- } else {
- throw new DeserializationException("Problem reading input port: unknown innerType '" + innerType + "'");
- }
- }
-
- /**
- * returns icon that is referenced in use case description
- */
- public ImageIcon getImageIcon() {
- if (null == icon_url) return null;
- try {
- URL u = new URL(icon_url);
- return new ImageIcon(u, getUsecaseid());
- } catch (Exception e) {
- logger.error(e);
- return null;
- }
- }
-
- /**
- * String representation of the use case. It also contains interesting
- * information on the availability of resources in the grid to actually
- * execute that workflow element.
- *
- * @return String
- */
- @Override
- public String toString() {
- List<String> hlp = new ArrayList<String>();
- hlp.add("usecaseid: " + getUsecaseid());
- hlp.add("description: " + getDescription());
- hlp.add("group: " + group);
- hlp.add("test: " + test_local);
- hlp.add("tags: " + getTags());
- for (Map.Entry<String, ScriptInput> cur : getInputs().entrySet()) {
- hlp.add(">" + cur.getKey() + ">: " + cur.getValue().toString());
- }
- for (Map.Entry<String, ScriptOutput> cur : getOutputs().entrySet()) {
- hlp.add("<" + cur.getKey() + "<: " + cur.getValue().toString());
- }
- hlp.add("RE: " + getREs().toString());
- hlp.add("preferred queues: " + getQueue_preferred());
- hlp.add("denied queues: " + getQueue_deny());
- String tos = super.toString() + "[";
- for (int i = 0; i < hlp.size(); i++) {
- if (i != 0)
- tos += ", ";
- tos += hlp.get(i);
- }
- return tos + " ]";
- }
-
- /**
- * hajo's test just pass an url or file url to an xml file
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws DeserializationException
- */
- public static void main(String[] argv) throws MalformedURLException, IOException, DeserializationException {
- UseCaseDescription d = new UseCaseDescription(new URL(argv[0]).openStream());
- logger.info(d.getCommand());
- }
-
- /**
- * @param command the command to set
- */
- @ConfigurationProperty(name = "command", label = "Command", description="What is actually executed on the shell")
- public void setCommand(String command) {
- this.command = command;
- }
-
- /**
- * @param description the description to set
- */
- @ConfigurationProperty(name = "description", label = "Description", description="Textual description of the tool", required=false, uri="http://purl.org/dc/elements/1.1/description")
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * @return the description
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * @param executionTimeoutInSeconds the executionTimeoutInSeconds to set
- */
- @ConfigurationProperty(name = "executionTimeoutInSeconds", label = "Execution Timeout In Seconds")
- public void setExecutionTimeoutInSeconds(int executionTimeoutInSeconds) {
- this.executionTimeoutInSeconds = executionTimeoutInSeconds;
- }
-
- /**
- * @return the executionTimeoutInSeconds
- */
- public int getExecutionTimeoutInSeconds() {
- return executionTimeoutInSeconds;
- }
-
- /**
- * @param inputs the inputs to set
- */
- public void setInputs(Map<String, ScriptInput> inputs) {
- this.inputs = inputs;
- }
-
- @ConfigurationProperty(name = "inputs", label = "Inputs", required=false)
- public void setInputs(Set<InputMap> inputs) {
- if (inputs != null) {
- this.inputs = new HashMap<String, ScriptInput>();
- for (InputMap inputMap : inputs) {
- this.inputs.put(inputMap.getPort(), inputMap.getInput());
- }
- } else {
- this.inputs = null;
- }
- }
-
- /**
- * @return the inputs
- */
- public Map<String, ScriptInput> getInputs() {
- if (inputs == null) {
- inputs = new HashMap<String, ScriptInput>();
- }
- return inputs;
- }
-
- /**
- * @param outputs the outputs to set
- */
- public void setOutputs(Map<String, ScriptOutput> outputs) {
- this.outputs = outputs;
- }
-
- @ConfigurationProperty(name = "outputs", label = "Outputs", required=false)
- public void setOutputs(Set<OutputMap> outputs) {
- if (outputs != null) {
- this.outputs = new HashMap<String, ScriptOutput>();
- for (OutputMap outputMap : outputs) {
- this.outputs.put(outputMap.getPort(), outputMap.getOutput());
- }
- } else {
- this.outputs = null;
- }
- }
-
- /**
- * @return the outputs
- */
- public Map<String, ScriptOutput> getOutputs() {
- if (outputs == null) {
- outputs = new HashMap<String, ScriptOutput>();
- }
- return outputs;
- }
-
- /**
- * @param preparingTimeoutInSeconds the preparingTimeoutInSeconds to set
- */
- @ConfigurationProperty(name = "preparingTimeoutInSeconds", label = "Preparing Timeout In Seconds")
- public void setPreparingTimeoutInSeconds(int preparingTimeoutInSeconds) {
- this.preparingTimeoutInSeconds = preparingTimeoutInSeconds;
- }
-
- /**
- * @return the preparingTimeoutInSeconds
- */
- public int getPreparingTimeoutInSeconds() {
- return preparingTimeoutInSeconds;
- }
-
- /**
- * @param queue_deny the queue_deny to set
- */
- public void setQueue_deny(ArrayList<String> queue_deny) {
- this.queue_deny = queue_deny;
- }
-
- /**
- * @return the queue_deny
- */
- public ArrayList<String> getQueue_deny() {
- if (queue_deny == null) {
- queue_deny = new ArrayList<String>();
- }
- return queue_deny;
- }
-
- /**
- * @param queue_preferred the queue_preferred to set
- */
- public void setQueue_preferred(ArrayList<String> queue_preferred) {
- this.queue_preferred = queue_preferred;
- }
-
- /**
- * @return the queue_preferred
- */
- public ArrayList<String> getQueue_preferred() {
- if (queue_preferred == null) {
- queue_preferred = new ArrayList<String>();
- }
- return queue_preferred;
- }
-
- /**
- * @param rEs the rEs to set
- */
- public void setREs(List<RuntimeEnvironmentConstraint> rEs) {
- REs = rEs;
- }
-
- /**
- * @return the rEs
- */
- public List<RuntimeEnvironmentConstraint> getREs() {
- if (REs == null) {
- REs = new ArrayList<RuntimeEnvironmentConstraint>();
- }
- return REs;
- }
-
- /**
- * @param static_inputs the static_inputs to set
- */
- @ConfigurationProperty(name = "staticInputs", label = "Static Inputs", ordering=OrderPolicy.NON_ORDERED, required=false)
- public void setStatic_inputs(List<ScriptInputStatic> static_inputs) {
- this.static_inputs = static_inputs;
- }
-
- /**
- * @return the static_inputs
- */
- public List<ScriptInputStatic> getStatic_inputs() {
- if (static_inputs == null) {
- static_inputs = new ArrayList<ScriptInputStatic>();
- }
- return static_inputs;
- }
-
- /**
- * @param tags the tags to set
- */
- public void setTags(List<String> tags) {
- this.tags = tags;
- }
-
- /**
- * @return the tags
- */
- public List<String> getTags() {
- if (tags == null) {
- tags = new ArrayList<String>();
- }
- return tags;
- }
-
- /**
- * @param usecaseid the usecaseid to set
- */
- @ConfigurationProperty(name = "usecaseid", label = "Title", uri="http://purl.org/dc/elements/1.1/title", required=false)
- public void setUsecaseid(String usecaseid) {
- this.usecaseid = usecaseid;
- }
-
- /**
- * @return the usecaseid
- */
- public String getUsecaseid() {
- return usecaseid;
- }
-
- public boolean isIncludeStdIn() {
- return includeStdIn;
- }
-
- @ConfigurationProperty(name = "includeStdIn", label = "Include STDIN")
- public void setIncludeStdIn(boolean includeStdIn) {
- this.includeStdIn = includeStdIn;
- }
-
- public boolean isIncludeStdOut() {
- return includeStdOut;
- }
-
- @ConfigurationProperty(name = "includeStdOut", label = "Include STDOUT")
- public void setIncludeStdOut(boolean includeStdOut) {
- this.includeStdOut = includeStdOut;
- }
-
- public boolean isIncludeStdErr() {
- return includeStdErr;
- }
-
- @ConfigurationProperty(name = "includeStdErr", label = "Include STDERR")
- public void setIncludeStdErr(boolean includeStdErr) {
- this.includeStdErr = includeStdErr;
- }
-
- /**
- * @return the validReturnCodes
- */
- public List<Integer> getValidReturnCodes() {
- if (validReturnCodes == null) {
- validReturnCodes = new ArrayList<Integer>();
- }
- if (validReturnCodes.isEmpty()) {
- validReturnCodes.add(0);
- }
- return validReturnCodes;
- }
-
- /**
- * @param validReturnCodes the validReturnCodes to set
- */
- public void setValidReturnCodes(List<Integer> validReturnCodes) {
- this.validReturnCodes = validReturnCodes;
- }
-
- public String getReturnCodesAsText() {
- return StringUtils.join(getValidReturnCodes(), ",");
- }
-
- public void setReturnCodesAsText(String text) {
- if (getValidReturnCodes() == null) {
- validReturnCodes = new ArrayList<Integer>();
- }
- validReturnCodes.clear();
- String[] codes = text.split(",");
- for (String code : codes) {
- try {
- Integer codeInt = new Integer(code);
- if (!validReturnCodes.contains(codeInt)) {
- validReturnCodes.add(codeInt);
- }
- }
- catch (NumberFormatException e) {
- logger.error(e);
- }
- }
- if (validReturnCodes.isEmpty()) {
- validReturnCodes.add(0);
- }
- Collections.sort(validReturnCodes);
- }
-
- /**
- * @return the group
- */
- public String getGroup() {
- return group;
- }
-
- /**
- * @param group the group to set
- */
- public void setGroup(String group) {
- this.group = group;
- }
-
- /**
- * @return the icon_url
- */
- public String getIcon_url() {
- return icon_url;
- }
-
- @ConfigurationBean(uri = ExternalToolActivity.URI + "#OutputMap")
- public static class OutputMap {
- private String port;
-
- private ScriptOutput output;
-
- public String getPort() {
- return port;
- }
-
- @ConfigurationProperty(name = "port", label = "Port")
- public void setPort(String port) {
- this.port = port;
- }
-
- public ScriptOutput getOutput() {
- return output;
- }
-
- @ConfigurationProperty(name = "output", label = "Output")
- public void setOutput(ScriptOutput output) {
- this.output = output;
- }
- }
-
- @ConfigurationBean(uri = ExternalToolActivity.URI + "#InputMap")
- public static class InputMap {
- private String port;
-
- private ScriptInputUser input;
-
- public String getPort() {
- return port;
- }
-
- @ConfigurationProperty(name = "port", label = "Port")
- public void setPort(String port) {
- this.port = port;
- }
-
- public ScriptInputUser getInput() {
- return input;
- }
-
- @ConfigurationProperty(name = "input", label = "Input")
- public void setInput(ScriptInputUser input) {
- this.input = input;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/98468d30/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseEnumeration.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseEnumeration.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseEnumeration.java
deleted file mode 100644
index d5c5d2c..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/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 de.uni_luebeck.inb.knowarc.usecases;
-
-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<UseCaseDescription> readDescriptionsFromUrl(String xmlFileUrl) throws IOException {
-
- List<UseCaseDescription> ret = new ArrayList<UseCaseDescription>();
- 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<UseCaseDescription> readDescriptionsFromStream(InputStream is) {
-
- List<UseCaseDescription> ret = new ArrayList<UseCaseDescription>();
-
- 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 UseCaseDescription(child));
- } catch (DeserializationException e) {
- logger.error(e);
- }
- }
- }
- return ret;
- }
-
- public static UseCaseDescription readDescriptionFromUrl(
- String repositoryUrl, String id) throws IOException {
- List<UseCaseDescription> descriptions = readDescriptionsFromUrl(repositoryUrl);
- for (UseCaseDescription usecase : descriptions) {
- if (usecase.getUsecaseid().equals(id)) {
- return usecase;
- }
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/98468d30/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/AskUserForPw.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/AskUserForPw.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/AskUserForPw.java
deleted file mode 100644
index e912db1..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/AskUserForPw.java
+++ /dev/null
@@ -1,32 +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 de.uni_luebeck.inb.knowarc.usecases.invocation;
-
-public interface AskUserForPw {
-
- // we will try keyfile first
- public String getKeyfile();
- public String getPassphrase();
-
- // then username+password
- public String getUsername();
- public String getPassword();
-
- public void authenticationSucceeded();
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/98468d30/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/InvocationException.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/InvocationException.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/InvocationException.java
deleted file mode 100644
index 2f4485f..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/InvocationException.java
+++ /dev/null
@@ -1,36 +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 de.uni_luebeck.inb.knowarc.usecases.invocation;
-
-public class InvocationException extends Exception {
-
- /**
- *
- */
- private static final long serialVersionUID = 437316164959631591L;
-
- public InvocationException(String string) {
- super(string);
- }
-
- public InvocationException(Exception e) {
- super(e);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/98468d30/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/UseCaseInvocation.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/UseCaseInvocation.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/UseCaseInvocation.java
deleted file mode 100644
index d6b2502..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/UseCaseInvocation.java
+++ /dev/null
@@ -1,322 +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 de.uni_luebeck.inb.knowarc.usecases.invocation;
-
-import java.io.BufferedWriter;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.io.IOUtils;
-
-import org.apache.taverna.invocation.InvocationContext;
-import org.apache.taverna.reference.ExternalReferenceSPI;
-import org.apache.taverna.reference.Identified;
-import org.apache.taverna.reference.IdentifiedList;
-import org.apache.taverna.reference.ReferenceService;
-import org.apache.taverna.reference.ReferenceServiceException;
-import org.apache.taverna.reference.ReferenceSet;
-import org.apache.taverna.reference.T2Reference;
-import org.apache.taverna.reference.impl.external.object.InlineByteArrayReferenceBuilder;
-import org.apache.taverna.reference.impl.external.object.InlineStringReferenceBuilder;
-import de.uni_luebeck.inb.knowarc.usecases.ScriptInput;
-import de.uni_luebeck.inb.knowarc.usecases.ScriptInputStatic;
-import de.uni_luebeck.inb.knowarc.usecases.ScriptInputUser;
-import de.uni_luebeck.inb.knowarc.usecases.UseCaseDescription;
-
-/**
- * An abstraction of various forms to bring job using the software that is
- * referenced as a use case towards their execution.
- *
- * @author Hajo Nils Krabbenhoeft with some contribution by
- * @author Steffen Moeller
- */
-public abstract class UseCaseInvocation {
-
- private String runId;
-
-
- protected static String getActualOsCommand(String osCommand, String pathToOriginal,
- String targetName, String pathTarget) {
- String actualOsCommand = osCommand;
- actualOsCommand = actualOsCommand.replace("%%PATH_TO_ORIGINAL%%", pathToOriginal);
- actualOsCommand = actualOsCommand.replace("%%TARGET_NAME%%", targetName);
- actualOsCommand = actualOsCommand.replace("%%PATH_TO_TARGET%%", pathTarget);
- return actualOsCommand;
- }
-
- protected UseCaseDescription usecase;
- protected final HashMap<String, String> tags = new HashMap<String, String>();
- protected int nTempFiles = 0;
- private static int submissionID = 0;
- protected static InlineByteArrayReferenceBuilder inlineByteArrayReferenceBuilder = new InlineByteArrayReferenceBuilder();
- protected static InlineStringReferenceBuilder inlineStringReferenceBuilder = new InlineStringReferenceBuilder();
- private InvocationContext invocationContext;
- private boolean retrieveData;
-
- /*
- * get the class of the data we expect for a given input
- */
- @SuppressWarnings("unchecked")
- public Class getType(String inputName) {
- if (!usecase.getInputs().containsKey(inputName))
- return null;
- ScriptInputUser input = (ScriptInputUser) usecase.getInputs().get(inputName);
- if (input.isList()) {
- if (input.isBinary())
- return List.class;
- else
- return List.class;
- } else {
- if (input.isBinary())
- return byte[].class;
- else
- return String.class;
- }
- }
-
- /*
- * get a list of all the input port names
- */
- public Set<String> getInputs() {
- return usecase.getInputs().keySet();
- }
-
-
- /*
- * get a id, incremented with each job. thus, this should be thread-wide
- * unique
- */
- public synchronized int getSubmissionID() {
- return submissionID++;
- }
-
- /*
- * set the data for the input port with given name
- */
- @SuppressWarnings("unchecked")
- public void setInput(String inputName, ReferenceService referenceService, T2Reference t2Reference) throws InvocationException {
- if (t2Reference == null) {
- throw new InvocationException("No input specified for " + inputName);
- }
- ScriptInputUser input = (ScriptInputUser) usecase.getInputs().get(inputName);
- if (input.isList()) {
- IdentifiedList<T2Reference> listOfReferences = (IdentifiedList<T2Reference>) referenceService
- .getListService().getList(t2Reference);
-
- if (!input.isConcatenate()) {
- // this is a list input (not concatenated)
- // so write every element to its own temporary file
- // and create a filelist file
-
- // we need to write the list elements to temporary files
- ScriptInputUser listElementTemp = new ScriptInputUser();
- listElementTemp.setBinary(input.isBinary());
- listElementTemp.setTempFile(true);
-
- String lineEndChar = "\n";
- if (!input.isFile() && !input.isTempFile()) {
- lineEndChar = " ";
- }
-
- String listFileContent = "";
- String filenamesFileContent = "";
- // create a list of all temp file names
- for (T2Reference cur : listOfReferences) {
- String tmp = setOneInput(referenceService, cur,
- listElementTemp);
- listFileContent += tmp + lineEndChar;
- int ind = tmp.lastIndexOf('/');
- if (ind == -1) {
- ind = tmp.lastIndexOf('\\');
- }
- if (ind != -1) {
- tmp = tmp.substring(ind + 1);
- }
- filenamesFileContent += tmp + lineEndChar;
- }
-
- // how do we want the listfile to be stored?
- ScriptInputUser listFile = new ScriptInputUser();
- listFile.setBinary(false); // since its a list file
- listFile.setFile(input.isFile());
- listFile.setTempFile(input.isTempFile());
- listFile.setTag(input.getTag());
- T2Reference listFileContentReference = referenceService
- .register(listFileContent, 0, true, invocationContext);
-
- tags.put(listFile.getTag(), setOneInput(referenceService,
- listFileContentReference, listFile));
-
- listFile.setTag(input.getTag() + "_NAMES");
- T2Reference filenamesFileContentReference = referenceService
- .register(filenamesFileContent, 0, true, null);
- tags.put(listFile.getTag(), setOneInput(referenceService,
- filenamesFileContentReference, listFile));
- } else {
- try {
- // first, concatenate all data
- if (input.isBinary()) {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- BufferedWriter outputWriter = new BufferedWriter(
- new OutputStreamWriter(outputStream));
- for (T2Reference cur : listOfReferences) {
- InputStreamReader inputReader = new InputStreamReader(
- getAsStream(referenceService, cur));
- IOUtils.copyLarge(inputReader, outputWriter);
- inputReader.close();
- }
- outputWriter.close();
- T2Reference binaryReference = referenceService
- .register(outputStream.toByteArray(), 0, true,
- invocationContext);
- tags.put(input.getTag(), setOneInput(referenceService,
- binaryReference, input));
- } else {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- BufferedWriter outputWriter = new BufferedWriter(
- new OutputStreamWriter(outputStream));
- for (T2Reference cur : listOfReferences) {
- InputStreamReader inputReader = new InputStreamReader(
- getAsStream(referenceService, cur));
- IOUtils.copyLarge(inputReader, outputWriter);
- outputWriter.write(" ");
- inputReader.close();
- }
- outputWriter.close();
- T2Reference binaryReference = referenceService
- .register(outputStream.toByteArray(), 0, true,
- invocationContext);
- tags.put(input.getTag(), setOneInput(referenceService,
- binaryReference, input));
- }
- } catch (IOException e) {
- throw new InvocationException(e);
- }
- }
- } else {
- tags.put(input.getTag(), setOneInput(referenceService, t2Reference,
- input));
- }
- }
-
- /*
- * submit a grid job and wait for it to finish, then get the result as
- * on-demand downloads or directly as data (in case of local execution)
- */
- public HashMap<String, Object> Submit(ReferenceService referenceService) throws InvocationException {
- submit_generate_job(referenceService);
- return submit_wait_fetch_results(referenceService);
- }
-
- /*
- * just submit the job. useful if you want to wait for it to finish later on
- *
- * Can the statics be made more static?
- */
- public void submit_generate_job(ReferenceService referenceService) throws InvocationException {
- for (ScriptInputStatic input : usecase.getStatic_inputs()) {
- T2Reference ref;
- if (input.getUrl() != null) {
- // Does this work OK with binary
- try {
- ref = referenceService.register(new URL(input.getUrl()), 0, true, null);
- } catch (ReferenceServiceException e) {
- throw new InvocationException(e);
- } catch (MalformedURLException e) {
- throw new InvocationException(e);
- }
- } else {
- ref = referenceService.register((String) input.getContent(), 0, true, null);
- }
- tags.put(input.getTag(), setOneInput(referenceService, ref, input));
-
- }
- submit_generate_job_inner();
- }
-
- protected abstract void submit_generate_job_inner() throws InvocationException;
-
- /*
- * wait for a submitted job to finish and fetch the results
- */
- public abstract HashMap<String, Object> submit_wait_fetch_results(ReferenceService referenceService) throws InvocationException;
-
- public abstract String setOneInput(ReferenceService referenceService, T2Reference t2Reference, ScriptInput input) throws InvocationException;
-
- protected InputStream getAsStream(ReferenceService referenceService, T2Reference t2Reference) {
- Identified identified = referenceService.resolveIdentifier(t2Reference, null, null);
- if (identified instanceof ReferenceSet) {
- ExternalReferenceSPI ref = ((ReferenceSet) identified).getExternalReferences().iterator().next();
- return ref.openStream(invocationContext);
- }
- return null;
- }
-
- public void setContext(InvocationContext context) {
- this.invocationContext = context;
-
- }
-
- public InvocationContext getContext() {
- return this.invocationContext;
- }
-
- public abstract void setStdIn(ReferenceService referenceService,
- T2Reference t2Reference);
-
- public abstract void rememberRun(String runId);
-
- /**
- * @return the runId
- */
- protected String getRunId() {
- return runId;
- }
-
- /**
- * @param runId the runId to set
- */
- protected void setRunId(String runId) {
- this.runId = runId;
- }
-
- /**
- * @return the retrieveData
- */
- protected boolean isRetrieveData() {
- return retrieveData;
- }
-
- /**
- * @param retrieveData the retrieveData to set
- */
- protected void setRetrieveData(boolean retrieveData) {
- this.retrieveData = retrieveData;
- }
-
-
-}