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:09:43 UTC

[08/54] [partial] incubator-taverna-engine git commit: Revert "temporarily empty repository"

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/pom.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-api/pom.xml b/taverna-reference-api/pom.xml
new file mode 100644
index 0000000..1c2664d
--- /dev/null
+++ b/taverna-reference-api/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>org.apache.taverna.engine</groupId>
+		<artifactId>taverna-engine</artifactId>
+		<version>3.1.0-incubating-SNAPSHOT</version>
+	</parent>
+	<artifactId>taverna-reference-api</artifactId>
+	<packaging>bundle</packaging>
+	<name>Apache Taverna Reference Manager API</name>
+	<description>
+		Core APIs and extension points for the T2 reference manager.
+		This includes the SPIs for external references, translators and
+		publishers.
+	</description>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-bundle-plugin</artifactId>
+				<configuration>
+					<instructions>
+						<Import-Package>
+						org.hibernate.proxy;resolution:=optional,
+						org.springframework.transaction.*;resolution:=optional, *
+						</Import-Package>
+					</instructions>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+	<dependencies>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>org.springframework.transaction</artifactId>
+			<version>${spring.version}</version>
+		</dependency>
+	</dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/AbstractExternalReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/AbstractExternalReference.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/AbstractExternalReference.java
new file mode 100644
index 0000000..599d0bb
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/AbstractExternalReference.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+import static net.sf.taverna.t2.reference.ReferencedDataNature.*;
+
+/**
+ * A trivial implementation of ExternalReference. This abstract class should be
+ * used as the superclass of any ExternalReference implementations as it
+ * provides base metadata for the hibernate-based persistence system used by the
+ * main reference manager implementation. While the interface contract cannot
+ * require this your extensions will likely not work properly unless you use
+ * this class.
+ * 
+ * @author Tom Oinn
+ */
+public abstract class AbstractExternalReference implements ExternalReferenceSPI {
+	// Used internally by Hibernate for this class and subclasses
+	private int primaryKey;
+
+	/**
+	 * Used by Hibernate internally to establish a foreign key relationship
+	 * between this abstract superclass and tables corresponding to
+	 * implementations of the ExternalReference interface. Has no impact on any
+	 * application level code, this method is only ever used by the internals of
+	 * the hibernate framework.
+	 */
+	public final void setPrimaryKey(int newKey) {
+		this.primaryKey = newKey;
+	}
+
+	/**
+	 * Used by Hibernate internally to establish a foreign key relationship
+	 * between this abstract superclass and tables corresponding to
+	 * implementations of the ExternalReference interface. Has no impact on any
+	 * application level code, this method is only ever used by the internals of
+	 * the hibernate framework.
+	 */
+	public final int getPrimaryKey() {
+		return this.primaryKey;
+	}
+
+	/**
+	 * Default to returning DataReferenceNature.UNKNOWN
+	 */
+	@Override
+	public ReferencedDataNature getDataNature() {
+		return UNKNOWN;
+	}
+
+	/**
+	 * Default to returning null for charset
+	 */
+	@Override
+	public String getCharset() {
+		return null;
+	}
+
+	/**
+	 * Default to a value of 0.0f for the resolution cost, but implementations
+	 * should at least attempt to set this to a more sensible level!
+	 */
+	@Override
+	public float getResolutionCost() {
+		return 0.0f;
+	}
+
+	@Override
+	public abstract ExternalReferenceSPI clone()
+			throws CloneNotSupportedException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ContextualizedT2Reference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ContextualizedT2Reference.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ContextualizedT2Reference.java
new file mode 100644
index 0000000..a5699b0
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ContextualizedT2Reference.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+/**
+ * Used by the {@link ReferenceService#traverseFrom(T2Reference, int)} when
+ * traversing a collection structure. Each contextualized t2reference contains
+ * the {@link T2Reference} along with an integer array index representing the
+ * position of that reference within the traversal structure. The index
+ * [i<sub>0</sub>,i<sub>1</sub>,i<sub>2</sub> ... i<sub>n</sub>] is interpreted
+ * such that the reference is located at
+ * parent.get(i<sub>0</sub>).get(i<sub>1</sub
+ * >).get(i<sub>2</sub>)....get(i<sub>n</sub>). If the index is empty then the
+ * T2Reference <em>is</em> the original reference supplied to the
+ * {@link ReferenceService#traverseFrom(T2Reference, int) traverseFrom} method.
+ * 
+ * @author Tom Oinn
+ */
+public interface ContextualizedT2Reference {
+	/**
+	 * @return the T2Reference to which the associated index applies.
+	 */
+	T2Reference getReference();
+
+	/**
+	 * @return the index of this T2Reference
+	 */
+	int[] getIndex();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/DaoException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/DaoException.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/DaoException.java
new file mode 100644
index 0000000..7de38df
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/DaoException.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+/**
+ * Thrown by the Data Access Object interface methods, wrapping any underlying
+ * exception.
+ * 
+ * @author Tom Oinn
+ */
+public class DaoException extends RuntimeException {
+	static final long serialVersionUID = 8496141798637577803L;
+
+	public DaoException() {
+		super();
+	}
+
+	public DaoException(String message) {
+		super(message);
+	}
+
+	public DaoException(Throwable cause) {
+		super(cause);
+	}
+
+	public DaoException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/DereferenceException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/DereferenceException.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/DereferenceException.java
new file mode 100644
index 0000000..d2f814f
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/DereferenceException.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+/**
+ * Thrown when a problem occurs during de-reference of an ExternalReferenceSPI
+ * implementation. This include operations which implicitly de-reference the
+ * reference such as those infering character set or data natures.
+ * 
+ * @author Tom Oinn
+ */
+public class DereferenceException extends RuntimeException {
+	private static final long serialVersionUID = 8054381613840005541L;
+
+	public DereferenceException() {
+		//
+	}
+
+	public DereferenceException(String message) {
+		super(message);
+	}
+
+	public DereferenceException(Throwable cause) {
+		super(cause);
+	}
+
+	public DereferenceException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocument.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocument.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocument.java
new file mode 100644
index 0000000..06a20e3
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocument.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Contains the definition of an error token within the workflow system.
+ * 
+ * @author Tom Oinn
+ * @author David Withers
+ */
+public interface ErrorDocument extends Identified {
+	/**
+	 * If the error document is created from a {@link Throwable} it will have a
+	 * stack trace, in this case the stack trace is represented as a list of
+	 * {@link StackTraceElement} beans
+	 */
+	List<StackTraceElementBean> getStackTraceStrings();
+
+	/**
+	 * If the error document is created from a {@link Throwable}, this contains
+	 * the message part of the {@link Throwable}.
+	 */
+	String getExceptionMessage();
+
+	/**
+	 * Error documents can carry an arbitrary string message, this returns it.
+	 */
+	String getMessage();
+
+	/**
+	 * If the error document is created from set of references that contain
+	 * error documents, this method returns them.
+	 */
+	Set<T2Reference> getErrorReferences();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentDao.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentDao.java
new file mode 100644
index 0000000..72fabf1
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentDao.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+import static org.springframework.transaction.annotation.Propagation.REQUIRED;
+import static org.springframework.transaction.annotation.Propagation.SUPPORTS;
+
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Data access object handling ErrorDocument instances.
+ * 
+ * @author Tom Oinn
+ */
+public interface ErrorDocumentDao {
+	/**
+	 * Store a named ErrorDocument to the database.
+	 * 
+	 * @param errorDoc
+	 *            error document to store
+	 * @throws DaoException
+	 *             if any exception is thrown when connecting to the underlying
+	 *             store or when storing the error document
+	 */
+	@Transactional(propagation = REQUIRED, readOnly = false)
+	void store(ErrorDocument errorDoc) throws DaoException;
+
+	/**
+	 * Retrieves a named and populated ErrorDocument
+	 * 
+	 * @param reference
+	 *            id of the error document to retrieve
+	 * @return a previously stored ErrorDocument instance
+	 * @throws DaoException
+	 *             if any exception is thrown when connecting to the underlying
+	 *             data store or when attempting retrieval of the error document
+	 */
+	@Transactional(propagation = SUPPORTS, readOnly = true)
+	ErrorDocument get(T2Reference reference) throws DaoException;
+
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	boolean delete(ErrorDocument errorDoc) throws DaoException;
+
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	void deleteErrorDocumentsForWFRun(String workflowRunId) throws DaoException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentService.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentService.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentService.java
new file mode 100644
index 0000000..6eee715
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentService.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+import java.util.Set;
+
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Provides facilities to register list of T2References, register empty lists at
+ * any given depth and to resolve appropriate T2Reference instances back to
+ * these lists. Registration operations assign names and lock the list contents
+ * as a result. This service operates strictly on T2References, it neither tries
+ * to nor is capable of any form of reference resolution, so aspects such as
+ * collection traversal are not handled here (these are performed by the top
+ * level reference service)
+ * 
+ * @author Tom Oinn
+ */
+@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
+public interface ErrorDocumentService {
+	/**
+	 * Register a new error document.
+	 * <p>
+	 * The created reference will be related with a workflow run id passed
+	 * through ReferenceContext so we can track all data referenced by a
+	 * specific run.
+	 * 
+	 * @param message
+	 *            a free text message describing the error, if available. If
+	 *            there is no message use the empty string here.
+	 * @param t
+	 *            a Throwable describing the underlying fault causing this error
+	 *            document to be registered, if any. If there is no Throwable
+	 *            associated use null.
+	 * @param depth
+	 *            depth of the error, used when returning an error document
+	 *            instead of an identified list.
+	 * @return a new ErrorDocument instance, constructed fully and stored in the
+	 *         underlying storage system
+	 */
+	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
+	ErrorDocument registerError(String message, Throwable t, int depth,
+			ReferenceContext context) throws ErrorDocumentServiceException;
+
+	/**
+	 * Equivalent to <code>registerError(message, null, depth, context)</code>.
+	 */
+	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
+	ErrorDocument registerError(String message, int depth,
+			ReferenceContext context) throws ErrorDocumentServiceException;
+
+	/**
+	 * Equivalent to <code>registerError("", t, depth, context)</code>.
+	 */
+	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
+	ErrorDocument registerError(Throwable t, int depth, ReferenceContext context)
+			throws ErrorDocumentServiceException;
+
+	/**
+	 * Register a new error document.
+	 * <p>
+	 * The created reference will be related with a workflow run id passed
+	 * through ReferenceContext so we can track all data referenced by a
+	 * specific run.
+	 * 
+	 * @param message
+	 *            a free text message describing the error, if available. If
+	 *            there is no message use the empty string here.
+	 * @param errors
+	 *            a set of references that contain error documents.
+	 * @param depth
+	 *            depth of the error, used when returning an error document
+	 *            instead of an identified list.
+	 * @return a new ErrorDocument instance, constructed fully and stored in the
+	 *         underlying storage system
+	 */
+	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
+	ErrorDocument registerError(String message, Set<T2Reference> errors,
+			int depth, ReferenceContext context)
+			throws ErrorDocumentServiceException;
+
+	/**
+	 * Retrieve a previously named and registered ErrorDocument from the backing
+	 * store
+	 * 
+	 * @param id
+	 *            identifier of the error document to retrieve
+	 * @return an ErrorDocument
+	 * @throws ErrorDocumentServiceException
+	 *             if anything goes wrong with the retrieval process or if there
+	 *             is something wrong with the reference (such as it being of
+	 *             the wrong reference type).
+	 */
+	ErrorDocument getError(T2Reference id) throws ErrorDocumentServiceException;
+
+	/**
+	 * Functionality the same as {@link #getError(T2Reference) getError} but in
+	 * asynchronous mode, returning immediately and using the supplied callback
+	 * to communicate its results.
+	 * 
+	 * @param id
+	 *            a {@link T2Reference} identifying an {@link ErrorDocument} to
+	 *            retrieve
+	 * @param callback
+	 *            a {@link ErrorDocumentServiceCallback} used to convey the
+	 *            results of the asynchronous call
+	 * @throws ErrorDocumentServiceException
+	 *             if the reference set service is not correctly configured.
+	 *             Exceptions encountered when performing the asynchronous call
+	 *             are not returned here, for obvious reasons, and are instead
+	 *             messaged through the callback interface.
+	 */
+	void getErrorAsynch(T2Reference id, ErrorDocumentServiceCallback callback)
+			throws ErrorDocumentServiceException;
+
+	/**
+	 * Return the T2Reference for the sole child of an error document
+	 * identifier.
+	 */
+	T2Reference getChild(T2Reference errorId)
+			throws ErrorDocumentServiceException;
+
+	@Transactional(propagation = Propagation.SUPPORTS, readOnly = false)
+	boolean delete(T2Reference reference) throws ReferenceServiceException;
+
+	/**
+	 * Delete all {@link ErrorDocument}S used by the specific workflow run.
+	 */
+	@Transactional(propagation = Propagation.SUPPORTS, readOnly = false)
+	void deleteErrorDocumentsForWorkflowRun(String workflowRunId)
+			throws ReferenceServiceException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentServiceCallback.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentServiceCallback.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentServiceCallback.java
new file mode 100644
index 0000000..5e55672
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentServiceCallback.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+/**
+ * Callback interface used by asynchronous methods in the
+ * {@link ErrorDocumentService} interface
+ * 
+ * @author Tom Oinn
+ */
+public interface ErrorDocumentServiceCallback {
+	/**
+	 * Called when the requested {@link ReferenceSet} has been successfully
+	 * retrieved.
+	 * 
+	 * @param errorDoc
+	 *            the ErrorDocument requested
+	 */
+	void errorRetrieved(ErrorDocument errorDoc);
+
+	/**
+	 * Called if the retrieval failed for some reason
+	 * 
+	 * @param cause
+	 *            an ErrorDocumentServiceException explaining the retrieval
+	 *            failure
+	 */
+	void errorRetrievalFailed(ErrorDocumentServiceException cause);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentServiceException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentServiceException.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentServiceException.java
new file mode 100644
index 0000000..3959c6a
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ErrorDocumentServiceException.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+/**
+ * RuntimeException subclass thrown by the error document service layer
+ * interfaces. All underlying exceptions are either handled by the service layer
+ * or wrapped in this exception (or a subclass) and rethrown.
+ * 
+ * @author Tom Oinn
+ */
+public class ErrorDocumentServiceException extends RuntimeException {
+	private static final long serialVersionUID = 5556399589785258956L;
+
+	public ErrorDocumentServiceException() {
+		super();
+	}
+
+	public ErrorDocumentServiceException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	public ErrorDocumentServiceException(String message) {
+		super(message);
+	}
+
+	public ErrorDocumentServiceException(Throwable cause) {
+		super(cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceBuilderSPI.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceBuilderSPI.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceBuilderSPI.java
new file mode 100644
index 0000000..2dfb340
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceBuilderSPI.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+import java.io.InputStream;
+
+/**
+ * Constructs an ExternalReferenceSPI instance from a byte stream. Used by the
+ * {@link ReferenceSetAugmentor} when there isn't a direct reference to
+ * reference translation path available for a desired target type, but available
+ * for external use wherever this functionality is needed.
+ * <p>
+ * Where an underlying resource is required this is extracted from the supplied
+ * ReferenceContext, this implies that all methods in implementations of this
+ * interface should be thread safe, allowing multiple concurrent threads
+ * cleanly. For SPI purposes implementations should be java beans with default
+ * constructors.
+ * 
+ * @author Tom Oinn
+ */
+public interface ExternalReferenceBuilderSPI<TargetType extends ExternalReferenceSPI> {
+	/**
+	 * Given a stream of bytes, build the appropriate target
+	 * ExternalReferenceSPI implementation which would de-reference to the value
+	 * of that stream and return it.
+	 * 
+	 * @param byteStream
+	 *            the bytestream to read target from.
+	 * @param context
+	 *            a reference resolution context, needed potentially to
+	 *            construct the new ExternalReferenceSchemeSPI, especially in
+	 *            cases where the context contains security agents giving access
+	 *            to a remote data staging system *
+	 * @throws ExternalReferenceConstructionException
+	 *             if an error occurs instantiating the new reference.
+	 * @return the newly constructed ExternalReferenceSPI instance.
+	 */
+	TargetType createReference(InputStream byteStream, ReferenceContext context);
+
+	/**
+	 * Expose the type of the ExternalReferenceSPI that this builder can
+	 * construct
+	 * 
+	 * @return the class of ExternalReferenceSPI returned by the create
+	 *         reference methods.
+	 */
+	Class<TargetType> getReferenceType();
+
+	/**
+	 * Because the reference builder may rely on facilities provided to it
+	 * through the context this method is available to check whether these
+	 * facilities are sufficient.
+	 * 
+	 * @param context
+	 *            the reference context that will be used to construct new
+	 *            references
+	 * @return whether the context contains necessary resources for the
+	 *         reference construction process
+	 */
+	boolean isEnabled(ReferenceContext context);
+
+	/**
+	 * Return an approximate complexity cost of the reference construction. In
+	 * general we can't make any guarantees about this because the complexity of
+	 * the construction depends on more than just the type involved - it can
+	 * depend on local configuration, network location relative to the data
+	 * stores referenced and in some cases on the data themselves. For now
+	 * though we assign an approximation, the default value is 1.0f and lower
+	 * values represent less costly operations.
+	 */
+	float getConstructionCost();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceConstructionException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceConstructionException.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceConstructionException.java
new file mode 100644
index 0000000..0892ecc
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceConstructionException.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+/**
+ * Thrown when an exception occurs during construction of an
+ * ExternalReferenceSPI instance. This includes construction through direct
+ * method invocation, through the ExternalReferenceBuilderSPI interface and
+ * through the ExternalReferenceTranslatorSPI interface.
+ * 
+ * @author Tom Oinn
+ */
+public class ExternalReferenceConstructionException extends RuntimeException {
+	private static final long serialVersionUID = 8334725795238353354L;
+
+	public ExternalReferenceConstructionException() {
+		super();
+	}
+
+	public ExternalReferenceConstructionException(String message) {
+		super(message);
+	}
+
+	public ExternalReferenceConstructionException(Throwable cause) {
+		super(cause);
+	}
+
+	public ExternalReferenceConstructionException(String message,
+			Throwable cause) {
+		super(message, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceSPI.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceSPI.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceSPI.java
new file mode 100644
index 0000000..4d6a047
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceSPI.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+import java.io.InputStream;
+
+/**
+ * A reference to a single piece of data. This may or may not be within the
+ * enactment infrastructure, it could refer to data held in a file, a URL, a
+ * grid storage system or anything of that nature. Ideally the data this
+ * reference points to should not change - we'd like to say 'must not change' at
+ * this point but this isn't always possible, implementations should aim to
+ * provide the appearance that data are immutable.
+ * <p>
+ * When used within the workflow engine implementations of this interface are
+ * always contained in a ReferenceSet instance.
+ * <p>
+ * Implementors of this interface are strongly advised to use the
+ * AbstractExternalReference superclass - this provides the necessary primary
+ * key information used by hibernate-based implementations of the reference
+ * manager. Technically we don't require it as it's possible that other backend
+ * stores may exist, but the core store used by T2 is based on hibernate so it's
+ * a very good idea to follow this! Basically if you don't your code won't work
+ * in the current system.
+ * <p>
+ * This interface is an SPI - while implementations are never constructed based
+ * on the SPI registry it is used to discover all implementing classes and
+ * automatically register their hibernate mapping files. Implementors should add
+ * their implementation class name to a
+ * META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI file in
+ * the implementation artifact. For examples please refer to the
+ * t2reference-core-extensions module, this contains implementations of this
+ * interface for common basic reference types.
+ * <p>
+ * Note - if your implementation class has a complex hibernate mapping that uses
+ * components which are themselves mapped into the database (perfectly legal to
+ * do) then you must mark those components as instances of HibernateMappedEntity
+ * so their corresponding mapping and class definitions are loaded by the
+ * Hibernate backed reference set dao. If your implementation class uses inline
+ * compound keys or other component types where you reference another class but
+ * the other class is not mapped itself in hibernate you must instead make the
+ * component class an instance of HibernateComponentClass - a marker interface -
+ * for the same reason. Both of these are SPIs themselves, and require the
+ * appropriate entries to be added to their service metadata files in your
+ * extension jar.
+ * 
+ * @author Tom Oinn
+ */
+public interface ExternalReferenceSPI extends Cloneable {
+	/**
+	 * Determine, if possible, whether the data this reference refers to is
+	 * textual or binary in nature. If this determination is impossible, either
+	 * because the ExternalReference implementation does not know or because the
+	 * data is not accessible for some reason then this should return
+	 * ReferenceDataNature.UNKNOWN
+	 * 
+	 * @return the nature of the referenced data
+	 */
+	ReferencedDataNature getDataNature();
+
+	/**
+	 * For textual data return the character set that should be used to pull
+	 * data into a java String object. Callers must deal with a null return
+	 * value in the event of either unknown charset or unknown or binary data
+	 * types.
+	 * 
+	 * @return string character set, for example 'utf-8', or <code>null</code>
+	 *         if binary or unknown type.
+	 */
+	String getCharset();
+
+	/**
+	 * Open and return an InputStream to the data referenced using, if required,
+	 * any facilities within the supplied context.
+	 * 
+	 * @param context
+	 *            the ReferenceContext object used to obtain e.g. security
+	 *            agents or other facilities required when de-referencing this
+	 *            reference.
+	 * @return an InputStream providing access to the referenced data
+	 * @throws DereferenceException
+	 *             if the reference cannot be de-referenced. This may be because
+	 *             of problems with the context such as security failures, or it
+	 *             may be because the reference is inherently not possible to
+	 *             de-reference (as in the case of a non-serializable API
+	 *             consumer reference).
+	 */
+	InputStream openStream(ReferenceContext context)
+			throws DereferenceException;
+
+	/**
+	 * Approximate size of the stored data or -1 if we do not know.
+	 */
+	Long getApproximateSizeInBytes();
+
+	/**
+	 * Resolution cost is an informal guide to how costly the process of
+	 * de-referencing this reference would be. It's used when assessing which
+	 * out of a set of ExternalReferenceSPI implementations to use to get the
+	 * value of the reference(s), in particular when rendering to POJOs or when
+	 * translating throught the de-reference / construct from stream route. As
+	 * this property is highly complex and potentially expensive in itself to
+	 * evaluate there's no requirement for it to be absolutely correct, it's
+	 * just used as a guide that, for example, it is easier to get bytes from a
+	 * file on the local disk than to get them from a resource held on a grid on
+	 * the other side of the planet.
+	 * 
+	 * @return a float representing some notion of resolution cost, lower values
+	 *         represent cheaper de-reference paths.
+	 */
+	float getResolutionCost();
+
+	ExternalReferenceSPI clone() throws CloneNotSupportedException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceTranslatorSPI.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceTranslatorSPI.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceTranslatorSPI.java
new file mode 100644
index 0000000..bc46dce
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceTranslatorSPI.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+/**
+ * Constructs an ExternalReference instance from an existing ExternalReference,
+ * most usually of a different type. Used by the {@link ReferenceSetAugmentor}.
+ * This SPI should not be used for cases where an ExternalReferenceSPI is
+ * constructed from a stream of bytes, this is intended for direct reference to
+ * reference translation with the assumption that this is more efficient for
+ * whatever reason. For cases where the reference is constructed from a byte
+ * stream you should implement {@link ExternalReferenceBuilder} instead.
+ * <p>
+ * For SPI purposes implementations should be java beans with default
+ * constructors, any required state such as the location of remote repositories
+ * to which data can be staged will be passed in in the ReferenceContext.
+ * 
+ * @author Tom Oinn
+ */
+public interface ExternalReferenceTranslatorSPI<SourceType extends ExternalReferenceSPI, TargetType extends ExternalReferenceSPI> {
+	/**
+	 * Given an existing ExternalReferenceSPI, build the appropriate target
+	 * ExternalReferenceSPI implementation and return it.
+	 * 
+	 * @param sourceReference
+	 *            the reference to be used as source for the translation.
+	 * @param context
+	 *            a reference resolution context, needed potentially to access
+	 *            the existing external references or to construct the new one,
+	 *            especially in cases where the context contains security agents
+	 *            giving access to a remote data staging system
+	 * @throws ExternalReferenceConstructionException
+	 *             if an error occurs instantiating the new reference.
+	 * @return the newly constructed ExternalReferenceSPI instance.
+	 */
+	TargetType createReference(SourceType sourceReference,
+			ReferenceContext context);
+
+	/**
+	 * Return the type of external reference that this translator consumes.
+	 * 
+	 * @return ExternalReferenceSPI class corresponding to the reference type
+	 *         used as a source by this translator.
+	 */
+	Class<SourceType> getSourceReferenceType();
+
+	/**
+	 * Return the type of external reference this translator constructs.
+	 * 
+	 * @return ExternalReferenceSPI class corresponding to the reference type
+	 *         emitted by this translator.
+	 */
+	Class<TargetType> getTargetReferenceType();
+
+	/**
+	 * Because the reference translator may rely on facilities provided to it
+	 * through the context this method is available to check whether these
+	 * facilities are sufficient.
+	 * 
+	 * @param context
+	 *            the reference context that will be used to construct new
+	 *            references during the translation process
+	 * @return whether the context contains necessary resources for the
+	 *         reference construction process
+	 */
+	boolean isEnabled(ReferenceContext context);
+
+	/**
+	 * Return an approximate complexity cost of the translation. In general we
+	 * can't make any guarantees about this because the complexity of the
+	 * translation depends on more than just the types involved - it can depend
+	 * on local configuration, network location relative to the data stores
+	 * referenced and in some cases on the data themselves. For now though we
+	 * assign an approximation, the default value is 1.0f and lower values
+	 * represent less costly operations.
+	 */
+	float getTranslationCost();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceValidationException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceValidationException.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceValidationException.java
new file mode 100644
index 0000000..c8b540d
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ExternalReferenceValidationException.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+/**
+ * Thrown by setter methods and constructors of ExternalReferenceSPI
+ * implementations when fed parameters which cause some kind of format or
+ * validation error. These might include badly formed URL or file paths or any
+ * other property that fails to validate against some reference type specific
+ * scheme.
+ * 
+ * @author Tom Oinn
+ */
+public class ExternalReferenceValidationException extends RuntimeException {
+	private static final long serialVersionUID = 3031393671457773057L;
+
+	public ExternalReferenceValidationException() {
+		//
+	}
+
+	public ExternalReferenceValidationException(String message) {
+		super(message);
+	}
+
+	public ExternalReferenceValidationException(Throwable cause) {
+		super(cause);
+	}
+
+	public ExternalReferenceValidationException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/Identified.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/Identified.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/Identified.java
new file mode 100644
index 0000000..8e9c5fd
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/Identified.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+/**
+ * Interface for any object that has an associated {@link T2Reference}
+ * 
+ * @author Tom Oinn
+ */
+public interface Identified {
+	/**
+	 * Return an appropriately configured instance of T2Reference for this
+	 * identified object.
+	 * 
+	 * @return the id of this object in the form of a T2Reference
+	 */
+	T2Reference getId();
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/IdentifiedList.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/IdentifiedList.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/IdentifiedList.java
new file mode 100644
index 0000000..032906f
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/IdentifiedList.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+import java.util.List;
+
+/**
+ * An identified list is a list which is identified by a T2Reference. Lists are
+ * immutable once named - if getId() returns a non null value all list methods
+ * modifying the underlying list data will throw {@link IllegalStateException}.
+ * In the reference management API this list sub-interface is used to represent
+ * both collections of identifiers (i.e. 'raw' stored lists) and more fully
+ * resolved structures where the types in the list can be reference sets, error
+ * documents and other lists of such. The {@link ListDao} interface uses only
+ * the 'raw' form consisting of flat lists of identifiers.
+ * <p>
+ * The IdentifiedList has a unique T2Reference associated with it. If this is
+ * null the contents of the list may be modified, otherwise all modification
+ * operations throw {@link IllegalStateException}. Lists in T2, once named, are
+ * immutable.
+ * 
+ * @author Tom Oinn
+ * 
+ * @param <T>
+ */
+public interface IdentifiedList<T> extends List<T>, Identified {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListDao.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListDao.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListDao.java
new file mode 100644
index 0000000..7e064be
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListDao.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+import static org.springframework.transaction.annotation.Propagation.REQUIRED;
+import static org.springframework.transaction.annotation.Propagation.SUPPORTS;
+
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Data access object handling NamedLists of T2Reference instances.
+ * 
+ * @author Tom Oinn
+ */
+public interface ListDao {
+	/**
+	 * Store a named and populated IdentifiedList of T2Reference to the
+	 * database.
+	 * 
+	 * @param theList
+	 *            list to store
+	 * @throws DaoException
+	 *             if any exception is thrown when connecting to the underlying
+	 *             store or when storing the list
+	 */
+	@Transactional(propagation = REQUIRED, readOnly = false)
+	void store(IdentifiedList<T2Reference> theList) throws DaoException;
+
+	/**
+	 * Retrieves a named and populated IdentifiedList of T2Reference from the
+	 * database by T2Reference
+	 * 
+	 * @param reference
+	 *            id of the list to retrieve
+	 * @return a previously stored list of T2References
+	 * @throws DaoException
+	 *             if any exception is thrown when connecting to the underlying
+	 *             data store or when attempting retrieval of the list
+	 */
+	@Transactional(propagation = SUPPORTS, readOnly = true)
+	IdentifiedList<T2Reference> get(T2Reference reference) throws DaoException;
+
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	boolean delete(IdentifiedList<T2Reference> theList) throws DaoException;
+
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	void deleteIdentifiedListsForWFRun(String workflowRunId)
+			throws DaoException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListService.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListService.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListService.java
new file mode 100644
index 0000000..dae18af
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListService.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+import static org.springframework.transaction.annotation.Propagation.REQUIRED;
+import static org.springframework.transaction.annotation.Propagation.SUPPORTS;
+
+import java.util.List;
+
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Provides facilities to register list of T2References, register empty lists at
+ * any given depth and to resolve appropriate T2Reference instances back to
+ * these lists. Registration operations assign names and lock the list contents
+ * as a result. This service operates strictly on T2References, it neither tries
+ * to nor is capable of any form of reference resolution, so aspects such as
+ * collection traversal are not handled here (these are performed by the top
+ * level reference service)
+ * 
+ * @author Tom Oinn
+ */
+@Transactional(propagation = SUPPORTS, readOnly = true)
+public interface ListService {
+	/**
+	 * Register a new list of T2References. The depth of the list will be
+	 * calculated based on the depth of the references within it - if these are
+	 * not uniform the list won't be created (all children of a list in T2 must
+	 * have the same depth as their siblings). Provided this constraint is
+	 * satisfied the list is named and stored in the backing store. The returned
+	 * list is at this point immutable, operations modifying it either directly
+	 * or through the ListIterator will fail with an IllegalStateException.
+	 * Implementations should copy the input list rather than keeping a
+	 * reference to it to preserve this property.
+	 * <p>
+	 * The created references will be related with a workflow run id passed
+	 * through ReferenceContext so we can track all data referenced by a
+	 * specific run.
+	 * 
+	 * @param items
+	 *            the T2Reference instances to store as a list.
+	 * @return a new IdentifiedList of T2Reference instances allocated with a
+	 *         T2Reference itself as the unique name and cached by the backing
+	 *         store.
+	 * @throws ListServiceException
+	 *             if there is a problem either with the specified list of
+	 *             references or with the storage subsystem.
+	 */
+	@Transactional(propagation = REQUIRED, readOnly = false)
+	IdentifiedList<T2Reference> registerList(List<T2Reference> items,
+			ReferenceContext context) throws ListServiceException;
+
+	/**
+	 * Register a new empty list with the specified depth. This is needed
+	 * because in the case of empty lists we can't calculate the depth from the
+	 * list items (what with there not being any!), but the depth property is
+	 * critical for the T2 iteration and collection management system in the
+	 * enactor - we need to know that this is an empty list that
+	 * <em>would have</em> contained lists, for example.
+	 * <p>
+	 * The created references will be related with a workflow run id passed
+	 * through ReferenceContext so we can track all data referenced by a
+	 * specific run.
+	 * 
+	 * @param depth
+	 *            the depth of the empty list, must be >=1
+	 * @return a new empty IdentifiedList allocated with a T2Reference itself as
+	 *         the unique name and cached by the backing store.
+	 * @throws ListServiceException
+	 *             if there is a problem with the storage subsystem or if called
+	 *             with an invalid depth argument
+	 */
+	@Transactional(propagation = REQUIRED, readOnly = false)
+	IdentifiedList<T2Reference> registerEmptyList(int depth,
+			ReferenceContext context) throws ListServiceException;
+
+	/**
+	 * Retrieve a previously named and registered list of T2Reference instances
+	 * identified by the specified T2Reference (which must be of type
+	 * T2ReferenceType.IdentifiedList)
+	 * 
+	 * @param id
+	 *            identifier of the list of reference to retrieve
+	 * @return an IdentifiedList of T2References. Note that because this list is
+	 *         named it is effectively immutable, if you want to modify the list
+	 *         you have to create and register a new list, you cannot modify the
+	 *         returned value of this directly. This is why there is no update
+	 *         method in the service or dao for reference lists.
+	 * @throws ListServiceException
+	 *             if anything goes wrong with the retrieval process or if there
+	 *             is something wrong with the reference (such as it being of
+	 *             the wrong reference type).
+	 */
+	IdentifiedList<T2Reference> getList(T2Reference id)
+			throws ListServiceException;
+
+	/**
+	 * Functionality the same as {@link #getList(T2Reference) getList} but in
+	 * asynchronous mode, returning immediately and using the supplied callback
+	 * to communicate its results.
+	 * 
+	 * @param id
+	 *            a {@link T2Reference} identifying an {@link IdentifiedList} to
+	 *            retrieve
+	 * @param callback
+	 *            a {@link ListServiceCallback} used to convey the results of
+	 *            the asynchronous call
+	 * @throws ListServiceException
+	 *             if the reference set service is not correctly configured.
+	 *             Exceptions encountered when performing the asynchronous call
+	 *             are not returned here, for obvious reasons, and are instead
+	 *             messaged through the callback interface.
+	 */
+	void getListAsynch(T2Reference id, ListServiceCallback callback)
+			throws ListServiceException;
+
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	boolean delete(T2Reference reference) throws ReferenceServiceException;
+
+	/**
+	 * Delete all {@link IdentifiedList}S used by the specific workflow run.
+	 */
+	@Transactional(propagation = SUPPORTS, readOnly = false)
+	void deleteIdentifiedListsForWorkflowRun(String workflowRunId)
+			throws ReferenceServiceException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListServiceCallback.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListServiceCallback.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListServiceCallback.java
new file mode 100644
index 0000000..754caf6
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListServiceCallback.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+/**
+ * Callback interface used by asynchronous methods in the
+ * {@link ListService} interface
+ * 
+ * @author Tom Oinn
+ */
+public interface ListServiceCallback {
+	/**
+	 * Called when the requested {@link ReferenceSet} has been successfully
+	 * retrieved.
+	 * 
+	 * @param references
+	 *            the ReferenceSet requested
+	 */
+	void listRetrieved(IdentifiedList<T2Reference> references);
+
+	/**
+	 * Called if the retrieval failed for some reason
+	 * 
+	 * @param cause
+	 *            a ListServiceException explaining the retrieval
+	 *            failure
+	 */
+	void listRetrievalFailed(ListServiceException cause);
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListServiceException.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListServiceException.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListServiceException.java
new file mode 100644
index 0000000..01cdd82
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ListServiceException.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+/**
+ * Thrown by methods in the ListService interface if anything goes wrong with
+ * list registration or retrieval. Any underlying exceptions that can't be
+ * handled in the service layer are wrapped in this and re-thrown.
+ * 
+ * @author Tom Oinn
+ */
+public class ListServiceException extends RuntimeException {
+	private static final long serialVersionUID = 5049346991071587866L;
+
+	public ListServiceException() {
+		super();
+	}
+
+	public ListServiceException(String message) {
+		super(message);
+	}
+
+	public ListServiceException(Throwable cause) {
+		super(cause);
+	}
+
+	public ListServiceException(String message, Throwable cause) {
+		super(message, cause);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/246a16e2/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceContext.java
----------------------------------------------------------------------
diff --git a/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceContext.java b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceContext.java
new file mode 100644
index 0000000..0ce2de3
--- /dev/null
+++ b/taverna-reference-api/src/main/java/net/sf/taverna/t2/reference/ReferenceContext.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (C) 2007 The University of Manchester   
+ * 
+ *  Modifications to the initial code base are copyright of their
+ *  respective authors, or their employers as appropriate.
+ * 
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1 of
+ *  the License, or (at your option) any later version.
+ *    
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *    
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ ******************************************************************************/
+package net.sf.taverna.t2.reference;
+
+import java.util.List;
+
+/**
+ * Many operations over the reference manager require access to an appropriate
+ * context. The context contains hooks out to platform level facilities such as
+ * the security agent framework (when used in conjunction with the enactor).
+ * <p>
+ * This interface is also used to pass in resources required by the external
+ * reference translation and construction SPIs. An example might be a translator
+ * from File to URL could work by copying the source file to a web share of some
+ * kind, but obviously this can't happen unless properties such as the location
+ * of the web share folder are known. These properties tend to be properties of
+ * the installation rather than of the code, referring as they do to resources
+ * on the machine hosting the reference manager (and elsewhere).
+ * <p>
+ * Where entities in the context represent properties of the platform rather
+ * than the 'session' they are likely to be configured in a central location
+ * such as a Spring context definition, this interface is neutral to those
+ * concerns.
+ * 
+ * @author Tom Oinn
+ */
+public interface ReferenceContext {
+	/**
+	 * Return a list of all entities in the resolution context which match the
+	 * supplied entity type argument.
+	 * 
+	 * @param <T>
+	 *            The generic type of the returned entity list. In general the
+	 *            compiler is smart enough that you don't need to specify this,
+	 *            it can pick it up from the entityType parameter.
+	 * @param entityType
+	 *            Class of entity to return. Use Object.class to return all
+	 *            entities within the reference context
+	 * @return a list of entities from the reference context which can be cast
+	 *         to the specified type.
+	 */
+	<T extends Object> List<T> getEntities(Class<T> entityType);
+
+	/**
+	 * Add an entity to the context.
+	 */
+	void addEntity(Object entity);
+}