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:35:53 UTC
[38/58] [abbrv] incubator-taverna-plugin-component git commit:
org.apache.taverna.component.*
org.apache.taverna.component.*
Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/commit/fb982e2f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/tree/fb982e2f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/diff/fb982e2f
Branch: refs/heads/master
Commit: fb982e2fc1bb0a02feb005c4ef8ba681f1e47059
Parents: 2421ba8
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Sat Feb 21 19:29:07 2015 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Sat Feb 21 19:29:07 2015 +0000
----------------------------------------------------------------------
.../taverna/t2/component/ComponentActivity.java | 152 ----
.../ComponentActivityConfigurationBean.java | 145 ----
.../t2/component/ComponentActivityFactory.java | 125 ----
.../ComponentActivityLocalChecker.java | 52 --
.../ComponentActivityUpgradeChecker.java | 69 --
.../t2/component/ComponentExceptionFactory.java | 27 -
.../t2/component/ComponentHealthCheck.java | 24 -
.../ComponentImplementationException.java | 26 -
.../sf/taverna/t2/component/ProxyCallback.java | 250 -------
.../component/profile/ActivityProfileImpl.java | 55 --
.../component/profile/BaseProfileLocator.java | 144 ----
.../component/profile/ComponentProfileImpl.java | 685 -------------------
.../t2/component/profile/PortProfileImpl.java | 60 --
.../profile/SemanticAnnotationProfileImpl.java | 177 -----
.../t2/component/registry/ClientVersion.java | 33 -
.../t2/component/registry/Component.java | 162 -----
.../t2/component/registry/ComponentFamily.java | 163 -----
.../registry/ComponentImplementationCache.java | 64 --
.../component/registry/ComponentRegistry.java | 245 -------
.../t2/component/registry/ComponentUtil.java | 113 ---
.../t2/component/registry/ComponentVersion.java | 66 --
.../ComponentVersionIdentification.java | 196 ------
.../registry/local/LocalComponent.java | 134 ----
.../registry/local/LocalComponentFamily.java | 141 ----
.../registry/local/LocalComponentRegistry.java | 205 ------
.../local/LocalComponentRegistryFactory.java | 45 --
.../registry/local/LocalComponentVersion.java | 94 ---
.../t2/component/registry/standard/Client.java | 637 -----------------
.../registry/standard/NewComponent.java | 221 ------
.../registry/standard/NewComponentFamily.java | 133 ----
.../registry/standard/NewComponentLicense.java | 59 --
.../registry/standard/NewComponentProfile.java | 104 ---
.../registry/standard/NewComponentRegistry.java | 469 -------------
.../standard/NewComponentRegistryFactory.java | 66 --
.../t2/component/registry/standard/Policy.java | 137 ----
.../registry/standard/annotations/Unused.java | 25 -
.../standard/annotations/package-info.java | 6 -
.../registry/standard/package-info.java | 5 -
.../t2/component/utils/AnnotationUtils.java | 91 ---
.../taverna/t2/component/utils/SystemUtils.java | 118 ----
.../taverna/component/ComponentActivity.java | 152 ++++
.../ComponentActivityConfigurationBean.java | 145 ++++
.../component/ComponentActivityFactory.java | 125 ++++
.../ComponentActivityLocalChecker.java | 52 ++
.../ComponentActivityUpgradeChecker.java | 69 ++
.../component/ComponentExceptionFactory.java | 27 +
.../taverna/component/ComponentHealthCheck.java | 24 +
.../ComponentImplementationException.java | 26 +
.../apache/taverna/component/ProxyCallback.java | 250 +++++++
.../component/profile/ActivityProfileImpl.java | 55 ++
.../component/profile/BaseProfileLocator.java | 144 ++++
.../component/profile/ComponentProfileImpl.java | 685 +++++++++++++++++++
.../component/profile/PortProfileImpl.java | 60 ++
.../profile/SemanticAnnotationProfileImpl.java | 177 +++++
.../component/registry/ClientVersion.java | 33 +
.../taverna/component/registry/Component.java | 162 +++++
.../component/registry/ComponentFamily.java | 163 +++++
.../registry/ComponentImplementationCache.java | 64 ++
.../component/registry/ComponentRegistry.java | 245 +++++++
.../component/registry/ComponentUtil.java | 112 +++
.../component/registry/ComponentVersion.java | 66 ++
.../ComponentVersionIdentification.java | 196 ++++++
.../registry/local/LocalComponent.java | 133 ++++
.../registry/local/LocalComponentFamily.java | 140 ++++
.../registry/local/LocalComponentRegistry.java | 204 ++++++
.../local/LocalComponentRegistryFactory.java | 44 ++
.../registry/local/LocalComponentVersion.java | 93 +++
.../component/registry/standard/Client.java | 637 +++++++++++++++++
.../registry/standard/NewComponent.java | 221 ++++++
.../registry/standard/NewComponentFamily.java | 133 ++++
.../registry/standard/NewComponentLicense.java | 58 ++
.../registry/standard/NewComponentProfile.java | 103 +++
.../registry/standard/NewComponentRegistry.java | 469 +++++++++++++
.../standard/NewComponentRegistryFactory.java | 66 ++
.../component/registry/standard/Policy.java | 136 ++++
.../registry/standard/annotations/Unused.java | 25 +
.../standard/annotations/package-info.java | 6 +
.../registry/standard/package-info.java | 5 +
.../component/utils/AnnotationUtils.java | 91 +++
.../taverna/component/utils/SystemUtils.java | 118 ++++
.../src/main/resources/EmptyProfile.xml | 2 +-
.../spring/component-activity-context.xml | 22 +-
.../main/resources/NewMyExperimentSchema.xsd | 2 +-
.../t2/component/ComponentActivityTest.java | 103 ---
.../component/registry/ComponentFamilyTest.java | 124 ----
.../registry/ComponentRegistryTest.java | 183 -----
.../t2/component/registry/ComponentTest.java | 113 ---
.../registry/ComponentVersionTest.java | 96 ---
.../taverna/t2/component/registry/Harness.java | 11 -
.../local/LocalComponentFamilyTest.java | 43 --
.../local/LocalComponentRegistryTest.java | 61 --
.../registry/local/LocalComponentTest.java | 43 --
.../local/LocalComponentVersionTest.java | 43 --
.../registry/local/RegistrySupport.java | 24 -
.../standard/NewComponentFamilyTest.java | 25 -
.../standard/NewComponentRegistryTest.java | 75 --
.../registry/standard/NewComponentTest.java | 25 -
.../standard/NewComponentVersionTest.java | 25 -
.../registry/standard/RegistrySupport.java | 33 -
.../net/sf/taverna/t2/util/AnnotationTest.java | 31 -
.../taverna/component/AnnotationTest.java | 30 +
.../component/ComponentActivityTest.java | 107 +++
.../component/registry/ComponentFamilyTest.java | 124 ++++
.../registry/ComponentRegistryTest.java | 183 +++++
.../component/registry/ComponentTest.java | 113 +++
.../registry/ComponentVersionTest.java | 96 +++
.../taverna/component/registry/Harness.java | 12 +
.../local/LocalComponentFamilyTest.java | 42 ++
.../local/LocalComponentRegistryTest.java | 61 ++
.../registry/local/LocalComponentTest.java | 42 ++
.../local/LocalComponentVersionTest.java | 42 ++
.../registry/local/RegistrySupport.java | 26 +
.../standard/NewComponentFamilyTest.java | 24 +
.../standard/NewComponentRegistryTest.java | 77 +++
.../registry/standard/NewComponentTest.java | 24 +
.../standard/NewComponentVersionTest.java | 24 +
.../registry/standard/RegistrySupport.java | 37 +
...rity.credentialmanager.CredentialProviderSPI | 2 +-
118 files changed, 6792 insertions(+), 6795 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/fb982e2f/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivity.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivity.java b/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivity.java
deleted file mode 100644
index f845829..0000000
--- a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivity.java
+++ /dev/null
@@ -1,152 +0,0 @@
-package net.sf.taverna.t2.component;
-
-import static net.sf.taverna.t2.workflowmodel.utils.AnnotationTools.getAnnotationString;
-import static net.sf.taverna.t2.workflowmodel.utils.AnnotationTools.setAnnotationString;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.net.MalformedURLException;
-import java.util.Map;
-
-import net.sf.taverna.t2.activities.dataflow.DataflowActivity;
-import net.sf.taverna.t2.annotation.annotationbeans.SemanticAnnotation;
-import net.sf.taverna.t2.component.registry.ComponentImplementationCache;
-import net.sf.taverna.t2.component.registry.ComponentUtil;
-import net.sf.taverna.t2.component.utils.AnnotationUtils;
-import net.sf.taverna.t2.component.utils.SystemUtils;
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.invocation.impl.InvocationContextImpl;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.Dataflow;
-import net.sf.taverna.t2.workflowmodel.EditException;
-import net.sf.taverna.t2.workflowmodel.Edits;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AbstractAsynchronousActivity;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityConfigurationException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.ComponentException;
-import org.apache.taverna.component.api.profile.ExceptionHandling;
-
-import uk.org.taverna.platform.execution.api.InvalidWorkflowException;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-public class ComponentActivity extends
- AbstractAsynchronousActivity<JsonNode> {
- public static final String URI = "http://ns.taverna.org.uk/2010/activity/component";
- private Logger logger = getLogger(ComponentActivity.class);
-
- private ComponentUtil util;
- private ComponentImplementationCache cache;
- private volatile DataflowActivity componentRealization;
- private JsonNode json;
- private ComponentActivityConfigurationBean bean;
- private SystemUtils system;
- private AnnotationUtils annUtils;
- private ComponentExceptionFactory cef;
-
- private Dataflow realizingDataflow = null;
-
- ComponentActivity(ComponentUtil util, ComponentImplementationCache cache,
- Edits edits, SystemUtils system, AnnotationUtils annUtils, ComponentExceptionFactory exnFactory) {
- this.util = util;
- this.cache = cache;
- this.system = system;
- this.annUtils = annUtils;
- setEdits(edits);
- this.componentRealization = new DataflowActivity();
- this.cef = exnFactory;
- }
-
- @Override
- public void configure(JsonNode json) throws ActivityConfigurationException {
- this.json = json;
- try {
- bean = new ComponentActivityConfigurationBean(json, util, cache);
- } catch (MalformedURLException e) {
- throw new ActivityConfigurationException(
- "failed to understand configuration", e);
- }
- try {
- configurePorts(bean.getPorts());
- } catch (ComponentException e) {
- throw new ActivityConfigurationException(
- "failed to get component realization", e);
- }
- }
-
- @Override
- public void executeAsynch(Map<String, T2Reference> inputs,
- AsynchronousActivityCallback callback) {
- try {
- ExceptionHandling exceptionHandling = bean.getExceptionHandling();
- // InvocationContextImpl newContext = copyInvocationContext(callback);
-
- getComponentRealization().executeAsynch(inputs, new ProxyCallback(
- callback, callback.getContext(), exceptionHandling, cef));
- } catch (ActivityConfigurationException e) {
- callback.fail("Unable to execute component", e);
- }
- }
-
- @SuppressWarnings("unused")
- private InvocationContextImpl copyInvocationContext(
- AsynchronousActivityCallback callback) {
- InvocationContext originalContext = callback.getContext();
- ReferenceService rs = originalContext.getReferenceService();
- InvocationContextImpl newContext = new InvocationContextImpl(rs, null);
- // for (Object o : originalContext.getEntities(Object.class)) {
- // newContext.addEntity(o);
- // }
- return newContext;
- }
-
- @Override
- public JsonNode getConfiguration() {
- return json;
- }
-
- ComponentActivityConfigurationBean getConfigBean() {
- return bean;
- }
-
- private DataflowActivity getComponentRealization()
- throws ActivityConfigurationException {
- synchronized (componentRealization) {
- try {
- if (componentRealization.getNestedDataflow() == null) {
- if (realizingDataflow == null)
- realizingDataflow = system.compile(util
- .getVersion(bean).getImplementation());
- componentRealization.setNestedDataflow(realizingDataflow);
- copyAnnotations();
- }
- } catch (ComponentException e) {
- logger.error("unable to read workflow", e);
- throw new ActivityConfigurationException(
- "unable to read workflow", e);
- } catch (InvalidWorkflowException e) {
- logger.error("unable to compile workflow", e);
- throw new ActivityConfigurationException(
- "unable to compile workflow", e);
- }
- }
-
- return componentRealization;
- }
-
- private void copyAnnotations() {
- // FIXME Completely wrong way of doing this!
- try {
- //annUtils.getAnnotation(subject, uriForAnnotation)
- String annotationValue = getAnnotationString(realizingDataflow,
- SemanticAnnotation.class, null);
- if (annotationValue != null)
- setAnnotationString(this, SemanticAnnotation.class,
- annotationValue, getEdits()).doEdit();
- } catch (EditException e) {
- logger.error("failed to set annotation string", e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/fb982e2f/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivityConfigurationBean.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivityConfigurationBean.java b/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivityConfigurationBean.java
deleted file mode 100644
index e70e83f..0000000
--- a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivityConfigurationBean.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package net.sf.taverna.t2.component;
-
-import static org.apache.log4j.Logger.getLogger;
-import static org.apache.taverna.component.api.config.ComponentPropertyNames.COMPONENT_NAME;
-import static org.apache.taverna.component.api.config.ComponentPropertyNames.COMPONENT_VERSION;
-import static org.apache.taverna.component.api.config.ComponentPropertyNames.FAMILY_NAME;
-import static org.apache.taverna.component.api.config.ComponentPropertyNames.REGISTRY_BASE;
-
-import java.io.Serializable;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import net.sf.taverna.t2.component.registry.ComponentImplementationCache;
-import net.sf.taverna.t2.component.registry.ComponentUtil;
-import net.sf.taverna.t2.component.registry.ComponentVersionIdentification;
-import net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean;
-import net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityOutputPortDefinitionBean;
-import net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityPortsDefinitionBean;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.Version;
-import org.apache.taverna.component.api.profile.ExceptionHandling;
-
-import uk.org.taverna.scufl2.api.container.WorkflowBundle;
-import uk.org.taverna.scufl2.api.port.InputWorkflowPort;
-import uk.org.taverna.scufl2.api.port.OutputWorkflowPort;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Component activity configuration bean.
- */
-public class ComponentActivityConfigurationBean extends
- ComponentVersionIdentification implements Serializable {
- public static final String ERROR_CHANNEL = "error_channel";
- public static final List<String> ignorableNames = Arrays
- .asList(ERROR_CHANNEL);
- private static final long serialVersionUID = 5774901665863468058L;
- private static final Logger logger = getLogger(ComponentActivity.class);
-
- private transient ActivityPortsDefinitionBean ports = null;
- private transient ExceptionHandling eh;
- private transient ComponentUtil util;
- private transient ComponentImplementationCache cache;
-
- public ComponentActivityConfigurationBean(Version.ID toBeCopied,
- ComponentUtil util, ComponentImplementationCache cache) {
- super(toBeCopied);
- this.util = util;
- this.cache = cache;
- try {
- getPorts();
- } catch (org.apache.taverna.component.api.ComponentException e) {
- logger.error("failed to get component realization", e);
- }
- }
-
- public ComponentActivityConfigurationBean(JsonNode json,
- ComponentUtil util, ComponentImplementationCache cache) throws MalformedURLException {
- super(getUrl(json), getFamily(json), getComponent(json),
- getVersion(json));
- this.util = util;
- this.cache = cache;
- }
-
- private static URL getUrl(JsonNode json) throws MalformedURLException {
- return new URL(json.get(REGISTRY_BASE).textValue());
- }
-
- private static String getFamily(JsonNode json) {
- return json.get(FAMILY_NAME).textValue();
- }
-
- private static String getComponent(JsonNode json) {
- return json.get(COMPONENT_NAME).textValue();
- }
-
- private static Integer getVersion(JsonNode json) {
- JsonNode node = json.get(COMPONENT_VERSION);
- if (node == null || !node.isInt())
- return null;
- return node.intValue();
- }
-
- private ActivityPortsDefinitionBean getPortsDefinition(WorkflowBundle w) {
- ActivityPortsDefinitionBean result = new ActivityPortsDefinitionBean();
- List<ActivityInputPortDefinitionBean> inputs = result
- .getInputPortDefinitions();
- List<ActivityOutputPortDefinitionBean> outputs = result
- .getOutputPortDefinitions();
-
- for (InputWorkflowPort iwp : w.getMainWorkflow().getInputPorts())
- inputs.add(makeInputDefinition(iwp));
- for (OutputWorkflowPort owp : w.getMainWorkflow().getOutputPorts())
- outputs.add(makeOutputDefinition(0, owp.getName()));//FIXME
-
- try {
- eh = util.getFamily(getRegistryBase(), getFamilyName())
- .getComponentProfile().getExceptionHandling();
- if (eh != null)
- outputs.add(makeOutputDefinition(1, ERROR_CHANNEL));
- } catch (org.apache.taverna.component.api.ComponentException e) {
- logger.error("failed to get exception handling for family", e);
- }
- return result;
- }
-
- private ActivityInputPortDefinitionBean makeInputDefinition(
- InputWorkflowPort dip) {
- ActivityInputPortDefinitionBean activityInputPortDefinitionBean = new ActivityInputPortDefinitionBean();
- activityInputPortDefinitionBean.setHandledReferenceSchemes(null);
- activityInputPortDefinitionBean.setMimeTypes((List<String>) null);
- activityInputPortDefinitionBean.setTranslatedElementType(String.class);
- activityInputPortDefinitionBean.setAllowsLiteralValues(true);
- activityInputPortDefinitionBean.setDepth(dip.getDepth());
- activityInputPortDefinitionBean.setName(dip.getName());
- return activityInputPortDefinitionBean;
- }
-
- private ActivityOutputPortDefinitionBean makeOutputDefinition(int depth,
- String name) {
- ActivityOutputPortDefinitionBean activityOutputPortDefinitionBean = new ActivityOutputPortDefinitionBean();
- activityOutputPortDefinitionBean.setMimeTypes(new ArrayList<String>());
- activityOutputPortDefinitionBean.setDepth(depth);
- activityOutputPortDefinitionBean.setGranularDepth(depth);
- activityOutputPortDefinitionBean.setName(name);
- return activityOutputPortDefinitionBean;
- }
-
- /**
- * @return the ports
- */
- public ActivityPortsDefinitionBean getPorts() throws org.apache.taverna.component.api.ComponentException{
- if (ports == null)
- ports = getPortsDefinition(cache.getImplementation(this));
- return ports;
- }
-
- public ExceptionHandling getExceptionHandling() {
- return eh;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/fb982e2f/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivityFactory.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivityFactory.java b/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivityFactory.java
deleted file mode 100644
index 50d7ec7..0000000
--- a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivityFactory.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package net.sf.taverna.t2.component;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.util.HashSet;
-import java.util.Set;
-
-import net.sf.taverna.t2.component.registry.ComponentImplementationCache;
-import net.sf.taverna.t2.component.registry.ComponentUtil;
-import net.sf.taverna.t2.component.utils.AnnotationUtils;
-import net.sf.taverna.t2.component.utils.SystemUtils;
-import net.sf.taverna.t2.workflowmodel.Edits;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityConfigurationException;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityFactory;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityInputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityOutputPort;
-import net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityInputPortDefinitionBean;
-import net.sf.taverna.t2.workflowmodel.processor.activity.config.ActivityOutputPortDefinitionBean;
-
-import org.apache.taverna.component.api.ComponentException;
-import org.apache.taverna.component.api.Version.ID;
-import org.springframework.beans.factory.annotation.Required;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-public class ComponentActivityFactory extends ComponentExceptionFactory
- implements ActivityFactory {
- private ComponentUtil util;
- private ComponentImplementationCache cache;
- private Edits edits;
- private SystemUtils system;
- private AnnotationUtils annUtils;
-
- @Override
- public ComponentActivity createActivity() {
- return new ComponentActivity(util, cache, edits, system, annUtils, this);
- }
-
- @Override
- public URI getActivityType() {
- return URI.create(ComponentActivity.URI);
- }
-
- @Override
- public JsonNode getActivityConfigurationSchema() {
- ObjectMapper objectMapper = new ObjectMapper();
- try {
- return objectMapper
- .readTree(getClass().getResource("/schema.json"));
- } catch (IOException e) {
- return objectMapper.createObjectNode();
- }
- }
-
- @Override
- public Set<ActivityInputPort> getInputPorts(JsonNode configuration)
- throws ActivityConfigurationException {
- try {
- Set<ActivityInputPort> activityInputPorts = new HashSet<>();
- for (ActivityInputPortDefinitionBean ipd : createConfiguration(
- configuration).getPorts().getInputPortDefinitions())
- activityInputPorts.add(edits.createActivityInputPort(
- ipd.getName(), ipd.getDepth(), true, null,
- ipd.getTranslatedElementType()));
- return activityInputPorts;
- } catch (MalformedURLException | ComponentException | RuntimeException e) {
- throw new ActivityConfigurationException(
- "failed to get implementation for configuration of inputs",
- e);
- }
- }
-
- @Override
- public Set<ActivityOutputPort> getOutputPorts(JsonNode configuration)
- throws ActivityConfigurationException {
- try {
- Set<ActivityOutputPort> activityOutputPorts = new HashSet<>();
- for (ActivityOutputPortDefinitionBean opd : createConfiguration(
- configuration).getPorts().getOutputPortDefinitions())
- activityOutputPorts.add(edits.createActivityOutputPort(
- opd.getName(), opd.getDepth(), opd.getGranularDepth()));
- return activityOutputPorts;
- } catch (MalformedURLException | ComponentException | RuntimeException e) {
- throw new ActivityConfigurationException(
- "failed to get implementation for configuration of outputs",
- e);
- }
- }
-
- public ComponentActivityConfigurationBean createConfiguration(ID id) {
- return new ComponentActivityConfigurationBean(id, util, cache);
- }
-
- public ComponentActivityConfigurationBean createConfiguration(JsonNode json)
- throws MalformedURLException {
- return new ComponentActivityConfigurationBean(json, util, cache);
- }
-
- @Required
- public void setComponentUtil(ComponentUtil util) {
- this.util = util;
- }
-
- @Required
- public void setDataflowCache(ComponentImplementationCache cache) {
- this.cache = cache;
- }
-
- @Required
- public void setEdits(Edits edits) {
- this.edits = edits;
- }
-
- @Required
- public void setSystemUtil(SystemUtils system) {
- this.system = system;
- }
-
- @Required
- public void setAnnotationUtils(AnnotationUtils annUtils) {
- this.annUtils = annUtils;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/fb982e2f/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivityLocalChecker.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivityLocalChecker.java b/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivityLocalChecker.java
deleted file mode 100644
index 846c36f..0000000
--- a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivityLocalChecker.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package net.sf.taverna.t2.component;
-
-import static net.sf.taverna.t2.component.ComponentHealthCheck.NON_SHAREABLE;
-import static net.sf.taverna.t2.visit.VisitReport.Status.WARNING;
-
-import java.util.List;
-
-import net.sf.taverna.t2.visit.VisitKind;
-import net.sf.taverna.t2.visit.VisitReport;
-import net.sf.taverna.t2.workflowmodel.health.HealthChecker;
-
-/**
- * Component health checker
- *
- */
-public class ComponentActivityLocalChecker implements
- HealthChecker<ComponentActivity> {
- private static final VisitKind visitKind = ComponentHealthCheck
- .getInstance();
-
- @Override
- public boolean canVisit(Object o) {
- /*
- * Return True if we can visit the object. We could do deeper (but not
- * time consuming) checks here, for instance if the health checker only
- * deals with ComponentActivity where a certain configuration option is
- * enabled.
- */
- return o instanceof ComponentActivity;
- }
-
- @Override
- public boolean isTimeConsuming() {
- /*
- * Return true if the health checker does a network lookup or similar
- * time consuming checks, in which case it would only be performed when
- * using File->Validate workflow or File->Run.
- */
- return false;
- }
-
- @Override
- public VisitReport visit(ComponentActivity activity, List<Object> ancestry) {
- if (!activity.getConfigBean().getRegistryBase().getProtocol()
- .startsWith("http"))
- return new VisitReport(visitKind, activity,
- "Local component makes workflow non-shareable",
- NON_SHAREABLE, WARNING);
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/fb982e2f/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivityUpgradeChecker.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivityUpgradeChecker.java b/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivityUpgradeChecker.java
deleted file mode 100644
index fadfb4c..0000000
--- a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentActivityUpgradeChecker.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component;
-
-import static net.sf.taverna.t2.component.ComponentHealthCheck.OUT_OF_DATE;
-import static net.sf.taverna.t2.visit.VisitReport.Status.WARNING;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.util.List;
-
-import net.sf.taverna.t2.component.registry.ComponentUtil;
-import net.sf.taverna.t2.visit.VisitKind;
-import net.sf.taverna.t2.visit.VisitReport;
-import net.sf.taverna.t2.workflowmodel.health.HealthChecker;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.ComponentException;
-import org.springframework.beans.factory.annotation.Required;
-
-/**
- * @author alanrw
- *
- */
-public class ComponentActivityUpgradeChecker implements
- HealthChecker<ComponentActivity> {
- private static final String OUTDATED_MSG = "Component out of date";
- private static final VisitKind visitKind = ComponentHealthCheck
- .getInstance();
- private static Logger logger = getLogger(ComponentActivityUpgradeChecker.class);
- private ComponentUtil utils;
-
- @Required
- public void setComponentUtil(ComponentUtil util) {
- this.utils = util;
- }
-
- @Override
- public boolean canVisit(Object o) {
- return o instanceof ComponentActivity;
- }
-
- @Override
- public boolean isTimeConsuming() {
- return false;
- }
-
- @Override
- public VisitReport visit(ComponentActivity activity, List<Object> ancestry) {
- ComponentActivityConfigurationBean config = activity.getConfigBean();
- int versionNumber = config.getComponentVersion();
- int latestVersion = 0;
-
- try {
- latestVersion = utils
- .getComponent(config.getRegistryBase(),
- config.getFamilyName(), config.getComponentName())
- .getComponentVersionMap().lastKey();
- } catch (ComponentException e) {
- logger.error("failed to get component description", e);
- }
-
- if (latestVersion > versionNumber)
- return new VisitReport(visitKind, activity, OUTDATED_MSG,
- OUT_OF_DATE, WARNING);
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/fb982e2f/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentExceptionFactory.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentExceptionFactory.java b/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentExceptionFactory.java
deleted file mode 100644
index f37e567..0000000
--- a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentExceptionFactory.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component;
-
-/**
- * @author alanrw
- *
- */
-class ComponentExceptionFactory {
- private static final String UNEXPECTED_ID = "http://ns.taverna.org.uk/2012/component/unexpected";
-
- ComponentExceptionFactory() {
- }
-
- public ComponentImplementationException createComponentException(
- String exceptionId, String message) {
- ComponentImplementationException result = new ComponentImplementationException(message);
- result.setExceptionId(exceptionId);
- return result;
- }
-
- public ComponentImplementationException createUnexpectedComponentException(
- String message) {
- return createComponentException(UNEXPECTED_ID, message);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/fb982e2f/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentHealthCheck.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentHealthCheck.java b/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentHealthCheck.java
deleted file mode 100644
index 7d4c906..0000000
--- a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentHealthCheck.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package net.sf.taverna.t2.component;
-
-import net.sf.taverna.t2.visit.VisitKind;
-import net.sf.taverna.t2.visit.Visitor;
-
-public class ComponentHealthCheck extends VisitKind {
- public static final int NO_PROBLEM = 0;
- public static final int OUT_OF_DATE = 10;
- public static final int NON_SHAREABLE = 20;
- public static final int FAILS_PROFILE = 30;
-
- @Override
- public Class<? extends Visitor<?>> getVisitorClass() {
- return ComponentActivityUpgradeChecker.class;
- }
-
- private static class Singleton {
- private static ComponentHealthCheck instance = new ComponentHealthCheck();
- }
-
- public static ComponentHealthCheck getInstance() {
- return Singleton.instance;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/fb982e2f/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentImplementationException.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentImplementationException.java b/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentImplementationException.java
deleted file mode 100644
index 11a8fde..0000000
--- a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ComponentImplementationException.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component;
-
-/**
- * @author alanrw
- *
- */
-public class ComponentImplementationException extends Exception {
- public ComponentImplementationException(String string) {
- super(string);
- this.setStackTrace(new StackTraceElement[] {});
- }
-
- private static final long serialVersionUID = -3844030382222698090L;
- private String exceptionId;
-
- public void setExceptionId(String exceptionId) {
- this.exceptionId = exceptionId;
- }
-
- public String getExceptionId() {
- return exceptionId;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/fb982e2f/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ProxyCallback.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ProxyCallback.java b/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ProxyCallback.java
deleted file mode 100644
index 9f3de98..0000000
--- a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/ProxyCallback.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component;
-
-import static net.sf.taverna.t2.reference.T2ReferenceType.ErrorDocument;
-import static net.sf.taverna.t2.reference.T2ReferenceType.IdentifiedList;
-import static net.sf.taverna.t2.reference.T2ReferenceType.ReferenceSet;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import javax.xml.ws.Holder;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.reference.ErrorDocument;
-import net.sf.taverna.t2.reference.ErrorDocumentService;
-import net.sf.taverna.t2.reference.IdentifiedList;
-import net.sf.taverna.t2.reference.ListService;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback;
-import net.sf.taverna.t2.workflowmodel.processor.dispatch.events.DispatchErrorType;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.profile.ExceptionHandling;
-import org.apache.taverna.component.api.profile.ExceptionReplacement;
-import org.apache.taverna.component.api.profile.HandleException;
-
-/**
- * @author alanrw
- *
- */
-public class ProxyCallback implements AsynchronousActivityCallback {
- private static final Logger logger = getLogger(ProxyCallback.class);
-
- private final ComponentExceptionFactory cef;
- private final AsynchronousActivityCallback proxiedCallback;
- private final ReferenceService references;
- private final InvocationContext context;
- private final ExceptionHandling exceptionHandling;
- private final ListService lists;
- private final ErrorDocumentService errors;
-
- /**
- * @param proxiedCallback
- * @param invocationContext
- * @param exceptionHandling
- * @param exnFactory
- */
- ProxyCallback(AsynchronousActivityCallback proxiedCallback,
- InvocationContext invocationContext,
- ExceptionHandling exceptionHandling,
- ComponentExceptionFactory exnFactory) {
- this.proxiedCallback = proxiedCallback;
- this.exceptionHandling = exceptionHandling;
- context = invocationContext;
- references = context.getReferenceService();
- lists = references.getListService();
- errors = references.getErrorDocumentService();
- cef = exnFactory;
- }
-
- @Override
- public InvocationContext getContext() {
- return context;
- }
-
- @Override
- public void requestRun(Runnable runMe) {
- proxiedCallback.requestRun(runMe);
- }
-
- @Override
- public void receiveResult(Map<String, T2Reference> data, int[] index) {
- if (exceptionHandling == null) {
- proxiedCallback.receiveResult(data, index);
- return;
- }
-
- List<T2Reference> exceptions = new ArrayList<>();
- Map<String, T2Reference> replacement = new HashMap<>();
- for (Entry<String, T2Reference> entry : data.entrySet())
- replacement.put(entry.getKey(),
- considerReference(entry.getValue(), exceptions));
- replacement.put("error_channel",
- references.register(exceptions, 1, true, context));
- proxiedCallback.receiveResult(replacement, index);
- }
-
- private T2Reference considerReference(T2Reference value,
- List<T2Reference> exceptions) {
- if (!value.containsErrors())
- return value;
- else if (!value.getReferenceType().equals(IdentifiedList))
- return replaceErrors(value, value.getDepth(), exceptions);
- else if (exceptionHandling.failLists())
- return replaceErrors(findFirstFailure(value), value.getDepth(),
- exceptions);
-
- List<T2Reference> replacementList = new ArrayList<>();
- for (T2Reference subValue : lists.getList(value))
- replacementList.add(considerReference(subValue, exceptions));
- return references.register(replacementList, value.getDepth(), true,
- context);
- }
-
- private T2Reference findFirstFailure(T2Reference value) {
- IdentifiedList<T2Reference> originalList = lists.getList(value);
- for (T2Reference subValue : originalList) {
- if (subValue.getReferenceType().equals(ErrorDocument))
- return subValue;
- if (subValue.getReferenceType().equals(IdentifiedList))
- if (subValue.containsErrors())
- return findFirstFailure(subValue);
- // No need to consider value
- }
- return null;
- }
-
- private T2Reference replaceErrors(T2Reference value, int depth,
- List<T2Reference> exceptions) {
- ErrorDocument doc = errors.getError(value);
-
- Holder<HandleException> handleException = new Holder<>();
- Set<ErrorDocument> toConsider = new HashSet<>();
- Set<ErrorDocument> considered = new HashSet<>();
- toConsider.add(doc);
-
- while (!toConsider.isEmpty())
- try {
- ErrorDocument nudoc = remapException(toConsider, considered,
- handleException);
- if (nudoc != null) {
- doc = nudoc;
- break;
- }
- } catch (Exception e) {
- logger.error("failed to locate exception mapping", e);
- }
-
- String exceptionMessage = doc.getExceptionMessage();
- // An exception that is not mentioned
- if (handleException.value == null) {
- ComponentImplementationException newException = cef
- .createUnexpectedComponentException(exceptionMessage);
- T2Reference replacement = errors.registerError(exceptionMessage,
- newException, depth, context).getId();
- exceptions.add(errors.registerError(exceptionMessage, newException,
- 0, context).getId());
- return replacement;
- }
-
- if (handleException.value.pruneStack())
- doc.getStackTraceStrings().clear();
-
- ExceptionReplacement exnReplacement = handleException.value
- .getReplacement();
- if (exnReplacement == null) {
- T2Reference replacement = references.register(doc, depth, true,
- context);
- exceptions.add(references.register(doc, 0, true, context));
- return replacement;
- }
-
- ComponentImplementationException newException = cef
- .createComponentException(exnReplacement.getReplacementId(),
- exnReplacement.getReplacementMessage());
- T2Reference replacement = errors.registerError(
- exnReplacement.getReplacementMessage(), newException, depth,
- context).getId();
- exceptions.add(errors.registerError(
- exnReplacement.getReplacementMessage(), newException, 0,
- context).getId());
- return replacement;
- }
-
- private ErrorDocument remapException(Set<ErrorDocument> toConsider,
- Set<ErrorDocument> considered,
- Holder<HandleException> handleException) {
- ErrorDocument found = null;
- ErrorDocument errorDoc = toConsider.iterator().next();
-
- considered.add(errorDoc);
- toConsider.remove(errorDoc);
- String exceptionMessage = errorDoc.getExceptionMessage();
- for (HandleException he : exceptionHandling.getHandleExceptions()) {
- if (!he.matches(exceptionMessage))
- continue;
- handleException.value = he;
- found = errorDoc;
- }
- if (!errorDoc.getErrorReferences().isEmpty())
- for (T2Reference subRef : errorDoc.getErrorReferences())
- for (T2Reference newErrorRef : getErrors(subRef)) {
- ErrorDocument subDoc = errors.getError(newErrorRef);
- if (subDoc == null)
- logger.error("Error document contains references to non-existent sub-errors");
- else if (!considered.contains(subDoc))
- toConsider.add(subDoc);
- }
- return found;
- }
-
- private Set<T2Reference> getErrors(T2Reference ref) {
- Set<T2Reference> result = new HashSet<>();
- if (ref.getReferenceType().equals(ReferenceSet)) {
- // nothing
- } else if (ref.getReferenceType().equals(IdentifiedList)) {
- IdentifiedList<T2Reference> originalList = lists.getList(ref);
- for (T2Reference subValue : originalList)
- if (subValue.containsErrors())
- result.addAll(getErrors(subValue));
- } else
- result.add(ref);
- return result;
- }
-
- @Override
- public void receiveCompletion(int[] completionIndex) {
- proxiedCallback.receiveCompletion(completionIndex);
- }
-
- @Override
- public void fail(String message, Throwable t, DispatchErrorType errorType) {
- proxiedCallback.fail(message, t, errorType);
- }
-
- @Override
- public void fail(String message, Throwable t) {
- proxiedCallback.fail(message, t);
- }
-
- @Override
- public void fail(String message) {
- proxiedCallback.fail(message);
- }
-
- @Override
- public String getParentProcessIdentifier() {
- // return "";
- return proxiedCallback.getParentProcessIdentifier();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/fb982e2f/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/ActivityProfileImpl.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/ActivityProfileImpl.java b/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/ActivityProfileImpl.java
deleted file mode 100644
index c0f61f7..0000000
--- a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/ActivityProfileImpl.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2012 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.component.profile;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.taverna.component.api.profile.ActivityProfile;
-import org.apache.taverna.component.api.profile.SemanticAnnotationProfile;
-
-import net.sf.taverna.t2.component.api.profile.doc.Activity;
-import net.sf.taverna.t2.component.api.profile.doc.SemanticAnnotation;
-
-/**
- * Specifies the semantic annotations that an activity must have.
- *
- * @author David Withers
- */
-public class ActivityProfileImpl implements ActivityProfile {
- private final ComponentProfileImpl componentProfile;
- private final Activity activity;
-
- public ActivityProfileImpl(ComponentProfileImpl componentProfile,
- Activity activity) {
- this.componentProfile = componentProfile;
- this.activity = activity;
- }
-
- @Override
- public List<SemanticAnnotationProfile> getSemanticAnnotations() {
- List<SemanticAnnotationProfile> saProfiles = new ArrayList<>();
- for (SemanticAnnotation annotation : activity.getSemanticAnnotation())
- saProfiles.add(new SemanticAnnotationProfileImpl(componentProfile,
- annotation));
- return saProfiles;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/fb982e2f/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/BaseProfileLocator.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/BaseProfileLocator.java b/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/BaseProfileLocator.java
deleted file mode 100644
index 91786ae..0000000
--- a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/BaseProfileLocator.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.component.profile;
-
-import static java.util.Locale.UK;
-import static org.apache.commons.httpclient.HttpStatus.SC_OK;
-import static org.apache.commons.io.FileUtils.writeStringToFile;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.params.HttpClientParams;
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.ComponentException;
-
-import uk.org.taverna.configuration.app.ApplicationConfiguration;
-
-/**
- * @author alanrw
- *
- */
-public class BaseProfileLocator {
- private static final String BASE_PROFILE_PATH = "BaseProfile.xml";
- private static final String BASE_PROFILE_URI = "http://build.mygrid.org.uk/taverna/BaseProfile.xml";
- private static final int TIMEOUT = 5000;
- private static final String pattern = "EEE, dd MMM yyyy HH:mm:ss z";
- private static final SimpleDateFormat format = new SimpleDateFormat(
- pattern, UK);
-
- private Logger logger = getLogger(BaseProfileLocator.class);
- private ApplicationConfiguration appConfig;
- private ComponentProfileImpl profile;
-
- private void locateBaseProfile() {
- File baseProfileFile = getBaseProfileFile();
- @SuppressWarnings("unused")
- boolean load = false;
- Long remoteBaseProfileTime = null;
- long localBaseProfileTime = -1;
-
- HttpClientParams params = new HttpClientParams();
- params.setConnectionManagerTimeout(TIMEOUT);
- params.setSoTimeout(TIMEOUT);
- HttpClient client = new HttpClient(params);
-
- try {
- remoteBaseProfileTime = getRemoteBaseProfileTimestamp(client);
- logger.info("NoticeTime is " + remoteBaseProfileTime);
- } catch (URISyntaxException e) {
- logger.error("URI problem", e);
- } catch (IOException e) {
- logger.info("Could not read base profile", e);
- } catch (ParseException e) {
- logger.error("Could not parse last-modified time", e);
- }
- if (baseProfileFile.exists())
- localBaseProfileTime = baseProfileFile.lastModified();
-
- try {
- if ((remoteBaseProfileTime != null)
- && (remoteBaseProfileTime > localBaseProfileTime)) {
- profile = new ComponentProfileImpl(null, new URL(BASE_PROFILE_URI),
- null);
- writeStringToFile(baseProfileFile, profile.getXML());
- }
- } catch (MalformedURLException e) {
- logger.error("URI problem", e);
- profile = null;
- } catch (ComponentException e) {
- logger.error("Component Registry problem", e);
- profile = null;
- } catch (IOException e) {
- logger.error("Unable to write profile", e);
- profile = null;
- }
-
- try {
- if ((profile == null) && baseProfileFile.exists())
- profile = new ComponentProfileImpl(null, baseProfileFile.toURI()
- .toURL(), null);
- } catch (Exception e) {
- logger.error("URI problem", e);
- profile = null;
- }
- }
-
- private long parseTime(String timestamp) throws ParseException {
- timestamp = timestamp.trim();
- if (timestamp.endsWith(" GMT"))
- timestamp = timestamp.substring(0, timestamp.length() - 3)
- + " +0000";
- else if (timestamp.endsWith(" BST"))
- timestamp = timestamp.substring(0, timestamp.length() - 3)
- + " +0100";
- return format.parse(timestamp).getTime();
- }
-
- private long getRemoteBaseProfileTimestamp(HttpClient client)
- throws URISyntaxException, IOException, HttpException,
- ParseException {
- URI baseProfileURI = new URI(BASE_PROFILE_URI);
- HttpMethod method = new GetMethod(baseProfileURI.toString());
- int statusCode = client.executeMethod(method);
- if (statusCode != SC_OK) {
- logger.warn("HTTP status " + statusCode + " while getting "
- + baseProfileURI);
- return -1;
- }
- Header h = method.getResponseHeader("Last-Modified");
- if (h == null)
- return -1;
- return parseTime(h.getValue());
- }
-
- private File getBaseProfileFile() {
- File config = new File(appConfig.getApplicationHomeDir(), "conf");
- if (!config.exists())
- config.mkdir();
- return new File(config, BASE_PROFILE_PATH);
- }
-
- public synchronized ComponentProfileImpl getProfile() {
- if (profile == null)
- locateBaseProfile();
- return profile;
- }
-
- public void setAppConfig(ApplicationConfiguration appConfig) {
- this.appConfig = appConfig;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/fb982e2f/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/ComponentProfileImpl.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/ComponentProfileImpl.java b/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/ComponentProfileImpl.java
deleted file mode 100644
index 37bf692..0000000
--- a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/ComponentProfileImpl.java
+++ /dev/null
@@ -1,685 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2012 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.component.profile;
-
-import static com.hp.hpl.jena.rdf.model.ModelFactory.createOntologyModel;
-import static java.lang.System.identityHashCode;
-import static java.util.Collections.emptyList;
-import static java.util.Collections.emptyMap;
-import static net.sf.taverna.t2.workflowmodel.health.HealthCheck.NO_PROBLEM;
-import static net.sf.taverna.t2.workflowmodel.health.RemoteHealthChecker.contactEndpoint;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.transform.stream.StreamSource;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.ComponentException;
-import org.apache.taverna.component.api.Registry;
-import org.apache.taverna.component.api.profile.ActivityProfile;
-import org.apache.taverna.component.api.profile.ExceptionHandling;
-import org.apache.taverna.component.api.profile.PortProfile;
-import org.apache.taverna.component.api.profile.SemanticAnnotationProfile;
-
-import net.sf.taverna.t2.component.api.profile.doc.Activity;
-import net.sf.taverna.t2.component.api.profile.doc.Ontology;
-import net.sf.taverna.t2.component.api.profile.doc.Port;
-import net.sf.taverna.t2.component.api.profile.doc.Profile;
-import net.sf.taverna.t2.component.api.profile.doc.SemanticAnnotation;
-
-import com.hp.hpl.jena.ontology.OntClass;
-import com.hp.hpl.jena.ontology.OntModel;
-import com.hp.hpl.jena.ontology.OntProperty;
-
-/**
- * A ComponentProfile specifies the inputs, outputs and semantic annotations
- * that a Component must contain.
- *
- * @author David Withers
- */
-public class ComponentProfileImpl implements
- org.apache.taverna.component.api.profile.Profile {
- private static final Logger logger = getLogger(ComponentProfileImpl.class);
- private static final Map<String, OntModel> ontologyModels = new HashMap<>();
- private static final JAXBContext jaxbContext;
- private BaseProfileLocator base;
- static {
- try {
- jaxbContext = JAXBContext.newInstance(Profile.class);
- } catch (JAXBException e) {
- // Should never happen! Represents a critical error
- throw new Error(
- "Failed to initialize profile deserialization engine", e);
- }
- }
- private org.apache.taverna.component.api.profile.Profile parent;
- private Profile profileDoc;
- private ExceptionHandling exceptionHandling;
- private Registry parentRegistry = null;
- private final Object lock = new Object();
- private Exception loaderException = null;
- protected volatile boolean loaded = false;
-
- public ComponentProfileImpl(URL profileURL, BaseProfileLocator base)
- throws ComponentException {
- this(null, profileURL, base);
- }
-
- public ComponentProfileImpl(String profileString, BaseProfileLocator base)
- throws ComponentException {
- this(null, profileString, base);
- }
-
- public ComponentProfileImpl(Registry registry, URI profileURI,
- BaseProfileLocator base) throws ComponentException,
- MalformedURLException {
- this(registry, profileURI.toURL(), base);
- }
-
- public ComponentProfileImpl(Registry registry, URL profileURL,
- BaseProfileLocator base) throws ComponentException {
- logger.info("Loading profile in " + identityHashCode(this) + " from "
- + profileURL);
- this.base = base;
- try {
- URL url = profileURL;
- if (url.getProtocol().startsWith("http"))
- url = new URI(url.getProtocol(), url.getAuthority(),
- url.getPath(), url.getQuery(), url.getRef()).toURL();
- loadProfile(this, url, base);
- } catch (MalformedURLException e) {
- logger.warn("Malformed URL? " + profileURL);
- } catch (URISyntaxException e) {
- logger.warn("Malformed URL? " + profileURL);
- }
- parentRegistry = registry;
- }
-
- public ComponentProfileImpl(Registry registry, String profileString,
- BaseProfileLocator base) throws ComponentException {
- logger.info("Loading profile in " + identityHashCode(this)
- + " from string");
- this.base = base;
- loadProfile(this, profileString, base);
- this.parentRegistry = registry;
- }
-
- private static void loadProfile(final ComponentProfileImpl profile,
- final Object source, BaseProfileLocator base) {
- Runnable r = new Runnable() {
- @Override
- public void run() {
- Date start = new Date();
- if (source instanceof URL)
- loadProfileFromURL(profile, (URL) source);
- else if (source instanceof String)
- loadProfileFromString(profile, (String) source);
- else
- throw new IllegalArgumentException(
- "Bad type of profile source: " + source.getClass());
- Date end = new Date();
- logger.info("Loaded profile in " + identityHashCode(profile)
- + " (in " + (end.getTime() - start.getTime())
- + " msec)");
- }
- };
- if (base.getProfile() == null)
- // Must load the base profile synchronously, to avoid deadlock
- r.run();
- else
- new Thread(r).start();
- }
-
- private static void loadProfileFromURL(ComponentProfileImpl profile, URL source) {
- try {
- URLConnection conn = source.openConnection();
- try {
- conn.addRequestProperty("Accept", "application/xml,*/*;q=0.1");
- } catch (Exception e) {
- }
- try (InputStream is = conn.getInputStream()) {
- profile.profileDoc = jaxbContext.createUnmarshaller()
- .unmarshal(new StreamSource(is), Profile.class)
- .getValue();
- }
- } catch (FileNotFoundException e) {
- profile.loaderException = e;
- logger.warn("URL not readable: " + source);
- } catch (Exception e) {
- profile.loaderException = e;
- logger.warn("Failed to load profile.", e);
- }
- synchronized (profile.lock) {
- profile.loaded = true;
- profile.lock.notifyAll();
- }
- }
-
- private static void loadProfileFromString(ComponentProfileImpl profile,
- String source) {
- try {
- profile.profileDoc = jaxbContext
- .createUnmarshaller()
- .unmarshal(new StreamSource(new StringReader(source)),
- Profile.class).getValue();
- } catch (Exception e) {
- profile.loaderException = e;
- logger.warn("Failed to load profile.", e);
- }
- synchronized (profile.lock) {
- profile.loaded = true;
- profile.lock.notifyAll();
- }
- }
-
- @Override
- public Registry getComponentRegistry() {
- return parentRegistry;
- }
-
- @Override
- public String getXML() throws ComponentException {
- try {
- StringWriter stringWriter = new StringWriter();
- jaxbContext.createMarshaller().marshal(getProfileDocument(),
- stringWriter);
- return stringWriter.toString();
- } catch (JAXBException e) {
- throw new ComponentException("Unable to serialize profile.", e);
- }
- }
-
- @Override
- public Profile getProfileDocument() throws ComponentException {
- try {
- synchronized (lock) {
- while (!loaded)
- lock.wait();
- if (loaderException != null) {
- if (loaderException instanceof FileNotFoundException)
- throw new ComponentException(
- "Profile not found/readable: "
- + loaderException.getMessage(),
- loaderException);
- throw new ComponentException(
- "Problem loading profile definition: "
- + loaderException.getMessage(),
- loaderException);
- }
- return profileDoc;
- }
- } catch (InterruptedException e) {
- logger.info("Interrupted during wait for lock.", e);
- return null;
- }
- }
-
- @Override
- public String getId() {
- try {
- return getProfileDocument().getId();
- } catch (ComponentException e) {
- return null;
- }
- }
-
- @Override
- public String getName() {
- try {
- return getProfileDocument().getName();
- } catch (ComponentException e) {
- return null;
- }
- }
-
- @Override
- public String getDescription() {
- try {
- return getProfileDocument().getDescription();
- } catch (ComponentException e) {
- return null;
- }
- }
-
- /**
- * @return Is this the base profile?
- */
- private boolean isBase() {
- if (base == null)
- return true;
- Object o = base.getProfile();
- return o == null || o == this;
- }
-
- private synchronized org.apache.taverna.component.api.profile.Profile parent()
- throws ComponentException {
- if (parent == null) {
- try {
- if (!isBase() && getProfileDocument().getExtends() != null
- && parentRegistry != null) {
- parent = parentRegistry
- .getComponentProfile(getProfileDocument()
- .getExtends().getProfileId());
- if (parent != null)
- return parent;
- }
- } catch (ComponentException e) {
- }
- parent = new EmptyProfile();
- }
- return parent;
- }
-
- @Override
- public String getOntologyLocation(String ontologyId) {
- String ontologyURI = null;
- try {
- for (Ontology ontology : getProfileDocument().getOntology())
- if (ontology.getId().equals(ontologyId))
- ontologyURI = ontology.getValue();
- } catch (ComponentException e) {
- }
- if ((ontologyURI == null) && !isBase())
- ontologyURI = base.getProfile().getOntologyLocation(ontologyId);
- return ontologyURI;
- }
-
- private Map<String, String> internalGetPrefixMap()
- throws ComponentException {
- Map<String, String> result = new TreeMap<>();
- try {
- for (Ontology ontology : getProfileDocument().getOntology())
- result.put(ontology.getId(), ontology.getValue());
- } catch (ComponentException e) {
- }
- result.putAll(parent().getPrefixMap());
- return result;
- }
-
- @Override
- public Map<String, String> getPrefixMap() throws ComponentException {
- Map<String, String> result = internalGetPrefixMap();
- if (!isBase())
- result.putAll(base.getProfile().getPrefixMap());
- return result;
- }
-
- private OntModel readOntologyFromURI(String ontologyId, String ontologyURI) {
- logger.info("Reading ontology for " + ontologyId + " from "
- + ontologyURI);
- OntModel model = createOntologyModel();
- try {
- URL url = new URL(ontologyURI);
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- // CRITICAL: must be retrieved as correct content type
- conn.addRequestProperty("Accept",
- "application/rdf+xml,application/xml;q=0.9");
- try (InputStream in = conn.getInputStream()) {
- // TODO Consider whether the encoding is handled right
- // ontologyModel.read(in, url.toString());
- model.read(new StringReader(IOUtils.toString(in, "UTF-8")),
- url.toString());
- }
- } catch (MalformedURLException e) {
- logger.error("Problem reading ontology " + ontologyId, e);
- return null;
- } catch (IOException e) {
- logger.error("Problem reading ontology " + ontologyId, e);
- return null;
- } catch (NullPointerException e) {
- // TODO Why is this different?
- logger.error("Problem reading ontology " + ontologyId, e);
- model = createOntologyModel();
- }
- return model;
- }
-
- private boolean isAccessible(String ontologyURI) {
- return contactEndpoint(null, ontologyURI).getResultId() == NO_PROBLEM;
- }
-
- @Override
- public OntModel getOntology(String ontologyId) {
- String ontologyURI = getOntologyLocation(ontologyId);
- synchronized (ontologyModels) {
- if (ontologyModels.containsKey(ontologyURI))
- return ontologyModels.get(ontologyURI);
- }
-
- // Drop out of critical section while we do I/O
- if (!isAccessible(ontologyURI)) {
- logger.warn("Catastrophic problem contacting ontology source.");
- // Catastrophic problem?!
- synchronized (ontologyModels) {
- ontologyModels.put(ontologyURI, null);
- }
- return null;
- }
- OntModel model = readOntologyFromURI(ontologyId, ontologyURI);
-
- synchronized (ontologyModels) {
- if (model != null && !ontologyModels.containsKey(ontologyURI)) {
- ontologyModels.put(ontologyURI, model);
- }
- return ontologyModels.get(ontologyURI);
- }
- }
-
- @Override
- public List<PortProfile> getInputPortProfiles() {
- List<PortProfile> portProfiles = new ArrayList<>();
- try {
- for (Port port : getProfileDocument().getComponent().getInputPort())
- portProfiles.add(new PortProfileImpl(this, port));
- } catch (ComponentException e) {
- }
- if (!isBase())
- portProfiles.addAll(base.getProfile().getInputPortProfiles());
- return portProfiles;
- }
-
- @Override
- public List<SemanticAnnotationProfile> getInputSemanticAnnotationProfiles()
- throws ComponentException {
- List<SemanticAnnotationProfile> saProfiles = new ArrayList<>();
- List<PortProfile> portProfiles = getInputPortProfiles();
- portProfiles.addAll(parent().getInputPortProfiles());
- for (PortProfile portProfile : portProfiles)
- saProfiles.addAll(portProfile.getSemanticAnnotations());
- if (!isBase())
- saProfiles.addAll(base.getProfile()
- .getInputSemanticAnnotationProfiles());
- return getUniqueSemanticAnnotationProfiles(saProfiles);
- }
-
- @Override
- public List<PortProfile> getOutputPortProfiles() {
- List<PortProfile> portProfiles = new ArrayList<>();
- try {
- for (Port port : getProfileDocument().getComponent()
- .getOutputPort())
- portProfiles.add(new PortProfileImpl(this, port));
- } catch (ComponentException e) {
- }
- if (!isBase())
- portProfiles.addAll(base.getProfile().getOutputPortProfiles());
- return portProfiles;
- }
-
- @Override
- public List<SemanticAnnotationProfile> getOutputSemanticAnnotationProfiles()
- throws ComponentException {
- List<SemanticAnnotationProfile> saProfiles = new ArrayList<>();
- List<PortProfile> portProfiles = getOutputPortProfiles();
- portProfiles.addAll(parent().getOutputPortProfiles());
- for (PortProfile portProfile : portProfiles)
- saProfiles.addAll(portProfile.getSemanticAnnotations());
- if (!isBase())
- saProfiles.addAll(base.getProfile()
- .getOutputSemanticAnnotationProfiles());
- return getUniqueSemanticAnnotationProfiles(saProfiles);
- }
-
- @Override
- public List<org.apache.taverna.component.api.profile.ActivityProfile> getActivityProfiles() {
- List<org.apache.taverna.component.api.profile.ActivityProfile> activityProfiles = new ArrayList<>();
- try {
- for (Activity activity : getProfileDocument().getComponent()
- .getActivity())
- activityProfiles.add(new ActivityProfileImpl(this, activity));
- } catch (ComponentException e) {
- }
- return activityProfiles;
- }
-
- @Override
- public List<SemanticAnnotationProfile> getActivitySemanticAnnotationProfiles()
- throws ComponentException {
- List<SemanticAnnotationProfile> saProfiles = new ArrayList<>();
- List<ActivityProfile> activityProfiles = getActivityProfiles();
- activityProfiles.addAll(parent().getActivityProfiles());
- for (ActivityProfile activityProfile : activityProfiles)
- saProfiles.addAll(activityProfile.getSemanticAnnotations());
- if (!isBase())
- saProfiles.addAll(base.getProfile()
- .getActivitySemanticAnnotationProfiles());
- return getUniqueSemanticAnnotationProfiles(saProfiles);
- }
-
- @Override
- public List<SemanticAnnotationProfile> getSemanticAnnotations()
- throws ComponentException {
- List<SemanticAnnotationProfile> saProfiles = getComponentProfiles();
- saProfiles.addAll(parent().getSemanticAnnotations());
- if (!isBase())
- saProfiles.addAll(base.getProfile().getSemanticAnnotations());
- return saProfiles;
- }
-
- private List<SemanticAnnotationProfile> getComponentProfiles() {
- List<SemanticAnnotationProfile> saProfiles = new ArrayList<>();
- try {
- for (SemanticAnnotation semanticAnnotation : getProfileDocument()
- .getComponent().getSemanticAnnotation())
- saProfiles.add(new SemanticAnnotationProfileImpl(this,
- semanticAnnotation));
- } catch (ComponentException e) {
- }
- return saProfiles;
- }
-
- private List<SemanticAnnotationProfile> getUniqueSemanticAnnotationProfiles(
- List<SemanticAnnotationProfile> semanticAnnotationProfiles) {
- List<SemanticAnnotationProfile> uniqueSemanticAnnotations = new ArrayList<>();
- Set<OntProperty> predicates = new HashSet<>();
- for (SemanticAnnotationProfile semanticAnnotationProfile : semanticAnnotationProfiles) {
- OntProperty prop = semanticAnnotationProfile.getPredicate();
- if (prop != null && !predicates.contains(prop)) {
- predicates.add(prop);
- uniqueSemanticAnnotations.add(semanticAnnotationProfile);
- }
- }
- return uniqueSemanticAnnotations;
- }
-
- @Override
- public ExceptionHandling getExceptionHandling() {
- try {
- if (exceptionHandling == null
- && getProfileDocument().getComponent()
- .getExceptionHandling() != null)
- exceptionHandling = new ExceptionHandling(getProfileDocument()
- .getComponent().getExceptionHandling());
- } catch (ComponentException e) {
- }
- return exceptionHandling;
- }
-
- @Override
- public String toString() {
- return "ComponentProfile" + "\n Name : " + getName()
- + "\n Description : " + getDescription()
- + "\n InputPortProfiles : " + getInputPortProfiles()
- + "\n OutputPortProfiles : " + getOutputPortProfiles();
- }
-
- @Override
- public int hashCode() {
- return 31 + ((getId() == null) ? 0 : getId().hashCode());
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ComponentProfileImpl other = (ComponentProfileImpl) obj;
- if (!loaded || !other.loaded)
- return false;
- if (getId() == null)
- return other.getId() == null;
- return getId().equals(other.getId());
- }
-
- public OntClass getClass(String className) {
- try {
- for (Ontology ontology : getProfileDocument().getOntology()) {
- OntModel ontModel = getOntology(ontology.getId());
- if (ontModel != null) {
- OntClass result = ontModel.getOntClass(className);
- if (result != null)
- return result;
- }
- }
- } catch (ComponentException e) {
- }
- return null;
- }
-
- @Override
- public void delete() throws ComponentException {
- throw new ComponentException("Deletion not supported.");
- }
-}
-
-/**
- * A simple do-nothing implementation of a profile. Used when there's no other
- * option for what a <i>real</i> profile extends.
- *
- * @author Donal Fellows
- */
-final class EmptyProfile implements
- org.apache.taverna.component.api.profile.Profile {
- @Override
- public String getName() {
- return "";
- }
-
- @Override
- public String getDescription() {
- return "";
- }
-
- @Override
- public Registry getComponentRegistry() {
- return null;
- }
-
- @Override
- public String getXML() throws ComponentException {
- throw new ComponentException("No document.");
- }
-
- @Override
- public Profile getProfileDocument() {
- return new Profile();
- }
-
- @Override
- public String getId() {
- return "";
- }
-
- @Override
- public String getOntologyLocation(String ontologyId) {
- return "";
- }
-
- @Override
- public Map<String, String> getPrefixMap() {
- return emptyMap();
- }
-
- @Override
- public OntModel getOntology(String ontologyId) {
- return null;
- }
-
- @Override
- public List<PortProfile> getInputPortProfiles() {
- return emptyList();
- }
-
- @Override
- public List<SemanticAnnotationProfile> getInputSemanticAnnotationProfiles() {
- return emptyList();
- }
-
- @Override
- public List<PortProfile> getOutputPortProfiles() {
- return emptyList();
- }
-
- @Override
- public List<SemanticAnnotationProfile> getOutputSemanticAnnotationProfiles() {
- return emptyList();
- }
-
- @Override
- public List<org.apache.taverna.component.api.profile.ActivityProfile> getActivityProfiles() {
- return emptyList();
- }
-
- @Override
- public List<SemanticAnnotationProfile> getActivitySemanticAnnotationProfiles() {
- return emptyList();
- }
-
- @Override
- public List<SemanticAnnotationProfile> getSemanticAnnotations() {
- return emptyList();
- }
-
- @Override
- public ExceptionHandling getExceptionHandling() {
- return null;
- }
-
- @Override
- public void delete() throws ComponentException {
- throw new ComponentException("Deletion forbidden.");
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/fb982e2f/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/PortProfileImpl.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/PortProfileImpl.java b/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/PortProfileImpl.java
deleted file mode 100644
index e8394f1..0000000
--- a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/PortProfileImpl.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2012 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.component.profile;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.taverna.component.api.profile.PortProfile;
-import org.apache.taverna.component.api.profile.SemanticAnnotationProfile;
-
-import net.sf.taverna.t2.component.api.profile.doc.Port;
-import net.sf.taverna.t2.component.api.profile.doc.SemanticAnnotation;
-
-/**
- * Specifies the semantic annotations that a port must have.
- *
- * @author David Withers
- */
-public class PortProfileImpl implements PortProfile {
- private final ComponentProfileImpl componentProfile;
- private final Port port;
-
- public PortProfileImpl(ComponentProfileImpl componentProfile, Port port) {
- this.componentProfile = componentProfile;
- this.port = port;
- }
-
- @Override
- public List<SemanticAnnotationProfile> getSemanticAnnotations() {
- List<SemanticAnnotationProfile> saProfiles = new ArrayList<>();
- for (SemanticAnnotation annotation : port.getSemanticAnnotation())
- saProfiles.add(new SemanticAnnotationProfileImpl(componentProfile,
- annotation));
- return saProfiles;
- }
-
- @Override
- public String toString() {
- return "PortProfile \n SemanticAnnotations : "
- + getSemanticAnnotations();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/fb982e2f/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/SemanticAnnotationProfileImpl.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/SemanticAnnotationProfileImpl.java b/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/SemanticAnnotationProfileImpl.java
deleted file mode 100644
index 0dc2393..0000000
--- a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/profile/SemanticAnnotationProfileImpl.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2012 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.component.profile;
-
-import static java.io.File.createTempFile;
-import static org.apache.commons.io.FileUtils.writeStringToFile;
-import static org.apache.log4j.Logger.getLogger;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.apache.taverna.component.api.profile.SemanticAnnotationProfile;
-
-import net.sf.taverna.t2.component.api.profile.doc.SemanticAnnotation;
-
-import com.hp.hpl.jena.ontology.Individual;
-import com.hp.hpl.jena.ontology.OntClass;
-import com.hp.hpl.jena.ontology.OntModel;
-import com.hp.hpl.jena.ontology.OntProperty;
-import com.hp.hpl.jena.ontology.OntResource;
-
-/**
- * Definition of a semantic annotation for a component element.
- *
- * @author David Withers
- */
-public class SemanticAnnotationProfileImpl implements SemanticAnnotationProfile {
- private static final Logger log = getLogger(SemanticAnnotationProfileImpl.class);
- private final ComponentProfileImpl componentProfile;
- private final SemanticAnnotation semanticAnnotation;
-
- public SemanticAnnotationProfileImpl(ComponentProfileImpl componentProfile,
- SemanticAnnotation semanticAnnotation) {
- this.componentProfile = componentProfile;
- this.semanticAnnotation = semanticAnnotation;
- }
-
- /**
- * Returns the ontology that defines semantic annotation.
- *
- * @return the ontology that defines semantic annotation
- */
- @Override
- public OntModel getOntology() {
- String ontology = semanticAnnotation.getOntology();
- if (ontology == null)
- return null;
- return componentProfile.getOntology(ontology);
- }
-
- /**
- * Returns the predicate for the semantic annotation.
- *
- * @return the predicate for the semantic annotation
- */
- @Override
- public OntProperty getPredicate() {
- OntModel ontology = getOntology();
- if (ontology == null)
- return null;
- String predicate = semanticAnnotation.getPredicate();
- if (predicate == null)
- return null;
- if (predicate.contains("foaf")) {
- StringWriter sw = new StringWriter();
- ontology.writeAll(sw, null, "RDF/XML");
- try {
- writeStringToFile(createTempFile("foaf", null), sw.toString());
- } catch (IOException e) {
- log.info("failed to write foaf ontology to temporary file", e);
- }
- }
-
- return ontology.getOntProperty(predicate);
- }
-
- @Override
- public String getPredicateString() {
- return semanticAnnotation.getPredicate();
- }
-
- @Override
- public String getClassString() {
- return semanticAnnotation.getClazz();
- }
-
- /**
- * Returns the individual that the semantic annotation must use.
- *
- * May be null if no explicit individual is required.
- *
- * @return the individual that the semantic annotation must use
- */
- @Override
- public Individual getIndividual() {
- String individual = semanticAnnotation.getValue();
- if (individual == null || individual.isEmpty())
- return null;
- return getOntology().getIndividual(individual);
- }
-
- /**
- * Returns the individuals in the range of the predicate defined in the
- * ontology.
- *
- * @return the individuals in the range of the predicate defined in the
- * ontology
- */
- @Override
- public List<Individual> getIndividuals() {
- OntModel ontology = getOntology();
- OntProperty prop = getPredicate();
- if (ontology == null || prop == null)
- return new ArrayList<>();
- OntResource range = prop.getRange();
- if (range == null)
- return new ArrayList<>();
- return ontology.listIndividuals(range).toList();
- }
-
- @Override
- public Integer getMinOccurs() {
- return semanticAnnotation.getMinOccurs().intValue();
- }
-
- @Override
- public Integer getMaxOccurs() {
- try {
- return Integer.valueOf(semanticAnnotation.getMaxOccurs());
- } catch (NumberFormatException e) {
- return null;
- }
- }
-
- @Override
- public String toString() {
- return "SemanticAnnotation " + "\n Predicate : " + getPredicate()
- + "\n Individual : " + getIndividual() + "\n Individuals : "
- + getIndividuals();
- }
-
- @Override
- public OntClass getRangeClass() {
- String clazz = this.getClassString();
- if (clazz != null)
- return componentProfile.getClass(clazz);
-
- OntProperty prop = getPredicate();
- if (prop == null)
- return null;
- OntResource range = prop.getRange();
- if (range != null && range.isClass())
- return range.asClass();
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-component/blob/fb982e2f/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/registry/ClientVersion.java
----------------------------------------------------------------------
diff --git a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/registry/ClientVersion.java b/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/registry/ClientVersion.java
deleted file mode 100644
index b06ae67..0000000
--- a/taverna-component-activity/src/main/java/net/sf/taverna/t2/component/registry/ClientVersion.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package net.sf.taverna.t2.component.registry;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-public class ClientVersion {
- private static final String DEFAULT_VERSION = "1.1.0";
- public static final String VERSION;
-
- private ClientVersion() {
- }
-
- static {
- InputStream is = ClientVersion.class
- .getResourceAsStream("version.properties");
- String version = DEFAULT_VERSION;
- if (is != null)
- try {
- Properties p = new Properties();
- p.load(is);
- version = p.getProperty("project.version", DEFAULT_VERSION);
- } catch (IOException e) {
- } finally {
- try {
- is.close();
- } catch (IOException e) {
- }
- }
- VERSION = version;
- }
-
-}