You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by re...@apache.org on 2015/03/27 17:22:21 UTC
[08/23] incubator-taverna-workbench-common-activities git commit:
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/actions/AddXMLInputSplitterAction.java
----------------------------------------------------------------------
diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/actions/AddXMLInputSplitterAction.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/actions/AddXMLInputSplitterAction.java
deleted file mode 100644
index 6faee9d..0000000
--- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/actions/AddXMLInputSplitterAction.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 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.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 net.sf.taverna.t2.activities.wsdl.servicedescriptions.WSDLServiceDescription;
-import net.sf.taverna.t2.activities.wsdl.xmlsplitter.AddXMLSplitterEdit;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import net.sf.taverna.wsdl.parser.ArrayTypeDescriptor;
-import net.sf.taverna.wsdl.parser.ComplexTypeDescriptor;
-import net.sf.taverna.wsdl.parser.TypeDescriptor;
-import net.sf.taverna.wsdl.parser.UnknownOperationException;
-import net.sf.taverna.wsdl.parser.WSDLParser;
-import net.sf.taverna.wsdl.xmlsplitter.XMLSplitterSerialisationHelper;
-
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.input.SAXBuilder;
-import org.xml.sax.SAXException;
-
-import uk.org.taverna.scufl2.api.activity.Activity;
-import uk.org.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/net/sf/taverna/t2/activities/wsdl/actions/AddXMLOutputSplitterAction.java
----------------------------------------------------------------------
diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/actions/AddXMLOutputSplitterAction.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/actions/AddXMLOutputSplitterAction.java
deleted file mode 100644
index 60cba69..0000000
--- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/actions/AddXMLOutputSplitterAction.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 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.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 net.sf.taverna.t2.activities.wsdl.servicedescriptions.WSDLServiceDescription;
-import net.sf.taverna.t2.activities.wsdl.xmlsplitter.AddXMLSplitterEdit;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import net.sf.taverna.wsdl.parser.ArrayTypeDescriptor;
-import net.sf.taverna.wsdl.parser.ComplexTypeDescriptor;
-import net.sf.taverna.wsdl.parser.TypeDescriptor;
-import net.sf.taverna.wsdl.parser.UnknownOperationException;
-import net.sf.taverna.wsdl.parser.WSDLParser;
-import net.sf.taverna.wsdl.xmlsplitter.XMLSplitterSerialisationHelper;
-import uk.org.taverna.scufl2.api.activity.Activity;
-import uk.org.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;
- }
-
-}
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/actions/AddXMLSplitterEdit.java
----------------------------------------------------------------------
diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/actions/AddXMLSplitterEdit.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/actions/AddXMLSplitterEdit.java
deleted file mode 100644
index 484feac..0000000
--- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/actions/AddXMLSplitterEdit.java
+++ /dev/null
@@ -1,315 +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.actions;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.activities.wsdl.servicedescriptions.WSDLServiceDescription;
-import net.sf.taverna.t2.activities.wsdl.xmlsplitter.XMLSplitterConfigurationBeanBuilder;
-import net.sf.taverna.t2.workbench.edits.CompoundEdit;
-import net.sf.taverna.t2.workbench.edits.Edit;
-import net.sf.taverna.t2.workbench.edits.EditException;
-import net.sf.taverna.t2.workflow.edits.AddChildEdit;
-import net.sf.taverna.t2.workflow.edits.AddDataLinkEdit;
-import net.sf.taverna.t2.workflow.edits.AddProcessorEdit;
-import net.sf.taverna.wsdl.parser.ArrayTypeDescriptor;
-import net.sf.taverna.wsdl.parser.TypeDescriptor;
-import net.sf.taverna.wsdl.xmlsplitter.XMLSplitterSerialisationHelper;
-
-import org.jdom.Element;
-
-import uk.org.taverna.scufl2.api.activity.Activity;
-import uk.org.taverna.scufl2.api.common.Scufl2Tools;
-import uk.org.taverna.scufl2.api.configurations.Configuration;
-import uk.org.taverna.scufl2.api.core.DataLink;
-import uk.org.taverna.scufl2.api.core.Processor;
-import uk.org.taverna.scufl2.api.core.Workflow;
-import uk.org.taverna.scufl2.api.iterationstrategy.CrossProduct;
-import uk.org.taverna.scufl2.api.port.InputProcessorPort;
-import uk.org.taverna.scufl2.api.port.OutputProcessorPort;
-import uk.org.taverna.scufl2.api.profiles.ProcessorBinding;
-import uk.org.taverna.scufl2.api.profiles.Profile;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-public class AddXMLSplitterEdit implements Edit<Workflow> {
-
- 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");
- public static final URI SPLITTER_CONFIG_TYPE = URI
- .create("http://ns.taverna.org.uk/2010/activity/xml-splitter#Config");
-
- private Scufl2Tools scufl2Tools = new Scufl2Tools();
-
- private final Workflow workflow;
- private final Profile profile;
- private final Activity activity;
- private TypeDescriptor typeDescriptor;
- private final String portName;
- private final boolean isInput;
-
- private CompoundEdit compoundEdit1 = null;
- private Edit<?> linkUpEdit;
- private boolean applied = false;
-
- public AddXMLSplitterEdit(Workflow workflow, Profile profile, Activity activity,
- TypeDescriptor typeDescriptor, String portName, boolean isInput) {
- this.workflow = workflow;
- this.profile = profile;
- this.activity = activity;
- this.typeDescriptor = typeDescriptor;
- this.portName = portName;
- this.isInput = isInput;
- }
-
- @Override
- public Workflow doEdit() throws EditException {
- if (applied) {
- throw new EditException("Edit has already been applied!");
- }
-
- Activity splitter = null;
- Configuration splitterConfiguration = null;
- String sourcePortName = "";
- Processor sourceProcessor = null;
-
- String sinkPortName = "";
- Processor sinkProcessor = null;
-
- Processor activityProcessor = null;
- List<ProcessorBinding> processorBindingsToActivity = scufl2Tools
- .processorBindingsToActivity(activity);
- for (ProcessorBinding processorBinding : processorBindingsToActivity) {
- activityProcessor = processorBinding.getBoundProcessor();
- break;
- }
- if (activityProcessor == null) {
- throw new EditException("Cannot find the processor that the activity belongs to");
- }
-
- String displayName = portName;
- if (portName.equals("parameters")) {
- displayName = isInput ? "input" : "output";
- }
- String processorName = activityProcessor.getName();
- String candidateName;
- if (displayName.startsWith(processorName)) {
- // No need to make GetRequest_GetRequestResponse
- candidateName = displayName;
- } else {
- // Combine with processor name
- String displayProcessorName;
- if (activity.getType().equals(INPUT_SPLITTER_TYPE)
- || activity.getType().equals(OUTPUT_SPLITTER_TYPE)) {
- // For splitters on splitters - avoid adding up blah_bluh_blih_more_stuff
- String[] processorNameSplit = processorName.replace("_input", "")
- .replace("_output", "").split("_");
- displayProcessorName = processorNameSplit[processorNameSplit.length - 1];
- } else {
- displayProcessorName = activityProcessor.getName();
- }
- candidateName = displayProcessorName + "_" + displayName;
- }
-
- Processor splitterProcessor = new Processor();
- splitterProcessor.setName(candidateName);
-
- CrossProduct crossProduct = new CrossProduct();
- crossProduct.setParent(splitterProcessor.getIterationStrategyStack());
-
- ProcessorBinding processorBinding = new ProcessorBinding();
- processorBinding.setBoundProcessor(splitterProcessor);
-
- try {
- if (activity.getType().equals(INPUT_SPLITTER_TYPE)) {
- if (!isInput) {
- throw new EditException(
- "Can only add an input splitter to another input splitter");
- }
- if (typeDescriptor instanceof ArrayTypeDescriptor
- && !((ArrayTypeDescriptor) typeDescriptor).isWrapped()) {
- typeDescriptor = ((ArrayTypeDescriptor) typeDescriptor).getElementType();
- }
-
- Element element = XMLSplitterSerialisationHelper
- .typeDescriptorToExtensionXML(typeDescriptor);
-// String wrappedType = new XMLOutputter().outputString(element);
-
- splitter = new Activity();
- splitter.setType(INPUT_SPLITTER_TYPE);
- splitterConfiguration = new Configuration();
- splitterConfiguration.setType(SPLITTER_CONFIG_TYPE);
- splitterConfiguration.setConfigures(splitter);
-// ((ObjectNode) splitterConfiguration.getJson()).put("wrappedType", wrappedType);
-
- JsonNode bean = XMLSplitterConfigurationBeanBuilder.buildBeanForInput(element);
- splitterConfiguration.setJson(bean);
-
- XMLSplitterPortBuilder.addPortsForInput(element, splitter, splitterProcessor,
- processorBinding);
-
- } else if (activity.getType().equals(OUTPUT_SPLITTER_TYPE)) {
- if (isInput) {
- throw new EditException(
- "Can only add an output splitter to another output splitter");
- }
- if (typeDescriptor instanceof ArrayTypeDescriptor
- && !((ArrayTypeDescriptor) typeDescriptor).isWrapped()) {
- typeDescriptor = ((ArrayTypeDescriptor) typeDescriptor).getElementType();
- }
-
- Element element = XMLSplitterSerialisationHelper
- .typeDescriptorToExtensionXML(typeDescriptor);
-// String wrappedType = new XMLOutputter().outputString(element);
-
- splitter = new Activity();
- splitter.setType(OUTPUT_SPLITTER_TYPE);
- splitterConfiguration = new Configuration();
- splitterConfiguration.setType(SPLITTER_CONFIG_TYPE);
- splitterConfiguration.setConfigures(splitter);
-// ((ObjectNode) splitterConfiguration.getJson()).put("wrappedType", wrappedType);
-
- JsonNode bean = XMLSplitterConfigurationBeanBuilder.buildBeanForOutput(element);
- splitterConfiguration.setJson(bean);
-
- XMLSplitterPortBuilder.addPortsForOutput(element, splitter, splitterProcessor,
- processorBinding);
-
- } else if (activity.getType().equals(WSDLServiceDescription.ACTIVITY_TYPE)) {
- if (isInput) {
- Element element = XMLSplitterSerialisationHelper
- .typeDescriptorToExtensionXML(typeDescriptor);
-// String wrappedType = new XMLOutputter().outputString(element);
-
- splitter = new Activity();
- splitter.setType(WSDLServiceDescription.INPUT_SPLITTER_TYPE);
- splitterConfiguration = new Configuration();
- splitterConfiguration.setType(SPLITTER_CONFIG_TYPE);
- splitterConfiguration.setConfigures(splitter);
-// ((ObjectNode) splitterConfiguration.getJson()).put("wrappedType", wrappedType);
-
- JsonNode bean = XMLSplitterConfigurationBeanBuilder.buildBeanForInput(element);
- splitterConfiguration.setJson(bean);
-
- XMLSplitterPortBuilder.addPortsForInput(element, splitter, splitterProcessor,
- processorBinding);
-
- } else {
- Element element = XMLSplitterSerialisationHelper
- .typeDescriptorToExtensionXML(typeDescriptor);
-// String wrappedType = new XMLOutputter().outputString(element);
-
- splitter = new Activity();
- splitter.setType(WSDLServiceDescription.OUTPUT_SPLITTER_TYPE);
- splitterConfiguration = new Configuration();
- splitterConfiguration.setType(SPLITTER_CONFIG_TYPE);
- splitterConfiguration.setConfigures(splitter);
-// ((ObjectNode) splitterConfiguration.getJson()).put("wrappedType", wrappedType);
-
- JsonNode bean = XMLSplitterConfigurationBeanBuilder.buildBeanForOutput(element);
- splitterConfiguration.setJson(bean);
-
- XMLSplitterPortBuilder.addPortsForOutput(element, splitter, splitterProcessor,
- processorBinding);
- }
- } else {
- throw new EditException(
- "The activity type is not suitable for adding xml processing processors");
- }
- } catch (Exception e) {
- throw new EditException(
- "An error occured whilst tyring to add an XMLSplitter to the activity:"
- + activity, e);
- }
-
- if (isInput) {
- sourcePortName = "output";
- sinkPortName = portName;
- sinkProcessor = activityProcessor;
- sourceProcessor = splitterProcessor;
- } else {
- sourcePortName = portName;
- sinkPortName = "input";
- sinkProcessor = splitterProcessor;
- sourceProcessor = activityProcessor;
- }
-
- processorBinding.setBoundActivity(splitter);
-
- List<Edit<?>> editList = new ArrayList<Edit<?>>();
- editList.add(new AddChildEdit<Profile>(profile, splitter));
- editList.add(new AddChildEdit<Profile>(profile, splitterConfiguration));
- editList.add(new AddChildEdit<Profile>(profile, processorBinding));
- editList.add(new AddProcessorEdit(workflow, splitterProcessor));
-
- compoundEdit1 = new CompoundEdit(editList);
- compoundEdit1.doEdit();
-
- List<Edit<?>> linkUpEditList = new ArrayList<Edit<?>>();
-
- OutputProcessorPort source = sourceProcessor.getOutputPorts().getByName(sourcePortName);
- InputProcessorPort sink = sinkProcessor.getInputPorts().getByName(sinkPortName);
-
- if (source == null)
- throw new EditException("Unable to find the source port when linking up "
- + sourcePortName + " to " + sinkPortName);
- if (sink == null)
- throw new EditException("Unable to find the sink port when linking up "
- + sourcePortName + " to " + sinkPortName);
-
- DataLink dataLink = new DataLink();
- dataLink.setReceivesFrom(source);
- dataLink.setSendsTo(sink);
- linkUpEditList.add(new AddDataLinkEdit(workflow, dataLink));
-
- linkUpEdit = new CompoundEdit(linkUpEditList);
- linkUpEdit.doEdit();
- applied = true;
- return workflow;
- }
-
- @Override
- public void undo() {
- if (!applied) {
- throw new RuntimeException("Attempt to undo edit that was never applied");
- }
- if (linkUpEdit.isApplied())
- linkUpEdit.undo();
- if (compoundEdit1.isApplied())
- compoundEdit1.undo();
- applied = false;
- }
-
- @Override
- public boolean isApplied() {
- return applied;
- }
-
- @Override
- public Object getSubject() {
- return workflow;
- }
-
-}
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/actions/WSDLActivityConfigureAction.java
----------------------------------------------------------------------
diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/actions/WSDLActivityConfigureAction.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/actions/WSDLActivityConfigureAction.java
deleted file mode 100644
index 92a8fb6..0000000
--- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/actions/WSDLActivityConfigureAction.java
+++ /dev/null
@@ -1,71 +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.actions;
-
-import java.awt.Frame;
-import java.awt.event.ActionEvent;
-
-import javax.swing.Action;
-import javax.swing.JDialog;
-
-import net.sf.taverna.t2.activities.wsdl.views.WSDLActivityConfigurationView;
-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.edits.EditManager;
-import net.sf.taverna.t2.workbench.file.FileManager;
-import net.sf.taverna.t2.workbench.ui.actions.activity.ActivityConfigurationAction;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ActivityConfigurationDialog;
-import net.sf.taverna.t2.workbench.ui.views.contextualviews.activity.ActivityConfigurationPanel;
-import uk.org.taverna.scufl2.api.activity.Activity;
-
-@SuppressWarnings("serial")
-public class WSDLActivityConfigureAction extends ActivityConfigurationAction {
-
- private final EditManager editManager;
- private final FileManager fileManager;
- private final CredentialManager credentialManager;
-
- public WSDLActivityConfigureAction(Activity activity, Frame owner, EditManager editManager,
- FileManager fileManager, ActivityIconManager activityIconManager,
- ServiceDescriptionRegistry serviceDescriptionRegistry, CredentialManager credentialManager) {
- super(activity, activityIconManager, serviceDescriptionRegistry);
- this.editManager = editManager;
- this.fileManager = fileManager;
- this.credentialManager = credentialManager;
- putValue(Action.NAME, "Configure security");
- }
-
- public void actionPerformed(ActionEvent e) {
- JDialog currentDialog = ActivityConfigurationAction.getDialog(getActivity());
- if (currentDialog != null) {
- currentDialog.toFront();
- return;
- }
- final ActivityConfigurationPanel rshellConfigView = new WSDLActivityConfigurationView(
- getActivity(), credentialManager);
- final ActivityConfigurationDialog dialog = new ActivityConfigurationDialog(getActivity(),
- rshellConfigView, editManager);
-
- ActivityConfigurationAction.setDialog(getActivity(), dialog, fileManager);
- }
-
-}
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/actions/XMLSplitterPortBuilder.java
----------------------------------------------------------------------
diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/actions/XMLSplitterPortBuilder.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/actions/XMLSplitterPortBuilder.java
deleted file mode 100644
index f41f298..0000000
--- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/actions/XMLSplitterPortBuilder.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.wsdl.actions;
-
-import net.sf.taverna.wsdl.parser.ArrayTypeDescriptor;
-import net.sf.taverna.wsdl.parser.BaseTypeDescriptor;
-import net.sf.taverna.wsdl.parser.ComplexTypeDescriptor;
-import net.sf.taverna.wsdl.parser.TypeDescriptor;
-import net.sf.taverna.wsdl.xmlsplitter.XMLSplitterSerialisationHelper;
-
-import org.jdom.Element;
-
-import uk.org.taverna.scufl2.api.activity.Activity;
-import uk.org.taverna.scufl2.api.common.NamedSet;
-import uk.org.taverna.scufl2.api.core.Processor;
-import uk.org.taverna.scufl2.api.port.InputActivityPort;
-import uk.org.taverna.scufl2.api.port.InputProcessorPort;
-import uk.org.taverna.scufl2.api.port.OutputActivityPort;
-import uk.org.taverna.scufl2.api.port.OutputProcessorPort;
-import uk.org.taverna.scufl2.api.profiles.ProcessorBinding;
-import uk.org.taverna.scufl2.api.profiles.ProcessorInputPortBinding;
-import uk.org.taverna.scufl2.api.profiles.ProcessorOutputPortBinding;
-
-/**
- * A helper class to facilitate in building XMLSplitter ports
- * from the type descriptor XML.
- *
- * @author Stuart Owen
- * @author David Withers
- */
-public class XMLSplitterPortBuilder {
-
- public static void addPortsForInput(Element element, Activity activity, Processor processor,
- ProcessorBinding binding) {
- TypeDescriptor descriptor = XMLSplitterSerialisationHelper.extensionXMLToTypeDescriptor(element);
- addOutputPort("output", 0, activity, processor, binding);
-
- if (descriptor instanceof ComplexTypeDescriptor) {
- for (TypeDescriptor typeDescriptor : ((ComplexTypeDescriptor) descriptor).getElements()) {
- addInputPort(typeDescriptor.getName(), depthForDescriptor(typeDescriptor), activity, processor,
- binding);
- }
- NamedSet<InputActivityPort> inputPorts = activity.getInputPorts();
- for (TypeDescriptor typeDescriptor : ((ComplexTypeDescriptor) descriptor).getAttributes()) {
- String name = typeDescriptor.getName();
- if (inputPorts.containsName(name)) {
- name = "1" + name;
- }
- addInputPort(name, depthForDescriptor(typeDescriptor), activity, processor, binding);
- }
- } else if (descriptor instanceof ArrayTypeDescriptor) {
- addInputPort(descriptor.getName(), 1, activity, processor, binding);
- }
- }
-
- public static void addPortsForOutput(Element element, Activity activity, Processor processor,
- ProcessorBinding binding) {
- TypeDescriptor descriptor = XMLSplitterSerialisationHelper.extensionXMLToTypeDescriptor(element);
- addInputPort("input", 0, activity, processor, binding);
-
- if (descriptor instanceof ComplexTypeDescriptor) {
- for (TypeDescriptor typeDescriptor : ((ComplexTypeDescriptor) descriptor).getElements()) {
- addOutputPort(typeDescriptor.getName(), depthForDescriptor(typeDescriptor), activity, processor,
- binding);
- }
- NamedSet<OutputActivityPort> outputPorts = activity.getOutputPorts();
- for (TypeDescriptor typeDescriptor : ((ComplexTypeDescriptor) descriptor).getAttributes()) {
- String name = typeDescriptor.getName();
- if (outputPorts.containsName(name)) {
- name = "1" + name;
- }
- addOutputPort(name, depthForDescriptor(typeDescriptor), activity, processor, binding);
- }
- } else if (descriptor instanceof ArrayTypeDescriptor) {
- addOutputPort(descriptor.getName(), 1, activity, processor, binding);
- }
- }
-
- private static int depthForDescriptor(TypeDescriptor desc) {
- if (desc instanceof ArrayTypeDescriptor
- && (!((ArrayTypeDescriptor) desc).isWrapped() || ((ArrayTypeDescriptor) desc)
- .getElementType() instanceof BaseTypeDescriptor)) {
- return 1;
- } else {
- return 0;
- }
- }
-
- private static void addOutputPort(String name, int depth, Activity activity,
- Processor processor, ProcessorBinding binding) {
- OutputActivityPort activityPort = new OutputActivityPort(activity, name);
- activityPort.setDepth(depth);
- activityPort.setGranularDepth(depth);
- OutputProcessorPort processorPort = new OutputProcessorPort(processor, name);
- processorPort.setDepth(depth);
- processorPort.setGranularDepth(depth);
- new ProcessorOutputPortBinding(binding, activityPort, processorPort);
- }
-
- private static void addInputPort(String name, int depth, Activity activity,
- Processor processor, ProcessorBinding binding) {
- InputActivityPort activityPort = new InputActivityPort(activity, name);
- activityPort.setDepth(depth);
- InputProcessorPort processorPort = new InputProcessorPort(processor, name);
- processorPort.setDepth(depth);
- new ProcessorInputPortBinding(binding, processorPort, activityPort);
- }
-
-}
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/menu/AddXMLInputSplitterForWSDLActivityMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLInputSplitterForWSDLActivityMenuAction.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLInputSplitterForWSDLActivityMenuAction.java
deleted file mode 100644
index a2935e6..0000000
--- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLInputSplitterForWSDLActivityMenuAction.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package net.sf.taverna.t2.activities.wsdl.menu;
-
-import net.sf.taverna.t2.activities.wsdl.servicedescriptions.WSDLServiceDescription;
-
-public class AddXMLInputSplitterForWSDLActivityMenuAction extends AddXMLInputSplitterMenuAction {
-
- public AddXMLInputSplitterForWSDLActivityMenuAction() {
- super(WSDLServiceDescription.ACTIVITY_TYPE);
- }
-
-}
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/menu/AddXMLInputSplitterForXMLInputSplitterMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLInputSplitterForXMLInputSplitterMenuAction.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLInputSplitterForXMLInputSplitterMenuAction.java
deleted file mode 100644
index 070c006..0000000
--- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLInputSplitterForXMLInputSplitterMenuAction.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package net.sf.taverna.t2.activities.wsdl.menu;
-
-import net.sf.taverna.t2.activities.wsdl.servicedescriptions.WSDLServiceDescription;
-
-public class AddXMLInputSplitterForXMLInputSplitterMenuAction extends AddXMLInputSplitterMenuAction {
-
- public AddXMLInputSplitterForXMLInputSplitterMenuAction() {
- super(WSDLServiceDescription.INPUT_SPLITTER_TYPE);
- }
-
-}
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/menu/AddXMLInputSplitterMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLInputSplitterMenuAction.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLInputSplitterMenuAction.java
deleted file mode 100644
index 60ef904..0000000
--- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLInputSplitterMenuAction.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.activities.wsdl.menu;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Map;
-
-import javax.swing.Action;
-import javax.wsdl.WSDLException;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.jdom.JDOMException;
-import org.xml.sax.SAXException;
-
-import net.sf.taverna.t2.activities.wsdl.InputPortTypeDescriptorActivity;
-import net.sf.taverna.t2.activities.wsdl.actions.AbstractAddXMLSplitterAction;
-import net.sf.taverna.t2.activities.wsdl.actions.AddXMLInputSplitterAction;
-import net.sf.taverna.t2.ui.menu.ContextualMenuComponent;
-import net.sf.taverna.t2.ui.menu.MenuComponent;
-import net.sf.taverna.t2.workbench.activitytools.AbstractConfigureActivityMenuAction;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import net.sf.taverna.wsdl.parser.TypeDescriptor;
-import net.sf.taverna.wsdl.parser.UnknownOperationException;
-
-/**
- * @author alanrw
- */
-public abstract class AddXMLInputSplitterMenuAction extends AbstractConfigureActivityMenuAction
- implements MenuComponent, ContextualMenuComponent {
-
- private static final String ADD_XML_INPUT_SPLITTER = "Add XML Input Splitter";
- private EditManager editManager;
- private SelectionManager selectionManager;
-
- public AddXMLInputSplitterMenuAction(URI activityType) {
- super(activityType);
- }
-
- @Override
- protected Action createAction() {
- AddXMLInputSplitterAction configAction = new AddXMLInputSplitterAction(findActivity(),
- null, editManager, selectionManager);
- Map<String, TypeDescriptor> descriptors;
- try {
- descriptors = configAction.getTypeDescriptors();
- } catch (UnknownOperationException | IOException | ParserConfigurationException
- | WSDLException | SAXException | JDOMException e) {
- return null;
- }
- if (!AbstractAddXMLSplitterAction.filterDescriptors(descriptors).isEmpty()) {
- configAction.putValue(Action.NAME, ADD_XML_INPUT_SPLITTER);
- addMenuDots(configAction);
- return configAction;
- } else {
- return null;
- }
- }
-
- public void setEditManager(EditManager editManager) {
- this.editManager = editManager;
- }
-
- public void setSelectionManager(SelectionManager selectionManager) {
- this.selectionManager = selectionManager;
- }
-
-}
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/menu/AddXMLOutputSplitterForWSDLActivityMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLOutputSplitterForWSDLActivityMenuAction.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLOutputSplitterForWSDLActivityMenuAction.java
deleted file mode 100644
index 58b3724..0000000
--- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLOutputSplitterForWSDLActivityMenuAction.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package net.sf.taverna.t2.activities.wsdl.menu;
-
-import net.sf.taverna.t2.activities.wsdl.servicedescriptions.WSDLServiceDescription;
-
-public class AddXMLOutputSplitterForWSDLActivityMenuAction extends AddXMLOutputSplitterMenuAction {
-
- public AddXMLOutputSplitterForWSDLActivityMenuAction() {
- super(WSDLServiceDescription.ACTIVITY_TYPE);
- }
-
-}
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/menu/AddXMLOutputSplitterForXMLOutputSplitterMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLOutputSplitterForXMLOutputSplitterMenuAction.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLOutputSplitterForXMLOutputSplitterMenuAction.java
deleted file mode 100644
index 129c996..0000000
--- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLOutputSplitterForXMLOutputSplitterMenuAction.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package net.sf.taverna.t2.activities.wsdl.menu;
-
-import net.sf.taverna.t2.activities.wsdl.servicedescriptions.WSDLServiceDescription;
-
-public class AddXMLOutputSplitterForXMLOutputSplitterMenuAction extends AddXMLOutputSplitterMenuAction {
-
- public AddXMLOutputSplitterForXMLOutputSplitterMenuAction() {
- super(WSDLServiceDescription.OUTPUT_SPLITTER_TYPE);
- }
-
-}
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/menu/AddXMLOutputSplitterMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLOutputSplitterMenuAction.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLOutputSplitterMenuAction.java
deleted file mode 100644
index 33541e6..0000000
--- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/AddXMLOutputSplitterMenuAction.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- *
- */
-package net.sf.taverna.t2.activities.wsdl.menu;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Map;
-
-import javax.swing.Action;
-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.AddXMLOutputSplitterAction;
-import net.sf.taverna.t2.workbench.activitytools.AbstractConfigureActivityMenuAction;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.selection.SelectionManager;
-import net.sf.taverna.wsdl.parser.TypeDescriptor;
-import net.sf.taverna.wsdl.parser.UnknownOperationException;
-
-import org.jdom.JDOMException;
-import org.xml.sax.SAXException;
-
-/**
- * @author alanrw
- */
-public abstract class AddXMLOutputSplitterMenuAction extends AbstractConfigureActivityMenuAction {
-
- private static final String ADD_XML_OUTPUT_SPLITTER = "Add XML Output Splitter";
- private EditManager editManager;
- private SelectionManager selectionManager;
-
- public AddXMLOutputSplitterMenuAction(URI activityType) {
- super(activityType);
- }
-
- @Override
- protected Action createAction() {
- AddXMLOutputSplitterAction configAction = new AddXMLOutputSplitterAction(
- findActivity(), null, editManager, selectionManager);
- Map<String, TypeDescriptor> descriptors;
- try {
- descriptors = configAction.getTypeDescriptors();
- } catch (UnknownOperationException | IOException | ParserConfigurationException
- | WSDLException | SAXException | JDOMException e) {
- return null;
- }
- if (!AbstractAddXMLSplitterAction.filterDescriptors(descriptors).isEmpty()) {
- configAction.putValue(Action.NAME, ADD_XML_OUTPUT_SPLITTER);
- addMenuDots(configAction);
- return configAction;
- } else {
- return null;
- }
- }
-
- public void setEditManager(EditManager editManager) {
- this.editManager = editManager;
- }
-
- public void setSelectionManager(SelectionManager selectionManager) {
- this.selectionManager = selectionManager;
- }
-
-}
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/menu/ConfigureWSDLMenuAction.java
----------------------------------------------------------------------
diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/ConfigureWSDLMenuAction.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/ConfigureWSDLMenuAction.java
deleted file mode 100644
index 87e7d0f..0000000
--- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/menu/ConfigureWSDLMenuAction.java
+++ /dev/null
@@ -1,78 +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.menu;
-
-import javax.swing.Action;
-
-import net.sf.taverna.t2.activities.wsdl.actions.WSDLActivityConfigureAction;
-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.ui.menu.ContextualMenuComponent;
-import net.sf.taverna.t2.ui.menu.MenuComponent;
-import net.sf.taverna.t2.workbench.activityicons.ActivityIconManager;
-import net.sf.taverna.t2.workbench.activitytools.AbstractConfigureActivityMenuAction;
-import net.sf.taverna.t2.workbench.edits.EditManager;
-import net.sf.taverna.t2.workbench.file.FileManager;
-
-public class ConfigureWSDLMenuAction extends AbstractConfigureActivityMenuAction implements
- MenuComponent, ContextualMenuComponent {
-
- private EditManager editManager;
- private ActivityIconManager activityIconManager;
- private ServiceDescriptionRegistry serviceDescriptionRegistry;
- private CredentialManager credentialManager;
- private FileManager fileManager;
-
- public ConfigureWSDLMenuAction() {
- super(WSDLServiceDescription.ACTIVITY_TYPE);
- }
-
- @Override
- protected Action createAction() {
- WSDLActivityConfigureAction configAction = new WSDLActivityConfigureAction(findActivity(),
- getParentFrame(), editManager, fileManager, activityIconManager,
- serviceDescriptionRegistry, credentialManager);
- addMenuDots(configAction);
- return configAction;
- }
-
- public void setEditManager(EditManager editManager) {
- this.editManager = editManager;
- }
-
- public void setFileManager(FileManager fileManager) {
- this.fileManager = fileManager;
- }
-
- public void setActivityIconManager(ActivityIconManager activityIconManager) {
- this.activityIconManager = activityIconManager;
- }
-
- 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/servicedescriptions/AddWSDLServiceDialog.java
----------------------------------------------------------------------
diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/AddWSDLServiceDialog.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/AddWSDLServiceDialog.java
deleted file mode 100644
index b2b31ae..0000000
--- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/AddWSDLServiceDialog.java
+++ /dev/null
@@ -1,303 +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.awt.BorderLayout;
-import java.awt.FlowLayout;
-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.KeyEvent;
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLConnection;
-
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.border.EmptyBorder;
-
-import net.sf.taverna.t2.workbench.MainWindow;
-import net.sf.taverna.t2.workbench.helper.HelpEnabledDialog;
-
-import org.apache.log4j.Logger;
-
-/**
- * Dialog that lets user specify a URL of a WSDL service they want
- * to add to the Service Panel. In the case the WSDL URL is behind
- * HTTPS or service's endpoints require HTTPS it will ask user to confirm
- * if they want to trust it.
- *
- * @author Alex Nenadic
- *
- */
-@SuppressWarnings("serial")
-public abstract class AddWSDLServiceDialog extends HelpEnabledDialog {
-
- private JTextField wsdlLocationField;
- private Logger logger = Logger.getLogger(AddWSDLServiceDialog.class);
-
- public AddWSDLServiceDialog() {
- super(MainWindow.getMainWindow(), "Add WSDL service", true, null); // create a non-modal dialog
- initComponents();
- setLocationRelativeTo(getParent());
- }
-
- private void initComponents() {
- JPanel mainPanel = new JPanel(new GridBagLayout());
- mainPanel.setBorder(new EmptyBorder(10,10,10,10));
-
- JLabel wsdlLocatitionLabel = new JLabel("WSDL location",WSDLActivityIcon.getWSDLIcon(), JLabel.LEFT);
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.weighty = 0.0;
-
- gbc.weightx = 0.0;
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.fill = GridBagConstraints.NONE;
- gbc.anchor = GridBagConstraints.WEST;
- gbc.insets = new Insets(5, 10, 0, 0);
- mainPanel.add(wsdlLocatitionLabel, gbc);
-
- wsdlLocationField = new JTextField("http://somehost/service?wsdl");
- gbc.weightx = 1.0;
- gbc.gridx = 1;
- gbc.gridy = 0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.anchor = GridBagConstraints.WEST;
- gbc.insets = new Insets(5, 10, 0, 5);
- mainPanel.add(wsdlLocationField, gbc);
-
- final JButton addServiceButton = new JButton("Add");
- addServiceButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent evt)
- {
- addPressed();
- }
- });
-
- // When user presses "Return" key fire the action on the "Add" button
- addServiceButton.addKeyListener(new java.awt.event.KeyAdapter() {
- public void keyPressed(java.awt.event.KeyEvent evt) {
- if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
- addPressed();
- }
- }
- });
- getRootPane().setDefaultButton(addServiceButton);
-
- JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
- buttonsPanel.add(addServiceButton);
-
- getContentPane().setLayout(new BorderLayout());
- getContentPane().add(mainPanel, BorderLayout.CENTER);
- getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
-
- setSize(getPreferredSize());
- pack();
- }
-
- /**
- * 'Add service' button pressed or otherwise activated.
- */
- private void addPressed()
- {
- final String wsdlURLString = wsdlLocationField.getText().trim();
- new Thread("Adding WSDL " + wsdlURLString) {
- public void run() {
- // Only add the service provider for this service if service URL
- // starts with 'http'
- // or if it starts with 'https' and user explicitly said they
- // wanted to trust this service.
- /*
- * if (shouldTrust(wsdlURLString)){ addRegistry(wsdlURLString);
- * }
- */
- try {
- URL url = new URL(wsdlURLString);
- URLConnection connection = url.openConnection();
- try {
- // If the url starts with 'https' - security hook for
- // https connection's trust manager
- // will be engaged and user will be asked automatically
- // if they want
- // to trust the connection (if it is not already
- // trusted). If the urls starts with 'http' -
- // this will not have any effect apart from checking if
- // we can open a connection.
- connection.connect(); // if this does not fail - add the
- // WSDL
- // service provider for this service to
- // the registry
- } finally {
- try {
- connection.getInputStream().close();
- } catch (IOException ex) {
- }
- }
- addRegistry(wsdlURLString);
- } catch (Exception ex) { // anything failed
- JOptionPane.showMessageDialog(null,
- "Could not read the WSDL definition from "
- + wsdlURLString + ":\n" + ex,
- "Could not add WSDL service",
- JOptionPane.ERROR_MESSAGE);
-
- logger.error(
- "Failed to add WSDL service provider for service: "
- + wsdlURLString, ex);
-
- }
- };
- }.start();
- closeDialog();
- }
-
- /**
- * If WSDL service's URL starts with 'https' - asks user
- * whether to trust it or not. If it starts with 'http' -
- * does not ask anything as the service is implicitly trusted (weird but true).
- */
- protected abstract void addRegistry(String wsdl);
-
- /**
- * Checks if a service is trusted and if not - asks user if they want to trust it.
- */
-// public boolean shouldTrust(String wsdlURLString){
-// try {
-// URI wsdlURI = new URI(wsdlURLString);
-// URL wsdlURL = wsdlURI.toURL();
-// String protocol = wsdlURL.getProtocol();
-// if (protocol.toLowerCase().startsWith("https")){
-// logger.info("Checking if service " + wsdlURLString + " is already trusted.");
-// // Check if opening an HTTPS connection will cause a SSLHandshakeException.
-// // This is most probably due to the fact that we do not have this service's
-// // certificate in Credential Manager's truststore
-// try {
-// HttpsURLConnection httpsConnection;
-// httpsConnection = (HttpsURLConnection) wsdlURL.openConnection();
-// httpsConnection.connect();
-// logger.info("HTTPS works out of the box for service " + wsdlURLString);
-// return true; // Opening HTTPS connection worked - so we trust this service already
-// }
-// catch (SSLException sslex) { // most probably due to the fact that service is not trusted, i.e. its certificate is not in Credential Manager's Truststore
-// logger.info("Service " + wsdlURLString + " is not trusted out of the box. Trying to fetch its certificate.");
-// logger.info("The SSLException was caused by: " + sslex.getCause());
-// // Handshake most probably failed as we do not already trust this service -
-// // fetch its certificate and ask user if they want to add this service as trusted
-// try {
-//
-// // This controls SSL socket creation for HTTPS connections
-// // per thread so the damage of switching off certificates
-// // verification is limited
-// ThreadLocalSSLSocketFactory.install();
-// // switch certificate checking off for a moment so we can fetch
-// // service's certificate
-// ThreadLocalSSLSocketFactory.startTrustingEverything();
-//
-// HttpsURLConnection httpsConnection;
-// httpsConnection = (HttpsURLConnection) wsdlURL
-// .openConnection();
-// httpsConnection.connect();
-// // Stop being overly trusting
-// ThreadLocalSSLSocketFactory.stopTrustingEverything();
-// Certificate[] certificates = httpsConnection
-// .getServerCertificates();
-// logger.info("Need to ask user if they want to trust service " + wsdlURLString);
-// // Ask user if they want to trust this service
-// ConfirmTrustedCertificateDialog confirmCertTrustDialog = new ConfirmTrustedCertificateDialog(
-// this, "Untrusted HTTPS connection", true,
-// (X509Certificate) certificates[0]);
-// confirmCertTrustDialog.setLocationRelativeTo(null);
-// confirmCertTrustDialog.setVisible(true);
-// boolean shouldTrust = confirmCertTrustDialog
-// .shouldTrust();
-// if (shouldTrust) {
-// try {
-// CredentialManager credManager = CredentialManager
-// .getInstance();
-// credManager
-// .saveTrustedCertificate((X509Certificate) certificates[0]);
-// return true;
-// } catch (CMException cme) {
-// logger
-// .error(
-// "Failed to add WSDL service provider for service: "
-// + wsdlURLString
-// + " . Credential Manager failed to "
-// + "save trusted certificate.",
-// cme);
-// return false;
-// }
-// } else {
-// // Do not even add a WSDL service provider for this
-// // service and tell user the service will not be
-// // added to Service Panel
-// JOptionPane
-// .showMessageDialog(
-// this,
-// "As you refused to trust it, the service will not be added to Service Panel.",
-// "Add WSDL service",
-// JOptionPane.INFORMATION_MESSAGE);
-// return false;
-// }
-// } catch (Exception e1) {
-// logger
-// .error(
-// "Failed to add WSDL service provider for service: "
-// + wsdlURLString
-// + ". 'Trust everyone' HTTPS connection failed.",
-// e1);
-// return false;
-// } finally {// switch it off here as well if some unexpected exception occurred
-// ThreadLocalSSLSocketFactory.stopTrustingEverything();
-// }
-//
-// } catch (Exception e2) {
-// logger.error("Failed to add WSDL service provider for service: "+ wsdlURLString+". Connecting to service failed.", e2);
-// return false;
-// }
-// }
-// else{ // protocol starts with 'http'
-// return true;
-// }
-// } catch (MalformedURLException e3) {
-// logger.error("Failed to add WSDL service provider: URL "+ wsdlURLString+" was malformed.", e3);
-// return false;
-// } catch (URISyntaxException e4) {
-// logger.error("Failed to add WSDL service provider: URI "+ wsdlURLString+" could not be parsed.", e4);
-// return false;
-// }
-// }
-
- /**
- * Closes the dialog.
- */
- private void closeDialog() {
- setVisible(false);
- dispose();
- }
-}
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/ConfirmTrustedCertificateDialog.java
----------------------------------------------------------------------
diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/ConfirmTrustedCertificateDialog.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/ConfirmTrustedCertificateDialog.java
deleted file mode 100644
index bc58aad..0000000
--- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/ConfirmTrustedCertificateDialog.java
+++ /dev/null
@@ -1,586 +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.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Dialog;
-import java.awt.FlowLayout;
-import java.awt.Frame;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.Font;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.math.BigInteger;
-import java.util.HashMap;
-
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.border.CompoundBorder;
-import javax.swing.border.EmptyBorder;
-import javax.swing.border.EtchedBorder;
-import javax.swing.JSeparator;
-
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.X509Certificate;
-import javax.security.auth.x500.X500Principal;
-
-import net.sf.taverna.t2.lang.ui.DialogTextArea;
-import net.sf.taverna.t2.security.credentialmanager.CMException;
-import net.sf.taverna.t2.security.credentialmanager.CMUtils;
-import net.sf.taverna.t2.workbench.helper.HelpEnabledDialog;
-
-import org.apache.log4j.Logger;
-import org.bouncycastle.asn1.ASN1OctetString;
-import org.bouncycastle.asn1.DERBitString;
-import org.bouncycastle.asn1.DEROctetString;
-import org.bouncycastle.asn1.misc.NetscapeCertType;
-
-/**
- * Displays the details of a X.509 certificate and asks user if they want to
- * trust it.
- *
- * @author Alex Nenadic
- */
-@SuppressWarnings("serial")
-public class ConfirmTrustedCertificateDialog extends HelpEnabledDialog {
-
- private static Logger logger = Logger.getLogger(ConfirmTrustedCertificateDialog.class);
-
- // Stores certificate to display
- private X509Certificate cert;
-
- // Stores user's decision as whether to trust this service's certificaet or not.
- private boolean shouldTrust;
-
- /**
- * Creates new ConfirmTrustedCertificateDialog where parent is a Frame.
- */
- public ConfirmTrustedCertificateDialog(Frame parent, String title,
- boolean modal, X509Certificate crt)
- throws CMException {
- super(parent, title, modal, null);
- this.cert = crt;
- initComponents();
- }
-
- /**
- * Creates new ConfirmTrustedCertificateDialog where parent is a Dialog.
- */
- public ConfirmTrustedCertificateDialog(Dialog parent, String title,
- boolean modal, X509Certificate crt)
- throws CMException {
- super(parent, title, modal, null);
- this.cert = crt;
- initComponents();
- }
-
- /**
- * Initialise the dialog's GUI components.
- */
- private void initComponents(){
-
- // title panel
- JPanel titlePanel = new JPanel(new BorderLayout());
- titlePanel.setBackground(Color.WHITE);
- JLabel titleLabel = new JLabel("View service's certificate");
- titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 13.5f));
- titleLabel.setBorder(new EmptyBorder(10, 10, 0, 10));
- DialogTextArea titleMessage = new DialogTextArea("This service requires HTTPS connection and has identified itself with the certificate below.\n" +
- "Do you want to trust this service? (Refusing to trust means you will not be able to invoke it from a workflow.)");
- 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);
-
- // Certificate details:
-
- // Grid Bag Constraints templates for labels (column 1) and
- // values (column 2) of certificate details
- GridBagConstraints gbcLabel = new GridBagConstraints();
- gbcLabel.gridx = 0;
- gbcLabel.ipadx = 20;
- gbcLabel.gridwidth = 1;
- gbcLabel.gridheight = 1;
- gbcLabel.insets = new Insets(2, 15, 2, 2);
- gbcLabel.anchor = GridBagConstraints.LINE_START;
-
- GridBagConstraints gbcValue = new GridBagConstraints();
- gbcValue.gridx = 1;
- gbcValue.gridwidth = 1;
- gbcValue.gridheight = 1;
- gbcValue.insets = new Insets(2, 5, 2, 2);
- gbcValue.anchor = GridBagConstraints.LINE_START;
-
- // Netscape Certificate Type non-critical extension (if any)
- // defines the intended uses of the certificate - to make it look like
- // firefox's view certificate dialog
- byte[] intendedUses = cert.getExtensionValue("2.16.840.1.113730.1.1"); // Netscape Certificate Type OID
- JLabel jlIntendedUses = null;
- JTextField jtfIntendedUsesValue = null;
- JPanel jpUses = null;
- GridBagConstraints gbc_jpUses = null;
- if (intendedUses != null) {
- jlIntendedUses = new JLabel(
- "This certificate has been approved for the following uses:");
- jlIntendedUses.setFont(new Font(null, Font.BOLD, 11));
- jlIntendedUses.setBorder(new EmptyBorder(5, 5, 5, 5));
-
- jtfIntendedUsesValue = new JTextField(45);
- jtfIntendedUsesValue.setText(getIntendedUses(intendedUses));
- jtfIntendedUsesValue.setEditable(false);
- jtfIntendedUsesValue.setFont(new Font(null, Font.PLAIN, 11));
-
- jpUses = new JPanel(new BorderLayout());
- jpUses.add(jlIntendedUses, BorderLayout.NORTH);
- jpUses.add(jtfIntendedUsesValue, BorderLayout.CENTER);
- JSeparator jsp = new JSeparator(JSeparator.HORIZONTAL);
- jpUses.add(jsp, BorderLayout.SOUTH);
-
- gbc_jpUses = (GridBagConstraints) gbcLabel.clone();
- gbc_jpUses.gridy = 0;
- gbc_jpUses.gridwidth = 2; // takes two columns
- gbc_jpUses.insets = new Insets(5, 5, 5, 5);// has slightly bigger insets
- }
-
- // Issued To
- JLabel jlIssuedTo = new JLabel("Issued To");
- jlIssuedTo.setFont(new Font(null, Font.BOLD, 11));
- GridBagConstraints gbc_jlIssuedTo = (GridBagConstraints) gbcLabel
- .clone();
- gbc_jlIssuedTo.gridy = 1;
- gbc_jlIssuedTo.gridwidth = 2; // takes two columns
- gbc_jlIssuedTo.insets = new Insets(5, 5, 5, 5);// has slightly bigger insets
- // Distinguished Name (DN)
- String sDN = cert.getSubjectX500Principal().getName(
- X500Principal.RFC2253);
- CMUtils util = new CMUtils();
- util.parseDN(sDN);
- // Extract the CN, O, OU and EMAILADDRESS fields
- String sCN = util.getCN();
- String sOrg = util.getO();
- String sOU = util.getOU();
- // String sEMAILADDRESS = CMX509Util.getEmilAddress();
- // Common Name (CN)
- JLabel jlCN = new JLabel("Common Name (CN)");
- jlCN.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlCN = (GridBagConstraints) gbcLabel.clone();
- gbc_jlCN.gridy = 2;
- JLabel jlCNValue = new JLabel(sCN);
- jlCNValue.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlCNValue = (GridBagConstraints) gbcValue
- .clone();
- gbc_jlCNValue.gridy = 2;
- // Organisation (O)
- JLabel jlOrg = new JLabel("Organisation (O)");
- jlOrg.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlOrg = (GridBagConstraints) gbcLabel.clone();
- gbc_jlOrg.gridy = 3;
- JLabel jlOrgValue = new JLabel(sOrg);
- jlOrgValue.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlOrgValue = (GridBagConstraints) gbcValue
- .clone();
- gbc_jlOrgValue.gridy = 3;
- // Organisation Unit (OU)
- JLabel jlOU = new JLabel("Organisation Unit (OU)");
- jlOU.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlOU = (GridBagConstraints) gbcLabel.clone();
- gbc_jlOU.gridy = 4;
- JLabel jlOUValue = new JLabel(sOU);
- jlOUValue.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlOUValue = (GridBagConstraints) gbcValue
- .clone();
- gbc_jlOUValue.gridy = 4;
- // E-mail Address
- // JLabel jlEmail = new JLabel("E-mail Address");
- // jlEmail.setFont(new Font(null, Font.PLAIN, 11));
- // GridBagConstraints gbc_jlEmail = (GridBagConstraints)
- // gbcLabel.clone();
- // gbc_jlEmail.gridy = 5;
- // JLabel jlEmailValue = new JLabel(sEMAILADDRESS);
- // jlEmailValue.setFont(new Font(null, Font.PLAIN, 11));
- // GridBagConstraints gbc_jlEmailValue = (GridBagConstraints)
- // gbcValue.clone();
- // gbc_jlEmailValue.gridy = 5;
- // Serial Number
- JLabel jlSN = new JLabel("Serial Number");
- jlSN.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlSN = (GridBagConstraints) gbcLabel.clone();
- gbc_jlSN.gridy = 6;
- JLabel jlSNValue = new JLabel();
- // Get the hexadecimal serial number
- StringBuffer strBuff = new StringBuffer(new BigInteger(1, cert
- .getSerialNumber().toByteArray()).toString(16).toUpperCase());
- // Place colons at every two hexadecimal characters
- if (strBuff.length() > 2) {
- for (int iCnt = 2; iCnt < strBuff.length(); iCnt += 3) {
- strBuff.insert(iCnt, ':');
- }
- }
- jlSNValue.setText(strBuff.toString());
- jlSNValue.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlSNValue = (GridBagConstraints) gbcValue
- .clone();
- gbc_jlSNValue.gridy = 6;
- // Version
- JLabel jlVersion = new JLabel("Version");
- jlVersion.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlVersion = (GridBagConstraints) gbcLabel
- .clone();
- gbc_jlVersion.gridy = 7;
- JLabel jlVersionValue = new JLabel(Integer.toString(cert.getVersion()));
- jlVersionValue.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlVersionValue = (GridBagConstraints) gbcValue
- .clone();
- gbc_jlVersionValue.gridy = 7;
-
- // Issued By
- JLabel jlIssuedBy = new JLabel("Issued By");
- jlIssuedBy.setFont(new Font(null, Font.BOLD, 11));
- GridBagConstraints gbc_jlIssuedBy = (GridBagConstraints) gbcLabel
- .clone();
- gbc_jlIssuedBy.gridy = 8;
- gbc_jlIssuedBy.gridwidth = 2; // takes two columns
- gbc_jlIssuedBy.insets = new Insets(5, 5, 5, 5);// has slightly bigger
- // insets
- // Distinguished Name (DN)
- String iDN = cert.getIssuerX500Principal().getName(
- X500Principal.RFC2253);
- util.parseDN(iDN);
- // Extract the CN, O and OU fields
- String iCN = util.getCN();
- String iOrg = util.getO();
- String iOU = util.getOU();
- // Common Name (CN)
- JLabel jlICN = new JLabel("Common Name (CN)");
- jlICN.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlICN = (GridBagConstraints) gbcLabel.clone();
- gbc_jlICN.gridy = 9;
- JLabel jlICNValue = new JLabel(iCN);
- jlICNValue.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlICNValue = (GridBagConstraints) gbcValue
- .clone();
- gbc_jlICNValue.gridy = 9;
- // Organisation (O)
- JLabel jlIOrg = new JLabel("Organisation (O)");
- jlIOrg.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlIOrg = (GridBagConstraints) gbcLabel.clone();
- gbc_jlIOrg.gridy = 10;
- JLabel jlIOrgValue = new JLabel(iOrg);
- jlIOrgValue.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlIOrgValue = (GridBagConstraints) gbcValue
- .clone();
- gbc_jlIOrgValue.gridy = 10;
- // Organisation Unit (OU)
- JLabel jlIOU = new JLabel("Organisation Unit (OU)");
- jlIOU.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlIOU = (GridBagConstraints) gbcLabel.clone();
- gbc_jlIOU.gridy = 11;
- JLabel jlIOUValue = new JLabel(iOU);
- jlIOUValue.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlIOUValue = (GridBagConstraints) gbcValue
- .clone();
- gbc_jlIOUValue.gridy = 11;
- // Validity
- JLabel jlValidity = new JLabel("Validity");
- jlValidity.setFont(new Font(null, Font.BOLD, 11));
- GridBagConstraints gbc_jlValidity = (GridBagConstraints) gbcLabel
- .clone();
- gbc_jlValidity.gridy = 12;
- gbc_jlValidity.gridwidth = 2; // takes two columns
- gbc_jlValidity.insets = new Insets(5, 5, 5, 5);// has slightly bigger
- // insets
- // Issued On
- JLabel jlIssuedOn = new JLabel("Issued On");
- jlIssuedOn.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlIssuedOn = (GridBagConstraints) gbcLabel
- .clone();
- gbc_jlIssuedOn.gridy = 13;
- JLabel jlIssuedOnValue = new JLabel(cert.getNotBefore().toString());
- jlIssuedOnValue.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlIssuedOnValue = (GridBagConstraints) gbcValue
- .clone();
- gbc_jlIssuedOnValue.gridy = 13;
- // Expires On
- JLabel jlExpiresOn = new JLabel("Expires On");
- jlExpiresOn.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlExpiresOn = (GridBagConstraints) gbcLabel
- .clone();
- gbc_jlExpiresOn.gridy = 14;
- JLabel jlExpiresOnValue = new JLabel(cert.getNotAfter().toString());
- jlExpiresOnValue.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlExpiresOnValue = (GridBagConstraints) gbcValue
- .clone();
- gbc_jlExpiresOnValue.gridy = 14;
-
- // Fingerprints
- byte[] bCert = new byte[0];
- try {
- bCert = cert.getEncoded();
- } catch (CertificateEncodingException ex) {
- logger.error("Could not get the encoded form of the certificate.", ex);
- }
- JLabel jlFingerprints = new JLabel("Fingerprints");
- jlFingerprints.setFont(new Font(null, Font.BOLD, 11));
- GridBagConstraints gbc_jlFingerprints = (GridBagConstraints) gbcLabel
- .clone();
- gbc_jlFingerprints.gridy = 15;
- gbc_jlFingerprints.gridwidth = 2; // takes two columns
- gbc_jlFingerprints.insets = new Insets(5, 5, 5, 5);// has slightly
- // bigger insets
- // SHA-1 Fingerprint
- JLabel jlSHA1Fingerprint = new JLabel("SHA1 Fingerprint");
- jlSHA1Fingerprint.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlSHA1Fingerprint = (GridBagConstraints) gbcLabel
- .clone();
- gbc_jlSHA1Fingerprint.gridy = 16;
- JLabel jlSHA1FingerprintValue = new JLabel(getMessageDigest(bCert,
- "SHA1"));
- jlSHA1FingerprintValue.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlSHA1FingerprintValue = (GridBagConstraints) gbcValue
- .clone();
- gbc_jlSHA1FingerprintValue.gridy = 16;
- // MD5 Fingerprint
- JLabel jlMD5Fingerprint = new JLabel("MD5 Fingerprint");
- jlMD5Fingerprint.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlMD5Fingerprint = (GridBagConstraints) gbcLabel
- .clone();
- gbc_jlMD5Fingerprint.gridy = 17;
- JLabel jlMD5FingerprintValue = new JLabel(
- getMessageDigest(bCert, "MD5"));
- jlMD5FingerprintValue.setFont(new Font(null, Font.PLAIN, 11));
- GridBagConstraints gbc_jlMD5FingerprintValue = (GridBagConstraints) gbcValue
- .clone();
- gbc_jlMD5FingerprintValue.gridy = 17;
-
- // Empty label to add a bit space at the bottom of the panel
- // to make it look like firefox's view certificate dialog
- JLabel jlEmpty = new JLabel("");
- GridBagConstraints gbc_jlEmpty = (GridBagConstraints) gbcLabel.clone();
- gbc_jlEmpty.gridy = 18;
- gbc_jlEmpty.gridwidth = 2; // takes two columns
- gbc_jlEmpty.ipady = 40;
-
- JPanel jpCertificate = new JPanel(new GridBagLayout());
- jpCertificate.setBorder(new CompoundBorder(new EmptyBorder(15, 15, 15,
- 15), new EtchedBorder()));
-
- if (intendedUses != null) {
- jpCertificate.add(jpUses, gbc_jpUses);
- }
- jpCertificate.add(jlIssuedTo, gbc_jlIssuedTo); // Issued To
- jpCertificate.add(jlCN, gbc_jlCN);
- jpCertificate.add(jlCNValue, gbc_jlCNValue);
- jpCertificate.add(jlOrg, gbc_jlOrg);
- jpCertificate.add(jlOrgValue, gbc_jlOrgValue);
- jpCertificate.add(jlOU, gbc_jlOU);
- jpCertificate.add(jlOUValue, gbc_jlOUValue);
- // jpCertificate.add(jlEmail, gbc_jlEmail);
- // jpCertificate.add(jlEmailValue, gbc_jlEmailValue);
- jpCertificate.add(jlSN, gbc_jlSN);
- jpCertificate.add(jlSNValue, gbc_jlSNValue);
- jpCertificate.add(jlVersion, gbc_jlVersion);
- jpCertificate.add(jlVersionValue, gbc_jlVersionValue);
- jpCertificate.add(jlIssuedBy, gbc_jlIssuedBy); // Issued By
- jpCertificate.add(jlICN, gbc_jlICN);
- jpCertificate.add(jlICNValue, gbc_jlICNValue);
- jpCertificate.add(jlIOrg, gbc_jlIOrg);
- jpCertificate.add(jlIOrgValue, gbc_jlIOrgValue);
- jpCertificate.add(jlIOU, gbc_jlIOU);
- jpCertificate.add(jlIOUValue, gbc_jlIOUValue);
- jpCertificate.add(jlValidity, gbc_jlValidity); // Validity
- jpCertificate.add(jlIssuedOn, gbc_jlIssuedOn);
- jpCertificate.add(jlIssuedOnValue, gbc_jlIssuedOnValue);
- jpCertificate.add(jlExpiresOn, gbc_jlExpiresOn);
- jpCertificate.add(jlExpiresOnValue, gbc_jlExpiresOnValue);
- jpCertificate.add(jlFingerprints, gbc_jlFingerprints); // Fingerprints
- jpCertificate.add(jlSHA1Fingerprint, gbc_jlSHA1Fingerprint);
- jpCertificate.add(jlSHA1FingerprintValue, gbc_jlSHA1FingerprintValue);
- jpCertificate.add(jlMD5Fingerprint, gbc_jlMD5Fingerprint);
- jpCertificate.add(jlMD5FingerprintValue, gbc_jlMD5FingerprintValue);
- jpCertificate.add(jlEmpty, gbc_jlEmpty); // Empty label to get some vertical space on the frame
-
- // OK button
- JPanel jpButtons = new JPanel(new FlowLayout(FlowLayout.CENTER));
-
- final JButton jbTrust = new JButton("Trust");
- jbTrust.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- trustPressed();
- }
- });
- final JButton jbDontTrust = new JButton("Do not trust");
- jbDontTrust.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- dontTrustPressed();
- }
- });
-
- jpButtons.add(jbTrust);
- jpButtons.add(jbDontTrust);
-
- // Put it all together
- getContentPane().add(titlePanel, BorderLayout.NORTH);
- getContentPane().add(jpCertificate, BorderLayout.CENTER);
- getContentPane().add(jpButtons, BorderLayout.SOUTH);
-
- // Resizing wreaks havoc
- setResizable(false);
-
- addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent evt) {
- closeDialog();
- }
- });
-
- getRootPane().setDefaultButton(jbTrust);
-
- pack();
- }
-
- /**
- * Get the digest of a message as a formatted String.
- *
- * @param bMessage
- * The message to digest
- * @param digestType
- * The message digest algorithm
- * @return The message digest
- */
- public static String getMessageDigest(byte[] bMessage, String digestType) {
- // Create message digest object using the supplied algorithm
- MessageDigest messageDigest;
- try {
- messageDigest = MessageDigest.getInstance(digestType);
- } catch (NoSuchAlgorithmException ex) {
- logger.error("Failed to create message digest.", ex);
- return "";
- }
-
- // Create raw message digest
- byte[] bFingerPrint = messageDigest.digest(bMessage);
-
- // Place the raw message digest into a StringBuffer as a Hex number
- StringBuffer strBuff = new StringBuffer(new BigInteger(1, bFingerPrint)
- .toString(16).toUpperCase());
-
- // Odd number of characters so add in a padding "0"
- if ((strBuff.length() % 2) != 0) {
- strBuff.insert(0, '0');
- }
-
- // Place colons at every two hex characters
- if (strBuff.length() > 2) {
- for (int iCnt = 2; iCnt < strBuff.length(); iCnt += 3) {
- strBuff.insert(iCnt, ':');
- }
- }
-
- // Return the formatted message digest
- return strBuff.toString();
- }
-
- /**
- * Gets the intended certificate uses, i.e. Netscape Certificate Type
- * extension (2.16.840.1.113730.1.1) value as a string
- *
- * @param value
- * Extension value as a DER-encoded OCTET string
- * @return Extension value as a string
- */
- private String getIntendedUses(byte[] value) {
-
- // Netscape Certificate Types (2.16.840.1.113730.1.1)
- int[] INTENDED_USES = new int[] { NetscapeCertType.sslClient,
- NetscapeCertType.sslServer, NetscapeCertType.smime,
- NetscapeCertType.objectSigning, NetscapeCertType.reserved,
- NetscapeCertType.sslCA, NetscapeCertType.smimeCA,
- NetscapeCertType.objectSigningCA, };
-
- // Netscape Certificate Type strings (2.16.840.1.113730.1.1)
- HashMap<String, String> INTENDED_USES_STRINGS = new HashMap<String, String>();
- INTENDED_USES_STRINGS.put("128", "SSL Client");
- INTENDED_USES_STRINGS.put("64", "SSL Server");
- INTENDED_USES_STRINGS.put("32", "S/MIME");
- INTENDED_USES_STRINGS.put("16", "Object Signing");
- INTENDED_USES_STRINGS.put("8", "Reserved");
- INTENDED_USES_STRINGS.put("4", "SSL CA");
- INTENDED_USES_STRINGS.put("2", "S/MIME CA");
- INTENDED_USES_STRINGS.put("1", "Object Signing CA");
-
- // Get octet string from extension value
- ASN1OctetString fromByteArray = new DEROctetString(value);
- byte[] octets = fromByteArray.getOctets();
- DERBitString fromByteArray2 = new DERBitString(octets);
- int val = new NetscapeCertType(fromByteArray2).intValue();
- StringBuffer strBuff = new StringBuffer();
- for (int i = 0, len = INTENDED_USES.length; i < len; i++) {
- int use = INTENDED_USES[i];
- if ((val & use) == use) {
- strBuff.append(INTENDED_USES_STRINGS.get(String.valueOf(use))
- + ", \n");
- }
- }
- // remove the last ", \n" from the end of the buffer
- String str = strBuff.toString();
- str = str.substring(0, str.length() - 3);
- return str;
- }
-
- /**
- * 'Trust' button pressed.
- */
- private void trustPressed() {
- shouldTrust = true;
- closeDialog();
- }
-
- /**
- * 'Do not trust' button pressed.
- */
- private void dontTrustPressed() {
- shouldTrust = false;
- closeDialog();
- }
-
- /**
- * Closes the dialog.
- */
- public void closeDialog() {
- setVisible(false);
- dispose();
- }
-
- public boolean shouldTrust() {
- return shouldTrust;
- }
-}
\ 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/servicedescriptions/WSDLActivityIcon.java
----------------------------------------------------------------------
diff --git a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/WSDLActivityIcon.java b/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/WSDLActivityIcon.java
deleted file mode 100644
index 79f8ccd..0000000
--- a/taverna-wsdl-activity-ui/src/main/java/net/sf/taverna/t2/activities/wsdl/servicedescriptions/WSDLActivityIcon.java
+++ /dev/null
@@ -1,60 +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
- * @author alanrw
- *
- */
-public class WSDLActivityIcon implements ActivityIconSPI {
-
- private static Icon icon;
-
- public int canProvideIconScore(URI activityType) {
- if (activityType.equals(WSDLServiceDescription.ACTIVITY_TYPE))
- return DEFAULT_ICON + 1;
- else
- return NO_ICON;
- }
-
- public Icon getIcon(URI activityType) {
- return getWSDLIcon();
- }
-
- public static Icon getWSDLIcon() {
- if (icon == null) {
- icon = new ImageIcon(WSDLActivityIcon.class.getResource("/wsdl.png"));
- }
- return icon;
- }
-}
-
-
-