You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by re...@apache.org on 2015/03/23 17:38:16 UTC
[32/51] [partial] incubator-taverna-engine git commit:
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/BlueReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/BlueReference.java b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/BlueReference.java
new file mode 100644
index 0000000..0f5b372
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/BlueReference.java
@@ -0,0 +1,128 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.t2referencetest;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.taverna.reference.AbstractExternalReference;
+import org.apache.taverna.reference.DereferenceException;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferencedDataNature;
+
+/**
+ * BlueReferences carry their data as an internal String and have a resolution
+ * cost of 1.0f whatever the value of that string.
+ *
+ * @author Tom Oinn
+ *
+ */
+public class BlueReference extends AbstractExternalReference implements
+ ExternalReferenceSPI {
+
+ // Hold the 'value' of this reference, probably the simplest backing store
+ // possible for an ExternalReferenceSPI implementation :)
+ private String contents;
+
+ public BlueReference() {
+ //
+ }
+
+ public BlueReference(String contents) {
+ this.contents = contents;
+ }
+
+ /**
+ * Set the 'value' of this reference as a string. It's not really a
+ * reference type in any true sense of the word, but it'll do for testing
+ * the augmentation system. This method is really here so you can configure
+ * test beans from spring.
+ */
+ public void setContents(String contents) {
+ this.contents = contents;
+ }
+
+ /**
+ * Get the 'value' of this reference as a string, really just returns the
+ * internal string representation.
+ */
+ public String getContents() {
+ return this.contents;
+ }
+
+ /**
+ * Fakes a de-reference operation, returning a byte stream over the string
+ * data.
+ */
+ @Override
+ public InputStream openStream(ReferenceContext arg0) {
+ try {
+ return new ByteArrayInputStream(this.contents
+ .getBytes(getCharset()));
+ } catch (UnsupportedEncodingException e) {
+ throw new DereferenceException(e);
+ }
+ }
+
+ /**
+ * Default resolution cost of 1.0f whatever the contents
+ */
+ @Override
+ public float getResolutionCost() {
+ return 1.0f;
+ }
+
+ /**
+ * Data nature set to 'ReferencedDataNature.TEXT'
+ */
+ @Override
+ public ReferencedDataNature getDataNature() {
+ return ReferencedDataNature.TEXT;
+ }
+
+ /**
+ * Character encoding set to 'UTF-8'
+ */
+ @Override
+ public String getCharset() {
+ return "UTF-8";
+ }
+
+ /**
+ * String representation for testing, returns <code>blue{CONTENTS}</code>
+ */
+ @Override
+ public String toString() {
+ return "blue{" + contents + "}";
+ }
+
+ @Override
+ public Long getApproximateSizeInBytes() {
+ return new Long(contents.getBytes().length);
+ }
+
+ @Override
+ public ExternalReferenceSPI clone() throws CloneNotSupportedException {
+ return new BlueReference(this.getContents());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/DummyReferenceSet.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/DummyReferenceSet.java b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/DummyReferenceSet.java
new file mode 100644
index 0000000..13cb9e7
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/DummyReferenceSet.java
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.t2referencetest;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceSet;
+import org.apache.taverna.reference.T2Reference;
+
+public class DummyReferenceSet implements ReferenceSet {
+
+ private Set<ExternalReferenceSPI> refs;
+
+ public DummyReferenceSet(ExternalReferenceSPI ref) {
+ refs = Collections.singleton(ref);
+ }
+
+ @Override
+ public T2Reference getId() {
+ return null;
+ }
+
+ @Override
+ public Set<ExternalReferenceSPI> getExternalReferences() {
+ return refs;
+ }
+
+ @Override
+ public Long getApproximateSizeInBytes() {
+ return null;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenBuilder.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenBuilder.java b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenBuilder.java
new file mode 100644
index 0000000..d14265f
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenBuilder.java
@@ -0,0 +1,106 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.t2referencetest;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.apache.taverna.reference.ExternalReferenceBuilderSPI;
+import org.apache.taverna.reference.ExternalReferenceConstructionException;
+import org.apache.taverna.reference.ReferenceContext;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Trivially build a GreenReference from an InputStream, implementing the
+ * ExternalReferenceBuilderSPI interface. Used in the augmentation test cases.
+ *
+ * @author Tom Oinn
+ *
+ */
+public class GreenBuilder implements
+ ExternalReferenceBuilderSPI<GreenReference> {
+
+ private static Logger logger = Logger
+ .getLogger(GreenBuilder.class);
+
+ /**
+ * Construct a new GreenReference from the given input stream, ignoring the
+ * otherwise helpful context as we don't need any resources from it. We
+ * assume UTF-8 encoding as that's what all the test reference types use,
+ * again, with a real example this might have to be a bit smarter!
+ *
+ * @throws ExternalReferenceConstructionException
+ * if there are any issues building the new GreenReference
+ * (which there won't be)
+ */
+ @Override
+ public GreenReference createReference(InputStream is,
+ ReferenceContext context)
+ throws ExternalReferenceConstructionException {
+ GreenReference newReference = new GreenReference();
+ // Read input stream into the 'contents' property of the reference
+ BufferedReader in = new BufferedReader(new InputStreamReader(is));
+ try {
+ newReference.setContents(in.readLine());
+ } catch (IOException e) {
+ throw new ExternalReferenceConstructionException(e);
+ } finally {
+ try {
+ is.close();
+ in.close();
+ } catch (IOException e) {
+ logger.error("Unable to close streams", e);
+ }
+ }
+ return newReference;
+ }
+
+ /**
+ * Construction cost fixed at 1.5f
+ *
+ * @return <code>1.5f</code>
+ */
+ @Override
+ public float getConstructionCost() {
+ return 1.5f;
+ }
+
+ /**
+ * @return <code>{@link org.apache.taverna.t2referencetest.GreenReference GreenReference}.class</code>
+ */
+ @Override
+ public Class<GreenReference> getReferenceType() {
+ return GreenReference.class;
+ }
+
+ /**
+ * Doesn't use any context resources so is always enabled
+ *
+ * @return <code>true</code>
+ */
+ @Override
+ public boolean isEnabled(ReferenceContext arg0) {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenReference.java b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenReference.java
new file mode 100644
index 0000000..edc66a0
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenReference.java
@@ -0,0 +1,128 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.t2referencetest;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.taverna.reference.AbstractExternalReference;
+import org.apache.taverna.reference.DereferenceException;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferencedDataNature;
+
+/**
+ * GreenReferences carry their data as an internal String and have a resolution
+ * cost of 1.1f whatever the value of that string.
+ *
+ * @author Tom Oinn
+ *
+ */
+public class GreenReference extends AbstractExternalReference implements
+ ExternalReferenceSPI {
+
+ // Hold the 'value' of this reference, probably the simplest backing store
+ // possible for an ExternalReferenceSPI implementation :)
+ private String contents;
+
+ public GreenReference() {
+ //
+ }
+
+ public GreenReference(String contents) {
+ this.contents = contents;
+ }
+
+ /**
+ * Set the 'value' of this reference as a string. It's not really a
+ * reference type in any true sense of the word, but it'll do for testing
+ * the augmentation system. This method is really here so you can configure
+ * test beans from spring.
+ */
+ public void setContents(String contents) {
+ this.contents = contents;
+ }
+
+ /**
+ * Get the 'value' of this reference as a string, really just returns the
+ * internal string representation.
+ */
+ public String getContents() {
+ return this.contents;
+ }
+
+ /**
+ * Fakes a de-reference operation, returning a byte stream over the string
+ * data.
+ */
+ @Override
+ public InputStream openStream(ReferenceContext arg0) {
+ try {
+ return new ByteArrayInputStream(this.contents
+ .getBytes(getCharset()));
+ } catch (UnsupportedEncodingException e) {
+ throw new DereferenceException(e);
+ }
+ }
+
+ /**
+ * Default resolution cost of 1.0f whatever the contents
+ */
+ @Override
+ public float getResolutionCost() {
+ return 1.1f;
+ }
+
+ /**
+ * Data nature set to 'ReferencedDataNature.TEXT'
+ */
+ @Override
+ public ReferencedDataNature getDataNature() {
+ return ReferencedDataNature.TEXT;
+ }
+
+ /**
+ * Character encoding set to 'UTF-8'
+ */
+ @Override
+ public String getCharset() {
+ return "UTF-8";
+ }
+
+ /**
+ * String representation for testing, returns <code>green{CONTENTS}</code>
+ */
+ @Override
+ public String toString() {
+ return "green{" + contents + "}";
+ }
+
+ @Override
+ public Long getApproximateSizeInBytes() {
+ return new Long(contents.getBytes().length);
+ }
+
+ @Override
+ public ExternalReferenceSPI clone() throws CloneNotSupportedException {
+ return new GreenReference(this.getContents());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenToRed.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenToRed.java b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenToRed.java
new file mode 100644
index 0000000..6c480e9
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/GreenToRed.java
@@ -0,0 +1,64 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.t2referencetest;
+
+import org.apache.taverna.reference.ExternalReferenceTranslatorSPI;
+import org.apache.taverna.reference.ReferenceContext;
+
+public class GreenToRed implements
+ ExternalReferenceTranslatorSPI<GreenReference, RedReference> {
+
+ @Override
+ public RedReference createReference(GreenReference ref,
+ ReferenceContext context) {
+ RedReference newReference = new RedReference();
+ newReference.setContents(ref.getContents());
+ // Insert a two second pause to simulate reference translation and to
+ // test the behaviour of multiple concurrent translations
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException ie) {
+ System.out
+ .println("Translation thread was interrupted, probably something wrong.");
+ }
+ return newReference;
+ }
+
+ @Override
+ public Class<GreenReference> getSourceReferenceType() {
+ return GreenReference.class;
+ }
+
+ @Override
+ public Class<RedReference> getTargetReferenceType() {
+ return RedReference.class;
+ }
+
+ @Override
+ public float getTranslationCost() {
+ return 0.4f;
+ }
+
+ @Override
+ public boolean isEnabled(ReferenceContext arg0) {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/RedReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/RedReference.java b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/RedReference.java
new file mode 100644
index 0000000..dd35127
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/RedReference.java
@@ -0,0 +1,128 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.t2referencetest;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.taverna.reference.AbstractExternalReference;
+import org.apache.taverna.reference.DereferenceException;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferencedDataNature;
+
+/**
+ * RedReferences carry their data as an internal String and have a resolution
+ * cost of 0.9f whatever the value of that string.
+ *
+ * @author Tom Oinn
+ *
+ */
+public class RedReference extends AbstractExternalReference implements
+ ExternalReferenceSPI {
+
+ // Hold the 'value' of this reference, probably the simplest backing store
+ // possible for an ExternalReferenceSPI implementation :)
+ private String contents;
+
+ public RedReference() {
+ //
+ }
+
+ public RedReference(String contents) {
+ this.contents = contents;
+ }
+
+ /**
+ * Set the 'value' of this reference as a string. It's not really a
+ * reference type in any true sense of the word, but it'll do for testing
+ * the augmentation system. This method is really here so you can configure
+ * test beans from spring.
+ */
+ public void setContents(String contents) {
+ this.contents = contents;
+ }
+
+ /**
+ * Get the 'value' of this reference as a string, really just returns the
+ * internal string representation.
+ */
+ public String getContents() {
+ return this.contents;
+ }
+
+ /**
+ * Fakes a de-reference operation, returning a byte stream over the string
+ * data.
+ */
+ @Override
+ public InputStream openStream(ReferenceContext arg0) {
+ try {
+ return new ByteArrayInputStream(this.contents
+ .getBytes(getCharset()));
+ } catch (UnsupportedEncodingException e) {
+ throw new DereferenceException(e);
+ }
+ }
+
+ /**
+ * Default resolution cost of 1.0f whatever the contents
+ */
+ @Override
+ public float getResolutionCost() {
+ return 0.9f;
+ }
+
+ /**
+ * Data nature set to 'ReferencedDataNature.TEXT'
+ */
+ @Override
+ public ReferencedDataNature getDataNature() {
+ return ReferencedDataNature.TEXT;
+ }
+
+ /**
+ * Character encoding set to 'UTF-8'
+ */
+ @Override
+ public String getCharset() {
+ return "UTF-8";
+ }
+
+ /**
+ * String representation for testing, returns <code>red{CONTENTS}</code>
+ */
+ @Override
+ public String toString() {
+ return "red{" + contents + "}";
+ }
+
+ @Override
+ public Long getApproximateSizeInBytes() {
+ return new Long(contents.getBytes().length);
+ }
+
+ @Override
+ public ExternalReferenceSPI clone() throws CloneNotSupportedException {
+ return new RedReference(this.getContents());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/YellowReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/YellowReference.java b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/YellowReference.java
new file mode 100644
index 0000000..959a59f
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/java/org/apache/taverna/t2referencetest/YellowReference.java
@@ -0,0 +1,129 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+package org.apache.taverna.t2referencetest;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.taverna.reference.AbstractExternalReference;
+import org.apache.taverna.reference.DereferenceException;
+import org.apache.taverna.reference.ExternalReferenceSPI;
+import org.apache.taverna.reference.ReferenceContext;
+import org.apache.taverna.reference.ReferencedDataNature;
+
+
+/**
+ * YellowReferences carry their data as an internal String and have a resolution
+ * cost of 1.0f whatever the value of that string.
+ *
+ * @author Tom Oinn
+ *
+ */
+public class YellowReference extends AbstractExternalReference implements
+ ExternalReferenceSPI {
+
+ // Hold the 'value' of this reference, probably the simplest backing store
+ // possible for an ExternalReferenceSPI implementation :)
+ private String contents;
+
+ public YellowReference() {
+ //
+ }
+
+ public YellowReference(String contents) {
+ this.contents = contents;
+ }
+
+ /**
+ * Set the 'value' of this reference as a string. It's not really a
+ * reference type in any true sense of the word, but it'll do for testing
+ * the augmentation system. This method is really here so you can configure
+ * test beans from spring.
+ */
+ public void setContents(String contents) {
+ this.contents = contents;
+ }
+
+ /**
+ * Get the 'value' of this reference as a string, really just returns the
+ * internal string representation.
+ */
+ public String getContents() {
+ return this.contents;
+ }
+
+ /**
+ * Fakes a de-reference operation, returning a byte stream over the string
+ * data.
+ */
+ @Override
+ public InputStream openStream(ReferenceContext arg0) {
+ try {
+ return new ByteArrayInputStream(this.contents
+ .getBytes(getCharset()));
+ } catch (UnsupportedEncodingException e) {
+ throw new DereferenceException(e);
+ }
+ }
+
+ /**
+ * Default resolution cost of 1.0f whatever the contents
+ */
+ @Override
+ public float getResolutionCost() {
+ return 1.0f;
+ }
+
+ /**
+ * Data nature set to 'ReferencedDataNature.TEXT'
+ */
+ @Override
+ public ReferencedDataNature getDataNature() {
+ return ReferencedDataNature.TEXT;
+ }
+
+ /**
+ * Character encoding set to 'UTF-8'
+ */
+ @Override
+ public String getCharset() {
+ return "UTF-8";
+ }
+
+ /**
+ * String representation for testing, returns <code>yellow{CONTENTS}</code>
+ */
+ @Override
+ public String toString() {
+ return "yellow{" + contents + "}";
+ }
+
+ @Override
+ public Long getApproximateSizeInBytes() {
+ return new Long(contents.getBytes().length);
+ }
+
+ @Override
+ public ExternalReferenceSPI clone() throws CloneNotSupportedException {
+ return new YellowReference(this.getContents());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI b/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI
deleted file mode 100644
index 3f1a123..0000000
--- a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI
+++ /dev/null
@@ -1,2 +0,0 @@
-# Implementation classes of ExternalReferenceBuilderSPI go here, one per line
-net.sf.taverna.t2referencetest.GreenBuilder
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI b/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI
deleted file mode 100644
index 20a63d6..0000000
--- a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceSPI
+++ /dev/null
@@ -1,5 +0,0 @@
-# Implementation classes of ExternalReferenceSPI go here, one per line
-net.sf.taverna.t2referencetest.GreenReference
-net.sf.taverna.t2referencetest.BlueReference
-net.sf.taverna.t2referencetest.RedReference
-net.sf.taverna.t2referencetest.YellowReference
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI b/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI
deleted file mode 100644
index 7fff1a3..0000000
--- a/taverna-reference-testhelpers/src/main/resources/META-INF/services/net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI
+++ /dev/null
@@ -1,2 +0,0 @@
-# Implementation classes of ExternalReferenceTranslatorSPI go here, one per line
-net.sf.taverna.t2referencetest.GreenToRed
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceBuilderSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceBuilderSPI b/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceBuilderSPI
new file mode 100644
index 0000000..c896a11
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceBuilderSPI
@@ -0,0 +1,2 @@
+# Implementation classes of ExternalReferenceBuilderSPI go here, one per line
+org.apache.taverna.t2referencetest.GreenBuilder
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceSPI b/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceSPI
new file mode 100644
index 0000000..7e9242c
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceSPI
@@ -0,0 +1,5 @@
+# Implementation classes of ExternalReferenceSPI go here, one per line
+org.apache.taverna.t2referencetest.GreenReference
+org.apache.taverna.t2referencetest.BlueReference
+org.apache.taverna.t2referencetest.RedReference
+org.apache.taverna.t2referencetest.YellowReference
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceTranslatorSPI
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceTranslatorSPI b/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceTranslatorSPI
new file mode 100644
index 0000000..c78a2c5
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/resources/META-INF/services/org.apache.taverna.reference.ExternalReferenceTranslatorSPI
@@ -0,0 +1,2 @@
+# Implementation classes of ExternalReferenceTranslatorSPI go here, one per line
+org.apache.taverna.t2referencetest.GreenToRed
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context-osgi.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context-osgi.xml b/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context-osgi.xml
index dc6c0a4..8250b0d 100644
--- a/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context-osgi.xml
+++ b/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context-osgi.xml
@@ -6,13 +6,13 @@
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd" >
- <service ref="greenBuilder" interface="net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI" />
+ <service ref="greenBuilder" interface="org.apache.taverna.reference.ExternalReferenceBuilderSPI" />
- <service ref="greenReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" />
- <service ref="blueReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" />
- <service ref="redReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" />
- <service ref="yellowReference" interface="net.sf.taverna.t2.reference.ExternalReferenceSPI" />
+ <service ref="greenReference" interface="org.apache.taverna.reference.ExternalReferenceSPI" />
+ <service ref="blueReference" interface="org.apache.taverna.reference.ExternalReferenceSPI" />
+ <service ref="redReference" interface="org.apache.taverna.reference.ExternalReferenceSPI" />
+ <service ref="yellowReference" interface="org.apache.taverna.reference.ExternalReferenceSPI" />
- <service ref="greenToRedTranslator" interface="net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI" />
+ <service ref="greenToRedTranslator" interface="org.apache.taverna.reference.ExternalReferenceTranslatorSPI" />
</beans:beans>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context.xml b/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context.xml
index 8838328..55d1f04 100644
--- a/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context.xml
+++ b/taverna-reference-testhelpers/src/main/resources/META-INF/spring/reference-testhelpers-context.xml
@@ -4,13 +4,13 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean id="greenBuilder" class="net.sf.taverna.t2referencetest.GreenBuilder" />
+ <bean id="greenBuilder" class="org.apache.taverna.t2referencetest.GreenBuilder" />
- <bean id="greenReference" class="net.sf.taverna.t2referencetest.GreenReference" />
- <bean id="blueReference" class="net.sf.taverna.t2referencetest.BlueReference" />
- <bean id="redReference" class="net.sf.taverna.t2referencetest.RedReference" />
- <bean id="yellowReference" class="net.sf.taverna.t2referencetest.YellowReference" />
+ <bean id="greenReference" class="org.apache.taverna.t2referencetest.GreenReference" />
+ <bean id="blueReference" class="org.apache.taverna.t2referencetest.BlueReference" />
+ <bean id="redReference" class="org.apache.taverna.t2referencetest.RedReference" />
+ <bean id="yellowReference" class="org.apache.taverna.t2referencetest.YellowReference" />
- <bean id="greenToRedTranslator" class="net.sf.taverna.t2referencetest.GreenToRed" />
+ <bean id="greenToRedTranslator" class="org.apache.taverna.t2referencetest.GreenToRed" />
</beans>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/BlueReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/BlueReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/BlueReference.hbm.xml
deleted file mode 100644
index 9483784..0000000
--- a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/BlueReference.hbm.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for blue reference bean -->
-<hibernate-mapping>
- <joined-subclass
- name="net.sf.taverna.t2referencetest.BlueReference"
- extends="net.sf.taverna.t2.reference.AbstractExternalReference">
- <!-- Link to primary key from abstract superclass -->
- <key column="bean_id" />
- <!-- Dummy reference specific props -->
- <property name="contents" type="string" />
- </joined-subclass>
-</hibernate-mapping>
-
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/GreenReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/GreenReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/GreenReference.hbm.xml
deleted file mode 100644
index dc65151..0000000
--- a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/GreenReference.hbm.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for green reference bean -->
-<hibernate-mapping>
- <joined-subclass
- name="net.sf.taverna.t2referencetest.GreenReference"
- extends="net.sf.taverna.t2.reference.AbstractExternalReference">
- <!-- Link to primary key from abstract superclass -->
- <key column="bean_id" />
- <!-- Dummy reference specific props -->
- <property name="contents" type="string" />
- </joined-subclass>
-</hibernate-mapping>
-
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/RedReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/RedReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/RedReference.hbm.xml
deleted file mode 100644
index 176f60d..0000000
--- a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/RedReference.hbm.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for red reference bean -->
-<hibernate-mapping>
- <joined-subclass
- name="net.sf.taverna.t2referencetest.RedReference"
- extends="net.sf.taverna.t2.reference.AbstractExternalReference">
- <!-- Link to primary key from abstract superclass -->
- <key column="bean_id" />
- <!-- Dummy reference specific props -->
- <property name="contents" type="string" />
- </joined-subclass>
-</hibernate-mapping>
-
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/YellowReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/YellowReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/YellowReference.hbm.xml
deleted file mode 100644
index 6f357f8..0000000
--- a/taverna-reference-testhelpers/src/main/resources/net/sf/taverna/t2referencetest/YellowReference.hbm.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<!-- Hibernate mapping for yellow reference bean -->
-<hibernate-mapping>
- <joined-subclass
- name="net.sf.taverna.t2referencetest.YellowReference"
- extends="net.sf.taverna.t2.reference.AbstractExternalReference">
- <!-- Link to primary key from abstract superclass -->
- <key column="bean_id" />
- <!-- Dummy reference specific props -->
- <property name="contents" type="string" />
- </joined-subclass>
-</hibernate-mapping>
-
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/BlueReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/BlueReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/BlueReference.hbm.xml
new file mode 100644
index 0000000..84c0c8b
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/BlueReference.hbm.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for blue reference bean -->
+<hibernate-mapping>
+ <joined-subclass extends="org.apache.taverna.reference.AbstractExternalReference" name="org.apache.taverna.t2referencetest.BlueReference">
+ <!-- Link to primary key from abstract superclass -->
+ <key column="bean_id"/>
+ <!-- Dummy reference specific props -->
+ <property name="contents" type="string"/>
+ </joined-subclass>
+</hibernate-mapping>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/GreenReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/GreenReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/GreenReference.hbm.xml
new file mode 100644
index 0000000..5cc3510
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/GreenReference.hbm.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for green reference bean -->
+<hibernate-mapping>
+ <joined-subclass extends="org.apache.taverna.reference.AbstractExternalReference" name="org.apache.taverna.t2referencetest.GreenReference">
+ <!-- Link to primary key from abstract superclass -->
+ <key column="bean_id"/>
+ <!-- Dummy reference specific props -->
+ <property name="contents" type="string"/>
+ </joined-subclass>
+</hibernate-mapping>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/RedReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/RedReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/RedReference.hbm.xml
new file mode 100644
index 0000000..3e4927c
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/RedReference.hbm.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for red reference bean -->
+<hibernate-mapping>
+ <joined-subclass extends="org.apache.taverna.reference.AbstractExternalReference" name="org.apache.taverna.t2referencetest.RedReference">
+ <!-- Link to primary key from abstract superclass -->
+ <key column="bean_id"/>
+ <!-- Dummy reference specific props -->
+ <property name="contents" type="string"/>
+ </joined-subclass>
+</hibernate-mapping>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/YellowReference.hbm.xml
----------------------------------------------------------------------
diff --git a/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/YellowReference.hbm.xml b/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/YellowReference.hbm.xml
new file mode 100644
index 0000000..af62328
--- /dev/null
+++ b/taverna-reference-testhelpers/src/main/resources/org/apache/taverna/t2referencetest/YellowReference.hbm.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!-- Hibernate mapping for yellow reference bean -->
+<hibernate-mapping>
+ <joined-subclass extends="org.apache.taverna.reference.AbstractExternalReference" name="org.apache.taverna.t2referencetest.YellowReference">
+ <!-- Link to primary key from abstract superclass -->
+ <key column="bean_id"/>
+ <!-- Dummy reference specific props -->
+ <property name="contents" type="string"/>
+ </joined-subclass>
+</hibernate-mapping>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/FileReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/FileReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/FileReference.java
deleted file mode 100644
index eeca752..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/FileReference.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*******************************************************************************
- * 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.impl.external.file;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-
-/**
- * Implementation of ExternalReference used to refer to data held in a locally
- * accessible file. Inherits from
- * {@link net.sf.taverna.t2.reference.AbstractExternalReference
- * AbstractExternalReference} to enable hibernate based persistence.
- *
- * @author Tom Oinn
- */
-public class FileReference extends AbstractExternalReference implements
- ExternalReferenceSPI {
- private String filePathString = null;
- private String charset = null;
- private File file = null;
- private String dataNatureName = ReferencedDataNature.UNKNOWN.name();
-
- /**
- * Explicitly declare default constructor, will be used by hibernate when
- * constructing instances of this bean from the database.
- */
- public FileReference() {
- super();
- }
-
- /**
- * Construct a file reference pointed at the specified file and with no
- * character set defined.
- */
- public FileReference(File theFile) {
- super();
- this.file = theFile.getAbsoluteFile();
- this.filePathString = this.file.getPath();
- this.charset = Charset.defaultCharset().name();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public InputStream openStream(ReferenceContext context) {
- try {
- return new FileInputStream(file);
- } catch (FileNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Setter used by hibernate to set the charset property of the file
- * reference
- */
- public void setCharset(String charset) {
- this.charset = charset;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getCharset() {
- return this.charset;
- }
-
- /**
- * Setter used by hibernate to set the file path property of the file
- * reference
- */
- public void setFilePath(String filePathString) {
- this.filePathString = filePathString;
- this.file = new File(filePathString).getAbsoluteFile();
- }
-
- /**
- * Getter used by hibernate to retrieve the file path string property
- */
- public String getFilePath() {
- return this.filePathString;
- }
-
- /**
- * Human readable string form for debugging, should not be regarded as
- * stable.
- */
- @Override
- public String toString() {
- return "file{" + file.getAbsolutePath() + "}";
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((file == null) ? 0 : file.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final FileReference other = (FileReference) obj;
- if (file == null) {
- if (other.file != null)
- return false;
- } else if (!file.equals(other.file))
- return false;
- return true;
- }
-
- @Override
- public Long getApproximateSizeInBytes() {
- return new Long(file.length());
- }
-
- /**
- * @return the dataNature
- */
- @Override
- public ReferencedDataNature getDataNature() {
- return Enum.valueOf(ReferencedDataNature.class, getDataNatureName());
- }
-
- /**
- * @param dataNature
- * the dataNature to set
- */
- public void setDataNature(ReferencedDataNature dataNature) {
- setDataNatureName(dataNature.name());
- }
-
- /**
- * @return the file
- */
- public final File getFile() {
- return file;
- }
-
- @Override
- public float getResolutionCost() {
- return (float) 100.0;
- }
-
- /**
- * @return the dataNatureName
- */
- public String getDataNatureName() {
- return dataNatureName;
- }
-
- /**
- * @param dataNatureName
- * the dataNatureName to set
- */
- public void setDataNatureName(String dataNatureName) {
- this.dataNatureName = dataNatureName;
- }
-
- public void deleteData() {
- try {
- getFile().delete();
- } catch (SecurityException e) {
- // TODO
- }
- }
-
- @Override
- public FileReference clone() {
- FileReference result = new FileReference();
- result.setFilePath(this.getFilePath());
- result.setCharset(this.getCharset());
- result.setDataNature(this.getDataNature());
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/FileToFileReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/FileToFileReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/FileToFileReference.java
deleted file mode 100644
index cde79a5..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/FileToFileReference.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * 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.impl.external.file;
-
-import java.io.File;
-import java.io.IOException;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ValueToReferenceConversionException;
-import net.sf.taverna.t2.reference.ValueToReferenceConverterSPI;
-
-/**
- * Converts java.lang.File instances to FileReference reference type
- *
- * @author Tom Oinn
- */
-public class FileToFileReference implements ValueToReferenceConverterSPI {
- /*
- * TODO - should probably do more sophisticated checks such as whether the
- * file is a file or directory etc etc, for now just checks whether the
- * specified object is a java.io.File
- */
- @Override
- public boolean canConvert(Object o, ReferenceContext context) {
- return (o instanceof File);
- }
-
- /**
- * Return a FileReference
- */
- @Override
- public ExternalReferenceSPI convert(Object o, ReferenceContext context)
- throws ValueToReferenceConversionException {
- FileReference result = new FileReference();
- try {
- result.setFilePath(((File) o).getCanonicalPath());
- } catch (IOException ioe) {
- throw new ValueToReferenceConversionException(ioe);
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/package.html b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/package.html
deleted file mode 100644
index 8be59b3..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/file/package.html
+++ /dev/null
@@ -1,4 +0,0 @@
-<body>
-Support for references to a file on a local (or otherwise mounted)
-filesystem
-</body>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/HttpReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/HttpReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/HttpReference.java
deleted file mode 100644
index d72eed6..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/HttpReference.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*******************************************************************************
- * 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.impl.external.http;
-
-import static java.lang.System.currentTimeMillis;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Date;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.DereferenceException;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ExternalReferenceValidationException;
-import net.sf.taverna.t2.reference.ReferenceContext;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.methods.HeadMethod;
-
-/**
- * Implementation of ExternalReference used to refer to data held in a locally
- * accessible file. Inherits from
- * {@link net.sf.taverna.t2.reference.AbstractExternalReference
- * AbstractExternalReference} to enable hibernate based persistence.
- *
- * @author Tom Oinn
- */
-public class HttpReference extends AbstractExternalReference implements
- ExternalReferenceSPI {
- private String httpUrlString = null;
- private URL httpUrl = null;
- private String charsetName = null;
- private boolean charsetFetched = false;
- private transient Long cachedLength;
- private transient Date cacheTime;
-
- /**
- * Explicitly declare default constructor, will be used by hibernate when
- * constructing instances of this bean from the database.
- */
- public HttpReference() {
- super();
- }
-
- /**
- * Return the data at the {@link URL} represented by this external reference
- */
- @Override
- public InputStream openStream(ReferenceContext context)
- throws DereferenceException {
- try {
- return httpUrl.openStream();
- } catch (IOException e) {
- throw new DereferenceException(e);
- }
- }
-
- @Override
- public String getCharset() throws DereferenceException {
- if (charsetFetched)
- return charsetName;
- charsetFetched = true;
- if (!httpUrl.getProtocol().equals("http")
- && !httpUrl.getProtocol().equals("https")) {
- charsetName = null;
- return null;
- }
- HeadMethod method = new HeadMethod(httpUrl.toExternalForm());
- HttpClient httpClient = new HttpClient();
- try {
- httpClient.executeMethod(method);
- charsetName = method.getResponseCharSet();
- return charsetName;
- } catch (HttpException e) {
- // throw new DereferenceException(e);
- } catch (IOException e) {
- // throw new DereferenceException(e);
- } finally {
- method.releaseConnection();
- }
- charsetName = null;
- return null;
- }
-
- /**
- * Setter used by hibernate to set the file path property of the file
- * reference
- *
- * @throws ExternalReferenceValidationException
- * if there is some problem parsing the supplied string as a URL
- */
- public void setHttpUrlString(String httpUrlString) {
- try {
- this.httpUrlString = httpUrlString;
- this.httpUrl = new URL(httpUrlString);
- } catch (MalformedURLException e) {
- throw new ExternalReferenceValidationException(e);
- }
- }
-
- /**
- * Getter used by hibernate to retrieve the file path string property
- */
- public String getHttpUrlString() {
- return this.httpUrlString;
- }
-
- /**
- * Human readable string form for debugging, should not be regarded as
- * stable.
- */
- @Override
- public String toString() {
- return "http{" + httpUrl.toExternalForm() + "}";
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((httpUrl == null) ? 0 : httpUrl.toExternalForm().hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof HttpReference))
- return false;
- final HttpReference other = (HttpReference) obj;
- if (httpUrl == null) {
- if (other.httpUrl != null)
- return false;
- } else if (!httpUrl.toExternalForm().equals(
- other.httpUrl.toExternalForm()))
- return false;
- return true;
- }
-
- // One minute
- private static final int CACHE_TIMEOUT = 60000;
-
- @Override
- public Long getApproximateSizeInBytes() {
- long now = currentTimeMillis();
- if (cachedLength != null && cacheTime != null
- && cacheTime.getTime() + CACHE_TIMEOUT > now)
- return cachedLength;
- try {
- HttpURLConnection c = (HttpURLConnection) httpUrl.openConnection();
- c.setRequestMethod("HEAD");
- c.connect();
- String lenString = c.getHeaderField("Content-Length");
- if (lenString != null && !lenString.isEmpty()) {
- cachedLength = new Long(lenString);
- cacheTime = new Date(now);
- return cachedLength;
- }
- // there is no Content-Length field so we cannot know the size
- } catch (Exception e) {
- // something went wrong, but we don't care what
- }
- cachedLength = null;
- cacheTime = null;
- return new Long(-1);
- }
-
- /**
- * @return the httpUrl
- */
- public final URL getHttpUrl() {
- return httpUrl;
- }
-
- @Override
- public float getResolutionCost() {
- return (float) 200.0;
- }
-
- public void deleteData() {
- throw new UnsupportedOperationException(
- "Cannot delete data referenced by a URL");
- }
-
- @Override
- public HttpReference clone() {
- HttpReference result = new HttpReference();
- result.setHttpUrlString(this.getHttpUrlString());
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/UrlToHttpReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/UrlToHttpReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/UrlToHttpReference.java
deleted file mode 100644
index 67c3fc8..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/UrlToHttpReference.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * 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.impl.external.http;
-
-import java.net.URL;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ValueToReferenceConversionException;
-import net.sf.taverna.t2.reference.ValueToReferenceConverterSPI;
-
-/**
- * Convert a URL with http protocol to a HttpReference reference type
- *
- * @author Tom Oinn
- *
- */
-public class UrlToHttpReference implements ValueToReferenceConverterSPI {
- /**
- * Can convert if the object is an instance of java.net.URL and the protocol
- * is HTTP
- */
- @Override
- public boolean canConvert(Object o, ReferenceContext context) {
- if (o instanceof URL) {
- String protocol = ((URL) o).getProtocol();
- if (protocol.equalsIgnoreCase("http") || protocol.equals("https"))
- return true;
- }
- return false;
- }
-
- /**
- * Return a new HttpReference constructed from
- * <code>((URL)o).toExternalForm()</code>
- */
- @Override
- public ExternalReferenceSPI convert(Object o, ReferenceContext context)
- throws ValueToReferenceConversionException {
- HttpReference result = new HttpReference();
- result.setHttpUrlString(((URL) o).toExternalForm());
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/package.html
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/package.html b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/package.html
deleted file mode 100644
index 49d1d32..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/http/package.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<body>
-Support for references to a URL with the HTTP protocol
-</body>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/BooleanToStringReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/BooleanToStringReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/BooleanToStringReference.java
deleted file mode 100644
index 77d54fb..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/BooleanToStringReference.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * 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.impl.external.object;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ValueToReferenceConversionException;
-import net.sf.taverna.t2.reference.ValueToReferenceConverterSPI;
-
-/**
- * Convert a java.lang.Boolean to a StringReference.
- *
- * @author Alan R Williams
- */
-public class BooleanToStringReference implements ValueToReferenceConverterSPI {
- /**
- * Can convert if the object is an instance of java.lang.Boolean
- */
- @Override
- public boolean canConvert(Object o, ReferenceContext context) {
- return o instanceof Boolean;
- }
-
- /**
- * Return a new InlineStringReference wrapping the supplied String
- */
- @Override
- public ExternalReferenceSPI convert(Object o, ReferenceContext context)
- throws ValueToReferenceConversionException {
- InlineStringReference result = new InlineStringReference();
- String stringValue = ((Boolean) o).toString();
- result.setContents(stringValue);
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/ByteArrayToByteArrayReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/ByteArrayToByteArrayReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/ByteArrayToByteArrayReference.java
deleted file mode 100644
index 41e60ea..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/ByteArrayToByteArrayReference.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * 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.impl.external.object;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ValueToReferenceConversionException;
-import net.sf.taverna.t2.reference.ValueToReferenceConverterSPI;
-
-/**
- * Convert a byte[] to a ByteArrayReference
- *
- * @author Tom Oinn
- */
-public class ByteArrayToByteArrayReference implements
- ValueToReferenceConverterSPI {
- /**
- * Can convert if the object is an instance of byte[]
- */
- @Override
- public boolean canConvert(Object o, ReferenceContext context) {
- return (o instanceof byte[]);
- }
-
- /**
- * Return a new InlineByteArrayReference wrapping the supplied byte[]
- */
- @Override
- public ExternalReferenceSPI convert(Object o, ReferenceContext context)
- throws ValueToReferenceConversionException {
- InlineByteArrayReference result = new InlineByteArrayReference();
- result.setValue((byte[]) o);
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/CharacterToStringReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/CharacterToStringReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/CharacterToStringReference.java
deleted file mode 100644
index c5d6c66..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/CharacterToStringReference.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * 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.impl.external.object;
-
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ValueToReferenceConversionException;
-import net.sf.taverna.t2.reference.ValueToReferenceConverterSPI;
-
-/**
- * Convert a {@link Character} to a StringReference.
- *
- * @author Alan R Williams
- */
-public class CharacterToStringReference implements ValueToReferenceConverterSPI {
- /**
- * Can convert if the object is an instance of java.lang.Character
- */
- @Override
- public boolean canConvert(Object o, ReferenceContext context) {
- return (o instanceof Character);
- }
-
- /**
- * Return a new {@link InlineStringReference} wrapping the supplied String
- */
- @Override
- public ExternalReferenceSPI convert(Object o, ReferenceContext context)
- throws ValueToReferenceConversionException {
- InlineStringReference result = new InlineStringReference();
- String stringValue = ((Character) o).toString();
- result.setContents(stringValue);
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReference.java
deleted file mode 100644
index fac9f02..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReference.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * 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.impl.external.object;
-
-import static org.apache.commons.codec.binary.Base64.decodeBase64;
-import static org.apache.commons.codec.binary.Base64.encodeBase64;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.DereferenceException;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ValueCarryingExternalReference;
-
-/**
- * A reference implementation that inlines an array of bytes. Rather
- * unpleasantly this currently exposes the byte array to Hibernate through a
- * textual value, as Derby allows long textual values but not long binary ones
- * (yuck). As it uses a fixed character set (UTF-8) to store and load I believe
- * this doesn't break things.
- * <p>
- * Unfortunately this does break things (binaries get corrupted) so I've added
- * base64 encoding of the value as a workaround.
- *
- * @author Tom Oinn
- * @author David Withers
- */
-public class InlineByteArrayReference extends AbstractExternalReference
- implements ValueCarryingExternalReference<byte[]> {
- private byte[] bytes = new byte[0];
-
- public void setValue(byte[] newBytes) {
- this.bytes = newBytes;
- }
-
- @Override
- public byte[] getValue() {
- return bytes;
- }
-
- @Override
- public Class<byte[]> getValueType() {
- return byte[].class;
- }
-
- @Override
- public InputStream openStream(ReferenceContext context)
- throws DereferenceException {
- return new ByteArrayInputStream(bytes);
- }
-
- private static final Charset charset = Charset.forName("UTF-8");
-
- public String getContents() {
- return new String(encodeBase64(bytes), charset);
- }
-
- public void setContents(String contentsAsString) {
- this.bytes = decodeBase64(contentsAsString.getBytes(charset));
- }
-
- @Override
- public Long getApproximateSizeInBytes() {
- return new Long(bytes.length);
- }
-
- @Override
- public InlineByteArrayReference clone() {
- InlineByteArrayReference result = new InlineByteArrayReference();
- result.setValue(this.getValue().clone());
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReferenceBuilder.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReferenceBuilder.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReferenceBuilder.java
deleted file mode 100644
index f58f77b..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteArrayReferenceBuilder.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * 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.impl.external.object;
-
-import static net.sf.taverna.t2.reference.impl.external.object.StreamToByteArrayConverter.readFile;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import net.sf.taverna.t2.reference.ExternalReferenceBuilderSPI;
-import net.sf.taverna.t2.reference.ExternalReferenceConstructionException;
-import net.sf.taverna.t2.reference.ReferenceContext;
-
-/**
- * Build an InlineByteArrayReference from an InputStream
- *
- * @author Tom Oinn
- *
- */
-public class InlineByteArrayReferenceBuilder implements
- ExternalReferenceBuilderSPI<InlineByteArrayReference> {
- @Override
- public InlineByteArrayReference createReference(InputStream byteStream,
- ReferenceContext context) {
- try {
- byte[] contents = readFile(byteStream);
- InlineByteArrayReference ref = new InlineByteArrayReference();
- ref.setValue(contents);
- return ref;
- } catch (IOException e) {
- throw new ExternalReferenceConstructionException(e);
- }
- }
-
- @Override
- public float getConstructionCost() {
- return 0.1f;
- }
-
- @Override
- public Class<InlineByteArrayReference> getReferenceType() {
- return InlineByteArrayReference.class;
- }
-
- @Override
- public boolean isEnabled(ReferenceContext context) {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteToInlineStringTranslator.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteToInlineStringTranslator.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteToInlineStringTranslator.java
deleted file mode 100644
index b9aa66c..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineByteToInlineStringTranslator.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package net.sf.taverna.t2.reference.impl.external.object;
-
-import java.io.UnsupportedEncodingException;
-
-import net.sf.taverna.t2.reference.ExternalReferenceConstructionException;
-import net.sf.taverna.t2.reference.ExternalReferenceTranslatorSPI;
-import net.sf.taverna.t2.reference.ReferenceContext;
-
-public class InlineByteToInlineStringTranslator
- implements
- ExternalReferenceTranslatorSPI<InlineByteArrayReference, InlineStringReference> {
- @Override
- public InlineStringReference createReference(
- InlineByteArrayReference sourceReference, ReferenceContext context) {
- String contents;
- try {
- String charset = sourceReference.getCharset();
- if (charset == null)
- // usual fallback:
- charset = "UTF-8";
- contents = new String(sourceReference.getValue(), charset);
- } catch (UnsupportedEncodingException e) {
- String msg = "Unknown character set "
- + sourceReference.getCharset();
- throw new ExternalReferenceConstructionException(msg, e);
- }
- InlineStringReference ref = new InlineStringReference();
- ref.setContents(contents);
- return ref;
- }
-
- @Override
- public Class<InlineByteArrayReference> getSourceReferenceType() {
- return InlineByteArrayReference.class;
- }
-
- @Override
- public Class<InlineStringReference> getTargetReferenceType() {
- return InlineStringReference.class;
- }
-
- @Override
- public boolean isEnabled(ReferenceContext context) {
- return true;
- }
-
- @Override
- public float getTranslationCost() {
- return 0.001f;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/5f1ddb71/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineStringReference.java
----------------------------------------------------------------------
diff --git a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineStringReference.java b/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineStringReference.java
deleted file mode 100644
index cf3de46..0000000
--- a/taverna-reference-types/src/main/java/net/sf/taverna/t2/reference/impl/external/object/InlineStringReference.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * 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.impl.external.object;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import net.sf.taverna.t2.reference.AbstractExternalReference;
-import net.sf.taverna.t2.reference.DereferenceException;
-import net.sf.taverna.t2.reference.ReferenceContext;
-import net.sf.taverna.t2.reference.ReferencedDataNature;
-import net.sf.taverna.t2.reference.ValueCarryingExternalReference;
-
-/**
- * Contains and references a String value
- *
- * @author Tom Oinn
- */
-public class InlineStringReference extends AbstractExternalReference implements
- ValueCarryingExternalReference<String> {
- /**
- * Hold the 'value' of this reference, probably the simplest backing store
- * possible for an ExternalReferenceSPI implementation :)
- */
- private String contents;
- private transient Long length;
-
- /**
- * Set the 'value' of this reference as a string. It's not really a
- * reference type in any true sense of the word, but it'll do for testing
- * the augmentation system. This method is really here so you can configure
- * test beans from spring.
- */
- public void setContents(String contents) {
- this.contents = contents;
- }
-
- /**
- * Get the 'value' of this reference as a string, really just returns the
- * internal string representation.
- */
- public String getContents() {
- return this.contents;
- }
-
- /**
- * Fakes a de-reference operation, returning a byte stream over the string
- * data.
- */
- @Override
- public InputStream openStream(ReferenceContext arg0) {
- try {
- return new ByteArrayInputStream(contents.getBytes(getCharset()));
- } catch (UnsupportedEncodingException e) {
- throw new DereferenceException(e);
- }
- }
-
- /**
- * Default resolution cost of 0.0f whatever the contents
- */
- @Override
- public float getResolutionCost() {
- return 0.0f;
- }
-
- /**
- * Data nature set to 'ReferencedDataNature.TEXT'
- */
- @Override
- public ReferencedDataNature getDataNature() {
- return ReferencedDataNature.TEXT;
- }
-
- /**
- * Character encoding set to 'UTF-8' by default
- */
- @Override
- public String getCharset() {
- return "UTF-8";
- }
-
- /**
- * String representation for testing, returns <code>string{CONTENTS}</code>
- */
- @Override
- public String toString() {
- return "string{" + contents + "}";
- }
-
- @Override
- public String getValue() {
- return getContents();
- }
-
- @Override
- public Class<String> getValueType() {
- return String.class;
- }
-
- @Override
- public Long getApproximateSizeInBytes() {
- if (length == null)
- length = new Long(contents.getBytes().length);
- return length;
- }
-
- @Override
- public InlineStringReference clone() {
- InlineStringReference result = new InlineStringReference();
- result.setContents(this.getContents());
- return result;
- }
-}