http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/WSDLServiceDescription.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/WSDLServiceDescription.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/WSDLServiceDescription.java deleted file mode 100644 index faa3f8c..0000000 --- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/WSDLServiceDescription.java +++ /dev/null @@ -1,154 +0,0 @@ -/********************************************************************* - * Copyright (C) 2007-2009 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.wsdl.servicedescriptions; - -import java.net.URI; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import javax.swing.Icon; - -import net.sf.taverna.t2.security.credentialmanager.CMException; -import net.sf.taverna.t2.security.credentialmanager.CredentialManager; -import net.sf.taverna.t2.servicedescriptions.ServiceDescription; - -import org.apache.log4j.Logger; - -import uk.org.taverna.scufl2.api.configurations.Configuration; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class WSDLServiceDescription extends ServiceDescription { - - public static final URI ACTIVITY_TYPE = URI.create("http://ns.taverna.org.uk/2010/activity/wsdl"); - public static final URI INPUT_SPLITTER_TYPE = URI.create("http://ns.taverna.org.uk/2010/activity/xml-splitter/in"); - public static final URI OUTPUT_SPLITTER_TYPE = URI.create("http://ns.taverna.org.uk/2010/activity/xml-splitter/out"); - - private static final String WSDL = "WSDL @ "; - - private String use; - private URI uri; - private String style; - private String operation; - private final CredentialManager credentialManager; - - private static Logger logger = Logger.getLogger(WSDLServiceDescription.class); - - public WSDLServiceDescription(CredentialManager credentialManager) { - this.credentialManager = credentialManager; - } - - public String getUse() { - return use; - } - - public void setUse(String use) { - this.use = use; - } - - public URI getURI() { - return uri; - } - - public void setURI(URI url) { - this.uri = url; - } - - public String getStyle() { - return style; - } - - public void setStyle(String style) { - this.style = style; - } - - public String getType() { - return "WSDL"; - } - - @Override - public String toString() { - return operation; - } - - public String getOperation() { - return operation; - } - - public void setOperation(String operation) { - this.operation = operation; - } - - public Icon getIcon() { - return WSDLActivityIcon.getWSDLIcon(); - } - - @Override - public URI getActivityType() { - return ACTIVITY_TYPE; - } - - @Override - public Configuration getActivityConfiguration() { - Configuration configuration = new Configuration(); - configuration.setType(ACTIVITY_TYPE.resolve("#Config")); - ObjectNode json = (ObjectNode) configuration.getJson(); - ObjectNode operation = json.objectNode(); - json.put("operation", operation); - operation.put("wsdl", getURI().toString()); - operation.put("name", getOperation()); - return configuration; - } - - public String getName() { - return getOperation(); - } - - public List<? extends Comparable<?>> getPath() { - return Collections.singletonList(WSDL + getURI()); - } - - protected List<Object> getIdentifyingData() { - return Arrays.<Object> asList(getURI(), getOperation()); - } - - @Override - public boolean isTemplateService() { - return needsSecurity(); - } - - protected boolean needsSecurity() { - if (credentialManager == null) { - // We don't know if it needs security or not - return false; - } - // A match is a good indicator that security configuration is needed - try { - return credentialManager.hasUsernamePasswordForService(getURI()); - } catch (CMException e) { - logger.warn("Could not check if credential manager has username/password for " + getURI(), e); - return false; - } - } - - -}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/WSDLServiceProvider.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/WSDLServiceProvider.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/WSDLServiceProvider.java deleted file mode 100644 index daf0cad..0000000 --- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/WSDLServiceProvider.java +++ /dev/null @@ -1,206 +0,0 @@ -package net.sf.taverna.t2.activities.wsdl.servicedescriptions; - -import java.io.IOException; -import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.swing.Icon; -import javax.wsdl.Operation; -import javax.wsdl.WSDLException; -import javax.xml.parsers.ParserConfigurationException; - -import net.sf.taverna.t2.activities.wsdl.WSDLActivityHealthChecker; -import net.sf.taverna.t2.lang.observer.Observable; -import net.sf.taverna.t2.lang.observer.Observer; -import net.sf.taverna.t2.security.credentialmanager.CredentialManager; -import net.sf.taverna.t2.servicedescriptions.AbstractConfigurableServiceProvider; -import net.sf.taverna.t2.servicedescriptions.CustomizedConfigurePanelProvider; -import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry; -import net.sf.taverna.t2.servicedescriptions.events.RemovedProviderEvent; -import net.sf.taverna.t2.servicedescriptions.events.ServiceDescriptionRegistryEvent; -import net.sf.taverna.wsdl.parser.UnknownOperationException; -import net.sf.taverna.wsdl.parser.WSDLParser; - -import org.apache.log4j.Logger; -import org.xml.sax.SAXException; - -public class WSDLServiceProvider extends - AbstractConfigurableServiceProvider<WSDLServiceProviderConfig> implements - CustomizedConfigurePanelProvider<WSDLServiceProviderConfig> { - - private static Logger logger = Logger.getLogger(WSDLServiceProvider.class); - - private static final URI providerId = URI - .create("http://taverna.sf.net/2010/service-provider/wsdl"); - - private CredentialManager credentialManager; - - public static class FlushWSDLCacheOnRemovalObserver implements - Observer<ServiceDescriptionRegistryEvent> { - public void notify( - Observable<ServiceDescriptionRegistryEvent> registry, - ServiceDescriptionRegistryEvent event) throws Exception { - if (!(event instanceof RemovedProviderEvent)) { - return; - } - RemovedProviderEvent removedProviderEvent = (RemovedProviderEvent) event; - if (!(removedProviderEvent.getProvider() instanceof WSDLServiceProvider)) { - return; - } - WSDLServiceProvider serviceProvider = (WSDLServiceProvider) removedProviderEvent - .getProvider(); - URI wsdlLocation = serviceProvider.getConfiguration().getURI(); - WSDLParser.flushCache(wsdlLocation.toASCIIString()); - logger.info("Flushed cache for WSDL " + wsdlLocation); - } - } - - private static final String WSDL_SERVICE = "WSDL service"; - - private static FlushWSDLCacheOnRemovalObserver flushObserver = new FlushWSDLCacheOnRemovalObserver(); - - private ServiceDescriptionRegistry serviceDescriptionRegistry; - - public WSDLServiceProvider() { - super(new WSDLServiceProviderConfig("http://somehost/service?wsdl")); - } - - public String getName() { - return WSDL_SERVICE; - } - - public List<WSDLServiceProviderConfig> getDefaultConfigurations() { - - List<WSDLServiceProviderConfig> defaults = new ArrayList<WSDLServiceProviderConfig>(); - - // If defaults have failed to load from a configuration file then load them here. - if (!serviceDescriptionRegistry.isDefaultSystemConfigurableProvidersLoaded()){ - // 2009-12-16: 503 server error - defaults.add(new WSDLServiceProviderConfig( - "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/eutils.wsdl")); - defaults.add(new WSDLServiceProviderConfig( - "http://soap.bind.ca/wsdl/bind.wsdl")); - defaults.add(new WSDLServiceProviderConfig( - "http://www.ebi.ac.uk/ws/services/urn:Dbfetch?wsdl")); - } // else return an empty list - - return defaults; - } - - public void findServiceDescriptionsAsync( - FindServiceDescriptionsCallBack callBack) { - - URI wsdl = serviceProviderConfig.getURI(); - - callBack.status("Parsing wsdl:" + wsdl); - WSDLParser parser = null; - try { - parser = new WSDLParser(wsdl.toASCIIString()); - List<Operation> operations = parser.getOperations(); - callBack.status("Found " + operations.size() + " WSDL operations:" - + wsdl); - List<WSDLServiceDescription> items = new ArrayList<WSDLServiceDescription>(); - for (Operation op : operations) { - WSDLServiceDescription item = new WSDLServiceDescription(credentialManager); - try { - String name = op.getName(); - item.setOperation(name); - String use = parser.getUse(name); - String style = parser.getStyle(); - if (!WSDLActivityHealthChecker.checkStyleAndUse(style, use)) { - logger.warn("Unsupported style and use combination " + style + "/" + use + " for operation " + name + " from " + wsdl); - continue; - } - item.setUse(use); - item.setStyle(style); - item.setURI(wsdl); - item.setDescription(parser.getOperationDocumentation(name)); - items.add(item); - } catch (UnknownOperationException e) { - String message = "Encountered an unexpected operation name:" - + item.getOperation(); - callBack.fail(message, e); - } - } - callBack.partialResults(items); - callBack.finished(); - } catch (ParserConfigurationException e) { - String message = "Error configuring the WSDL parser"; - callBack.fail(message, e); - } catch (WSDLException e) { - String message = "There was an error with the wsdl: " + wsdl; - callBack.fail(message, e); - } catch (IOException e) { - String message = "There was an IO error parsing the wsdl: " + wsdl - + " Possible reason: the wsdl location was incorrect."; - callBack.fail(message, e); - } catch (SAXException e) { - String message = "There was an error with the XML in the wsdl: " - + wsdl; - callBack.fail(message, e); - } catch (IllegalArgumentException e) { // a problem with the wsdl url - String message = "There was an error with the wsdl: " + wsdl + " " - + "Possible reason: the wsdl location was incorrect."; - callBack.fail(message, e); - } catch (Exception e) { // anything else we did not expect - String message = "There was an error with the wsdl: " + wsdl; - callBack.fail(message, e); - } - } - - @Override - public String toString() { - return getName() + " " + getConfiguration().getURI(); - } - - public Icon getIcon() { - return WSDLActivityIcon.getWSDLIcon(); - } - - @Override - protected List<? extends Object> getIdentifyingData() { - List<String> result; - result = Arrays.asList(getConfiguration().getURI().toString()); - return result; - } - - /** - * Will be set by ServiceDescriptionRegistryImpl - * - * @param registry Registry this provider has been added to - */ - public void setServiceDescriptionRegistry(ServiceDescriptionRegistry serviceDescriptionRegistry) { - this.serviceDescriptionRegistry = serviceDescriptionRegistry; - synchronized (flushObserver) { - // Add the (static common) observer if the registry does not have it - if (!serviceDescriptionRegistry.getObservers().contains(flushObserver)) { - serviceDescriptionRegistry.addObserver(flushObserver); - } - } - } - - @SuppressWarnings("serial") - public void createCustomizedConfigurePanel(final CustomizedConfigureCallBack<WSDLServiceProviderConfig> callBack) { - - AddWSDLServiceDialog addWSDLServiceDialog = new AddWSDLServiceDialog() { - @Override - protected void addRegistry(String wsdlURL) { - - WSDLServiceProviderConfig providerConfig = new WSDLServiceProviderConfig(wsdlURL); - callBack.newProviderConfiguration(providerConfig); - } - }; - addWSDLServiceDialog.setVisible(true); - } - - public String getId() { - return providerId.toString(); - } - - public void setCredentialManager(CredentialManager credentialManager) { - this.credentialManager = credentialManager; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/WSDLServiceProviderConfig.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/WSDLServiceProviderConfig.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/WSDLServiceProviderConfig.java deleted file mode 100644 index 9a63c03..0000000 --- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/WSDLServiceProviderConfig.java +++ /dev/null @@ -1,32 +0,0 @@ -package net.sf.taverna.t2.activities.wsdl.servicedescriptions; - -import java.net.URI; - -import net.sf.taverna.t2.lang.beans.PropertyAnnotated; -import net.sf.taverna.t2.lang.beans.PropertyAnnotation; - -public class WSDLServiceProviderConfig extends PropertyAnnotated { - private URI uri; - - public WSDLServiceProviderConfig() { - } - - public WSDLServiceProviderConfig(String uri) { - this.uri = URI.create(uri); - } - - @PropertyAnnotation(displayName = "WSDL location", preferred = true) - public URI getURI() { - return uri; - } - - public void setURI(URI uri) { - this.uri = uri; - } - - @Override - public String toString() { - return getURI().toASCIIString(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/XMLInputSplitterActivityIcon.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/XMLInputSplitterActivityIcon.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/XMLInputSplitterActivityIcon.java deleted file mode 100644 index cc92f3b..0000000 --- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/XMLInputSplitterActivityIcon.java +++ /dev/null @@ -1,63 +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.wsdl.servicedescriptions; - -import java.net.URI; - -import javax.swing.Icon; -import javax.swing.ImageIcon; - -import net.sf.taverna.t2.workbench.activityicons.ActivityIconSPI; - -/** - * - * @author Alex Nenadic - * - */ -public class XMLInputSplitterActivityIcon implements ActivityIconSPI{ - - private static final URI ACTIVITY_TYPE = URI.create("http://ns.taverna.org.uk/2010/activity/xml-splitter/in"); - - private static Icon icon = null; - - public int canProvideIconScore(URI activityType) { - if (activityType.equals(ACTIVITY_TYPE)) - return DEFAULT_ICON + 1; - else - return NO_ICON; - } - - public Icon getIcon(URI activityType) { - return getXMLOutputSplitterIcon(); - } - - public static Icon getXMLOutputSplitterIcon() { - if (icon == null) { - icon = new ImageIcon(XMLOutputSplitterActivityIcon.class.getResource("/xml-splitter.png")); - } - return icon; - } - -} - - - - http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/XMLOutputSplitterActivityIcon.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/XMLOutputSplitterActivityIcon.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/XMLOutputSplitterActivityIcon.java deleted file mode 100644 index 73c9bcb..0000000 --- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/XMLOutputSplitterActivityIcon.java +++ /dev/null @@ -1,64 +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.wsdl.servicedescriptions; - -import java.net.URI; - -import javax.swing.Icon; -import javax.swing.ImageIcon; - -import net.sf.taverna.t2.workbench.activityicons.ActivityIconSPI; - -/** - * - * @author Alex Nenadic - * - */ -public class XMLOutputSplitterActivityIcon implements ActivityIconSPI{ - - private static final URI ACTIVITY_TYPE = URI.create("http://ns.taverna.org.uk/2010/activity/xml-splitter/out"); - - private static Icon icon = null; - - public int canProvideIconScore(URI activityType) { - if (activityType.equals(ACTIVITY_TYPE)) - return DEFAULT_ICON + 1; - else - return NO_ICON; - } - - public Icon getIcon(URI activityType) { - return getXMLOutputSplitterIcon(); - } - - public static Icon getXMLOutputSplitterIcon() { - if (icon == null) { - icon = new ImageIcon(XMLOutputSplitterActivityIcon.class.getResource("/xml-splitter.png")); - } - return icon; - } - -} - - - - - http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/AbstractXMLSplitterActionView.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/AbstractXMLSplitterActionView.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/AbstractXMLSplitterActionView.java deleted file mode 100644 index 0ca95e5..0000000 --- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/AbstractXMLSplitterActionView.java +++ /dev/null @@ -1,159 +0,0 @@ -package net.sf.taverna.t2.activities.wsdl.views; - -import java.io.IOException; -import java.util.Map; - -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.wsdl.WSDLException; -import javax.xml.parsers.ParserConfigurationException; - -import net.sf.taverna.t2.activities.wsdl.actions.AbstractAddXMLSplitterAction; -import net.sf.taverna.t2.activities.wsdl.actions.AddXMLInputSplitterAction; -import net.sf.taverna.t2.activities.wsdl.actions.AddXMLOutputSplitterAction; -import net.sf.taverna.t2.activities.wsdl.servicedescriptions.WSDLServiceDescription; -import net.sf.taverna.t2.workbench.configuration.colour.ColourManager; -import net.sf.taverna.t2.workbench.edits.EditManager; -import net.sf.taverna.t2.workbench.selection.SelectionManager; -import net.sf.taverna.t2.workbench.ui.actions.activity.HTMLBasedActivityContextualView; -import net.sf.taverna.wsdl.parser.TypeDescriptor; -import net.sf.taverna.wsdl.parser.UnknownOperationException; - -import org.apache.log4j.Logger; -import org.jdom.JDOMException; -import org.xml.sax.SAXException; - -import uk.org.taverna.scufl2.api.activity.Activity; -import uk.org.taverna.scufl2.api.port.DepthPort; -import uk.org.taverna.scufl2.api.port.InputActivityPort; -import uk.org.taverna.scufl2.api.port.OutputActivityPort; - -@SuppressWarnings("serial") -public abstract class AbstractXMLSplitterActionView extends HTMLBasedActivityContextualView { - - private static Logger logger = Logger.getLogger(AbstractXMLSplitterActionView.class); - protected final EditManager editManager; - protected final SelectionManager selectionManager; - protected AbstractAddXMLSplitterAction splitterAction; - - public AbstractXMLSplitterActionView(Activity activity, EditManager editManager, - SelectionManager selectionManager, ColourManager colourManager) { - super(activity, colourManager); - this.editManager = editManager; - this.selectionManager = selectionManager; - if (getActivity().getType().equals(WSDLServiceDescription.OUTPUT_SPLITTER_TYPE)) { - splitterAction = new AddXMLOutputSplitterAction(getActivity(), - null, editManager, selectionManager); - } else if (getActivity().getType().equals(WSDLServiceDescription.INPUT_SPLITTER_TYPE)) { - splitterAction = new AddXMLInputSplitterAction(getActivity(), - null, editManager, selectionManager); - } - super.initView(); - } - - @Override - public void initView() { - } - - protected void addOutputSplitter(final JComponent mainFrame, JPanel flowPanel) { - if (getActivity().getType().equals(WSDLServiceDescription.OUTPUT_SPLITTER_TYPE)) { - try { - Map<String, TypeDescriptor> descriptors = splitterAction.getTypeDescriptors(); - if (!AbstractAddXMLSplitterAction.filterDescriptors(descriptors).isEmpty()) { - flowPanel.add(new JButton(splitterAction)); - } - } catch (UnknownOperationException | IOException | ParserConfigurationException - | WSDLException | SAXException | JDOMException e) { - logger.warn("Could not find type descriptors for " + getActivity(), e); - } - } - } - - protected void addInputSplitter(final JComponent mainFrame, JPanel flowPanel) { - if (getActivity().getType().equals(WSDLServiceDescription.INPUT_SPLITTER_TYPE)) { - try { - Map<String, TypeDescriptor> descriptors = splitterAction.getTypeDescriptors(); - if (!AbstractAddXMLSplitterAction.filterDescriptors(descriptors).isEmpty()) { - splitterAction.setOwner(mainFrame); - flowPanel.add(new JButton(splitterAction)); - } - } catch (UnknownOperationException | IOException | ParserConfigurationException - | WSDLException | SAXException | JDOMException e) { - logger.warn("Could not find type descriptors for " + getActivity(), e); - } - } - } - - protected String describePorts() { - StringBuilder html = new StringBuilder(); - - if (!getActivity().getInputPorts().isEmpty()) { - html.append("<tr><th colspan='2' align='left'>Inputs</th></tr>"); - for (InputActivityPort port : getActivity().getInputPorts()) { - TypeDescriptor descriptor = null; - if (getActivity().getType().equals(WSDLServiceDescription.INPUT_SPLITTER_TYPE)) { - try { - descriptor = splitterAction.getTypeDescriptors().get(port.getName()); - } catch (UnknownOperationException | IOException | ParserConfigurationException - | WSDLException | SAXException | JDOMException e) { - logger.warn("Could not find type descriptors for " + getActivity(), e); - } - } - if (descriptor == null) { - html.append(describePort(port)); - } else { - html.append(describePort(port, descriptor)); - } - - } - } - - if (!getActivity().getOutputPorts().isEmpty()) { - html.append("<tr><th colspan='2' align='left'>Outputs</th></tr>"); - for (OutputActivityPort port : getActivity().getOutputPorts()) { - TypeDescriptor descriptor = null; - if (getActivity().getType().equals(WSDLServiceDescription.OUTPUT_SPLITTER_TYPE)) { - try { - descriptor = splitterAction.getTypeDescriptors().get(port.getName()); - } catch (UnknownOperationException | IOException | ParserConfigurationException - | WSDLException | SAXException | JDOMException e) { - logger.warn("Could not find type descriptors for " + getActivity(), e); - } - } - if (descriptor == null) { - html.append(describePort(port)); - } else { - html.append(describePort(port, descriptor)); - } - } - } - - return html.toString(); - } - - private String describePort(DepthPort port, TypeDescriptor descriptor) { - String html = "<tr><td>" + port.getName() + "</td><td>"; - if (descriptor != null && descriptor.isOptional()) { - html += "<em>optional</em><br>"; - } - html+="Depth:"+port.getDepth()+"<br>"; - if (descriptor != null ) { - html+="<code>"+descriptor.getQname().toString()+"</code><br>"; -// if (descriptor.getDocumentation() != null && !descriptor.getDocumentation().isEmpty()){ -// html += "<p>"+descriptor.getDocumentation()+"</p>"; -// } - } - - html+="</td></tr>"; - return html; - } - - private String describePort(DepthPort port) { - String html = "<tr><td>" + port.getName() + "</td><td>"; - html += "Depth:" + port.getDepth() + "<br>"; - html += "</td></tr>"; - return html; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/WSDLActivityConfigurationView.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/WSDLActivityConfigurationView.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/WSDLActivityConfigurationView.java deleted file mode 100644 index 4f728d9..0000000 --- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/WSDLActivityConfigurationView.java +++ /dev/null @@ -1,446 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007-2008 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.wsdl.views; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.net.URI; - -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.SwingConstants; -import javax.swing.border.Border; -import javax.swing.border.EmptyBorder; -import javax.swing.plaf.basic.BasicComboBoxRenderer; - -import net.sf.taverna.t2.activities.wsdl.security.SecurityProfiles; -import net.sf.taverna.t2.lang.ui.DialogTextArea; -import net.sf.taverna.t2.security.credentialmanager.CredentialManager; -import net.sf.taverna.t2.workbench.ui.credentialmanager.CredentialManagerUI; -import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ActivityConfigurationPanel; -import uk.org.taverna.scufl2.api.activity.Activity; - -/** - * Configuration dialog for WSDL activity. - * - * @author Alex Nenadic - */ -@SuppressWarnings("serial") -public class WSDLActivityConfigurationView extends ActivityConfigurationPanel implements ItemListener { - - private CredentialManager credentialManager; - private CredentialManagerUI credManagerUI; - - private ButtonGroup buttonGroup; - private JRadioButton noSecurityRadioButton; - private JLabel noSecurityLabel; - private JRadioButton httpSecurityAuthNRadioButton; - private JLabel httpSecurityAuthNLabel; - private JRadioButton wsSecurityAuthNRadioButton; - private JLabel wsSecurityAuthNLabel; - - // Password types - private final String PLAINTEXT_PASSWORD = "Plaintext password"; - private final String DIGEST_PASSWORD = "Digest password"; - private String[] passwordTypes = new String[] { PLAINTEXT_PASSWORD, DIGEST_PASSWORD }; - private String[] tooltips = new String[] { - "Password will be sent in plaintext (which is OK if service is using HTTPS)", - "Password will be digested (cryptographically hashed) before sending" }; - private JComboBox<String> passwordTypeComboBox; - private JCheckBox addTimestampCheckBox; - private JButton setHttpUsernamePasswordButton; - private JButton setWsdlUsernamePasswordButton; - - // private Logger logger = Logger.getLogger(WSDLActivityConfigurationView.class); - - public WSDLActivityConfigurationView(Activity activity, CredentialManager credentialManager) { - super(activity); - this.credentialManager = credentialManager; - initialise(); - } - - @Override - protected void initialise() { - super.initialise(); - - int gridy = 0; - - // title panel - JPanel titlePanel = new JPanel(new BorderLayout()); - titlePanel.setBackground(Color.WHITE); - JLabel titleLabel = new JLabel("Security configuration"); - titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 13.5f)); - titleLabel.setBorder(new EmptyBorder(10, 10, 0, 10)); - DialogTextArea titleMessage = new DialogTextArea( - "Select a security profile for the service"); - titleMessage.setMargin(new Insets(5, 20, 10, 10)); - titleMessage.setFont(titleMessage.getFont().deriveFont(11f)); - titleMessage.setEditable(false); - titleMessage.setFocusable(false); - titlePanel.setBorder(new EmptyBorder(10, 10, 0, 10)); - titlePanel.add(titleLabel, BorderLayout.NORTH); - titlePanel.add(titleMessage, BorderLayout.CENTER); - addDivider(titlePanel, SwingConstants.BOTTOM, true); - - // Main panel - JPanel mainPanel = new JPanel(); - mainPanel.setLayout(new GridBagLayout()); - mainPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); - - // Create the radio buttons - noSecurityRadioButton = new JRadioButton("None"); - noSecurityRadioButton.addItemListener(this); - - wsSecurityAuthNRadioButton = new JRadioButton( - "WS-Security username and password authentication"); - wsSecurityAuthNRadioButton.addItemListener(this); - - httpSecurityAuthNRadioButton = new JRadioButton("HTTP username and password authentication"); - httpSecurityAuthNRadioButton.addItemListener(this); - - // Group the radio buttons - buttonGroup = new ButtonGroup(); - buttonGroup.add(noSecurityRadioButton); - buttonGroup.add(wsSecurityAuthNRadioButton); - buttonGroup.add(httpSecurityAuthNRadioButton); - - GridBagConstraints gbc = new GridBagConstraints(); - gbc.weightx = 1.0; - gbc.weighty = 0.0; - - gbc.gridx = 0; - gbc.gridy = gridy++; - gbc.fill = GridBagConstraints.NONE; - gbc.anchor = GridBagConstraints.WEST; - gbc.insets = new Insets(5, 10, 0, 0); - mainPanel.add(noSecurityRadioButton, gbc); - - noSecurityLabel = new JLabel("Service requires no security"); - noSecurityLabel.setFont(noSecurityLabel.getFont().deriveFont(11f)); - // addDivider(noSecurityLabel, SwingConstants.BOTTOM, false); - gbc.gridx = 0; - gbc.gridy = gridy++; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.anchor = GridBagConstraints.WEST; - gbc.insets = new Insets(0, 40, 10, 10); - mainPanel.add(noSecurityLabel, gbc); - - gbc.gridx = 0; - gbc.gridy = gridy++; - gbc.fill = GridBagConstraints.NONE; - gbc.anchor = GridBagConstraints.WEST; - gbc.insets = new Insets(5, 10, 0, 0); - mainPanel.add(httpSecurityAuthNRadioButton, gbc); - - ActionListener usernamePasswordListener = new ActionListener() { - - public void actionPerformed(ActionEvent e) { - // Get Credential Manager UI to get the username and password for the service - if (credManagerUI == null) { - credManagerUI = new CredentialManagerUI(credentialManager); - } - credManagerUI.newPasswordForService(URI.create(getJson().get("operation") - .get("wsdl").textValue())); - } - }; - - httpSecurityAuthNLabel = new JLabel( - "Service requires HTTP username and password in order to authenticate the user"); - httpSecurityAuthNLabel.setFont(httpSecurityAuthNLabel.getFont().deriveFont(11f)); - gbc.gridx = 0; - gbc.gridy = gridy++; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.anchor = GridBagConstraints.WEST; - gbc.insets = new Insets(0, 40, 10, 10); - mainPanel.add(httpSecurityAuthNLabel, gbc); - - // Set username and password button; - setHttpUsernamePasswordButton = new JButton("Set username and password"); - gbc.gridx = 0; - gbc.gridy = gridy++; - gbc.fill = GridBagConstraints.NONE; - gbc.anchor = GridBagConstraints.EAST; - gbc.insets = new Insets(0, 40, 10, 10); - gbc.weightx = 1.0; - gbc.weighty = 1.0; // add any vertical space to this component - mainPanel.add(setHttpUsernamePasswordButton, gbc); - setHttpUsernamePasswordButton.addActionListener(usernamePasswordListener); - - gbc.gridx = 0; - gbc.gridy = gridy++; - gbc.fill = GridBagConstraints.NONE; - gbc.anchor = GridBagConstraints.WEST; - gbc.insets = new Insets(5, 10, 0, 0); - mainPanel.add(wsSecurityAuthNRadioButton, gbc); - - wsSecurityAuthNLabel = new JLabel( - "Service requires WS-Security username and password in order to authenticate the user"); - wsSecurityAuthNLabel.setFont(wsSecurityAuthNLabel.getFont().deriveFont(11f)); - gbc.gridx = 0; - gbc.gridy = gridy++; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.anchor = GridBagConstraints.WEST; - gbc.insets = new Insets(0, 40, 0, 0); - mainPanel.add(wsSecurityAuthNLabel, gbc); - - // Password type list - passwordTypeComboBox = new JComboBox<>(passwordTypes); - passwordTypeComboBox.setRenderer(new ComboBoxTooltipRenderer()); - gbc.gridx = 0; - gbc.gridy = gridy++; - gbc.fill = GridBagConstraints.NONE; - gbc.anchor = GridBagConstraints.WEST; - gbc.insets = new Insets(10, 40, 0, 0); - mainPanel.add(passwordTypeComboBox, gbc); - - // 'Add timestamp' checkbox - addTimestampCheckBox = new JCheckBox("Add a timestamp to SOAP message"); - gbc.gridx = 0; - gbc.gridy = gridy++; - gbc.fill = GridBagConstraints.NONE; - gbc.anchor = GridBagConstraints.WEST; - gbc.insets = new Insets(5, 40, 10, 10); - mainPanel.add(addTimestampCheckBox, gbc); - - // Set username and password button; - setWsdlUsernamePasswordButton = new JButton("Set username and password"); - gbc.gridx = 0; - gbc.gridy = gridy++; - gbc.fill = GridBagConstraints.NONE; - gbc.anchor = GridBagConstraints.EAST; - gbc.insets = new Insets(0, 40, 10, 10); - gbc.weightx = 1.0; - gbc.weighty = 1.0; // add any vertical space to this component - mainPanel.add(setWsdlUsernamePasswordButton, gbc); - setWsdlUsernamePasswordButton.addActionListener(usernamePasswordListener); - - addDivider(mainPanel, SwingConstants.BOTTOM, true); - - // Enable/disable controls based on what is the current security profiles - if (!getJson().has("securityProfile")) { - noSecurityRadioButton.setSelected(true); - } else { - URI securityProfile = URI.create(getJson().get("securityProfile").textValue()); - if (securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_PLAINTEXTPASSWORD) - || securityProfile - .equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_DIGESTPASSWORD) - || securityProfile - .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD) - || securityProfile - .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD)) { - wsSecurityAuthNRadioButton.setSelected(true); - } - if (securityProfile.equals(SecurityProfiles.HTTP_BASIC_AUTHN) - || securityProfile.equals(SecurityProfiles.HTTP_DIGEST_AUTHN)) { - httpSecurityAuthNRadioButton.setSelected(true); - } - if (securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_PLAINTEXTPASSWORD) - || securityProfile - .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD)) { - passwordTypeComboBox.setSelectedItem(PLAINTEXT_PASSWORD); - } else if (securityProfile - .equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_DIGESTPASSWORD) - || securityProfile - .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD)) { - passwordTypeComboBox.setSelectedItem(DIGEST_PASSWORD); - } - if (securityProfile - .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD) - || securityProfile - .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD)) { - addTimestampCheckBox.setSelected(true); - } else { - addTimestampCheckBox.setSelected(false); - } - } - - // Put everything together - JPanel layoutPanel = new JPanel(new BorderLayout()); - layoutPanel.add(titlePanel, BorderLayout.NORTH); - layoutPanel.add(mainPanel, BorderLayout.CENTER); - layoutPanel.setPreferredSize(new Dimension(550, 400)); - - add(layoutPanel); - } - - @Override - public boolean checkValues() { - return true; - } - - @Override - public void noteConfiguration() { - - if (noSecurityRadioButton.isSelected()) { - getJson().remove("securityProfile"); // no security required - } else if (httpSecurityAuthNRadioButton.isSelected()) { - getJson().put("securityProfile", SecurityProfiles.HTTP_BASIC_AUTHN.toString()); - } else if (wsSecurityAuthNRadioButton.isSelected()) { // plaintext password - if (passwordTypeComboBox.getSelectedItem().equals(PLAINTEXT_PASSWORD)) { - if (addTimestampCheckBox.isSelected()) { - getJson().put( - "securityProfile", - SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD - .toString()); - } else { - getJson().put("securityProfile", - SecurityProfiles.WSSECURITY_USERNAMETOKEN_PLAINTEXTPASSWORD.toString()); - } - } else { // digest password - if (addTimestampCheckBox.isSelected()) { - getJson().put( - "securityProfile", - SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD - .toString()); - } else { - getJson().put("securityProfile", - SecurityProfiles.WSSECURITY_USERNAMETOKEN_DIGESTPASSWORD.toString()); - } - } - } - } - - /** - * Disable/enable items on the panel based on this radio button - * has been selected. - */ - public void itemStateChanged(ItemEvent e) { - - Object source = e.getItemSelectable(); - if (source == noSecurityRadioButton) { - httpSecurityAuthNLabel.setEnabled(false); - wsSecurityAuthNLabel.setEnabled(false); - passwordTypeComboBox.setEnabled(false); - setHttpUsernamePasswordButton.setEnabled(false); - setWsdlUsernamePasswordButton.setEnabled(false); - addTimestampCheckBox.setEnabled(false); - - noSecurityLabel.setEnabled(true); - } else if (source == httpSecurityAuthNRadioButton) { - noSecurityLabel.setEnabled(false); - httpSecurityAuthNLabel.setEnabled(true); - wsSecurityAuthNLabel.setEnabled(false); - passwordTypeComboBox.setEnabled(false); - setHttpUsernamePasswordButton.setEnabled(true); - setWsdlUsernamePasswordButton.setEnabled(false); - addTimestampCheckBox.setEnabled(false); - } else if (source == wsSecurityAuthNRadioButton) { - noSecurityLabel.setEnabled(false); - httpSecurityAuthNLabel.setEnabled(false); - wsSecurityAuthNLabel.setEnabled(true); - passwordTypeComboBox.setEnabled(true); - setHttpUsernamePasswordButton.setEnabled(false); - setWsdlUsernamePasswordButton.setEnabled(true); - addTimestampCheckBox.setEnabled(true); - } - } - - /** - * A renderer for JComboBox that will display a tooltip for - * the selected item. - */ - class ComboBoxTooltipRenderer extends BasicComboBoxRenderer { - public Component getListCellRendererComponent(JList list, Object value, int index, - boolean isSelected, boolean cellHasFocus) { - if (isSelected) { - setBackground(list.getSelectionBackground()); - setForeground(list.getSelectionForeground()); - if (-1 < index) { - list.setToolTipText(tooltips[index]); - } - } else { - setBackground(list.getBackground()); - setForeground(list.getForeground()); - } - setFont(list.getFont()); - setText((value == null) ? "" : value.toString()); - return this; - } - } - - /** - * Adds a light gray or etched border to the top or bottom of a JComponent. - * - * @author David Withers - * @param component - */ - protected void addDivider(JComponent component, final int position, final boolean etched) { - component.setBorder(new Border() { - private final Color borderColor = new Color(.6f, .6f, .6f); - - public Insets getBorderInsets(Component c) { - if (position == SwingConstants.TOP) { - return new Insets(5, 0, 0, 0); - } else { - return new Insets(0, 0, 5, 0); - } - } - - public boolean isBorderOpaque() { - return false; - } - - public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { - if (position == SwingConstants.TOP) { - if (etched) { - g.setColor(borderColor); - g.drawLine(x, y, x + width, y); - g.setColor(Color.WHITE); - g.drawLine(x, y + 1, x + width, y + 1); - } else { - g.setColor(Color.LIGHT_GRAY); - g.drawLine(x, y, x + width, y); - } - } else { - if (etched) { - g.setColor(borderColor); - g.drawLine(x, y + height - 2, x + width, y + height - 2); - g.setColor(Color.WHITE); - g.drawLine(x, y + height - 1, x + width, y + height - 1); - } else { - g.setColor(Color.LIGHT_GRAY); - g.drawLine(x, y + height - 1, x + width, y + height - 1); - } - } - } - - }); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/WSDLActivityContextualView.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/WSDLActivityContextualView.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/WSDLActivityContextualView.java deleted file mode 100644 index ac129ec..0000000 --- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/WSDLActivityContextualView.java +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007-2008 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.wsdl.views; - -import java.awt.BorderLayout; -import java.awt.FlowLayout; -import java.awt.Frame; - -import javax.swing.Action; -import javax.swing.JComponent; -import javax.swing.JPanel; - -import net.sf.taverna.t2.activities.wsdl.actions.WSDLActivityConfigureAction; -import net.sf.taverna.t2.security.credentialmanager.CredentialManager; -import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry; -import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager; -import net.sf.taverna.t2.workbench.configuration.colour.ColourManager; -import net.sf.taverna.t2.workbench.edits.EditManager; -import net.sf.taverna.t2.workbench.file.FileManager; -import net.sf.taverna.t2.workbench.selection.SelectionManager; -import net.sf.taverna.t2.workbench.ui.actions.activity.HTMLBasedActivityContextualView; -import uk.org.taverna.scufl2.api.activity.Activity; - -import com.fasterxml.jackson.databind.JsonNode; - -@SuppressWarnings("serial") -public class WSDLActivityContextualView extends AbstractXMLSplitterActionView { - - private final ActivityIconManager activityIconManager; - private final ServiceDescriptionRegistry serviceDescriptionRegistry; - private final CredentialManager credentialManager; - private final FileManager fileManager; - - public WSDLActivityContextualView(Activity activity, EditManager editManager, FileManager fileManager, - SelectionManager selectionManager, ActivityIconManager activityIconManager, - ColourManager colourManager, CredentialManager credentialManager, - ServiceDescriptionRegistry serviceDescriptionRegistry) { - super(activity, editManager, selectionManager, colourManager); - this.fileManager = fileManager; - this.activityIconManager = activityIconManager; - this.credentialManager = credentialManager; - this.serviceDescriptionRegistry = serviceDescriptionRegistry; - } - - /** - * Gets the component from the {@link HTMLBasedActivityContextualView} and adds buttons to it - * allowing XML splitters to be added - */ - @Override - public JComponent getMainFrame() { - final JComponent mainFrame = super.getMainFrame(); - JPanel flowPanel = new JPanel(new FlowLayout()); - - addInputSplitter(mainFrame, flowPanel); - addOutputSplitter(mainFrame, flowPanel); - - mainFrame.add(flowPanel, BorderLayout.SOUTH); - return mainFrame; - } - - @Override - public String getViewTitle() { - return "WSDL-based service"; - } - - @Override - protected String getRawTableRowsHtml() { - JsonNode operation = getConfigBean().getJson().get("operation"); - String summary = "<tr><td>WSDL</td><td>" + operation.get("wsdl").textValue(); - summary += "</td></tr><tr><td>Operation</td><td>" + operation.get("name").textValue() - + "</td></tr>"; - boolean securityConfigured = getConfigBean().getJson().has("securityProfile"); - summary += "<tr><td>Secure</td><td>" + securityConfigured + "</td></tr>"; - summary += "</tr>"; - summary += describePorts(); - return summary; - } - - @Override - public Action getConfigureAction(Frame owner) { - return new WSDLActivityConfigureAction(getActivity(), owner, editManager, fileManager, - activityIconManager, serviceDescriptionRegistry, credentialManager); - } - - @Override - public int getPreferredPosition() { - return 100; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/WSDLActivityViewFactory.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/WSDLActivityViewFactory.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/WSDLActivityViewFactory.java deleted file mode 100644 index b3fb8ed..0000000 --- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/WSDLActivityViewFactory.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007-2008 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.wsdl.views; - -import java.util.Arrays; -import java.util.List; - -import net.sf.taverna.t2.activities.wsdl.servicedescriptions.WSDLServiceDescription; -import net.sf.taverna.t2.security.credentialmanager.CredentialManager; -import net.sf.taverna.t2.servicedescriptions.ServiceDescriptionRegistry; -import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager; -import net.sf.taverna.t2.workbench.configuration.colour.ColourManager; -import net.sf.taverna.t2.workbench.edits.EditManager; -import net.sf.taverna.t2.workbench.file.FileManager; -import net.sf.taverna.t2.workbench.selection.SelectionManager; -import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView; -import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory; -import uk.org.taverna.scufl2.api.activity.Activity; - -public class WSDLActivityViewFactory implements ContextualViewFactory<Activity> { - - private EditManager editManager; - private ActivityIconManager activityIconManager; - private ColourManager colourManager; - private SelectionManager selectionManager; - private ServiceDescriptionRegistry serviceDescriptionRegistry; - private CredentialManager credentialManager; - private FileManager fileManager; - - public boolean canHandle(Object object) { - return object instanceof Activity - && ((Activity) object).getType().equals(WSDLServiceDescription.ACTIVITY_TYPE); - } - - public List<ContextualView> getViews(Activity activity) { - return Arrays - .asList(new ContextualView[] { new WSDLActivityContextualView(activity, - editManager, fileManager, selectionManager, activityIconManager, colourManager, - credentialManager, serviceDescriptionRegistry) }); - } - - public void setEditManager(EditManager editManager) { - this.editManager = editManager; - } - - public void setFileManager(FileManager fileManager) { - this.fileManager = fileManager; - } - - public void setSelectionManager(SelectionManager selectionManager) { - this.selectionManager = selectionManager; - } - - public void setActivityIconManager(ActivityIconManager activityIconManager) { - this.activityIconManager = activityIconManager; - } - - public void setColourManager(ColourManager colourManager) { - this.colourManager = colourManager; - } - - public void setServiceDescriptionRegistry(ServiceDescriptionRegistry serviceDescriptionRegistry) { - this.serviceDescriptionRegistry = serviceDescriptionRegistry; - } - - public void setCredentialManager(CredentialManager credentialManager) { - this.credentialManager = credentialManager; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/XMLSplitterContextualView.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/XMLSplitterContextualView.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/XMLSplitterContextualView.java deleted file mode 100644 index 228edd4..0000000 --- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/XMLSplitterContextualView.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007-2008 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.wsdl.views; - -import java.awt.BorderLayout; -import java.awt.FlowLayout; - -import javax.swing.JComponent; -import javax.swing.JPanel; - -import net.sf.taverna.t2.workbench.configuration.colour.ColourManager; -import net.sf.taverna.t2.workbench.edits.EditManager; -import net.sf.taverna.t2.workbench.selection.SelectionManager; -import net.sf.taverna.t2.workbench.ui.actions.activity.HTMLBasedActivityContextualView; - -import org.apache.log4j.Logger; - -import uk.org.taverna.scufl2.api.activity.Activity; - -@SuppressWarnings("serial") -public class XMLSplitterContextualView extends AbstractXMLSplitterActionView { - - public XMLSplitterContextualView(Activity activity, - EditManager editManager, SelectionManager selectionManager, ColourManager colourManager) { - super(activity, editManager, selectionManager, colourManager); - } - - static Logger logger = Logger.getLogger(XMLSplitterContextualView.class); - - /** - * Gets the component from the {@link HTMLBasedActivityContextualView} and adds buttons to it - * allowing XML splitters to be added - */ - @Override - public JComponent getMainFrame() { - final JComponent mainFrame = super.getMainFrame(); - JPanel flowPanel = new JPanel(new FlowLayout()); - - addInputSplitter(mainFrame, flowPanel); - addOutputSplitter(mainFrame, flowPanel); - mainFrame.add(flowPanel, BorderLayout.SOUTH); - return mainFrame; - } - - @Override - public String getViewTitle() { - return "XML splitter"; - } - - @Override - protected String getRawTableRowsHtml() { - return describePorts(); - } - - @Override - public int getPreferredPosition() { - return 100; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/XMLSplitterViewFactory.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/XMLSplitterViewFactory.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/XMLSplitterViewFactory.java deleted file mode 100644 index d0d5f8f..0000000 --- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/views/XMLSplitterViewFactory.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2007-2008 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.wsdl.views; - -import java.util.Arrays; -import java.util.List; - -import net.sf.taverna.t2.activities.wsdl.servicedescriptions.WSDLServiceDescription; -import net.sf.taverna.t2.activities.wsdl.xmlsplitter.XMLInputSplitterActivity; -import net.sf.taverna.t2.activities.wsdl.xmlsplitter.XMLOutputSplitterActivity; -import net.sf.taverna.t2.workbench.configuration.colour.ColourManager; -import net.sf.taverna.t2.workbench.edits.EditManager; -import net.sf.taverna.t2.workbench.selection.SelectionManager; -import net.sf.taverna.t2.workbench.ui.views.contextualviews.ContextualView; -import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ContextualViewFactory; -import uk.org.taverna.scufl2.api.activity.Activity; - -public class XMLSplitterViewFactory implements ContextualViewFactory<Activity> { - - private EditManager editManager; - private SelectionManager selectionManager; - private ColourManager colourManager; - - public boolean canHandle(Object object) { - - return object instanceof Activity - && (((Activity) object).getType().equals(WSDLServiceDescription.INPUT_SPLITTER_TYPE) - || ((Activity) object).getType().equals(WSDLServiceDescription.OUTPUT_SPLITTER_TYPE)); - } - - public List<ContextualView> getViews(Activity activity) { - return Arrays.asList(new ContextualView[] { new XMLSplitterContextualView(activity, - editManager, selectionManager, colourManager) }); - } - - public void setEditManager(EditManager editManager) { - this.editManager = editManager; - } - - public void setSelectionManager(SelectionManager selectionManager) { - this.selectionManager = selectionManager; - } - - public void setColourManager(ColourManager colourManager) { - this.colourManager = colourManager; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/actions/AbstractAddXMLSplitterAction.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/actions/AbstractAddXMLSplitterAction.java b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/actions/AbstractAddXMLSplitterAction.java new file mode 100644 index 0000000..fd5b494 --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/actions/AbstractAddXMLSplitterAction.java @@ -0,0 +1,155 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.activities.wsdl.actions; + +import java.awt.event.ActionEvent; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.AbstractAction; +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.wsdl.WSDLException; +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.taverna.workbench.edits.EditException; +import org.apache.taverna.workbench.edits.EditManager; +import org.apache.taverna.workbench.selection.SelectionManager; +import org.apache.taverna.wsdl.parser.ArrayTypeDescriptor; +import org.apache.taverna.wsdl.parser.ComplexTypeDescriptor; +import org.apache.taverna.wsdl.parser.TypeDescriptor; +import org.apache.taverna.wsdl.parser.UnknownOperationException; + +import org.apache.log4j.Logger; +import org.jdom.JDOMException; +import org.xml.sax.SAXException; + +import org.apache.taverna.scufl2.api.activity.Activity; +import org.apache.taverna.scufl2.api.common.Scufl2Tools; +import org.apache.taverna.scufl2.api.core.Workflow; +import org.apache.taverna.scufl2.api.profiles.Profile; + +/** + * Abstract superclass of {@link AddXMLOutputSplitterAction} and + * {@link AddXMLInputSplitterAction}. + * <p> + * Pops up a {@link JOptionPane} with the names of all the wsdl ports. The one + * that is selected is added as an input/output splitter to the currently open + * dataflow using the {@link AddXMLSplitterEdit} + * + * @author Ian Dunlop + * @author Stian Soiland-Reyes + * @author Stuart Owen + * + */ +@SuppressWarnings("serial") +public abstract class AbstractAddXMLSplitterAction extends AbstractAction { + + private static Logger logger = Logger.getLogger(AddXMLOutputSplitterAction.class); + + protected Scufl2Tools scufl2Tools = new Scufl2Tools(); + + protected JComponent owner; + protected final Activity activity; + protected final EditManager editManager; + protected final SelectionManager selectionManager; + + public AbstractAddXMLSplitterAction(Activity activity, + JComponent owner, EditManager editManager, SelectionManager selectionManager) { + this.activity = activity; + this.owner = owner; + this.editManager = editManager; + this.selectionManager = selectionManager; + } + + public void actionPerformed(ActionEvent ev) { + List<String> possibilities; + Map<String, TypeDescriptor> typeDescriptors; + try { + typeDescriptors = getTypeDescriptors(); + } catch (UnknownOperationException ex) { + logger.error("Can't find operation for activity " + + activity, ex); + return; + } catch (IOException | ParserConfigurationException | WSDLException | SAXException | JDOMException ex) { + logger.error("Can't read definition for activity " + + activity, ex); + return; + } + + typeDescriptors = filterDescriptors(typeDescriptors); + + possibilities = new ArrayList<String>(typeDescriptors.keySet()); + if (possibilities.isEmpty()) { + logger.warn("No type descriptors found for activity " + activity); + return; + } + Collections.sort(possibilities); + + String portName = (String) JOptionPane.showInputDialog(owner, + "Select the port to add the splitter to", + "Add output XML splitter", JOptionPane.PLAIN_MESSAGE, null, + possibilities.toArray(), possibilities.get(0)); + + Workflow workflow = selectionManager.getSelectedWorkflow(); + Profile profile = selectionManager.getSelectedProfile(); + TypeDescriptor typeDescriptorForPort = typeDescriptors + .get(portName); + + if (typeDescriptorForPort instanceof ArrayTypeDescriptor + || typeDescriptorForPort instanceof ComplexTypeDescriptor) { + AddXMLSplitterEdit edit = new AddXMLSplitterEdit(workflow, profile, + activity, typeDescriptorForPort, portName, isInput()); + try { + editManager.doDataflowEdit(workflow.getParent(), edit); + } catch (EditException ex) { + logger.error("Could not perform edit to add " + portName, ex); + } + } else { + logger.warn("Unknown typedescriptor for " + portName); + } + } + + public static Map<String, TypeDescriptor> filterDescriptors( + Map<String, TypeDescriptor> descriptors) { + Map<String, TypeDescriptor> filtered = new HashMap<String, TypeDescriptor>(); + for (Entry<String, TypeDescriptor> entry : descriptors.entrySet()) { + TypeDescriptor descriptor = entry.getValue(); + if (descriptor.getMimeType().contains("'text/xml'")) { + filtered.put(entry.getKey(), descriptor); + } + } + return filtered; + } + + protected abstract boolean isInput(); + + public abstract Map<String, TypeDescriptor> getTypeDescriptors() + throws UnknownOperationException, IOException, ParserConfigurationException, WSDLException, SAXException, JDOMException; + + public void setOwner(JComponent owner) { + this.owner = owner; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/actions/AddXMLInputSplitterAction.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/actions/AddXMLInputSplitterAction.java b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/actions/AddXMLInputSplitterAction.java new file mode 100644 index 0000000..784edae --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/actions/AddXMLInputSplitterAction.java @@ -0,0 +1,102 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.activities.wsdl.actions; + +import java.io.IOException; +import java.io.StringReader; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.wsdl.WSDLException; +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.taverna.activities.wsdl.servicedescriptions.WSDLServiceDescription; +import org.apache.taverna.workbench.edits.EditManager; +import org.apache.taverna.workbench.selection.SelectionManager; +import org.apache.taverna.wsdl.parser.ArrayTypeDescriptor; +import org.apache.taverna.wsdl.parser.ComplexTypeDescriptor; +import org.apache.taverna.wsdl.parser.TypeDescriptor; +import org.apache.taverna.wsdl.parser.UnknownOperationException; +import org.apache.taverna.wsdl.parser.WSDLParser; +import org.apache.taverna.wsdl.xmlsplitter.XMLSplitterSerialisationHelper; + +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; +import org.xml.sax.SAXException; + +import org.apache.taverna.scufl2.api.activity.Activity; +import org.apache.taverna.scufl2.api.configurations.Configuration; + +/** + * Pops up a {@link JOptionPane} with the names of all the wsdl ports. The one + * that is selected is added as an input splitter to the currently open dataflow + * using the {@link AddXMLSplitterEdit} + * + * @author Ian Dunlop + * @author Stian Soiland-Reyes + */ +@SuppressWarnings("serial") +public class AddXMLInputSplitterAction extends AbstractAddXMLSplitterAction { + + public AddXMLInputSplitterAction(Activity activity, JComponent owner, EditManager editManager, + SelectionManager selectionManager) { + super(activity, owner, editManager, selectionManager); + putValue(NAME, "Add input XML splitter"); + } + + @Override + public Map<String, TypeDescriptor> getTypeDescriptors() throws UnknownOperationException, IOException, ParserConfigurationException, WSDLException, SAXException, JDOMException { + Map<String, TypeDescriptor> descriptors = new HashMap<String, TypeDescriptor>(); + Configuration configuration = scufl2Tools.configurationFor(activity, selectionManager.getSelectedProfile()); + if (activity.getType().equals(WSDLServiceDescription.ACTIVITY_TYPE)) { + String wsdlLocation = configuration.getJson().get("operation").get("wsdl").textValue(); + String operationName = configuration.getJson().get("operation").get("name").textValue(); + List<TypeDescriptor> inputDescriptors = new WSDLParser(wsdlLocation) + .getOperationInputParameters(operationName); + for (TypeDescriptor descriptor : inputDescriptors) { + descriptors.put(descriptor.getName(), descriptor); + } + } else if (activity.getType().equals(WSDLServiceDescription.INPUT_SPLITTER_TYPE)) { + String wrappedType = configuration.getJson().get("wrappedType").textValue(); + Element element = new SAXBuilder().build(new StringReader(wrappedType)).getRootElement(); + TypeDescriptor typeDescriptor = XMLSplitterSerialisationHelper.extensionXMLToTypeDescriptor(element); + if (typeDescriptor instanceof ComplexTypeDescriptor) { + for (TypeDescriptor desc : ((ComplexTypeDescriptor)typeDescriptor).getElements()) { + descriptors.put(desc.getName(), desc); + } + } + else if (typeDescriptor instanceof ArrayTypeDescriptor) { + TypeDescriptor desc = ((ArrayTypeDescriptor)typeDescriptor).getElementType(); + descriptors.put(typeDescriptor.getName(), desc); + } + } + return descriptors; + } + + @Override + protected boolean isInput() { + return true; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench-common-activities/blob/163747de/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/actions/AddXMLOutputSplitterAction.java ---------------------------------------------------------------------- diff --git a/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/actions/AddXMLOutputSplitterAction.java b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/actions/AddXMLOutputSplitterAction.java new file mode 100644 index 0000000..f94a485 --- /dev/null +++ b/taverna-wsdl-activity-ui/src/main/java/org/apache/taverna/activities/wsdl/actions/AddXMLOutputSplitterAction.java @@ -0,0 +1,103 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +package org.apache.taverna.activities.wsdl.actions; + +import java.io.IOException; +import java.io.StringReader; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.wsdl.WSDLException; +import javax.xml.parsers.ParserConfigurationException; + +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; +import org.xml.sax.SAXException; + +import org.apache.taverna.activities.wsdl.servicedescriptions.WSDLServiceDescription; +import org.apache.taverna.workbench.edits.EditManager; +import org.apache.taverna.workbench.selection.SelectionManager; +import org.apache.taverna.wsdl.parser.ArrayTypeDescriptor; +import org.apache.taverna.wsdl.parser.ComplexTypeDescriptor; +import org.apache.taverna.wsdl.parser.TypeDescriptor; +import org.apache.taverna.wsdl.parser.UnknownOperationException; +import org.apache.taverna.wsdl.parser.WSDLParser; +import org.apache.taverna.wsdl.xmlsplitter.XMLSplitterSerialisationHelper; +import org.apache.taverna.scufl2.api.activity.Activity; +import org.apache.taverna.scufl2.api.configurations.Configuration; + +/** + * Pops up a {@link JOptionPane} with the names of all the wsdl ports. The one + * that is selected is added as an output splitter to the currently open + * dataflow using the {@link AddXMLSplitterEdit} + * + * @author Ian Dunlop + * @author Stian Soiland-Reyes + */ +@SuppressWarnings("serial") +public class AddXMLOutputSplitterAction extends AbstractAddXMLSplitterAction { + + public AddXMLOutputSplitterAction(Activity activity, JComponent owner, EditManager editManager, + SelectionManager selectionManager) { + super(activity, owner, editManager, selectionManager); + putValue(NAME, "Add output XML splitter"); + + } + + @Override + public Map<String, TypeDescriptor> getTypeDescriptors() throws UnknownOperationException, IOException, ParserConfigurationException, WSDLException, SAXException, JDOMException { + Map<String, TypeDescriptor> descriptors = new HashMap<String, TypeDescriptor>(); + Configuration configuration = scufl2Tools.configurationFor(activity, selectionManager.getSelectedProfile()); + if (activity.getType().equals(WSDLServiceDescription.ACTIVITY_TYPE)) { + String wsdlLocation = configuration.getJson().get("operation").get("wsdl").textValue(); + String operationName = configuration.getJson().get("operation").get("name").textValue(); + List<TypeDescriptor> inputDescriptors = new WSDLParser(wsdlLocation) + .getOperationOutputParameters(operationName); + for (TypeDescriptor descriptor : inputDescriptors) { + descriptors.put(descriptor.getName(), descriptor); + } + } else if (activity.getType().equals(WSDLServiceDescription.OUTPUT_SPLITTER_TYPE)) { + String wrappedType = configuration.getJson().get("wrappedType").textValue(); + Element element = new SAXBuilder().build(new StringReader(wrappedType)).getRootElement(); + TypeDescriptor typeDescriptor = XMLSplitterSerialisationHelper.extensionXMLToTypeDescriptor(element); + if (typeDescriptor instanceof ComplexTypeDescriptor) { + for (TypeDescriptor desc : ((ComplexTypeDescriptor) typeDescriptor) + .getElements()) { + descriptors.put(desc.getName(), desc); + } + } + else if (typeDescriptor instanceof ArrayTypeDescriptor) { + TypeDescriptor desc = ((ArrayTypeDescriptor)typeDescriptor).getElementType(); + descriptors.put(typeDescriptor.getName(), desc); + } + } + return descriptors; + } + + @Override + protected boolean isInput() { + return false; + } + +}
