Repository: incubator-taverna-plugin-bioinformatics Updated Branches: refs/heads/master 793628502 -> e13e3b741
http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/e13e3b74/taverna-soaplab-activity/src/main/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivity.java ---------------------------------------------------------------------- diff --git a/taverna-soaplab-activity/src/main/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivity.java b/taverna-soaplab-activity/src/main/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivity.java deleted file mode 100644 index 53091e1..0000000 --- a/taverna-soaplab-activity/src/main/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivity.java +++ /dev/null @@ -1,413 +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.activities.soaplab; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.namespace.QName; -import javax.xml.rpc.ServiceException; - -import net.sf.taverna.t2.reference.ReferenceService; -import net.sf.taverna.t2.reference.ReferenceServiceException; -import net.sf.taverna.t2.reference.T2Reference; -import net.sf.taverna.t2.workflowmodel.OutputPort; -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.ActivityInputPort; -import net.sf.taverna.t2.workflowmodel.processor.activity.AsynchronousActivityCallback; - -import org.apache.axis.client.Call; -import org.apache.axis.client.Service; -import org.apache.log4j.Logger; - -import com.fasterxml.jackson.databind.JsonNode; - -/** - * An Activity providing Soaplab functionality. - * - * @author David Withers - */ -public class SoaplabActivity extends AbstractAsynchronousActivity<JsonNode> { - - public static final String URI = "http://ns.taverna.org.uk/2010/activity/soaplab"; - - private static final Logger logger = Logger - .getLogger(SoaplabActivity.class); - - private static final int INVOCATION_TIMEOUT = 0; - - private JsonNode json; - -// private Map<String, Class<?>> inputTypeMap = new HashMap<String, Class<?>>(); - - public SoaplabActivity() { - } - - @Override - public void configure(JsonNode configurationBean) throws ActivityConfigurationException { - this.json = configurationBean; -// generatePorts(); - } - - @Override - public JsonNode getConfiguration() { - return json; - } - - @Override - public void executeAsynch(final Map<String, T2Reference> data, - final AsynchronousActivityCallback callback) { - callback.requestRun(new Runnable() { - - @SuppressWarnings("unchecked") - public void run() { - ReferenceService referenceService = callback.getContext().getReferenceService(); - - Map<String, T2Reference> outputData = new HashMap<String, T2Reference>(); - - try { - // Copy the contents of the data set in the input map - // to a new Map object which just contains the raw data - // objects - Map<String, Object> soaplabInputMap = new HashMap<String, Object>(); - for (Map.Entry<String, T2Reference> entry : data - .entrySet()) { - Class<?> inputType = getInputType(entry.getKey()); - logger.info("Resolving " + entry.getKey() + " to " - + inputType); - soaplabInputMap.put(entry.getKey(), referenceService.renderIdentifier( - entry.getValue(), inputType, callback.getContext())); - logger.info(" Value = " - + soaplabInputMap.get(entry.getKey())); - } - - // Invoke the web service... - Call call = (Call) new Service().createCall(); - call.setTimeout(new Integer(INVOCATION_TIMEOUT)); - // TODO is there endpoint stored in the configuration as a - // String or a URL? - // URL soaplabWSDLURL = new - // URL(configurationBean.getEndpoint()); - call.setTargetEndpointAddress(json.get("endpoint").textValue()); - - // Invoke the job and wait for it to complete - call.setOperationName(new QName("createAndRun")); - String jobID = (String) call - .invoke(new Object[] { soaplabInputMap }); - // Get the array of desired outputs to avoid pulling - // everything back - // TODO Decide how to get the bound ports for the processor - // OutputPort[] boundOutputs = - // this.proc.getBoundOutputPorts(); - OutputPort[] boundOutputs = getOutputPorts().toArray( - new OutputPort[0]); - String[] outputPortNames = new String[boundOutputs.length]; - for (int i = 0; i < outputPortNames.length; i++) { - outputPortNames[i] = boundOutputs[i].getName(); - logger.debug("Adding output : " + outputPortNames[i]); - } - - if (!isPollingDefined()) { - // If we're not polling then use this behaviour - call.setOperationName(new QName("waitFor")); - call.invoke(new Object[] { jobID }); - } else { - // Wait for the polling interval then request a status - // and do this until the status is terminal. - boolean polling = true; - // Number of milliseconds to wait before the first - // status request. - int pollingInterval = json.get("pollingInterval").intValue(); - while (polling) { - try { - Thread.sleep(pollingInterval); - } catch (InterruptedException ie) { - // do nothing - } - call.setOperationName(new QName("getStatus")); - String statusString = (String) call - .invoke(new Object[] { jobID }); - logger.info("Polling, status is : " + statusString); - if (statusString.equals("RUNNING") - || statusString.equals("CREATED")) { - pollingInterval = (int) ((double) pollingInterval * json - .get("pollingBackoff").doubleValue()); - if (pollingInterval > json.get("pollingIntervalMax").intValue()) { - pollingInterval = json.get("pollingIntervalMax").intValue(); - } - } else { - // Either completed with an error or success - polling = false; - } - } - } - - // Get the status code - call.setOperationName(new QName("getStatus")); - String statusString = (String) call - .invoke(new Object[] { jobID }); - if (statusString.equals("TERMINATED_BY_ERROR")) { - // Get the report - call.setOperationName(new QName("getSomeResults")); - HashMap<String, String> temp = new HashMap<String, String>( - (Map) call.invoke(new Object[] { jobID, - new String[] { "report" } })); - String reportText = temp.get("report"); - callback.fail("Soaplab call returned an error : " - + reportText); - return; - } - - // Get the results required by downstream processors - call.setOperationName(new QName("getSomeResults")); - HashMap<String, Object> outputMap = new HashMap<String, Object>( - (Map) call.invoke(new Object[] { jobID, - outputPortNames })); - - // Tell soaplab that we don't need this session any more - call.setOperationName(new QName("destroy")); - call.invoke(new Object[] { jobID }); - - // Build the map of DataThing objects - for (Map.Entry<String, Object> entry : outputMap.entrySet()) { - String parameterName = entry.getKey(); - Object outputObject = entry.getValue(); - if (logger.isDebugEnabled()) - logger.debug("Soaplab : parameter '" - + parameterName + "' has type '" - + outputObject.getClass().getName() + "'"); - - if (outputObject instanceof String[]) { - // outputThing = DataThingFactory - // .bake((String[]) outputObject); - outputData.put(parameterName, referenceService - .register(Arrays.asList(outputObject), 1, true, callback.getContext())); - } else if (outputObject instanceof byte[][]) { - // Create a List of byte arrays, this will - // map to l('application/octet-stream') in - // the output document. - // outputThing = DataThingFactory - // .bake((byte[][]) outputObject); - List<byte[]> list = new ArrayList<byte[]>(); - for (byte[] byteArray : (byte[][]) outputObject) { - list.add(byteArray); - } - outputData.put(parameterName, referenceService - .register(list, 1, true, callback.getContext())); - // outputData.put(parameterName, dataFacade - // .register(Arrays.asList(outputObject))); - } else if (outputObject instanceof List) { - List<?> convertedList = convertList((List<?>) outputObject); - outputData.put(parameterName, referenceService - .register(convertedList, 1, true, callback.getContext())); - } else { - // Fallthrough case, this mostly applies to - // output of type byte[] or string, both of which - // are handled perfectly sensibly by default. - outputData.put(parameterName, referenceService - .register(outputObject, 0, true, callback.getContext())); - } - } - - // success - callback.receiveResult(outputData, new int[0]); - } catch (ReferenceServiceException e) { - callback.fail("Error accessing soaplab input/output data", e); - } catch (IOException e) { - callback.fail("Failure calling soaplab", e); - } catch (ServiceException e) { - callback.fail("Failure calling soaplab", e); - } - } - - }); - - } - - public boolean isPollingDefined() { - return json != null - && (json.get("pollingInterval").intValue() != 0 - || json.get("pollingBackoff").doubleValue() != 1.0 || json - .get("pollingIntervalMax").intValue() != 0); - } - - private List<?> convertList(List<?> theList) { - if (theList.size() == 0) { - return theList; - } - - List<byte[]> listOfBytes = new ArrayList<byte[]>(); - for (Object element : theList) { - if (element instanceof List) { - List<?> list = ((List<?>) element); - if (list.size() > 0 && (list.get(0) instanceof Byte)) { - byte[] bytes = new byte[list.size()]; - for (int j = 0; j < list.size(); j++) { - bytes[j] = ((Byte) list.get(j)).byteValue(); - } - listOfBytes.add(bytes); - } else { - // If we can't cope here just return the original - // object - return theList; - } - } else { - return theList; - } - } - return listOfBytes; - } - - private Class<?> getInputType(String portName) { - Class<?> inputType = String.class; - for (ActivityInputPort inputPort : getInputPorts()) { - if (inputPort.getName().equals(portName)) { - return inputPort.getTranslatedElementClass(); - } - } - return inputType; - } - -// @SuppressWarnings("unchecked") -// private void generatePorts() throws ActivityConfigurationException { -// // Wipe the existing port declarations -// // ports = new ArrayList(); -// try { -// // Do web service type stuff[tm] -// Map<String, String>[] inputs = (Map<String, String>[]) Soap -// .callWebService(json.get("endpoint").textValue(), -// "getInputSpec"); -// // Iterate over the inputs -// for (int i = 0; i < inputs.length; i++) { -// Map<String, String> input_spec = inputs[i]; -// String input_name = input_spec.get("name"); -// String input_type = input_spec.get("type").toLowerCase(); -// // Could get other properties such as defaults here -// // but at the moment we've got nowhere to put them -// // so we don't bother. -// if (input_type.equals("string")) { -// addInput(input_name, 0, true, -// new ArrayList<Class<? extends ExternalReferenceSPI>>(), String.class); -// inputTypeMap.put(input_name, String.class); -// } else if (input_type.equals("string[]")) { -// addInput(input_name, 1, true, -// new ArrayList<Class<? extends ExternalReferenceSPI>>(), String.class); -// inputTypeMap.put(input_name, String.class); -// } else if (input_type.equals("byte[]")) { -// addInput(input_name, 0, true, -// new ArrayList<Class<? extends ExternalReferenceSPI>>(), byte[].class); -// inputTypeMap.put(input_name, byte[].class); -// } else if (input_type.equals("byte[][]")) { -// addInput(input_name, 1, true, -// new ArrayList<Class<? extends ExternalReferenceSPI>>(), byte[].class); -// inputTypeMap.put(input_name, byte[].class); -// } else { -// // Count number of [] to get the arrays right -// int depth = (input_type.split("\\[\\]", -1).length) -1 ; -// logger.info("Soaplab input type '" + input_type -// + "' unknown for input '" + input_name + "' in " -// + json.get("endpoint").textValue() -// + ", will attempt to add as String depth " + depth); -// addInput(input_name, depth, true, -// new ArrayList<Class<? extends ExternalReferenceSPI>>(), String.class); -// inputTypeMap.put(input_name, String.class); -// } -// } -// -// // Get outputs -// Map<String, String>[] results = (Map<String, String>[]) Soap -// .callWebService(json.get("endpoint").textValue(), -// "getResultSpec"); -// // Iterate over the outputs -// for (int i = 0; i < results.length; i++) { -// Map<String, String> output_spec = results[i]; -// String output_name = output_spec.get("name"); -// String output_type = output_spec.get("type").toLowerCase(); -// // Check to see whether the output is either report or -// // detailed_status, in -// // which cases we ignore it, this is soaplab metadata rather -// // than application data. -// if ((!output_name.equalsIgnoreCase("detailed_status"))) { -// -// // && (!output_name.equalsIgnoreCase("report"))) { -// if (output_type.equals("string")) { -// addOutput(output_name, 0, "text/plain"); -// } else if (output_type.equals("string[]")) { -// addOutput(output_name, 1, "text/plain"); -// } else if (output_type.equals("byte[]")) { -// addOutput(output_name, 0, "application/octet-stream"); -// } else if (output_type.equals("byte[][]")) { -// addOutput(output_name, 1, "application/octet-stream"); -// } else { -// // Count number of [] to get the arrays right -// int depth = (output_type.split("\\[\\]", -1).length) -1 ; -// logger.info("Soaplab output type '" + output_type -// + "' unknown for output '" + output_name + "' in " -// + json.get("endpoint").textValue() -// + ", will add as depth " + depth); -// addOutput(output_name, depth, null); -// } -// } -// } -// -// } catch (ServiceException se) { -// throw new ActivityConfigurationException( -// json.get("endpoint").textValue() -// + ": Unable to create a new call to connect\n to soaplab, error was : " -// + se.getMessage()); -// } catch (RemoteException re) { -// throw new ActivityConfigurationException( -// ": Unable to call the get spec method for\n endpoint : " -// + json.get("endpoint").textValue() -// + "\n Remote exception message " -// + re.getMessage()); -// } catch (NullPointerException npe) { -// // If we had a null pointer exception, go around again - this is a -// // bug somewhere between axis and soaplab -// // that occasionally causes NPEs to happen in the first call or two -// // to a given soaplab installation. It also -// // manifests in the Talisman soaplab clients. -// generatePorts(); -// } -// } - -// protected void addOutput(String portName, int portDepth, String type) { -// ActivityOutputPort port = edits.createActivityOutputPort( -// portName, portDepth, portDepth); -// MimeType mimeType = null; -// if (type != null) { -// mimeType = new MimeType(); -// mimeType.setText(type); -// } -// try { -// edits.getAddAnnotationChainEdit(port, mimeType).doEdit(); -// } catch (EditException e) { -// logger.debug("Error adding MimeType annotation to port", e); -// } -// outputPorts.add(port); -// } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/e13e3b74/taverna-soaplab-activity/src/main/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityConfigurationBean.java ---------------------------------------------------------------------- diff --git a/taverna-soaplab-activity/src/main/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityConfigurationBean.java b/taverna-soaplab-activity/src/main/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityConfigurationBean.java deleted file mode 100644 index fa6bdec..0000000 --- a/taverna-soaplab-activity/src/main/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityConfigurationBean.java +++ /dev/null @@ -1,119 +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.activities.soaplab; - -import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean; -import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty; - -/** - * A configuration bean specific to a Soaplab activity. In particular it provides details - * about the Soaplab service endpoint and the polling settings. - * - * @author David Withers - */ -@ConfigurationBean(uri = SoaplabActivity.URI + "#Config") -public class SoaplabActivityConfigurationBean { - - private String endpoint = null; - - private int pollingInterval = 0; - - private double pollingBackoff = 1.0; - - private int pollingIntervalMax = 0; - - /** - * Returns the endpoint. - * - * @return the endpoint - */ - public String getEndpoint() { - return endpoint; - } - - /** - * Sets the endpoint. - * - * @param endpoint the new endpoint - */ - @ConfigurationProperty(name = "endpoint", label = "Soaplab Service Endpoint", description = "The endpoint of the Soaplab service") - public void setEndpoint(String endpoint) { - this.endpoint = endpoint; - } - - /** - * Returns the pollingInterval. - * - * @return the pollingInterval - */ - public int getPollingInterval() { - return pollingInterval; - } - - /** - * Sets the pollingInterval. - * - * @param pollingInterval the new pollingInterval - */ - @ConfigurationProperty(name = "pollingInterval", label = "Polling Interval", description = "The polling time interval (in milliseconds)", required = false) - public void setPollingInterval(int pollingInterval) { - this.pollingInterval = pollingInterval; - } - - /** - * Returns the pollingBackoff. - * - * @return the pollingBackoff - */ - public double getPollingBackoff() { - return pollingBackoff; - } - - /** - * Sets the pollingBackoff. - * - * @param pollingBackoff the new pollingBackoff - */ - @ConfigurationProperty(name = "pollingBackoff", label = "Polling Backoff", description = "The polling backoff factor", required = false) - public void setPollingBackoff(double pollingBackoff) { - this.pollingBackoff = pollingBackoff; - } - - /** - * Returns the pollingIntervalMax. - * - * @return the pollingIntervalMax - */ - public int getPollingIntervalMax() { - return pollingIntervalMax; - } - - /** - * Sets the pollingIntervalMax. - * - * @param pollingIntervalMax the new pollingIntervalMax - */ - @ConfigurationProperty(name = "pollingIntervalMax", label = "Max Polling Interval", description = "The maximum polling time interval (in milliseconds)", required = false) - public void setPollingIntervalMax(int pollingIntervalMax) { - this.pollingIntervalMax = pollingIntervalMax; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/e13e3b74/taverna-soaplab-activity/src/main/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityFactory.java ---------------------------------------------------------------------- diff --git a/taverna-soaplab-activity/src/main/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityFactory.java b/taverna-soaplab-activity/src/main/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityFactory.java deleted file mode 100644 index 3c62c9d..0000000 --- a/taverna-soaplab-activity/src/main/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityFactory.java +++ /dev/null @@ -1,216 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2011 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.activities.soaplab; - -import java.io.IOException; -import java.net.URI; -import java.rmi.RemoteException; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import javax.xml.rpc.ServiceException; - -import net.sf.taverna.t2.annotation.annotationbeans.MimeType; -import net.sf.taverna.t2.workflowmodel.EditException; -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 org.apache.log4j.Logger; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * An {@link ActivityFactory} for creating <code>SoaplabActivity</code>. - * - * @author David Withers - */ -public class SoaplabActivityFactory implements ActivityFactory { - - private static final Logger logger = Logger.getLogger(SoaplabActivityFactory.class); - - private Edits edits; - - @Override - public SoaplabActivity createActivity() { - return new SoaplabActivity(); - } - - @Override - public URI getActivityType() { - return URI.create(SoaplabActivity.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 json) throws ActivityConfigurationException { - Set<ActivityInputPort> inputPorts = new HashSet<>(); - try { - // Do web service type stuff[tm] - Map<String, String>[] inputs = (Map<String, String>[]) Soap - .callWebService(json.get("endpoint").textValue(), - "getInputSpec"); - // Iterate over the inputs - for (int i = 0; i < inputs.length; i++) { - Map<String, String> input_spec = inputs[i]; - String input_name = input_spec.get("name"); - String input_type = input_spec.get("type").toLowerCase(); - // Could get other properties such as defaults here - // but at the moment we've got nowhere to put them - // so we don't bother. - if (input_type.equals("string")) { - inputPorts.add(edits.createActivityInputPort(input_name, 0, true, - null, String.class)); - } else if (input_type.equals("string[]")) { - inputPorts.add(edits.createActivityInputPort(input_name, 1, true, - null, String.class)); - } else if (input_type.equals("byte[]")) { - inputPorts.add(edits.createActivityInputPort(input_name, 0, true, - null, byte[].class)); - } else if (input_type.equals("byte[][]")) { - inputPorts.add(edits.createActivityInputPort(input_name, 1, true, - null, byte[].class)); - } else { - // Count number of [] to get the arrays right - int depth = (input_type.split("\\[\\]", -1).length) -1 ; - logger.info("Soaplab input type '" + input_type - + "' unknown for input '" + input_name + "' in " - + json.get("endpoint").textValue() - + ", will attempt to add as String depth " + depth); - inputPorts.add(edits.createActivityInputPort(input_name, depth, true, null, String.class)); - } - } - } catch (ServiceException se) { - throw new ActivityConfigurationException( - json.get("endpoint").textValue() - + ": Unable to create a new call to connect\n to soaplab, error was : " - + se.getMessage()); - } catch (RemoteException re) { - throw new ActivityConfigurationException( - ": Unable to call the get spec method for\n endpoint : " - + json.get("endpoint").textValue() - + "\n Remote exception message " - + re.getMessage()); - } catch (NullPointerException npe) { - // If we had a null pointer exception, go around again - this is a - // bug somewhere between axis and soaplab - // that occasionally causes NPEs to happen in the first call or two - // to a given soaplab installation. It also - // manifests in the Talisman soaplab clients. - return getInputPorts(json); - } - return inputPorts; - } - - @Override - public Set<ActivityOutputPort> getOutputPorts(JsonNode json) throws ActivityConfigurationException { - Set<ActivityOutputPort> outputPorts = new HashSet<>(); - try { - // Get outputs - Map<String, String>[] results = (Map<String, String>[]) Soap - .callWebService(json.get("endpoint").textValue(), - "getResultSpec"); - // Iterate over the outputs - for (int i = 0; i < results.length; i++) { - Map<String, String> output_spec = results[i]; - String output_name = output_spec.get("name"); - String output_type = output_spec.get("type").toLowerCase(); - // Check to see whether the output is either report or - // detailed_status, in - // which cases we ignore it, this is soaplab metadata rather - // than application data. - if ((!output_name.equalsIgnoreCase("detailed_status"))) { - - // && (!output_name.equalsIgnoreCase("report"))) { - if (output_type.equals("string")) { - outputPorts.add(createOutput(output_name, 0, "text/plain")); - } else if (output_type.equals("string[]")) { - outputPorts.add(createOutput(output_name, 1, "text/plain")); - } else if (output_type.equals("byte[]")) { - outputPorts.add(createOutput(output_name, 0, "application/octet-stream")); - } else if (output_type.equals("byte[][]")) { - outputPorts.add(createOutput(output_name, 1, "application/octet-stream")); - } else { - // Count number of [] to get the arrays right - int depth = (output_type.split("\\[\\]", -1).length) -1 ; - logger.info("Soaplab output type '" + output_type - + "' unknown for output '" + output_name + "' in " - + json.get("endpoint").textValue() - + ", will add as depth " + depth); - outputPorts.add(createOutput(output_name, depth, null)); - } - } - } - - } catch (ServiceException se) { - throw new ActivityConfigurationException( - json.get("endpoint").textValue() - + ": Unable to create a new call to connect\n to soaplab, error was : " - + se.getMessage()); - } catch (RemoteException re) { - throw new ActivityConfigurationException( - ": Unable to call the get spec method for\n endpoint : " - + json.get("endpoint").textValue() - + "\n Remote exception message " - + re.getMessage()); - } catch (NullPointerException npe) { - // If we had a null pointer exception, go around again - this is a - // bug somewhere between axis and soaplab - // that occasionally causes NPEs to happen in the first call or two - // to a given soaplab installation. It also - // manifests in the Talisman soaplab clients. - return getOutputPorts(json); - } - return outputPorts; - } - - public void setEdits(Edits edits) { - this.edits = edits; - } - - public ActivityOutputPort createOutput(String portName, int portDepth, String type) { - ActivityOutputPort port = edits.createActivityOutputPort(portName, portDepth, portDepth); - if (type != null) { - MimeType mimeType = new MimeType(); - mimeType.setText(type); - try { - edits.getAddAnnotationChainEdit(port, mimeType).doEdit(); - } catch (EditException e) { - logger.debug("Error adding MimeType annotation to port", e); - } - } - return port; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/e13e3b74/taverna-soaplab-activity/src/main/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityHealthChecker.java ---------------------------------------------------------------------- diff --git a/taverna-soaplab-activity/src/main/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityHealthChecker.java b/taverna-soaplab-activity/src/main/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityHealthChecker.java deleted file mode 100644 index 69b910e..0000000 --- a/taverna-soaplab-activity/src/main/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityHealthChecker.java +++ /dev/null @@ -1,66 +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.activities.soaplab; - -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.SocketTimeoutException; -import java.net.URL; -import java.net.URLConnection; -import java.util.List; - -import net.sf.taverna.t2.workflowmodel.Processor; -import net.sf.taverna.t2.workflowmodel.processor.activity.Activity; -import net.sf.taverna.t2.workflowmodel.health.HealthCheck; -import net.sf.taverna.t2.workflowmodel.health.HealthChecker; -import net.sf.taverna.t2.visit.VisitReport; -import net.sf.taverna.t2.visit.VisitReport.Status; - -import net.sf.taverna.t2.workflowmodel.health.RemoteHealthChecker; -import net.sf.taverna.t2.workflowmodel.processor.activity.DisabledActivity; - -public class SoaplabActivityHealthChecker extends RemoteHealthChecker { - - public boolean canVisit(Object subject) { - if (subject == null) { - return false; - } - if (subject instanceof SoaplabActivity) { - return true; - } - if (subject instanceof DisabledActivity) { - return (((DisabledActivity) subject).getActivity() instanceof SoaplabActivity); - } - return false; - } - - public VisitReport visit(Object o, List<Object> ancestors) { - SoaplabActivityConfigurationBean configuration = null; - Activity activity = (Activity) o; - if (activity instanceof SoaplabActivity) { - configuration = (SoaplabActivityConfigurationBean) activity.getConfiguration(); - } else if (activity instanceof DisabledActivity) { - configuration = (SoaplabActivityConfigurationBean) ((DisabledActivity) activity).getActivityConfiguration(); - } - return contactEndpoint(activity, configuration.getEndpoint()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/e13e3b74/taverna-soaplab-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker ---------------------------------------------------------------------- diff --git a/taverna-soaplab-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker b/taverna-soaplab-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker deleted file mode 100644 index 1e52569..0000000 --- a/taverna-soaplab-activity/src/main/resources/META-INF/services/net.sf.taverna.t2.workflowmodel.health.HealthChecker +++ /dev/null @@ -1 +0,0 @@ -net.sf.taverna.t2.activities.soaplab.SoaplabActivityHealthChecker \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/e13e3b74/taverna-soaplab-activity/src/main/resources/META-INF/spring/soaplab-activity-context-osgi.xml ---------------------------------------------------------------------- diff --git a/taverna-soaplab-activity/src/main/resources/META-INF/spring/soaplab-activity-context-osgi.xml b/taverna-soaplab-activity/src/main/resources/META-INF/spring/soaplab-activity-context-osgi.xml deleted file mode 100644 index 434f054..0000000 --- a/taverna-soaplab-activity/src/main/resources/META-INF/spring/soaplab-activity-context-osgi.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans:beans xmlns="http://www.springframework.org/schema/osgi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:beans="http://www.springframework.org/schema/beans" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/osgi - http://www.springframework.org/schema/osgi/spring-osgi.xsd"> - - <service ref="soaplabActivityHealthChecker" interface="net.sf.taverna.t2.workflowmodel.health.HealthChecker" /> - - <service ref="soaplabActivityFactory" interface="net.sf.taverna.t2.workflowmodel.processor.activity.ActivityFactory" /> - - <reference id="edits" interface="net.sf.taverna.t2.workflowmodel.Edits" /> - -</beans:beans> http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/e13e3b74/taverna-soaplab-activity/src/main/resources/META-INF/spring/soaplab-activity-context.xml ---------------------------------------------------------------------- diff --git a/taverna-soaplab-activity/src/main/resources/META-INF/spring/soaplab-activity-context.xml b/taverna-soaplab-activity/src/main/resources/META-INF/spring/soaplab-activity-context.xml deleted file mode 100644 index 8a6eb40..0000000 --- a/taverna-soaplab-activity/src/main/resources/META-INF/spring/soaplab-activity-context.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans.xsd"> - - <bean id="soaplabActivityHealthChecker" class="net.sf.taverna.t2.activities.soaplab.SoaplabActivityHealthChecker" /> - - <bean id="soaplabActivityFactory" class="net.sf.taverna.t2.activities.soaplab.SoaplabActivityFactory"> - <property name="edits" ref="edits" /> - </bean> - -</beans> http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/e13e3b74/taverna-soaplab-activity/src/main/resources/schema.json ---------------------------------------------------------------------- diff --git a/taverna-soaplab-activity/src/main/resources/schema.json b/taverna-soaplab-activity/src/main/resources/schema.json deleted file mode 100644 index d2a908a..0000000 --- a/taverna-soaplab-activity/src/main/resources/schema.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-03/schema#", - "id": "http://ns.taverna.org.uk/2010/activity/soaplab.schema.json", - "title": "Soaplab consumer activity configuration", - "type": "object", - "properties": { - "@context": { - "description": "JSON-LD context for interpreting the configuration as RDF", - "required": true, - "enum": ["http://ns.taverna.org.uk/2010/activity/soaplab.context.json"] - }, - "endpoint": { - "title": "Soaplab Service Endpoint", - "description": "The endpoint of the Soaplab service", - "type": "string", - "required": true - } - "pollingInterval": { - "title": "Polling Interval", - "description": "The polling time interval (in milliseconds", - "type": "integer", - "default": 0, - "required": true - } - "pollingBackoff": { - "title": "Polling Backoff", - "description": "The polling backoff factor", - "type": "number", - "default": 1.0, - "required": true - } - "pollingIntervalMax": { - "title": "Max Polling Interval", - "description": "The maximum polling time interval (in milliseconds)", - "type": "integer", - "default": 0, - "required": true - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/e13e3b74/taverna-soaplab-activity/src/test/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityConfigurationBeanTest.java ---------------------------------------------------------------------- diff --git a/taverna-soaplab-activity/src/test/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityConfigurationBeanTest.java b/taverna-soaplab-activity/src/test/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityConfigurationBeanTest.java deleted file mode 100644 index 3dc9ec3..0000000 --- a/taverna-soaplab-activity/src/test/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityConfigurationBeanTest.java +++ /dev/null @@ -1,92 +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.activities.soaplab; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Before; -import org.junit.Test; - -/** - * Unit tests for SoaplabActivityConfigurationBean. - * - * @author David Withers - */ -public class SoaplabActivityConfigurationBeanTest { - - private SoaplabActivityConfigurationBean bean; - - private String endpoint = "http://www.ebi.ac.uk/soaplab/emboss4/services/utils_misc.embossversion"; - - @Before - public void setUp() throws Exception { - bean = new SoaplabActivityConfigurationBean(); - } - - @Test - public void testGetEndpoint() { - assertNull(bean.getEndpoint()); - } - - @Test - public void testSetEndpoint() { - bean.setEndpoint(endpoint); - assertEquals(endpoint, bean.getEndpoint()); - bean.setEndpoint(null); - assertNull(bean.getEndpoint()); - - } - - @Test - public void testGetPollingInterval() { - assertEquals(0, bean.getPollingInterval()); - } - - @Test - public void testSetPollingInterval() { - bean.setPollingInterval(2000); - assertEquals(2000, bean.getPollingInterval()); - } - - @Test - public void testGetPollingBackoff() { - assertEquals(1.0, bean.getPollingBackoff(), 0); - } - - @Test - public void testSetPollingBackoff() { - bean.setPollingBackoff(1.4); - assertEquals(1.4, bean.getPollingBackoff(), 0); - } - - @Test - public void testGetPollingIntervalMax() { - assertEquals(0, bean.getPollingIntervalMax()); - } - - @Test - public void testSetPollingIntervalMax() { - bean.setPollingInterval(5000); - assertEquals(5000, bean.getPollingInterval()); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-plugin-bioinformatics/blob/e13e3b74/taverna-soaplab-activity/src/test/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityTest.java ---------------------------------------------------------------------- diff --git a/taverna-soaplab-activity/src/test/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityTest.java b/taverna-soaplab-activity/src/test/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityTest.java deleted file mode 100644 index e0b0dca..0000000 --- a/taverna-soaplab-activity/src/test/java/net/sf/taverna/t2/activities/soaplab/SoaplabActivityTest.java +++ /dev/null @@ -1,127 +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.activities.soaplab; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import net.sf.taverna.t2.activities.testutils.ActivityInvoker; -import net.sf.taverna.t2.workflowmodel.processor.activity.ActivityOutputPort; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * Unit tests for SoaplabActivity. - * - * @author David Withers - */ -public class SoaplabActivityTest { - - private SoaplabActivity activity; - - private ObjectNode configurationBean; - - @Ignore("Integration test") - @Before - public void setUp() throws Exception { - activity = new SoaplabActivity(); - configurationBean = JsonNodeFactory.instance.objectNode(); - configurationBean.put("endpoint", "http://www.ebi.ac.uk/soaplab/emboss4/services/utils_misc.embossversion"); - } - - @Ignore("Integration test") - @Test - public void testExecuteAsynch() throws Exception { - Map<String, Object> inputs = new HashMap<String, Object>(); - // inputs.put("full", "true"); - Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>(); - expectedOutputs.put("report", String.class); - expectedOutputs.put("outfile", String.class); - - activity.configure(configurationBean); - - Map<String, Object> outputs = ActivityInvoker.invokeAsyncActivity( - activity, inputs, expectedOutputs); - assertTrue(outputs.containsKey("report")); - // assertTrue(outputs.get("report") instanceof String); - assertTrue(outputs.containsKey("outfile")); - assertTrue(outputs.get("outfile") instanceof String); - System.out.println(outputs.get("outfile")); - - // test with polling - configurationBean.put("pollingInterval", 5); - configurationBean.put("PollingIntervalMax", 6); - configurationBean.put("PollingBackoff", 1.2); - activity.configure(configurationBean); - - outputs = ActivityInvoker.invokeAsyncActivity(activity, inputs, - expectedOutputs); - assertTrue(outputs.containsKey("report")); - assertTrue(outputs.containsKey("outfile")); - } - - @Ignore("Integration test") - @Test - public void testSoaplabActivity() { - assertNotNull(new SoaplabActivity()); - } - - @Ignore("Integration test") - @Test - public void testConfigureSoaplabActivityConfigurationBean() - throws Exception { - Set<String> expectedOutputs = new HashSet<String>(); - expectedOutputs.add("report"); - expectedOutputs.add("outfile"); - - activity.configure(configurationBean); - Set<ActivityOutputPort> ports = activity.getOutputPorts(); - assertEquals(expectedOutputs.size(), ports.size()); - for (ActivityOutputPort outputPort : ports) { - assertTrue("Wrong output : " + outputPort.getName(), - expectedOutputs.remove(outputPort.getName())); - } - } - - @Ignore("Integration test") - @Test - public void testIsPollingDefined() throws Exception { - assertFalse(activity.isPollingDefined()); - activity.configure(configurationBean); - assertFalse(activity.isPollingDefined()); - configurationBean.put("pollingInterval", 1000); - activity.configure(configurationBean); - assertTrue(activity.isPollingDefined()); - } - -}