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 2015/02/23 11:17:04 UTC

[23/28] incubator-taverna-common-activities git commit: Revert "temporarily empty repository"

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/jetty/InteractionJetty.java
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/jetty/InteractionJetty.java b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/jetty/InteractionJetty.java
new file mode 100644
index 0000000..c5fb3af
--- /dev/null
+++ b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/jetty/InteractionJetty.java
@@ -0,0 +1,203 @@
+/**
+ *
+ */
+package net.sf.taverna.t2.activities.interaction.jetty;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import net.sf.taverna.t2.activities.interaction.FeedReader;
+import net.sf.taverna.t2.activities.interaction.InteractionUtils;
+import net.sf.taverna.t2.activities.interaction.ResponseFeedListener;
+import net.sf.taverna.t2.activities.interaction.feed.ShowRequestFeedListener;
+import net.sf.taverna.t2.activities.interaction.preference.InteractionPreference;
+import net.sf.taverna.t2.security.credentialmanager.CMException;
+import net.sf.taverna.t2.security.credentialmanager.CredentialManager;
+import net.sf.taverna.t2.security.credentialmanager.UsernamePassword;
+//import net.sf.taverna.t2.spi.SPIRegistry;
+import net.sf.webdav.WebdavServlet;
+
+import org.apache.abdera.protocol.server.ServiceManager;
+import org.apache.abdera.protocol.server.provider.basic.BasicProvider;
+import org.apache.abdera.protocol.server.servlet.AbderaServlet;
+import org.apache.log4j.Logger;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.handler.HandlerList;
+import org.mortbay.jetty.security.Constraint;
+import org.mortbay.jetty.security.ConstraintMapping;
+import org.mortbay.jetty.security.HashUserRealm;
+import org.mortbay.jetty.security.SecurityHandler;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+
+/**
+ * @author alanrw
+ * 
+ */
+public class InteractionJetty {
+
+	private static Logger logger = Logger.getLogger(InteractionJetty.class);
+	
+	private InteractionUtils interactionUtils;
+	
+	private ShowRequestFeedListener showRequestFeedListener;
+	private ResponseFeedListener responseFeedListener;
+
+	private InteractionPreference interactionPreference;
+
+	private static Server server;
+
+	private static String REALM_NAME = "TavernaInteraction";
+	
+	private static boolean listenersStarted = false;
+
+	public synchronized void startJettyIfNecessary(CredentialManager credentialManager) {
+		if (server != null) {
+			return;
+		}
+		
+//		final ClassLoader previousContextClassLoader = Thread.currentThread()
+//				.getContextClassLoader();
+//		Thread.currentThread().setContextClassLoader(
+//				InteractionJetty.class.getClassLoader());
+
+		final String port = interactionPreference.getPort();
+
+		server = new Server(Integer.parseInt(port));
+		server.setStopAtShutdown(true);
+
+		final WebdavServlet interactionServlet = new WebdavServlet();
+
+		final ServletHolder interactionHolder = new ServletHolder();
+		interactionHolder.setServlet(interactionServlet);
+
+		try {
+
+			interactionHolder.setInitParameter("rootpath",
+					getInteractionDirectory().getCanonicalPath());
+		} catch (final IOException e1) {
+			logger.error("Unable to set root of interaction", e1);
+		}
+
+		final HandlerList handlers = new HandlerList();
+		final Context overallContext = new Context(handlers, "/",
+				Context.SESSIONS);
+		overallContext.setContextPath("/");
+		server.setHandler(overallContext);
+
+		final AbderaServlet abderaServlet = new AbderaServlet();
+		final ServletHolder abderaHolder = new ServletHolder(abderaServlet);
+		abderaHolder.setInitParameter(ServiceManager.PROVIDER,
+				BasicProvider.class.getName());
+
+		overallContext.addServlet(abderaHolder, "/*");
+		overallContext.addServlet(interactionHolder, "/interaction/*");
+
+		if (interactionPreference.getUseUsername()) {
+			final Constraint constraint = new Constraint();
+			constraint.setName(Constraint.__BASIC_AUTH);
+
+			constraint.setRoles(new String[] { "user", "admin", "moderator" });
+			constraint.setAuthenticate(true);
+
+			final ConstraintMapping cm = new ConstraintMapping();
+			cm.setConstraint(constraint);
+			cm.setPathSpec("/*");
+
+			final SecurityHandler sh = new SecurityHandler();
+			try {
+				final HashUserRealm realm = new HashUserRealm(REALM_NAME);
+				final URI serviceURI = createServiceURI(port);
+				final UsernamePassword up = credentialManager
+						.getUsernameAndPasswordForService(serviceURI, true,
+								"Please specify the username and password to secure your interactions");
+				if (up != null) {
+					final String username = up.getUsername();
+					realm.put(username, up.getPasswordAsString());
+					realm.addUserToRole(username, "user");
+				}
+				sh.setUserRealm(realm);
+			} catch (final CMException e) {
+				logger.error(e);
+			} catch (final URISyntaxException e) {
+				logger.error(e);
+			}
+			sh.setConstraintMappings(new ConstraintMapping[] { cm });
+			overallContext.addHandler(sh);
+
+		}
+
+		getFeedDirectory();
+
+		try {
+			server.start();
+			while (!server.isRunning()) {
+				Thread.sleep(5000);
+			}
+		} catch (final Exception e) {
+			logger.error("Unable to start Jetty");
+		}
+//		Thread.currentThread()
+//				.setContextClassLoader(previousContextClassLoader);
+	}
+
+	public static URI createServiceURI(final String port)
+			throws URISyntaxException {
+		return new URI("http://localhost:" + port + "/#" + REALM_NAME);
+	}
+
+	public File getJettySubdirectory(final String subdirectoryName) {
+		final File workingDir = interactionUtils
+				.getInteractionServiceDirectory();
+		final File subDir = new File(workingDir, "jetty/" + subdirectoryName);
+		subDir.mkdirs();
+		return subDir;
+	}
+
+	public File getFeedDirectory() {
+		return getJettySubdirectory("feed");
+	}
+
+	public File getInteractionDirectory() {
+		return getJettySubdirectory("interaction");
+	}
+	
+	public synchronized void startListenersIfNecessary() {
+		if (listenersStarted) {
+			return;
+		}
+		listenersStarted = true;
+		startListener(this.responseFeedListener);
+		startListener(showRequestFeedListener);
+
+	}
+
+	private void startListener(FeedReader fr) {
+		try {
+			fr.start();
+		}
+		catch (Exception e) {
+			logger.error("Failed to start " + fr.getClass().getCanonicalName(), e);
+		}
+	}
+	
+	public void setInteractionUtils(InteractionUtils interactionUtils) {
+		this.interactionUtils = interactionUtils;
+	}
+
+	public void setShowRequestFeedListener(
+			ShowRequestFeedListener showRequestFeedListener) {
+		this.showRequestFeedListener = showRequestFeedListener;
+	}
+
+	public void setResponseFeedListener(ResponseFeedListener responseFeedListener) {
+		this.responseFeedListener = responseFeedListener;
+	}
+
+	public void setInteractionPreference(InteractionPreference interactionPreference) {
+		this.interactionPreference = interactionPreference;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/preference/InteractionPreference.java
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/preference/InteractionPreference.java b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/preference/InteractionPreference.java
new file mode 100644
index 0000000..c2ba982
--- /dev/null
+++ b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/preference/InteractionPreference.java
@@ -0,0 +1,268 @@
+/**
+ *
+ */
+package net.sf.taverna.t2.activities.interaction.preference;
+
+import java.awt.GraphicsEnvironment;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+
+import uk.org.taverna.configuration.app.ApplicationConfiguration;
+
+/**
+ * @author alanrw
+ * 
+ */
+public class InteractionPreference {
+	
+	private ApplicationConfiguration appConfig;
+
+	private static final String USE_JETTY = "useJetty";
+
+	private static final String DEFAULT_USE_JETTY = "true";
+
+	private static final String PORT = "port";
+
+	private static final String DEFAULT_PORT = "8080";
+
+	private static final String HOST = "host";
+
+	private static final String DEFAULT_HOST = "http://localhost";
+
+	private static final String WEBDAV_PATH = "webdavPath";
+
+	private static final String DEFAULT_WEBDAV_PATH = "/interaction";
+
+	private static final String FEED_PATH = "feedPath";
+
+	private static final String DEFAULT_FEED_PATH = "/feed";
+
+	private static final String USE_USERNAME = "Secure with username / password";
+
+	private static final String DEFAULT_USE_USERNAME = "false";
+
+	// private static final String USE_HTTPS = "Use HTTPS";
+
+	// private static final String DEFAULT_USE_HTTPS = "false";
+
+	private final Logger logger = Logger.getLogger(InteractionPreference.class);
+
+	private final Properties properties;
+
+	private File getConfigFile() {
+		final File home = appConfig
+				.getApplicationHomeDir();
+		final File config = new File(home, "conf");
+		if (!config.exists()) {
+			config.mkdir();
+		}
+		final File configFile = new File(config, this.getFilePrefix() + "-"
+				+ this.getUUID() + ".config");
+		return configFile;
+	}
+
+	private InteractionPreference(ApplicationConfiguration appConfig) {
+		setAppConfig(appConfig);
+		final File configFile = this.getConfigFile();
+		this.properties = new Properties();
+		if (configFile.exists()) {
+			try {
+				final FileReader reader = new FileReader(configFile);
+				this.properties.load(reader);
+				reader.close();
+			} catch (final FileNotFoundException e) {
+				this.logger.error(e);
+			} catch (final IOException e) {
+				this.logger.error(e);
+			}
+		}
+		if (GraphicsEnvironment.isHeadless()
+				|| ((System.getProperty("java.awt.headless") != null) && System
+						.getProperty("java.awt.headless").equals("true"))) {
+			final String definedHost = System
+					.getProperty("taverna.interaction.host");
+			if (definedHost != null) {
+				this.properties.setProperty(USE_JETTY, "false");
+				this.logger.info("USE_JETTY set to false");
+				this.properties.setProperty(HOST, definedHost);
+			}
+			final String definedPort = System
+					.getProperty("taverna.interaction.port");
+			if (definedPort != null) {
+				this.properties.setProperty(PORT, definedPort);
+			}
+			final String definedWebDavPath = System
+					.getProperty("taverna.interaction.webdav_path");
+			if (definedWebDavPath != null) {
+				this.properties.setProperty(WEBDAV_PATH, definedWebDavPath);
+			}
+			final String definedFeedPath = System
+					.getProperty("taverna.interaction.feed_path");
+			if (definedFeedPath != null) {
+				this.properties.setProperty(FEED_PATH, definedFeedPath);
+			}
+		} else {
+			this.logger.info("Running non-headless");
+		}
+		this.fillDefaultProperties();
+	}
+
+	private void fillDefaultProperties() {
+		if (!this.properties.containsKey(USE_JETTY)) {
+			this.properties.setProperty(USE_JETTY, DEFAULT_USE_JETTY);
+			this.logger.info("USE_JETTY set to " + DEFAULT_USE_JETTY);
+		}
+		if (!this.properties.containsKey(PORT)) {
+			this.properties.setProperty(PORT, DEFAULT_PORT);
+		}
+		if (!this.properties.containsKey(HOST)) {
+			this.properties.setProperty(HOST, DEFAULT_HOST);
+		}
+		if (!this.properties.containsKey(WEBDAV_PATH)) {
+			this.properties.setProperty(WEBDAV_PATH, DEFAULT_WEBDAV_PATH);
+		}
+		if (!this.properties.containsKey(FEED_PATH)) {
+			this.properties.setProperty(FEED_PATH, DEFAULT_FEED_PATH);
+		}
+		if (!this.properties.containsKey(USE_USERNAME)) {
+			this.properties.setProperty(USE_USERNAME, DEFAULT_USE_USERNAME);
+		}
+		/*
+		 * if (!properties.containsKey(USE_HTTPS)) {
+		 * properties.setProperty(USE_HTTPS, DEFAULT_USE_HTTPS); }
+		 */
+	}
+
+	public String getFilePrefix() {
+		return "Interaction";
+	}
+
+	public void store() {
+		try {
+			final FileOutputStream out = new FileOutputStream(
+					this.getConfigFile());
+			this.properties.store(out, "");
+			out.close();
+		} catch (final FileNotFoundException e) {
+			this.logger.error(e);
+		} catch (final IOException e) {
+			this.logger.error(e);
+		}
+	}
+
+	public String getUUID() {
+		return "DA992717-5A46-469D-AE25-883F0E4CD348";
+	}
+
+	public void setPort(final String text) {
+		this.properties.setProperty(PORT, text);
+	}
+
+	public void setHost(final String text) {
+		this.properties.setProperty(HOST, text);
+	}
+
+	public void setUseJetty(final boolean use) {
+		this.properties.setProperty(USE_JETTY, Boolean.toString(use));
+	}
+
+	public void setFeedPath(final String path) {
+		this.properties.setProperty(FEED_PATH, path);
+	}
+
+	public void setWebDavPath(final String path) {
+		this.properties.setProperty(WEBDAV_PATH, path);
+	}
+
+	public String getPort() {
+		return this.properties.getProperty(PORT);
+	}
+
+	public String getHost() {
+		return this.properties.getProperty(HOST);
+	}
+
+	public boolean getUseJetty() {
+		return (Boolean.parseBoolean(this.properties.getProperty(USE_JETTY)));
+	}
+
+	public String getFeedPath() {
+		return this.properties.getProperty(FEED_PATH);
+	}
+
+	public String getWebDavPath() {
+		return this.properties.getProperty(WEBDAV_PATH);
+	}
+
+	public String getDefaultHost() {
+		return DEFAULT_HOST;
+	}
+
+	public String getDefaultFeedPath() {
+		return DEFAULT_FEED_PATH;
+	}
+
+	public String getDefaultWebDavPath() {
+		return DEFAULT_WEBDAV_PATH;
+	}
+
+	public String getFeedUrlString() {
+		return this.getHost() + ":" + this.getPort() + this.getFeedPath();
+	}
+
+	public String getLocationUrl() {
+		return this.getHost() + ":" + this.getPort() + this.getWebDavPath();
+	}
+
+	public boolean getUseUsername() {
+		return (Boolean.parseBoolean(this.properties.getProperty(USE_USERNAME)));
+	}
+
+	public void setUseUsername(final boolean useUsername) {
+		this.properties
+				.setProperty(USE_USERNAME, Boolean.toString(useUsername));
+	}
+
+	public String getOutputDataUrlString(final String interactionId) {
+		return this.getLocationUrl()
+				+ "/interaction" + interactionId + "OutputData.json";
+	}
+
+	public String getInputDataUrlString(final String interactionId) {
+		return this.getLocationUrl()
+				+ "/interaction" + interactionId + "InputData.json";
+	}
+
+	public URL getFeedUrl() throws MalformedURLException {
+		return new URL(this.getFeedUrlString());
+	}
+
+	public String getInteractionUrlString(final String interactionId) {
+		return this.getLocationUrl()
+				+ "/interaction" + interactionId + ".html";
+	}
+
+	public String getPresentationUrlString(final String interactionId) {
+		return this.getLocationUrl()
+				+ "/presentation" + interactionId + ".html";
+	}
+
+	public String getPublicationUrlString(final String interactionId,
+			final String key) {
+		return this.getLocationUrl()
+				+ "/interaction" + interactionId + "_" + key;
+	}
+
+	public void setAppConfig(ApplicationConfiguration appConfig) {
+		this.appConfig = appConfig;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/InteractionVelocity.java
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/InteractionVelocity.java b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/InteractionVelocity.java
new file mode 100644
index 0000000..d0601b2
--- /dev/null
+++ b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/InteractionVelocity.java
@@ -0,0 +1,130 @@
+/**
+ *
+ */
+package net.sf.taverna.t2.activities.interaction.velocity;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+
+import net.sf.taverna.t2.activities.interaction.InteractionActivity;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.log4j.Logger;
+import org.apache.velocity.Template;
+import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.RuntimeSingleton;
+import org.apache.velocity.runtime.resource.loader.StringResourceLoader;
+import org.apache.velocity.runtime.resource.util.StringResourceRepository;
+
+/**
+ * @author alanrw
+ * 
+ */
+public class InteractionVelocity {
+
+	public static Logger logger = Logger.getLogger(InteractionVelocity.class);
+
+	private static boolean velocityInitialized = false;
+
+	private static final String TEMPLATE_SUFFIX = ".vm";
+
+	private Template interactionTemplate = null;
+	private static final String INTERACTION_TEMPLATE_NAME = "interaction";
+
+	private ArrayList<String> templateNames = new ArrayList<String>();
+
+	private VelocityEngine ve = new VelocityEngine();
+	
+	@SuppressWarnings("deprecation")
+	public synchronized void checkVelocity() {
+		if (velocityInitialized) { 
+			return;
+		}
+		velocityInitialized = true;
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "string");
+		ve.setProperty("resource.loader.class",
+				"org.apache.velocity.runtime.resource.loader.StringResourceLoader");
+		ve.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
+				"org.apache.velocity.runtime.log.Log4JLogChute");
+		ve.setProperty("runtime.log.logsystem.log4j.logger",
+				"net.sf.taverna.t2.activities.interaction.velocity.InteractionVelocity");
+		ve.init();
+		ve.loadDirective(RequireDirective.class.getName());
+		ve.loadDirective(ProduceDirective.class.getName());
+		ve.loadDirective(NotifyDirective.class.getName());
+
+		loadTemplates();
+
+		interactionTemplate = ve.getTemplate(INTERACTION_TEMPLATE_NAME);
+		if (interactionTemplate == null) {
+			logger.error("Could not open interaction template "
+					+ INTERACTION_TEMPLATE_NAME);
+		}
+	}
+
+	private void loadTemplates() {
+		final InputStream is = InteractionActivity.class
+				.getResourceAsStream("/index");
+		if (is == null) {
+			logger.error("Unable to read /index");
+			return;
+		}
+		final BufferedReader br = new BufferedReader(new InputStreamReader(is));
+		try {
+			for (String line = br.readLine(); line != null; line = br
+					.readLine()) {
+				if (line.startsWith("#")) {
+					continue;
+				}
+				line = line.trim();
+				if (line.isEmpty()) {
+					continue;
+				}
+				final String templatePath = line + TEMPLATE_SUFFIX;
+				logger.info("Looking for " + templatePath);
+				final StringResourceRepository repo = StringResourceLoader
+						.getRepository();
+				try {
+					repo.putStringResource(line,
+							getTemplateFromResource(templatePath));
+				} catch (final IOException e) {
+					logger.error(
+							"Failed reading template from " + templatePath, e);
+				}
+				final Template t = Velocity.getTemplate(line);
+				if (t == null) {
+					logger.error("Registration failed");
+				}
+				if (!line.equals(INTERACTION_TEMPLATE_NAME)) {
+					templateNames.add(line);
+				}
+			}
+		} catch (final IOException e) {
+			logger.error("Failed reading template index", e);
+		}
+	}
+
+	public Template getInteractionTemplate() {
+		checkVelocity();
+		return interactionTemplate;
+	}
+
+	private String getTemplateFromResource(final String templatePath)
+			throws IOException {
+		checkVelocity();
+		final InputStream stream = InteractionVelocity.class
+				.getResourceAsStream("/" + templatePath);
+		final String result = IOUtils.toString(stream, "UTF-8");
+		return result;
+	}
+
+	public ArrayList<String> getTemplateNames() {
+		checkVelocity();
+		return templateNames;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/NotifyChecker.java
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/NotifyChecker.java b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/NotifyChecker.java
new file mode 100644
index 0000000..82fe384
--- /dev/null
+++ b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/NotifyChecker.java
@@ -0,0 +1,26 @@
+/**
+ *
+ */
+package net.sf.taverna.t2.activities.interaction.velocity;
+
+import org.apache.velocity.runtime.parser.node.ASTDirective;
+import org.apache.velocity.runtime.visitor.BaseVisitor;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * @author alanrw
+ * 
+ */
+public class NotifyChecker extends BaseVisitor {
+
+	@Override
+	public Object visit(final ASTDirective node, final Object data) {
+		ObjectNode json = (ObjectNode) data;
+		if (node.getDirectiveName().equals("notify")) {
+			json.put("progressNotification", true);
+		}
+		return null;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/NotifyDirective.java
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/NotifyDirective.java b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/NotifyDirective.java
new file mode 100644
index 0000000..050b907
--- /dev/null
+++ b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/NotifyDirective.java
@@ -0,0 +1,58 @@
+/**
+ *
+ */
+package net.sf.taverna.t2.activities.interaction.velocity;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.velocity.context.InternalContextAdapter;
+import org.apache.velocity.exception.MethodInvocationException;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.runtime.directive.Directive;
+import org.apache.velocity.runtime.parser.node.Node;
+
+/**
+ * @author alanrw
+ * 
+ */
+public class NotifyDirective extends Directive {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.velocity.runtime.directive.Directive#getName()
+	 */
+	@Override
+	public String getName() {
+		return "notify";
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.velocity.runtime.directive.Directive#getType()
+	 */
+	@Override
+	public int getType() {
+		return LINE;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.velocity.runtime.directive.Directive#render(org.apache.velocity
+	 * .context.InternalContextAdapter, java.io.Write\ r,
+	 * org.apache.velocity.runtime.parser.node.Node)
+	 */
+	@Override
+	public boolean render(final InternalContextAdapter context,
+			final Writer writer, final Node node) throws IOException,
+			ResourceNotFoundException, ParseErrorException,
+			MethodInvocationException {
+		return true;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/ProduceChecker.java
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/ProduceChecker.java b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/ProduceChecker.java
new file mode 100644
index 0000000..a2b8f60
--- /dev/null
+++ b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/ProduceChecker.java
@@ -0,0 +1,35 @@
+/**
+ *
+ */
+package net.sf.taverna.t2.activities.interaction.velocity;
+
+import java.util.Map;
+
+import org.apache.velocity.runtime.parser.node.ASTDirective;
+import org.apache.velocity.runtime.visitor.BaseVisitor;
+
+/**
+ * @author alanrw
+ * 
+ */
+public class ProduceChecker extends BaseVisitor {
+
+	@Override
+	public Object visit(final ASTDirective node, final Object data) {
+		@SuppressWarnings("unchecked")
+		final Map<String, Integer> map = ((Map<String, Integer>) data);
+		if (node.getDirectiveName().equals("produce")) {
+			final String key = String.valueOf(node.jjtGetChild(0).value(
+					this.context));
+			if (node.jjtGetNumChildren() > 1) {
+				final Integer depth = (Integer) node.jjtGetChild(1).value(
+						this.context);
+				map.put(key, depth);
+			} else {
+				map.put(key, 0);
+			}
+		}
+		return map;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/ProduceDirective.java
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/ProduceDirective.java b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/ProduceDirective.java
new file mode 100644
index 0000000..144f224
--- /dev/null
+++ b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/ProduceDirective.java
@@ -0,0 +1,58 @@
+/**
+ *
+ */
+package net.sf.taverna.t2.activities.interaction.velocity;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.velocity.context.InternalContextAdapter;
+import org.apache.velocity.exception.MethodInvocationException;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.runtime.directive.Directive;
+import org.apache.velocity.runtime.parser.node.Node;
+
+/**
+ * @author alanrw
+ * 
+ */
+public class ProduceDirective extends Directive {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.velocity.runtime.directive.Directive#getName()
+	 */
+	@Override
+	public String getName() {
+		return "produce";
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.velocity.runtime.directive.Directive#getType()
+	 */
+	@Override
+	public int getType() {
+		return LINE;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.velocity.runtime.directive.Directive#render(org.apache.velocity
+	 * .context.InternalContextAdapter, java.io.Write\ r,
+	 * org.apache.velocity.runtime.parser.node.Node)
+	 */
+	@Override
+	public boolean render(final InternalContextAdapter context,
+			final Writer writer, final Node node) throws IOException,
+			ResourceNotFoundException, ParseErrorException,
+			MethodInvocationException {
+		return true;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/RequireChecker.java
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/RequireChecker.java b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/RequireChecker.java
new file mode 100644
index 0000000..d723764
--- /dev/null
+++ b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/RequireChecker.java
@@ -0,0 +1,35 @@
+/**
+ *
+ */
+package net.sf.taverna.t2.activities.interaction.velocity;
+
+import java.util.Map;
+
+import org.apache.velocity.runtime.parser.node.ASTDirective;
+import org.apache.velocity.runtime.visitor.BaseVisitor;
+
+/**
+ * @author alanrw
+ * 
+ */
+public class RequireChecker extends BaseVisitor {
+
+	@Override
+	public Object visit(final ASTDirective node, final Object data) {
+		@SuppressWarnings("unchecked")
+		final Map<String, Integer> map = (Map<String, Integer>) data;
+		if (node.getDirectiveName().equals("require")) {
+			final String key = String.valueOf(node.jjtGetChild(0).value(
+					this.context));
+			if (node.jjtGetNumChildren() > 1) {
+				final Integer depth = (Integer) node.jjtGetChild(1).value(
+						this.context);
+				map.put(key, depth);
+			} else {
+				map.put(key, 0);
+			}
+		}
+		return map;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/RequireDirective.java
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/RequireDirective.java b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/RequireDirective.java
new file mode 100644
index 0000000..34b053a
--- /dev/null
+++ b/taverna-interaction-activity/src/main/java/net/sf/taverna/t2/activities/interaction/velocity/RequireDirective.java
@@ -0,0 +1,58 @@
+/**
+ *
+ */
+package net.sf.taverna.t2.activities.interaction.velocity;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.apache.velocity.context.InternalContextAdapter;
+import org.apache.velocity.exception.MethodInvocationException;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.runtime.directive.Directive;
+import org.apache.velocity.runtime.parser.node.Node;
+
+/**
+ * @author alanrw
+ * 
+ */
+public class RequireDirective extends Directive {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.velocity.runtime.directive.Directive#getName()
+	 */
+	@Override
+	public String getName() {
+		return "require";
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.velocity.runtime.directive.Directive#getType()
+	 */
+	@Override
+	public int getType() {
+		return LINE;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.apache.velocity.runtime.directive.Directive#render(org.apache.velocity
+	 * .context.InternalContextAdapter, java.io.Write\ r,
+	 * org.apache.velocity.runtime.parser.node.Node)
+	 */
+	@Override
+	public boolean render(final InternalContextAdapter context,
+			final Writer writer, final Node node) throws IOException,
+			ResourceNotFoundException, ParseErrorException,
+			MethodInvocationException {
+		return true;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/Authorize.vm
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/Authorize.vm b/taverna-interaction-activity/src/main/resources/Authorize.vm
new file mode 100644
index 0000000..ac9a387
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/Authorize.vm
@@ -0,0 +1,73 @@
+#produce("answer")
+<!doctype html>
+<html>
+  <head>
+      <meta charset="utf-8" />
+      <title></title>
+      <style>
+      	html, body { height: 100%; width: 100%; margin: 0; }
+      </style>
+  </head>
+  <body>
+
+       <script type="text/javascript" src="$pmrpcUrl"></script>
+
+       <script type="text/javascript">
+       
+       var sites = {};
+
+#foreach( $value in $loginSites )
+      sites["${value.getName()}"] = "${value.getAuthorizeUrl(${interactionUrl})}";
+#end
+       
+       function forward() {
+         var chosenSiteName = document.myform.mySelect.options[document.myform.mySelect.selectedIndex].value;
+         window.open(sites[chosenSiteName]);
+       }
+       
+           function reply(token) {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["OK", {"answer" : token}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submitted</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submission failed</h1>';}
+           });
+         }
+ 
+          function considerReply() {
+            pmrpc.call({
+              destination : "publish",
+              publicProcedureName : "getParameterValue",
+              params: ["oauth_token"],
+              onSuccess : function(retVal) { if ((retVal.returnValue != null) && (retVal.returnValue != '')) { reply(retVal.returnValue);}}
+           });
+         }
+                  
+         function cancel() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["Cancelled", {}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancelled</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancellation failed</h1>';}
+           });
+	       return true;
+         }
+         
+         window.onload = considerReply();
+       </script>
+  
+  <h2>Please select an authentication site</h2>
+      <form name="myform" onSubmit="forward(); return false;">
+      <select name="mySelect">
+#foreach( $value in $loginSites )
+      <option value="$value.getName()">$value.getName()</option>
+#end
+      </select><br />
+      <input type="button" value="Cancel" onClick = "cancel()"/>
+      <input type="button" value="Submit" onClick = "forward()"/>
+    </form> 
+  </body>
+</html>
+

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.activities.interaction.FeedReader
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.activities.interaction.FeedReader b/taverna-interaction-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.activities.interaction.FeedReader
new file mode 100644
index 0000000..684a478
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.activities.interaction.FeedReader
@@ -0,0 +1,2 @@
+net.sf.taverna.t2.activities.interaction.feed.ShowRequestFeedListener
+net.sf.taverna.t2.activities.interaction.ResponseFeedListener

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.RunDeletionListener
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.RunDeletionListener b/taverna-interaction-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.RunDeletionListener
new file mode 100644
index 0000000..fb7c12a
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.RunDeletionListener
@@ -0,0 +1 @@
+net.sf.taverna.t2.activities.interaction.InteractionRunDeletionListener

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker b/taverna-interaction-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
new file mode 100644
index 0000000..4ee82f4
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker
@@ -0,0 +1 @@
+net.sf.taverna.t2.activities.interaction.InteractionActivityHealthChecker

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/META-INF/spring/interaction-activity-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/META-INF/spring/interaction-activity-context-osgi.xml b/taverna-interaction-activity/src/main/resources/META-INF/spring/interaction-activity-context-osgi.xml
new file mode 100644
index 0000000..f3a35e0
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/META-INF/spring/interaction-activity-context-osgi.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans:beans xmlns="http://www.springframework.org/schema/osgi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:beans="http://www.springframework.org/schema/beans"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans
+                                 http://www.springframework.org/schema/beans/spring-beans.xsd
+                                 http://www.springframework.org/schema/osgi
+                                 http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+	<service ref="interactionActivityHealthChecker" interface="net.sf.taverna.t2.workflowmodel.health.HealthChecker" />
+
+	<service ref="interactionActivityFactory" interface="net.sf.taverna.t2.workflowmodel.processor.activity.ActivityFactory" />
+
+	<reference id="credentialManager" interface="net.sf.taverna.t2.security.credentialmanager.CredentialManager" />
+
+  <reference id="applicationConfiguration"
+         interface="uk.org.taverna.configuration.app.ApplicationConfiguration" />
+
+		
+	<service ref="interactionRunDeletionListener" interface="net.sf.taverna.t2.workflowmodel.RunDeletionListener" />
+
+</beans:beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/META-INF/spring/interaction-activity-context.xml
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/META-INF/spring/interaction-activity-context.xml b/taverna-interaction-activity/src/main/resources/META-INF/spring/interaction-activity-context.xml
new file mode 100644
index 0000000..a629d65
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/META-INF/spring/interaction-activity-context.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans
+                           http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+	<bean id="interactionActivityHealthChecker" class="net.sf.taverna.t2.activities.interaction.InteractionActivityHealthChecker" />
+
+	<bean id="interactionActivityFactory" class="net.sf.taverna.t2.activities.interaction.InteractionActivityFactory">
+		<property name="credentialManager" ref="credentialManager" />
+		<property name="interactionRecorder" ref="interactionRecorder" />
+		<property name="interactionUtils" ref="interactionUtils" />
+		<property name="interactionJetty" ref="interactionJetty" />
+		<property name="interactionPreference" ref="interactionPreference" />
+		<property name="responseFeedListener" ref="responseFeedListener"/>
+		<property name="interactionVelocity" ref="interactionVelocity" />
+	</bean>
+	
+	<bean id="interactionUtils" class="net.sf.taverna.t2.activities.interaction.InteractionUtils">
+		<property name="appConfig" ref="applicationConfiguration" />
+		<property name="interactionRecorder" ref="interactionRecorder" />
+		<property name="interactionPreference" ref="interactionPreference" />
+	</bean>
+	
+	<bean id="interactionRecorder" class="net.sf.taverna.t2.activities.interaction.InteractionRecorder">
+		<property name="interactionUtils" ref="interactionUtils" />
+	</bean>
+	
+	<bean id="interactionRunDeletionListener" class="net.sf.taverna.t2.activities.interaction.InteractionRunDeletionListener">
+		<property name="interactionRecorder" ref="interactionRecoder"/>
+	</bean>
+	
+	<bean id="responseFeedListener" class="net.sf.taverna.t2.activities.interaction.ResponseFeedListener">
+		<property name="interactionRecorder" ref="interactionRecorder"/>
+		<property name="interactionPreference" ref="interactionPreference" />
+	</bean>
+	
+	<bean id="showRequestFeedListener" class="net.sf.taverna.t2.activities.interaction.feed.ShowRequestFeedListener">
+		<property name="interactionPreference" ref="interactionPreference" />
+	</bean>
+	
+	<bean id="interactionJetty" class="net.sf.taverna.t2.activities.interaction.jetty.InteractionJetty">
+		<property name="interactionUtils" ref="interactionUtils" />
+		<property name="responseFeedListener" ref="responseFeedListener"/>
+		<property name="showRequestFeedListener" ref="showRequestFeedListener"/>
+		<property name="interactionPreference" ref="interactionPreference" />
+	</bean>
+	
+	<bean id="hackedFilesystemAdapter" class="net.sf.taverna.t2.activities.interaction.jetty.HackedFilesystemAdapter">
+		<property name="interactionJetty" ref="interactionJetty"/>
+	</bean>
+	
+	<bean id="interactionPreference" class="net.sf.taverna.t2.activities.interaction.preference.InteractionPreference">
+		<constructor-arg ref="applicationConfiguration" />
+	</bean>
+	
+	<bean id="interactionVelocity"
+		class="net.sf.taverna.t2.activities.interaction.velocity.InteractionVelocity"
+		init-method="checkVelocity">
+	</bean>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/MasterPassword.vm
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/MasterPassword.vm b/taverna-interaction-activity/src/main/resources/MasterPassword.vm
new file mode 100644
index 0000000..94e7859
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/MasterPassword.vm
@@ -0,0 +1,47 @@
+#produce("password")
+<!doctype html>
+<html>
+  <head>
+      <meta charset="utf-8" />
+      <title></title>
+   </head>
+  <body>
+
+       <script type="text/javascript" src="$pmrpcUrl"></script>
+
+       <script type="text/javascript">
+
+         function reply() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["OK", {"password" : document.myform.password.value}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submitted</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submission failed</h1>';}
+           });
+	       return true;
+         }
+         
+         function cancel() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["Cancelled", {}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancelled</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancellation failed</h1>';}
+           });
+	       return true;
+         }
+
+       </script>
+  
+  <h2>Credential Manager request</h2>
+    <p>Please enter the master password for the Credential Manager</p>
+    <form name="myform" onSubmit="reply(); return false;">
+      <label>Password<input type="password" name="password"/></label><br />
+      <input type="button" value="Cancel" onClick = "cancel()"/>
+      <input type="button" value="Submit" onClick = "reply()"/>
+    </form> 
+  </body>
+</html>
+

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/TrustedCertificate.vm
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/TrustedCertificate.vm b/taverna-interaction-activity/src/main/resources/TrustedCertificate.vm
new file mode 100644
index 0000000..44a5359
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/TrustedCertificate.vm
@@ -0,0 +1,57 @@
+#require("serviceURI")
+#require("requestingPrompt")
+#produce("username")
+#produce("password")
+#produce("shouldSave")
+<!doctype html>
+<html>
+  <head>
+      <meta charset="utf-8" />
+      <title></title>
+   </head>
+  <body>
+
+       <script type="text/javascript" src="$pmrpcUrl"></script>
+
+       <script type="text/javascript">
+
+         function reply() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["OK", {"username" : document.myform.username.value,
+                              "password" : document.myform.password.value,
+                              "shouldsave" : document.myform.shouldsave.checked}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submitted</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submission failed</h1>';}
+           });
+	       return true;
+         }
+         
+         function cancel() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["Cancelled", {}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancelled</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancellation failed</h1>';}
+           });
+	       return true;
+         }
+
+       </script>
+  
+  <h2>Credential Manager request</h2>
+    <p>The credential manager could not find a username and password for the service at <code>$!serviceURI</code></p>
+    <p>$!requestingPrompt</p>
+    <p>Please provide a username and password</p>
+    <form name="myform" onSubmit="reply(); return false;">
+      <label>User name<input type="text" name="username"/></label><br />
+      <label>Password<input type="password" name="password"/></label><br />
+      <label>Save in credental manager<input type="checkbox" name="shouldsave"/></label><br />
+      <input type="button" value="Cancel" onClick = "cancel()"/>
+      <input type="button" value="Submit" onClick = "reply()"/>
+    </form> 
+  </body>
+</html>
+

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/TruststorePassword.vm
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/TruststorePassword.vm b/taverna-interaction-activity/src/main/resources/TruststorePassword.vm
new file mode 100644
index 0000000..6106115
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/TruststorePassword.vm
@@ -0,0 +1,48 @@
+#produce("password")
+<!doctype html>
+<html>
+  <head>
+      <meta charset="utf-8" />
+      <title></title>
+   </head>
+  <body>
+
+       <script type="text/javascript" src="$pmrpcUrl"></script>
+
+       <script type="text/javascript">
+
+         function reply() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["OK", {"password" : document.myform.password.value}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submitted</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submission failed</h1>';}
+           });
+	       return true;
+         }
+         
+         function cancel() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["Cancelled", {}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancelled</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancellation failed</h1>';}
+           });
+	       return true;
+         }
+
+       </script>
+  
+  <h2>Credential Manager request</h2>
+    <p>The Credential Manager needs to copy certificates from the Java truststore.</p>
+    <p>Please enter the truststore password</p>
+    <form name="myform" onSubmit="reply(); return false;">
+      <label>Password<input type="password" name="password"/></label><br />
+      <input type="button" value="Cancel" onClick = "cancel()"/>
+      <input type="button" value="Submit" onClick = "reply()"/>
+    </form> 
+  </body>
+</html>
+

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/UsernamePassword.vm
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/UsernamePassword.vm b/taverna-interaction-activity/src/main/resources/UsernamePassword.vm
new file mode 100644
index 0000000..671c3ee
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/UsernamePassword.vm
@@ -0,0 +1,57 @@
+#require("serviceURI")
+#require("requestingPrompt")
+#produce("username")
+#produce("password")
+#produce("shouldSave")
+<!doctype html>
+<html>
+  <head>
+      <meta charset="UTF-8" />
+      <title></title>
+   </head>
+  <body>
+
+       <script type="text/javascript" src="$pmrpcUrl"></script>
+
+       <script type="text/javascript">
+
+         function reply() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["OK", {"username" : document.myform.username.value,
+                              "password" : document.myform.password.value,
+                              "shouldsave" : document.myform.shouldsave.checked}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submitted</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submission failed</h1>';}
+           });
+	       return true;
+         }
+         
+         function cancel() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["Cancelled", {}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancelled</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancellation failed</h1>';}
+           });
+	       return true;
+         }
+
+       </script>
+  
+  <h2>Credential Manager request</h2>
+    <p>The credential manager could not find a username and password for the service at <code>$!serviceURI</code></p>
+    <p>$!requestingPrompt</p>
+    <p>Please provide a username and password</p>
+    <form name="myform" onSubmit="reply(); return false;">
+      <label>User name<input type="text" name="username"/></label><br />
+      <label>Password<input type="password" name="password"/></label><br />
+      <label>Save in credental manager<input type="checkbox" name="shouldsave"/></label><br />
+      <input type="button" value="Cancel" onClick = "cancel()"/>
+      <input type="button" value="Submit" onClick = "reply()"/>
+    </form> 
+  </body>
+</html>
+

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/abdera/adapter/feed.properties
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/abdera/adapter/feed.properties b/taverna-interaction-activity/src/main/resources/abdera/adapter/feed.properties
new file mode 100644
index 0000000..3371f38
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/abdera/adapter/feed.properties
@@ -0,0 +1,5 @@
+subUri=feed
+adapterClassName=net.sf.taverna.t2.activities.interaction.jetty.HackedFilesystemAdapter
+title=Taverna interaction
+author=alanrw
+configFile=dummyFileLocation
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/ask.vm
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/ask.vm b/taverna-interaction-activity/src/main/resources/ask.vm
new file mode 100644
index 0000000..92ce145
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/ask.vm
@@ -0,0 +1,51 @@
+#require("message")
+#require("title")
+#produce("answer")
+<!doctype html>
+<html>
+  <head>
+      <meta charset="UTF-8" />
+      <title></title>
+   </head>
+  <body>
+
+       <script type="text/javascript" src="$pmrpcUrl"></script>
+
+       <script type="text/javascript">
+
+         function reply() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["OK", {"answer" : document.myform.answerInput.value}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submitted</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submission failed</h1>';}
+           });
+	       return true;
+         }
+         
+         function cancel() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["Cancelled", {}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancelled</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancellation failed</h1>';}
+           });
+	       return true;
+         }
+         pmrpc.call({
+           destination : "publish",
+           publicProcedureName : "setTitle",
+           params : ["$!title"]});
+       </script>
+  
+  <h2>$!message</h2>
+    <form name="myform" onSubmit="reply(); return false;">
+      <input type="text" name="answerInput"/><br />
+      <input type="button" value="Cancel" onClick = "cancel()"/>
+      <input type="button" value="Submit" onClick = "reply()"/>
+    </form> 
+  </body>
+</html>
+

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/choose.vm
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/choose.vm b/taverna-interaction-activity/src/main/resources/choose.vm
new file mode 100644
index 0000000..f594beb
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/choose.vm
@@ -0,0 +1,74 @@
+#require("selectionValues",1)
+#require("message")
+#require("title")
+#produce("answer")
+<!doctype html>
+<html>
+  <head>
+      <meta charset="utf-8" />
+      <title></title>
+      <style>
+      </style>
+  </head>
+  <body>
+
+       <script type="text/javascript" src="$pmrpcUrl"></script>
+
+       <script type="text/javascript">
+
+         function reply() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["OK", {"answer" : getSelectedItem()}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submitted</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Data submission failed</h1>';}
+           });
+	       return true;
+         }
+         
+         function getSelectedItem() {
+           chosen = "";
+           theForm = document.myform;
+           buttons = document.getElementsByTagName('input');
+           for (i = 0; i <buttons.length; i++) {
+             if ((buttons[i].type == 'radio') && buttons[i].checked) {
+               chosen = buttons[i].value
+             }
+           }
+
+           if (chosen == "") {
+             alert("No Location Chosen")
+           }
+           return chosen;
+         }
+         
+         function cancel() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["Cancelled", {}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancelled</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancellation failed</h1>';}
+           });
+	       return true;
+         }
+
+         pmrpc.call({
+           destination : "publish",
+           publicProcedureName : "setTitle",
+           params : ["$!title"]});
+           
+       </script>
+  
+  <h2>$!message</h2>
+    <form name="myform" onSubmit="reply(); return false;">
+#foreach( $value in $selectionValues )
+      <label>$value<input type="radio" name="group" value="$value" /></label><br />  
+#end
+      <input type="button" value="Cancel" onClick = "cancel()"/>
+      <input type="button" value="Submit" onClick = "reply()"/>
+    </form> 
+  </body>
+</html>
+

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/index
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/index b/taverna-interaction-activity/src/main/resources/index
new file mode 100644
index 0000000..8d3d1bc
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/index
@@ -0,0 +1,15 @@
+ask
+choose
+notify
+select
+#select_file
+tell
+warn
+interaction
+#Authorize
+#UsernamePassword
+#MasterPassword
+#TruststorePassword
+#TrustedCertificate
+
+

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/interaction.css
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/interaction.css b/taverna-interaction-activity/src/main/resources/interaction.css
new file mode 100644
index 0000000..a6e3301
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/interaction.css
@@ -0,0 +1,5 @@
+      	html, body { height: 100%; width: 100%; margin: 0; border:0; }
+      	#presentationFrame, #presentationDiv { height: 90%; width: 95%; margin: 0; border:0; frameborder:0; }
+     	#acknowledgment { width: 95%; margin: 0; border:0; frameborder:0; background-color: #eeeb99; color: #555555; text-align:center; }
+     	#acknowledgment p {padding: 10px;}
+     	
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/interaction.vm
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/interaction.vm b/taverna-interaction-activity/src/main/resources/interaction.vm
new file mode 100644
index 0000000..b2d71e1
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/interaction.vm
@@ -0,0 +1,168 @@
+<!doctype html>
+<html>
+  <head>
+      <meta charset="utf-8" />
+      <title></title>
+      <link rel="stylesheet" type="text/css" href="interaction.css">
+       <script type="text/javascript" src="$pmrpcUrl"></script>
+       
+  </head>
+  <body>
+  
+       <script type="text/javascript">
+       
+       var appendError = function(str){
+         throw new Error("DEBUG: "+str)
+       }
+
+       function log(str){
+         setTimeout("appendError('"+str+"')", 1)
+       }
+       
+         function createReplyContent(status) {
+           date = new Date();
+           msg = "";
+           msg += "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
+           msg += "<entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:thr=\"http://purl.org/syndication/thread/1.0\">\n";
+           msg += "<title>\"A reply to " + "$entryId" + "\"</title>\n";
+           msg += "<id>" + "$entryId" + "reply" + "</id>\n";
+           msg += "<content/>\n";
+           msg += "<interaction:run-id xmlns:interaction=\"http://ns.taverna.org.uk/2012/interaction\">" + "$runId" + "</interaction:run-id>\n";
+           msg += "<interaction:in-reply-to  xmlns:interaction=\"http://ns.taverna.org.uk/2012/interaction\">" + "$entryId" + "</interaction:in-reply-to>\n";
+           msg += "<interaction:result-status xmlns:interaction=\"http://ns.taverna.org.uk/2012/interaction\">";
+           msg += escape(status);
+           msg += "</interaction:result-status>";
+          msg += "</entry>\n";
+           return msg;
+         }
+
+       // Copied from http://www.netlobo.com/url_query_string_javascript.html
+       function getParameterValue( name )
+	{
+  	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
+  	var regexS = "[\\?&]"+name+"=([^&#]*)";
+  	var regex = new RegExp( regexS );
+  	var results = regex.exec( window.location.href );
+  	if( results == null )
+    	return "";
+  	else
+    	return results[1];
+	}
+
+
+         function reply(status, results) {
+             document.getElementById('presentationDiv').innerHTML="<p>Returning results</p>";
+#if ($outputDataUrl)
+           var outputData = JSON.stringify(results);
+           var dataRequest = new XMLHttpRequest();
+           dataRequest.open("PUT", "$outputDataUrl", false);
+           dataRequest.setRequestHeader("Content-Type", "application/json");
+           dataRequest.send(outputData);
+#end           
+           var msg = createReplyContent(status);
+           var xmlhttp = new XMLHttpRequest();
+           xmlhttp.open("POST", "$feed", false);
+           xmlhttp.setRequestHeader("Content-Type", "application/atom+xml;type=entry");
+           xmlhttp.setRequestHeader("Slug", "$entryId" + "-reply");
+           xmlhttp.send(msg);
+           var shownMessage = 'Returned results';
+           if (status != 'OK') {
+             shownMessage = status;
+           }
+           document.getElementById('presentationDiv').innerHTML="<p>" + shownMessage + "</p>";
+             
+           return false;
+         }
+         
+
+	  function getDataFromUrl(url, type) {
+	      var xmlhttp = new XMLHttpRequest();
+	      xmlhttp.open("GET", url, false);
+	      if (type != null) {
+			if (xmlhttp.overrideMimeType){
+				xmlhttp.overrideMimeType(type);
+			}
+			else{
+				xmlhttp.setRequestHeader("Content-Type",type);
+			}
+		  }
+	      xmlhttp.send();
+	      if (xmlhttp.status != 200) {
+	      	return '';
+	      }
+	      return xmlhttp.responseText;
+	  }
+	  
+	  var inputData = null;
+	  
+      function registerCalls() {
+			pmrpc.register( {
+         	  publicProcedureName : "reply",
+         	  procedure : function(status, results) {
+         	     reply(status, results);
+         	     return "OK";
+         	  }
+           });
+ 
+ 			pmrpc.register( {
+         	  publicProcedureName : "getParameterValue",
+         	  procedure : function(parameterName) {
+         	     return getParameterValue(parameterName);
+         	  }
+           });
+           
+           inputData = JSON.parse(getDataFromUrl('$inputDataUrl', "application/json"));
+         
+           pmrpc.register( {
+             publicProcedureName : "getInputData",
+             procedure : function() {
+//               log("Returning input data");
+#if (!$outputDataUrl)
+               reply("OK", {});
+#end
+               return inputData;
+             }
+           });
+         
+           pmrpc.register( {
+             publicProcedureName : "getWorkflowRunId",
+             procedure : function () {
+               return '$runId';
+             }
+           });
+ 
+         pmrpc.register( {
+         	publicProcedureName : "setTitle",
+         	procedure : function(title) {
+         	   document.title = title;
+         	   return "OK";
+         	}
+         });
+         
+         pmrpc.register( {
+         	publicProcedureName : "getDataFromUrl",
+         	procedure : function(url, type) {
+         		return getDataFromUrl(url, type);
+         	}
+         });
+
+         document.getElementById('presentationFrame').src = "$presentationUrl";
+         document.title = 'Taverna interaction';
+       }
+       
+       window.onload = function() {
+//           log("Interaction loaded");
+           registerCalls();
+           };
+      
+  	   </script>      
+ 
+     <div id="presentationDiv">
+       <iframe id="presentationFrame" name="presentationFrame" src="about:blank">
+</iframe>
+     </div>
+     <div id="acknowledgment">
+       <p>The interaction service was developed in the <a href="http://www.biovel.eu" target="_blank">BioVeL project</a></p>
+     </div>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/json2.js
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/json2.js b/taverna-interaction-activity/src/main/resources/json2.js
new file mode 100644
index 0000000..2dbf60d
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/json2.js
@@ -0,0 +1,487 @@
+/*
+    http://www.JSON.org/json2.js
+    2011-10-19
+
+    Public Domain.
+
+    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+
+    See http://www.JSON.org/js.html
+
+
+    This code should be minified before deployment.
+    See http://javascript.crockford.com/jsmin.html
+
+    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
+    NOT CONTROL.
+
+
+    This file creates a global JSON object containing two methods: stringify
+    and parse.
+
+        JSON.stringify(value, replacer, space)
+            value       any JavaScript value, usually an object or array.
+
+            replacer    an optional parameter that determines how object
+                        values are stringified for objects. It can be a
+                        function or an array of strings.
+
+            space       an optional parameter that specifies the indentation
+                        of nested structures. If it is omitted, the text will
+                        be packed without extra whitespace. If it is a number,
+                        it will specify the number of spaces to indent at each
+                        level. If it is a string (such as '\t' or '&nbsp;'),
+                        it contains the characters used to indent at each level.
+
+            This method produces a JSON text from a JavaScript value.
+
+            When an object value is found, if the object contains a toJSON
+            method, its toJSON method will be called and the result will be
+            stringified. A toJSON method does not serialize: it returns the
+            value represented by the name/value pair that should be serialized,
+            or undefined if nothing should be serialized. The toJSON method
+            will be passed the key associated with the value, and this will be
+            bound to the value
+
+            For example, this would serialize Dates as ISO strings.
+
+                Date.prototype.toJSON = function (key) {
+                    function f(n) {
+                        // Format integers to have at least two digits.
+                        return n < 10 ? '0' + n : n;
+                    }
+
+                    return this.getUTCFullYear()   + '-' +
+                         f(this.getUTCMonth() + 1) + '-' +
+                         f(this.getUTCDate())      + 'T' +
+                         f(this.getUTCHours())     + ':' +
+                         f(this.getUTCMinutes())   + ':' +
+                         f(this.getUTCSeconds())   + 'Z';
+                };
+
+            You can provide an optional replacer method. It will be passed the
+            key and value of each member, with this bound to the containing
+            object. The value that is returned from your method will be
+            serialized. If your method returns undefined, then the member will
+            be excluded from the serialization.
+
+            If the replacer parameter is an array of strings, then it will be
+            used to select the members to be serialized. It filters the results
+            such that only members with keys listed in the replacer array are
+            stringified.
+
+            Values that do not have JSON representations, such as undefined or
+            functions, will not be serialized. Such values in objects will be
+            dropped; in arrays they will be replaced with null. You can use
+            a replacer function to replace those with JSON values.
+            JSON.stringify(undefined) returns undefined.
+
+            The optional space parameter produces a stringification of the
+            value that is filled with line breaks and indentation to make it
+            easier to read.
+
+            If the space parameter is a non-empty string, then that string will
+            be used for indentation. If the space parameter is a number, then
+            the indentation will be that many spaces.
+
+            Example:
+
+            text = JSON.stringify(['e', {pluribus: 'unum'}]);
+            // text is '["e",{"pluribus":"unum"}]'
+
+
+            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
+            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
+
+            text = JSON.stringify([new Date()], function (key, value) {
+                return this[key] instanceof Date ?
+                    'Date(' + this[key] + ')' : value;
+            });
+            // text is '["Date(---current time---)"]'
+
+
+        JSON.parse(text, reviver)
+            This method parses a JSON text to produce an object or array.
+            It can throw a SyntaxError exception.
+
+            The optional reviver parameter is a function that can filter and
+            transform the results. It receives each of the keys and values,
+            and its return value is used instead of the original value.
+            If it returns what it received, then the structure is not modified.
+            If it returns undefined then the member is deleted.
+
+            Example:
+
+            // Parse the text. Values that look like ISO date strings will
+            // be converted to Date objects.
+
+            myData = JSON.parse(text, function (key, value) {
+                var a;
+                if (typeof value === 'string') {
+                    a =
+/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
+                    if (a) {
+                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+                            +a[5], +a[6]));
+                    }
+                }
+                return value;
+            });
+
+            myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
+                var d;
+                if (typeof value === 'string' &&
+                        value.slice(0, 5) === 'Date(' &&
+                        value.slice(-1) === ')') {
+                    d = new Date(value.slice(5, -1));
+                    if (d) {
+                        return d;
+                    }
+                }
+                return value;
+            });
+
+
+    This is a reference implementation. You are free to copy, modify, or
+    redistribute.
+*/
+
+/*jslint evil: true, regexp: true */
+
+/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
+    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
+    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
+    lastIndex, length, parse, prototype, push, replace, slice, stringify,
+    test, toJSON, toString, valueOf
+*/
+
+
+// Create a JSON object only if one does not already exist. We create the
+// methods in a closure to avoid creating global variables.
+
+var JSON;
+if (!JSON) {
+    JSON = {};
+}
+
+(function () {
+    'use strict';
+
+    function f(n) {
+        // Format integers to have at least two digits.
+        return n < 10 ? '0' + n : n;
+    }
+
+    if (typeof Date.prototype.toJSON !== 'function') {
+
+        Date.prototype.toJSON = function (key) {
+
+            return isFinite(this.valueOf())
+                ? this.getUTCFullYear()     + '-' +
+                    f(this.getUTCMonth() + 1) + '-' +
+                    f(this.getUTCDate())      + 'T' +
+                    f(this.getUTCHours())     + ':' +
+                    f(this.getUTCMinutes())   + ':' +
+                    f(this.getUTCSeconds())   + 'Z'
+                : null;
+        };
+
+        String.prototype.toJSON      =
+            Number.prototype.toJSON  =
+            Boolean.prototype.toJSON = function (key) {
+                return this.valueOf();
+            };
+    }
+
+    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+        gap,
+        indent,
+        meta = {    // table of character substitutions
+            '\b': '\\b',
+            '\t': '\\t',
+            '\n': '\\n',
+            '\f': '\\f',
+            '\r': '\\r',
+            '"' : '\\"',
+            '\\': '\\\\'
+        },
+        rep;
+
+
+    function quote(string) {
+
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can safely slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe escape
+// sequences.
+
+        escapable.lastIndex = 0;
+        return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
+            var c = meta[a];
+            return typeof c === 'string'
+                ? c
+                : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+        }) + '"' : '"' + string + '"';
+    }
+
+
+    function str(key, holder) {
+
+// Produce a string from holder[key].
+
+        var i,          // The loop counter.
+            k,          // The member key.
+            v,          // The member value.
+            length,
+            mind = gap,
+            partial,
+            value = holder[key];
+
+// If the value has a toJSON method, call it to obtain a replacement value.
+
+        if (value && typeof value === 'object' &&
+                typeof value.toJSON === 'function') {
+            value = value.toJSON(key);
+        }
+
+// If we were called with a replacer function, then call the replacer to
+// obtain a replacement value.
+
+        if (typeof rep === 'function') {
+            value = rep.call(holder, key, value);
+        }
+
+// What happens next depends on the value's type.
+
+        switch (typeof value) {
+        case 'string':
+            return quote(value);
+
+        case 'number':
+
+// JSON numbers must be finite. Encode non-finite numbers as null.
+
+            return isFinite(value) ? String(value) : 'null';
+
+        case 'boolean':
+        case 'null':
+
+// If the value is a boolean or null, convert it to a string. Note:
+// typeof null does not produce 'null'. The case is included here in
+// the remote chance that this gets fixed someday.
+
+            return String(value);
+
+// If the type is 'object', we might be dealing with an object or an array or
+// null.
+
+        case 'object':
+
+// Due to a specification blunder in ECMAScript, typeof null is 'object',
+// so watch out for that case.
+
+            if (!value) {
+                return 'null';
+            }
+
+// Make an array to hold the partial results of stringifying this object value.
+
+            gap += indent;
+            partial = [];
+
+// Is the value an array?
+
+            if (Object.prototype.toString.apply(value) === '[object Array]') {
+
+// The value is an array. Stringify every element. Use null as a placeholder
+// for non-JSON values.
+
+                length = value.length;
+                for (i = 0; i < length; i += 1) {
+                    partial[i] = str(i, value) || 'null';
+                }
+
+// Join all of the elements together, separated with commas, and wrap them in
+// brackets.
+
+                v = partial.length === 0
+                    ? '[]'
+                    : gap
+                    ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
+                    : '[' + partial.join(',') + ']';
+                gap = mind;
+                return v;
+            }
+
+// If the replacer is an array, use it to select the members to be stringified.
+
+            if (rep && typeof rep === 'object') {
+                length = rep.length;
+                for (i = 0; i < length; i += 1) {
+                    if (typeof rep[i] === 'string') {
+                        k = rep[i];
+                        v = str(k, value);
+                        if (v) {
+                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
+                        }
+                    }
+                }
+            } else {
+
+// Otherwise, iterate through all of the keys in the object.
+
+                for (k in value) {
+                    if (Object.prototype.hasOwnProperty.call(value, k)) {
+                        v = str(k, value);
+                        if (v) {
+                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
+                        }
+                    }
+                }
+            }
+
+// Join all of the member texts together, separated with commas,
+// and wrap them in braces.
+
+            v = partial.length === 0
+                ? '{}'
+                : gap
+                ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
+                : '{' + partial.join(',') + '}';
+            gap = mind;
+            return v;
+        }
+    }
+
+// If the JSON object does not yet have a stringify method, give it one.
+
+    if (typeof JSON.stringify !== 'function') {
+        JSON.stringify = function (value, replacer, space) {
+
+// The stringify method takes a value and an optional replacer, and an optional
+// space parameter, and returns a JSON text. The replacer can be a function
+// that can replace values, or an array of strings that will select the keys.
+// A default replacer method can be provided. Use of the space parameter can
+// produce text that is more easily readable.
+
+            var i;
+            gap = '';
+            indent = '';
+
+// If the space parameter is a number, make an indent string containing that
+// many spaces.
+
+            if (typeof space === 'number') {
+                for (i = 0; i < space; i += 1) {
+                    indent += ' ';
+                }
+
+// If the space parameter is a string, it will be used as the indent string.
+
+            } else if (typeof space === 'string') {
+                indent = space;
+            }
+
+// If there is a replacer, it must be a function or an array.
+// Otherwise, throw an error.
+
+            rep = replacer;
+            if (replacer && typeof replacer !== 'function' &&
+                    (typeof replacer !== 'object' ||
+                    typeof replacer.length !== 'number')) {
+                throw new Error('JSON.stringify');
+            }
+
+// Make a fake root object containing our value under the key of ''.
+// Return the result of stringifying the value.
+
+            return str('', {'': value});
+        };
+    }
+
+
+// If the JSON object does not yet have a parse method, give it one.
+
+    if (typeof JSON.parse !== 'function') {
+        JSON.parse = function (text, reviver) {
+
+// The parse method takes a text and an optional reviver function, and returns
+// a JavaScript value if the text is a valid JSON text.
+
+            var j;
+
+            function walk(holder, key) {
+
+// The walk method is used to recursively walk the resulting structure so
+// that modifications can be made.
+
+                var k, v, value = holder[key];
+                if (value && typeof value === 'object') {
+                    for (k in value) {
+                        if (Object.prototype.hasOwnProperty.call(value, k)) {
+                            v = walk(value, k);
+                            if (v !== undefined) {
+                                value[k] = v;
+                            } else {
+                                delete value[k];
+                            }
+                        }
+                    }
+                }
+                return reviver.call(holder, key, value);
+            }
+
+
+// Parsing happens in four stages. In the first stage, we replace certain
+// Unicode characters with escape sequences. JavaScript handles many characters
+// incorrectly, either silently deleting them, or treating them as line endings.
+
+            text = String(text);
+            cx.lastIndex = 0;
+            if (cx.test(text)) {
+                text = text.replace(cx, function (a) {
+                    return '\\u' +
+                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+                });
+            }
+
+// In the second stage, we run the text against regular expressions that look
+// for non-JSON patterns. We are especially concerned with '()' and 'new'
+// because they can cause invocation, and '=' because it can cause mutation.
+// But just to be safe, we want to reject all unexpected forms.
+
+// We split the second stage into 4 regexp operations in order to work around
+// crippling inefficiencies in IE's and Safari's regexp engines. First we
+// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
+// replace all simple value tokens with ']' characters. Third, we delete all
+// open brackets that follow a colon or comma or that begin the text. Finally,
+// we look to see that the remaining characters are only whitespace or ']' or
+// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
+
+            if (/^[\],:{}\s]*$/
+                    .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
+                        .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
+                        .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
+
+// In the third stage we use the eval function to compile the text into a
+// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
+// in JavaScript: it can begin a block or an object literal. We wrap the text
+// in parens to eliminate the ambiguity.
+
+                j = eval('(' + text + ')');
+
+// In the optional fourth stage, we recursively walk the new structure, passing
+// each name/value pair to a reviver function for possible transformation.
+
+                return typeof reviver === 'function'
+                    ? walk({'': j}, '')
+                    : j;
+            }
+
+// If the text is not JSON parseable, then a SyntaxError is thrown.
+
+            throw new SyntaxError('JSON.parse');
+        };
+    }
+}());

http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/390c286b/taverna-interaction-activity/src/main/resources/notify.vm
----------------------------------------------------------------------
diff --git a/taverna-interaction-activity/src/main/resources/notify.vm b/taverna-interaction-activity/src/main/resources/notify.vm
new file mode 100644
index 0000000..a144ccc
--- /dev/null
+++ b/taverna-interaction-activity/src/main/resources/notify.vm
@@ -0,0 +1,39 @@
+#require("message")
+#require("title")
+#notify
+<!doctype html>
+<html>
+  <head>
+      <meta charset="utf-8" />
+      <title></title>
+      <style>
+      </style>
+  </head>
+  <body>
+
+       <script type="text/javascript" src="$pmrpcUrl"></script>
+
+       <script type="text/javascript">
+         
+         function cancel() {
+           pmrpc.call({
+             destination : "publish",
+             publicProcedureName : "reply",
+             params : ["Cancelled", {}],
+             onSuccess : function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancelled</h1>';},
+             onFailure: function() {document.getElementsByTagName('body')[0].innerHTML='<h1>Cancellation failed</h1>';}
+           });
+	       return true;
+         }
+         
+         pmrpc.call({
+           destination : "publish",
+           publicProcedureName : "setTitle",
+           params : ["$!title"]});
+
+       </script>
+  
+  <h2>Message: $!message</h2>
+  </body>
+</html>
+