http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/health_check/BioCatalogueWSDLActivityHealthCheckVisitExplainer.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/health_check/BioCatalogueWSDLActivityHealthCheckVisitExplainer.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/health_check/BioCatalogueWSDLActivityHealthCheckVisitExplainer.java deleted file mode 100644 index ed6afe6..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/health_check/BioCatalogueWSDLActivityHealthCheckVisitExplainer.java +++ /dev/null @@ -1,127 +0,0 @@ -package org.apache.taverna.ui.perspectives.biocatalogue.integration.health_check; -/* - * 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. - */ - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JPanel; - -import org.apache.taverna.biocatalogue.model.SoapOperationIdentity; -import org.apache.taverna.lang.ui.ReadOnlyTextArea; -import org.apache.taverna.visit.VisitKind; -import org.apache.taverna.visit.VisitReport; -import org.apache.taverna.workbench.report.explainer.VisitExplainer; - -// import status constants -import static org.apache.taverna.ui.perspectives.biocatalogue.integration.health_check.BioCatalogueWSDLActivityHealthCheck.*; - -/** - * - * @author Sergejs Aleksejevs - */ -public class BioCatalogueWSDLActivityHealthCheckVisitExplainer implements VisitExplainer -{ - - public boolean canExplain(VisitKind vk, int resultId) { - return (vk instanceof BioCatalogueWSDLActivityHealthCheck); - } - - - /** - * This class only handles {@link VisitReport} instances that are of - * {@link BioCatalogueWSDLActivityHealthCheck} kind. Therefore, decisions on - * the explanations / solutions are made solely by visit result IDs. - */ - public JComponent getExplanation(final VisitReport vr) - { - int resultId = vr.getResultId(); - String explanation = null; - - switch (resultId) { - case MESSAGE_IN_VISIT_REPORT: - explanation = (String) vr.getProperty(EXPLANATION_MSG_PROPERTY); break; - - default: - explanation = "Unknown issue - no expalanation available"; break; - } - - - JButton bRunBioCatalogueHealthCheck = new JButton("View monitoring status details"); - bRunBioCatalogueHealthCheck.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - SoapOperationIdentity soapOpIdentity = - new SoapOperationIdentity((String)vr.getProperty(BioCatalogueWSDLActivityHealthCheck.WSDL_LOCATION_PROPERTY), - (String)vr.getProperty(BioCatalogueWSDLActivityHealthCheck.OPERATION_NAME_PROPERTY), null); - - ServiceHealthChecker.checkWSDLProcessor(soapOpIdentity); - } - }); - JPanel jpButton = new JPanel(); - jpButton.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); - jpButton.add(bRunBioCatalogueHealthCheck); - jpButton.setOpaque(false); - - JPanel jpExplanation = new JPanel(new BorderLayout()); - jpExplanation.add(new ReadOnlyTextArea(explanation), BorderLayout.CENTER); - jpExplanation.add(jpButton, BorderLayout.SOUTH); - - return (jpExplanation); - } - - - - /** - * This class only handles {@link VisitReport} instances that are of - * {@link BioCatalogueWSDLActivityHealthCheck} kind. Therefore, decisions on - * the explanations / solutions are made solely by visit result IDs. - */ - public JComponent getSolution(VisitReport vr) - { - String explanation = null; - - // instead of switching between possible health check resultIDs, - // simply choose from possible statuses: for all failures there's - // nothing specific that can be done, so no need to differentiate - // displayed messages - switch (vr.getStatus()) { - case OK: - explanation = "This WSDL service works fine - no change necessary"; break; - - case WARNING: - case SEVERE: - explanation = "This remote WSDL service appears to have an internal problem. There is nothing " + - "specific that can be done to fix it locally.\n\n" + - "It is possible that the current state of the service will still allow to execute " + - "the workflow successfully. Also, the service may have already recovered since the " + - "last time it's monitoring status has been checked.\n\n" + - "If this problem does affect the current workflow, it may be resolved by the " + - "service provider. It may be worth contacting them to report the issue."; - break; - - default: - explanation = "Unknown issue - no solution available"; break; - } - - return (new ReadOnlyTextArea(explanation)); - } - -}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/health_check/BioCatalogueWSDLActivityHealthChecker.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/health_check/BioCatalogueWSDLActivityHealthChecker.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/health_check/BioCatalogueWSDLActivityHealthChecker.java deleted file mode 100644 index df00c27..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/health_check/BioCatalogueWSDLActivityHealthChecker.java +++ /dev/null @@ -1,215 +0,0 @@ -package org.apache.taverna.ui.perspectives.biocatalogue.integration.health_check; -/* - * 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. - */ - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -import org.apache.commons.lang.StringEscapeUtils; -import org.apache.log4j.Logger; -import org.biocatalogue.x2009.xml.rest.MonitoringStatusLabel; -import org.biocatalogue.x2009.xml.rest.Service; -import org.biocatalogue.x2009.xml.rest.ServiceTest; -import org.biocatalogue.x2009.xml.rest.TestScript; - -import org.apache.taverna.biocatalogue.model.SoapOperationIdentity; -import org.apache.taverna.biocatalogue.model.Util; -import org.apache.taverna.biocatalogue.model.connectivity.BioCatalogueClient; -import org.apache.taverna.activities.wsdl.WSDLActivity; -import org.apache.taverna.activities.wsdl.WSDLActivityConfigurationBean; -import org.apache.taverna.ui.perspectives.biocatalogue.MainComponentFactory; -import org.apache.taverna.visit.VisitReport; -import org.apache.taverna.visit.VisitReport.Status; -import org.apache.taverna.workflowmodel.health.HealthChecker; - - -/** - * A {@link HealthChecker} for a {@link WSDLActivity}. - * - * @author Sergejs Aleksejevs - */ -public class BioCatalogueWSDLActivityHealthChecker implements HealthChecker<WSDLActivity> -{ - private static final int MILLIS_IN_THE_PAST_FOR_OLDEST_MONITORING_DATA = 48 * 60 * 60 * 1000; // 48hrs - - - private Logger logger; - - public BioCatalogueWSDLActivityHealthChecker() { - logger = Logger.getLogger(BioCatalogueWSDLActivityHealthChecker.class); - } - - - public boolean canVisit(Object subject) { - return (subject instanceof WSDLActivity); - } - - - public VisitReport visit(WSDLActivity activity, List<Object> ancestors) - { - WSDLActivityConfigurationBean configBean = activity.getConfiguration(); - SoapOperationIdentity soapOpIdentity = new SoapOperationIdentity(configBean.getWsdl(), configBean.getOperation(), null); - - try { - // make BioCatalogue API request to fetch the data - Service serviceWithMonitoringData = BioCatalogueClient.getInstance().lookupParentServiceMonitoringData(soapOpIdentity); - MonitoringStatusLabel.Enum serviceStatusLabel = null; - - - VisitReport.Status status = null; - String visitReportLabel = null; - String visitReportExplanation = null; - List<VisitReport> subReports = new ArrayList<VisitReport>(); - - - if (serviceWithMonitoringData == null) { - // BioCatalogue doesn't "know" about this service - it appears not to be registered; - // --> nothing to report to Taverna - return (null); - } - else if (serviceWithMonitoringData.getLatestMonitoringStatus() == null) { - // BioCatalogue "knows" this service, but for some reason there was no monitoring data available; - // possibly an API change? either way --> nothing to report to Taverna - return (null); - } - else - { - Calendar lastCheckedAt = serviceWithMonitoringData.getLatestMonitoringStatus().getLastChecked(); - String agoString = Util.getAgoString(lastCheckedAt, Calendar.getInstance(), MILLIS_IN_THE_PAST_FOR_OLDEST_MONITORING_DATA); - if (agoString == null) { - return (null); - } - - serviceStatusLabel = serviceWithMonitoringData.getLatestMonitoringStatus().getLabel(); - switch (serviceStatusLabel.intValue()) { - case MonitoringStatusLabel.INT_PASSED: - visitReportLabel = "Service Catalogue: all tests passed " + agoString; - visitReportExplanation = "The Service Catalogue reports that all available tests for this WSDL service have " + - "been successful. They have been last executed " + agoString; - status = Status.OK; - break; - - case MonitoringStatusLabel.INT_WARNING: - case MonitoringStatusLabel.INT_FAILED: - visitReportLabel = "Service Catalogue: some tests failed " + agoString; - visitReportExplanation = "Some test scripts for this WSDL service have failed"; - - // only extract data about failing test scripts - subReports = createTestScriptSubReportsForFailingService(activity, serviceWithMonitoringData); - if (subReports.size() == 0) { - // failing tests must have been for endpoint / WSDL location - but not for scripts; - // Taverna doesn't need to know about the former, as it replicates internal checks - return (null); - } - else { - // determine the worst status and report as the one of the collection of subreports - status = VisitReport.getWorstStatus(subReports); - } - break; - - case MonitoringStatusLabel.INT_UNCHECKED: - // monitoring record states that the status of this service was not (yet) checked; - // possibly monitoring on BioCatalogue was switched off before this service was registered; - // --> nothing to report to Taverna - return (null); - - default: - visitReportLabel = "Service Catalogue: unknown monitoring status received - \"" + serviceStatusLabel.toString() + "\""; - visitReportExplanation = "The Service Catalogue has returned a new monitoring status for this service: \"" + - serviceStatusLabel.toString() + "\"\n\n" + - "It has never been used before and probably indicates a change in the Service Catalogue API. " + - "Please report this issue to the Service Catalogue developers."; - status = Status.WARNING; - break; - } - } - - // wrap determined values into a single VisitReport object; then attach data to identify - // this service in associated VisitExplainer - VisitReport report = new VisitReport(BioCatalogueWSDLActivityHealthCheck.getInstance(), activity, - visitReportLabel, BioCatalogueWSDLActivityHealthCheck.MESSAGE_IN_VISIT_REPORT, status, subReports); - report.setProperty(BioCatalogueWSDLActivityHealthCheck.WSDL_LOCATION_PROPERTY, soapOpIdentity.getWsdlLocation()); - report.setProperty(BioCatalogueWSDLActivityHealthCheck.OPERATION_NAME_PROPERTY, soapOpIdentity.getOperationName()); - report.setProperty(BioCatalogueWSDLActivityHealthCheck.EXPLANATION_MSG_PROPERTY, visitReportExplanation); - - return (report); - } - catch (Exception e) { - // not sure what could have happened - it will be visible in the logs - logger.error("Unexpected error while performing health check for " + - soapOpIdentity.getWsdlLocation() + " service.", e); - return (null); - } - } - - - private List<VisitReport> createTestScriptSubReportsForFailingService(WSDLActivity activity, Service serviceWithMonitoringData) - { - List<VisitReport> subReports = new ArrayList<VisitReport>(); - - try { - List<ServiceTest> serviceTests = serviceWithMonitoringData.getMonitoring().getTests().getServiceTestList(); - for (ServiceTest test : serviceTests) - { - if (test.getTestType().getTestScript() != null && - test.getTestType().getTestScript()instanceof TestScript) - { - TestScript testScript = test.getTestType().getTestScript(); - - String agoString = Util.getAgoString(test.getLatestStatus().getLastChecked(), Calendar.getInstance(), - MILLIS_IN_THE_PAST_FOR_OLDEST_MONITORING_DATA); - - // only proceed if this test wasn't run too long ago - if (agoString != null) { - String label = "Service Catalogue: \"" + testScript.getName() + "\" test script " + test.getLatestStatus().getLabel(); - VisitReport report = new VisitReport(BioCatalogueWSDLActivityHealthCheck.getInstance(), activity, - label, BioCatalogueWSDLActivityHealthCheck.MESSAGE_IN_VISIT_REPORT, - ServiceMonitoringStatusInterpreter.translateBioCatalogueStatusForTaverna(test.getLatestStatus().getLabel())); - report.setProperty(BioCatalogueWSDLActivityHealthCheck.WSDL_LOCATION_PROPERTY, activity.getConfiguration().getWsdl()); - report.setProperty(BioCatalogueWSDLActivityHealthCheck.OPERATION_NAME_PROPERTY, activity.getConfiguration().getOperation()); - report.setProperty(BioCatalogueWSDLActivityHealthCheck.EXPLANATION_MSG_PROPERTY, - "This test was last executed " + agoString + "." + - "\n\n" + StringEscapeUtils.escapeHtml(test.getLatestStatus().getMessage()) + - "\n\n---- Test script description ----\n" + StringEscapeUtils.escapeHtml(testScript.getDescription())); - - subReports.add(report); - } - } - } - } - catch (Exception e) { - // log the error, but do not terminate the method - maybe some sub reports were successfully - // generated, in which case at least partial result can be returned - logger.error("Encountered unexpected problem while trying to generate a collection of sub-reports " + - "for a failing service: " + activity.getConfiguration().getWsdl(), e); - } - - return (subReports); - } - - - /** - * Health check for the WSDL activities involves fetching - * the monitoring status of each activity from BioCatalogue - - * this *may* be time consuming. - */ - public boolean isTimeConsuming() { - return true; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/health_check/ServiceHealthChecker.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/health_check/ServiceHealthChecker.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/health_check/ServiceHealthChecker.java deleted file mode 100644 index 32a6670..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/health_check/ServiceHealthChecker.java +++ /dev/null @@ -1,296 +0,0 @@ -package org.apache.taverna.ui.perspectives.biocatalogue.integration.health_check; -/* - * 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. - */ - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.List; - -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; -import javax.swing.border.EmptyBorder; - -import org.apache.log4j.Logger; -import org.biocatalogue.x2009.xml.rest.ResourceLink; -import org.biocatalogue.x2009.xml.rest.RestMethod; -import org.biocatalogue.x2009.xml.rest.Service; -import org.biocatalogue.x2009.xml.rest.ServiceTest; -import org.biocatalogue.x2009.xml.rest.SoapOperation; - -import org.apache.taverna.biocatalogue.model.BioCataloguePluginConstants; -import org.apache.taverna.biocatalogue.model.Resource; -import org.apache.taverna.biocatalogue.model.Resource.TYPE; -import org.apache.taverna.biocatalogue.model.ResourceManager; -import org.apache.taverna.biocatalogue.model.SoapOperationIdentity; -import org.apache.taverna.biocatalogue.model.SoapProcessorIdentity; -import org.apache.taverna.biocatalogue.model.connectivity.BioCatalogueClient; -import org.apache.taverna.biocatalogue.ui.JClickableLabel; -import org.apache.taverna.biocatalogue.ui.JWaitDialog; -import org.apache.taverna.ui.perspectives.biocatalogue.MainComponent; -import org.apache.taverna.ui.perspectives.biocatalogue.MainComponentFactory; - - -/** - * This class helps with "health checks" of individual Taverna processors - * (i.e. SOAP operations) and the workflows in general (by iterating through - * the processors). - * - * @author Sergejs Aleksejevs - */ -public class ServiceHealthChecker -{ - private static Logger logger = Logger.getLogger(ServiceHealthChecker.class); - - // deny creation of instances of this class - private ServiceHealthChecker() { }; - - - // ===================================================================================================== - // *** Health Check of Individual Service / Processor *** - // ===================================================================================================== - - /** - * @param serviceURL URL of SOAP service or REST service on BioCatalogue; - * URL should be of the - */ - public static void checkServiceByURL(String serviceURL) - { - if (serviceURL != null) { - checkMonitoringStatusRoutine(serviceURL); - } - else { - // for some reason the URL of the service wasn't provided... - JOptionPane.showMessageDialog(null, "Cannot provide monitoring status for this service - " + - "unknown service URL", "Service Catalogue Error", JOptionPane.ERROR_MESSAGE); - } - } - - - /** - * @param - */ - public static void checkResource(ResourceLink serviceOrOperationOrMethod) - { - if (serviceOrOperationOrMethod != null) { - checkMonitoringStatusRoutine(serviceOrOperationOrMethod); - } - else { - // for some reason resource object wasn't provided... - JOptionPane.showMessageDialog(null, "Cannot provide monitoring status - " + - "null reference received", "Service Catalogue Error", JOptionPane.ERROR_MESSAGE); - } - } - - - /** - * Used when invoked from the workflow diagram - e.g. when a URL of the specific - * resource on BioCatalogue is not known, but have enough of identifying data - * to proceed with health check. - * - * @param soapOperationDetails - */ - public static void checkWSDLProcessor(SoapOperationIdentity soapOperationDetails) - { - if (!soapOperationDetails.hasError()) { - checkMonitoringStatusRoutine(soapOperationDetails); - } - else { - // this error message comes from Integration class extracting SOAP operation details from the contextual selection - JOptionPane.showMessageDialog(null, soapOperationDetails.getErrorDetails(), "Service Catalogue Error", JOptionPane.WARNING_MESSAGE); - } - } - - - /** - * @param serviceOrSoapOperationToCheck Instance of SoapOperationIdentity representing Taverna processor - * or String representing a URL of the service to check health for. - */ - private static void checkMonitoringStatusRoutine(final Object serviceOrSoapOperationToCheck) - { - // helper variable to determine the kind of check to perform - the difference is minimal: - // wording in the status messages ("Web Service" | "processor" | "REST Service") and which method to call on - // the BioCatalogue client to fetch monitoring data - final boolean bCheckingService = (serviceOrSoapOperationToCheck instanceof String); - final boolean bCheckingWSDLProcessor = (serviceOrSoapOperationToCheck instanceof SoapOperationIdentity); - final boolean bCheckingResource = (serviceOrSoapOperationToCheck instanceof ResourceLink); - - final StringBuilder itemToCheck = new StringBuilder(); - if (bCheckingService) { - itemToCheck.append("service"); - } - else if (bCheckingWSDLProcessor) { - itemToCheck.append("WSDL service"); - } - else if (bCheckingResource) { - TYPE resourceType = Resource.getResourceTypeFromResourceURL(((ResourceLink)serviceOrSoapOperationToCheck).getHref()); - itemToCheck.append(resourceType.getTypeName()); - } - - // create the wait dialog, but don't make it visible - first need to start the background processing thread - final JWaitDialog jwd = new JWaitDialog(MainComponent.dummyOwnerJFrame, "Checking "+itemToCheck+" status", - "Please wait while status of selected "+itemToCheck+" is being checked..."); - - new Thread(itemToCheck + " lookup and health check operation") { - public void run() { - try - { - BioCatalogueClient client = BioCatalogueClient.getInstance(); - Service serviceMonitoringData = null; - - // attempt to get monitoring data from BioCatalogue - for this need to identify what type of - // item was provided as a parameter - if (bCheckingService) { - serviceMonitoringData = client.getBioCatalogueServiceMonitoringData((String)serviceOrSoapOperationToCheck); - } - else if (bCheckingWSDLProcessor) { - serviceMonitoringData = client.lookupParentServiceMonitoringData((SoapOperationIdentity)serviceOrSoapOperationToCheck); - } - else if (bCheckingResource) { - String resourceURL = ((ResourceLink)serviceOrSoapOperationToCheck).getHref(); - TYPE resourceType = Resource.getResourceTypeFromResourceURL(resourceURL); - -// if (resourceType == TYPE.Service) { -// serviceMonitoringData = client.getBioCatalogueServiceMonitoringData(resourceURL); -// } -// else - if (resourceType == TYPE.SOAPOperation) { - String parentServiceURL = ((SoapOperation)serviceOrSoapOperationToCheck).getAncestors().getService().getHref(); - serviceMonitoringData = client.getBioCatalogueServiceMonitoringData(parentServiceURL); - } - else if (resourceType == TYPE.RESTMethod) { - String parentServiceURL = ((RestMethod)serviceOrSoapOperationToCheck).getAncestors().getService().getHref(); - serviceMonitoringData = client.getBioCatalogueServiceMonitoringData(parentServiceURL); - } - else { - JOptionPane.showMessageDialog(jwd, "Unexpected resource type - can't execute health check for this", - "Service Catalogue Error", JOptionPane.ERROR_MESSAGE); - logger.error("Service Catalogue: Could not perform health check for" + resourceType); - } - } - - - // need to make this assignment to make the variable final - otherwise unavailable inside the new thread... - final Service serviceWithMonitoringData = serviceMonitoringData; - SwingUtilities.invokeLater(new Runnable() { - public void run() { - if (serviceWithMonitoringData == null) { - jwd.setTitle("Service Catalogue - Information"); - jwd.waitFinished(new JLabel("There is no information about this "+itemToCheck+" in the Service Catalogue", - UIManager.getIcon("OptionPane.informationIcon"), JLabel.CENTER)); - } - else if (serviceWithMonitoringData.getLatestMonitoringStatus() == null) { - jwd.setTitle("Service Catalogue Warning"); - jwd.waitFinished(new JLabel("This "+itemToCheck+" is known to the Service Catalogue, but no monitoring data was available.", - UIManager.getIcon("OptionPane.warningIcon"), JLabel.CENTER)); - } - else - { - // set the overall status message - String overallStatusLabel = "<html><b>Overall status:</b><br>" + - serviceWithMonitoringData.getLatestMonitoringStatus().getMessage() + "<br>" + - "(last checked"; - if (serviceWithMonitoringData.getLatestMonitoringStatus().getLastChecked() == null) { - overallStatusLabel += ": never"; - } - else { - overallStatusLabel += " at " + BioCatalogueClient.getShortDateFormatter().format( - serviceWithMonitoringData.getLatestMonitoringStatus().getLastChecked().getTime()); - } - overallStatusLabel += ")</html>"; - JLabel jlOverallStatus = new JLabel(overallStatusLabel); - - // create panel for additional status messages (e.g. endpoint, wsdl location, etc) - JPanel jpStatusMessages = new JPanel(); - jpStatusMessages.setLayout(new BoxLayout(jpStatusMessages, BoxLayout.Y_AXIS)); - - for (ServiceTest test : serviceWithMonitoringData.getMonitoring().getTests().getServiceTestList()) - { - // First get the service type - String testLabel = "<html><br><b>"; - if (test.getTestType().getUrlMonitor() != null) - { - if (test.getTestType().getUrlMonitor().getUrl().endsWith("wsdl")) { - // WSDL location test - testLabel += "WSDL Location Availability:</b><br>" + - "URL: " + test.getTestType().getUrlMonitor().getUrl(); - } - else { - // Endpoint availability test - testLabel += "Endpoint Availability:</b><br>" + - "URL: " + test.getTestType().getUrlMonitor().getUrl(); - } - } - else if (test.getTestType().getTestScript() != null) { - // test script - testLabel += "Test Script: " + test.getTestType().getTestScript().getName() + "</b>"; - } - else { - testLabel += "Unknown test type</b>"; - } - testLabel += "<br>"; - - // Add service results - testLabel += test.getLatestStatus().getMessage() + "</html>"; - - // Add the current test into the test messages panel - jpStatusMessages.add(new JLabel(testLabel)); - } - - // either way add the overall status on top of everything - jpStatusMessages.add(jlOverallStatus, 0); - jpStatusMessages.setBorder(new EmptyBorder(10,10,10,10)); - JScrollPane jspStatusMessages = new JScrollPane(jpStatusMessages); - jspStatusMessages.setBorder(BorderFactory.createEmptyBorder()); - - // *** Put everything together *** - JPanel jpHealthCheckStatus = new JPanel(new BorderLayout(15, 10)); - jpHealthCheckStatus.add(new JLabel(ServiceMonitoringStatusInterpreter.getStatusIcon(serviceWithMonitoringData, false)), - BorderLayout.WEST); - jpHealthCheckStatus.add(jspStatusMessages, BorderLayout.CENTER); - - jwd.setTitle("Service Catalogue - Monitoring Status"); - jwd.waitFinished(jpHealthCheckStatus); - } - } - }); - } - catch (Exception e) { - logger.error("Service Catalogue: Error occurred while checking status of selected", e); - jwd.setTitle("Service Catalogue - Error"); - jwd.waitFinished(new JLabel("<html>An unexpected error occurred while checking status of selected " + - itemToCheck + "<br>Please see error log for details...", - UIManager.getIcon("OptionPane.errorIcon"), JLabel.CENTER)); - } - } - }.start(); - - jwd.setVisible(true); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/health_check/ServiceMonitoringStatusInterpreter.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/health_check/ServiceMonitoringStatusInterpreter.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/health_check/ServiceMonitoringStatusInterpreter.java deleted file mode 100644 index 880327d..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/health_check/ServiceMonitoringStatusInterpreter.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.apache.taverna.ui.perspectives.biocatalogue.integration.health_check; -/* - * 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. - */ - -import java.net.URL; - -import javax.swing.Icon; -import javax.swing.ImageIcon; - -import org.apache.taverna.biocatalogue.model.ResourceManager; -import org.apache.taverna.visit.VisitReport; -import org.apache.taverna.visit.VisitReport.Status; - -import org.biocatalogue.x2009.xml.rest.MonitoringStatus; -import org.biocatalogue.x2009.xml.rest.MonitoringStatusLabel; -import org.biocatalogue.x2009.xml.rest.Service; - -/** - * @author Sergejs Aleksejevs - */ -public class ServiceMonitoringStatusInterpreter -{ - // prevent instantiation of this class - private ServiceMonitoringStatusInterpreter() { /* do nothing */ } - - - /** - * @param serviceWithMonitoringData - * @param listingIconRequired True to get a small icon suitable for a JList entry; - * false to get a larger icon. - * @return - */ - public static ImageIcon getStatusIcon(Service serviceWithMonitoringData, boolean listingIconRequired) - { - MonitoringStatus latestMonitoringStatus = serviceWithMonitoringData.getLatestMonitoringStatus(); - if (latestMonitoringStatus == null) { - return ResourceManager.getImageIcon((listingIconRequired ? - ResourceManager.SERVICE_STATUS_UNCHECKED_ICON : - ResourceManager.SERVICE_STATUS_UNCHECKED_ICON_LARGE)); - } - MonitoringStatusLabel.Enum serviceStatusLabel = latestMonitoringStatus.getLabel(); - - switch (serviceStatusLabel.intValue()) { - case MonitoringStatusLabel.INT_PASSED: - return ResourceManager.getImageIcon((listingIconRequired ? - ResourceManager.SERVICE_STATUS_PASSED_ICON : - ResourceManager.SERVICE_STATUS_PASSED_ICON_LARGE)); - case MonitoringStatusLabel.INT_WARNING: - return ResourceManager.getImageIcon((listingIconRequired ? - ResourceManager.SERVICE_STATUS_WARNING_ICON : - ResourceManager.SERVICE_STATUS_WARNING_ICON_LARGE)); - case MonitoringStatusLabel.INT_FAILED: - return ResourceManager.getImageIcon((listingIconRequired ? - ResourceManager.SERVICE_STATUS_FAILED_ICON : - ResourceManager.SERVICE_STATUS_FAILED_ICON_LARGE)); - case MonitoringStatusLabel.INT_UNCHECKED: - return ResourceManager.getImageIcon((listingIconRequired ? - ResourceManager.SERVICE_STATUS_UNCHECKED_ICON : - ResourceManager.SERVICE_STATUS_UNCHECKED_ICON_LARGE)); - default: - return (ResourceManager.getImageIcon(ResourceManager.SERVICE_STATUS_UNKNOWN_ICON)); - } - - } - - - public static VisitReport.Status translateBioCatalogueStatusForTaverna(MonitoringStatusLabel.Enum monitoringStatusLabelEnum) - { - switch (monitoringStatusLabelEnum.intValue()) { - case MonitoringStatusLabel.INT_PASSED: return Status.OK; - case MonitoringStatusLabel.INT_WARNING: return Status.WARNING; - case MonitoringStatusLabel.INT_FAILED: return Status.SEVERE; - case MonitoringStatusLabel.INT_UNCHECKED: return Status.OK; // not really OK, but Taverna isn't interested in missing data anyway - default: return Status.WARNING; // could be worth to pop up a warning in this case, as it may mean something has changed - } - } - - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/menus/BioCatalogueContextualMenuSection.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/menus/BioCatalogueContextualMenuSection.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/menus/BioCatalogueContextualMenuSection.java deleted file mode 100644 index 5518c77..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/menus/BioCatalogueContextualMenuSection.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.apache.taverna.ui.perspectives.biocatalogue.integration.menus; -/* - * 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. - */ - -import java.awt.event.ActionEvent; -import java.net.URI; - -import javax.swing.AbstractAction; -import javax.swing.Action; - -import org.apache.taverna.biocatalogue.model.ResourceManager; -import org.apache.taverna.lang.ui.ShadedLabel; -import org.apache.taverna.ui.menu.AbstractMenuSection; -import org.apache.taverna.ui.menu.ContextualMenuComponent; -import org.apache.taverna.ui.menu.ContextualSelection; -import org.apache.taverna.ui.menu.DefaultContextualMenu; -import org.apache.taverna.workflowmodel.Dataflow; -import org.apache.taverna.workflowmodel.InputPort; -import org.apache.taverna.workflowmodel.Processor; - - -public class BioCatalogueContextualMenuSection extends AbstractMenuSection implements ContextualMenuComponent -{ - // TODO - this shouldn't be here, must reference this field in AbstractMenuSection!! - public static final String SECTION_COLOR = "sectionColor"; - - - public static final URI BIOCATALOGUE_MENU_SECTION_ID = URI.create("http://biocatalogue.org/2010/contextMenu/biocatalogue_section"); - private static final String SECTION_TITLE = "Service Catalogue"; - - private ContextualSelection contextualSelection; - - - public BioCatalogueContextualMenuSection() { - super(DefaultContextualMenu.DEFAULT_CONTEXT_MENU, 100000, BIOCATALOGUE_MENU_SECTION_ID); - } - - public ContextualSelection getContextualSelection() { - return contextualSelection; - } - - public void setContextualSelection(ContextualSelection contextualSelection) { - this.contextualSelection = contextualSelection; - } - - @Override - public boolean isEnabled() { - return super.isEnabled() - && (getContextualSelection().getSelection() instanceof Dataflow || - getContextualSelection().getSelection() instanceof Processor || - getContextualSelection().getSelection() instanceof InputPort); - } - - @SuppressWarnings("serial") - protected Action createAction() - { - Action action = new AbstractAction(SECTION_TITLE, ResourceManager.getImageIcon(ResourceManager.FAVICON)) { - public void actionPerformed(ActionEvent e) { - } - }; - action.putValue(SECTION_COLOR, ShadedLabel.GREEN); - return (action); - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/menus/MenuActionInputPort.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/menus/MenuActionInputPort.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/menus/MenuActionInputPort.java deleted file mode 100644 index 31efc59..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/menus/MenuActionInputPort.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.apache.taverna.ui.perspectives.biocatalogue.integration.menus; -/* - * 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. - */ - -import java.awt.event.ActionEvent; -import java.net.URISyntaxException; - -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JOptionPane; - -import org.apache.taverna.ui.menu.AbstractContextualMenuAction; - -import org.apache.taverna.workflowmodel.InputPort; - - -/** - * This class currently won't be used, as an entry for it was removed from - * META-INF/services/META-INF/services/net.sf.taverna.t2.ui.menu.MenuComponent - * - * This is because no useful action is yet available for input/output ports. - * - * @author Sergejs Aleksejevs - */ -public class MenuActionInputPort extends AbstractContextualMenuAction { - - public MenuActionInputPort() throws URISyntaxException { - super(BioCatalogueContextualMenuSection.BIOCATALOGUE_MENU_SECTION_ID, 15); - } - - @Override - protected Action createAction() { - return new AbstractAction("InputPort") { - public void actionPerformed(ActionEvent e) { - JOptionPane.showMessageDialog(getContextualSelection().getRelativeToComponent(), "Hoho!"); - } - }; - } - - @Override - public boolean isEnabled() { - return (super.isEnabled() && getContextualSelection().getSelection() instanceof InputPort); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/menus/MenuActionProcessorHealthCheck.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/menus/MenuActionProcessorHealthCheck.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/menus/MenuActionProcessorHealthCheck.java deleted file mode 100644 index 60ec793..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/menus/MenuActionProcessorHealthCheck.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.apache.taverna.ui.perspectives.biocatalogue.integration.menus; -/* - * 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. - */ - -import java.awt.event.ActionEvent; -import java.net.URISyntaxException; - -import javax.swing.AbstractAction; -import javax.swing.Action; - -import org.apache.taverna.biocatalogue.model.SoapOperationIdentity; -import org.apache.taverna.ui.menu.AbstractContextualMenuAction; -import org.apache.taverna.ui.perspectives.biocatalogue.integration.Integration; -import org.apache.taverna.ui.perspectives.biocatalogue.integration.health_check.ServiceHealthChecker; -import org.apache.taverna.workflowmodel.Processor; - - -public class MenuActionProcessorHealthCheck extends AbstractContextualMenuAction { - - public MenuActionProcessorHealthCheck() throws URISyntaxException { - super(BioCatalogueContextualMenuSection.BIOCATALOGUE_MENU_SECTION_ID, 20); - } - - @SuppressWarnings("serial") -@Override - protected Action createAction() - { - Action action = new AbstractAction("Service Health Check") { - public void actionPerformed(ActionEvent e) { - SoapOperationIdentity soapOperationDetails = Integration.extractSoapOperationDetailsFromProcessorContextualSelection(getContextualSelection()); - ServiceHealthChecker.checkWSDLProcessor(soapOperationDetails); - } - }; - action.putValue(Action.SHORT_DESCRIPTION, "Check monitoring status of this service"); - return (action); - } - - @Override - public boolean isEnabled() - { - // FIXME - this will only work for SOAP processors for now.. - boolean isEnabled = super.isEnabled() && getContextualSelection().getSelection() instanceof Processor; - - if (isEnabled) { - SoapOperationIdentity soapOperationDetails = Integration.extractSoapOperationDetailsFromProcessorContextualSelection(getContextualSelection()); - isEnabled = !soapOperationDetails.hasError(); - } - - return isEnabled; - } - - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/BioCatalogueRESTServiceProvider.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/BioCatalogueRESTServiceProvider.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/BioCatalogueRESTServiceProvider.java deleted file mode 100644 index 62800ed..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/BioCatalogueRESTServiceProvider.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.apache.taverna.ui.perspectives.biocatalogue.integration.service_panel; -/* - * 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. - */ - -import java.net.URI; -import java.util.Collections; -import java.util.List; - -import javax.swing.Icon; - -import org.apache.log4j.Logger; - -//import net.sf.taverna.t2.activities.rest.ui.servicedescription.RESTActivityIcon; -import org.apache.taverna.servicedescriptions.AbstractConfigurableServiceProvider; -import org.apache.taverna.servicedescriptions.impl.ServiceDescriptionRegistryImpl; - -/** - * Service provider for REST service added to the Service Panel through the - * BioCatalogue perspective. - * - * @author Alex Nenadic - */ -public class BioCatalogueRESTServiceProvider extends - AbstractConfigurableServiceProvider<RESTFromBioCatalogueServiceDescription> { - - public static final String PROVIDER_NAME = "Service Catalogue - selected services"; - - private static final URI providerId = URI - .create("http://taverna.sf.net/2010/service-provider/servicecatalogue/rest"); - - private static Logger logger = Logger.getLogger(BioCatalogueRESTServiceProvider.class); - - public BioCatalogueRESTServiceProvider( - RESTFromBioCatalogueServiceDescription restServiceDescription) { - super(restServiceDescription); - } - - public BioCatalogueRESTServiceProvider() { - super(new RESTFromBioCatalogueServiceDescription()); - } - - @Override - protected List<? extends Object> getIdentifyingData() { - return getConfiguration().getIdentifyingData(); - } - - @Override - public void findServiceDescriptionsAsync( - FindServiceDescriptionsCallBack callBack) { - callBack.status("Starting Service Catalogue REST Service Provider"); - registerNewRESTMethod(getConfiguration(), callBack); - } - - @Override - public Icon getIcon() { -// return RESTActivityIcon.getRESTActivityIcon(); - return getConfiguration().getIcon(); - } - - @Override - public String getId() { - return providerId.toString(); - } - - @Override - public String getName() { - return "Service Catalogue REST"; - } - - @Override - public String toString() { - return "Service Catalogue REST service " + getConfiguration().getName(); - } - - public static boolean registerNewRESTMethod( - RESTFromBioCatalogueServiceDescription restServiceDescription, - FindServiceDescriptionsCallBack callBack) { - if (callBack == null) { - // We are not adding service through a callback and - // findServiceDescriptionsAsync() - - // we are adding directly from the BioCatalogue perspective. - ServiceDescriptionRegistryImpl serviceDescriptionRegistry = ServiceDescriptionRegistryImpl - .getInstance(); - serviceDescriptionRegistry - .addServiceDescriptionProvider(new BioCatalogueRESTServiceProvider( - restServiceDescription)); - return true; - } else { - { - // Add the REST method to the Service Panel through the callback - callBack.partialResults(Collections - .singletonList(restServiceDescription)); - callBack.finished(); - return (true); - } - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/BioCatalogueServiceProvider.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/BioCatalogueServiceProvider.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/BioCatalogueServiceProvider.java deleted file mode 100644 index d57f978..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/BioCatalogueServiceProvider.java +++ /dev/null @@ -1,290 +0,0 @@ -package org.apache.taverna.ui.perspectives.biocatalogue.integration.service_panel; -/* - * 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. - */ - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import javax.swing.Icon; -import javax.wsdl.Operation; -import javax.wsdl.WSDLException; -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.log4j.Logger; -import org.xml.sax.SAXException; - -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.io.xml.DomDriver; - -import org.apache.taverna.biocatalogue.model.SoapOperationIdentity; -import org.apache.taverna.biocatalogue.model.Util; -import org.apache.taverna.activities.wsdl.WSDLActivityHealthChecker; -import org.apache.taverna.servicedescriptions.ServiceDescription; -import org.apache.taverna.servicedescriptions.ServiceDescriptionProvider; -import org.apache.taverna.ui.perspectives.biocatalogue.BioCataloguePerspective; -import org.apache.taverna.ui.perspectives.biocatalogue.integration.config.BioCataloguePluginConfiguration; -import org.apache.taverna.wsdl.parser.UnknownOperationException; -import org.apache.taverna.wsdl.parser.WSDLParser; - -public class BioCatalogueServiceProvider implements ServiceDescriptionProvider -{ - public static final String PROVIDER_NAME = "Service Catalogue - selected services"; - - private static BioCatalogueServiceProvider instanceOfSelf = null; - private static FindServiceDescriptionsCallBack callBack; - - private static List<SoapOperationIdentity> registeredSOAPOperations; - private static List<RESTFromBioCatalogueServiceDescription> registeredRESTMethods; - - private static Logger logger = Logger.getLogger(BioCatalogueServiceProvider.class); - - - public BioCatalogueServiceProvider() { - BioCatalogueServiceProvider.instanceOfSelf = this; - } - - @SuppressWarnings("unchecked") - public void findServiceDescriptionsAsync(FindServiceDescriptionsCallBack callBack) - { - BioCatalogueServiceProvider.callBack = callBack; - callBack.status("Starting Service Catalogue Service Provider"); - - // --- Initilise the service provider with stored services --- - - // read stored settings - // NB! it's crucial to set the custom classloader, otherwise XStream would fail, - // as it would attempt to use the default one, which wouldn't know about the - // plugin's classes - logger.info("Starting to deserialise the list of services stored in the configuration file"); - XStream xstream = new XStream(new DomDriver()); - xstream.setClassLoader(BioCataloguePerspective.class.getClassLoader()); - - BioCataloguePluginConfiguration configuration = BioCataloguePluginConfiguration.getInstance(); - - // *** load stored SOAP operations *** - String loadedSOAPServicesXMLString = configuration.getProperty(BioCataloguePluginConfiguration.SOAP_OPERATIONS_IN_SERVICE_PANEL); - - Object loadedSOAPServices = (loadedSOAPServicesXMLString == null ? - null : - xstream.fromXML(loadedSOAPServicesXMLString)); - - registeredSOAPOperations = (loadedSOAPServices == null || !(loadedSOAPServices instanceof List<?>) ? - new ArrayList<SoapOperationIdentity>() : - (List<SoapOperationIdentity>)loadedSOAPServices - ); - logger.info("Deserialised " + registeredSOAPOperations.size() + Util.pluraliseNoun("SOAP operation", registeredSOAPOperations.size())); - - // prepare the correct format of data for initialisation - List<ServiceDescription> results = new ArrayList<ServiceDescription>(); - for (SoapOperationIdentity opId : registeredSOAPOperations) { - results.add(new WSDLOperationFromBioCatalogueServiceDescription(opId)); - } - - - // *** load stored REST methods *** - String loadedRESTMethodsXMLString = configuration.getProperty(BioCataloguePluginConfiguration.REST_METHODS_IN_SERVICE_PANEL); - - Object loadedRESTMethods = (loadedRESTMethodsXMLString == null ? - null : - xstream.fromXML(loadedRESTMethodsXMLString)); - - registeredRESTMethods = (loadedRESTMethods == null || !(loadedRESTMethods instanceof List<?>) ? - new ArrayList<RESTFromBioCatalogueServiceDescription>() : - (List<RESTFromBioCatalogueServiceDescription>)loadedRESTMethods); - logger.info("Deserialised " + registeredRESTMethods.size() + Util.pluraliseNoun("REST method", registeredRESTMethods.size())); - - results.addAll(registeredRESTMethods); - - - // *** send the services to the Service Panel *** - callBack.partialResults(results); - - - // NB! This is to be called when it is known that no more items will be added - - // it's never true for this provider, as items may be added on user request - // at any time! - // - // callBack.finished(); - } - - public Icon getIcon() { - return null; - } - - public String getName(){ - // TODO - not sure where this is used - return "My dummy service"; - } - - public String getId() { - return "http://www.taverna.org.uk/2010/services/servicecatalogue"; - } - - - /** - * Adds a new "processor" - i.e. a WSDL operation into the main Service Panel. - * - * @param wsdlLocation URL of the WSDL location of the operation to add. - * @param operationName Name of the operation within specified WSDL document. - * @return True if the operation was added; - * false if the service provided was not yet initiliased (unlikely) or - * when supplied strings were empty/null. - */ - public static boolean registerNewWSDLOperation(SoapOperationIdentity soapOperationDetails) - { - if (BioCatalogueServiceProvider.instanceOfSelf == null || soapOperationDetails == null || - soapOperationDetails.getWsdlLocation() == null || soapOperationDetails.getWsdlLocation().length() == 0 || - soapOperationDetails.getOperationName() == null || soapOperationDetails.getOperationName().length() == 0) - { - // the service provider hasn't been initialised yet - // OR not all details available - return (false); - } - else - { - // record the newly added operation in the internal list - registeredSOAPOperations.add(soapOperationDetails); - - // add the provided operation to the Service Panel - ServiceDescription service = new WSDLOperationFromBioCatalogueServiceDescription(soapOperationDetails); - BioCatalogueServiceProvider.callBack.partialResults(Collections.singletonList(service)); - return (true); - } - - } - - /** - * Adds a SOAP/WSDL service and all of its operations into the Taverna's Service Panel. - */ - public static boolean registerNewWSDLService(String wsdlURL) - { - if (BioCatalogueServiceProvider.instanceOfSelf == null || wsdlURL == null) - { - // the service provider hasn't been initialised yet - // OR not all details available - return (false); - } - else - { - // Do the same thing as in the WSDL service provider - callBack.status("Service Catalogue service provider: Parsing wsdl: " + wsdlURL); - WSDLParser parser = null; - try { - parser = new WSDLParser(wsdlURL); - List<Operation> operations = parser.getOperations(); - callBack.status("Found " + operations.size() + " WSDL operations of service " - + wsdlURL); - List<WSDLOperationFromBioCatalogueServiceDescription> items = new ArrayList<WSDLOperationFromBioCatalogueServiceDescription>(); - for (Operation operation : operations) { - WSDLOperationFromBioCatalogueServiceDescription item; - try { - String operationName = operation.getName(); - String operationDesc = parser.getOperationDocumentation(operationName); - String use = parser.getUse(operationName); - String style = parser.getStyle(); - if (!WSDLActivityHealthChecker.checkStyleAndUse(style, use)) { - logger.warn("Unsupported style and use combination " + style + "/" + use + " for operation " + operationName + " from " + wsdlURL); - continue; - } - item = new WSDLOperationFromBioCatalogueServiceDescription(wsdlURL, operationName, operationDesc); - items.add(item); - - // Record the newly added operation in the internal list - SoapOperationIdentity soapOperationDetails = new SoapOperationIdentity(wsdlURL, operationName, operationDesc); - registeredSOAPOperations.add(soapOperationDetails); - } catch (UnknownOperationException e) { - String message = "Encountered an unexpected operation name:" - + operation.getName(); - callBack.fail(message, e); - return false; - } - } - callBack.partialResults(items); - callBack.finished(); - return true; - } catch (ParserConfigurationException e) { - String message = "Error configuring the WSDL parser"; - callBack.fail(message, e); - return false; - } catch (WSDLException e) { - String message = "There was an error with the wsdl: " + wsdlURL; - callBack.fail(message, e); - return false; - } catch (IOException e) { - String message = "There was an IO error parsing the wsdl: " + wsdlURL - + " Possible reason: the wsdl location was incorrect."; - callBack.fail(message, e); - return false; - } catch (SAXException e) { - String message = "There was an error with the XML in the wsdl: " - + wsdlURL; - callBack.fail(message, e); - return false; - } catch (IllegalArgumentException e) { // a problem with the wsdl url - String message = "There was an error with the wsdl: " + wsdlURL + " " - + "Possible reason: the wsdl location was incorrect."; - callBack.fail(message, e); - return false; - } catch (Exception e) { // anything else we did not expect - String message = "There was an error with the wsdl: " + wsdlURL; - callBack.fail(message, e); - return false; - } - } - - } - - - public static boolean registerNewRESTMethod(RESTFromBioCatalogueServiceDescription restServiceDescription) - { - if (restServiceDescription == null) { - return (false); - } - else - { - // record the newly added method in the internal list - registeredRESTMethods.add(restServiceDescription); - - // add the provided method to the Service Panel - BioCatalogueServiceProvider.callBack.partialResults(Collections.singletonList(restServiceDescription)); - return (true); - } - } - - - public static List<SoapOperationIdentity> getRegisteredSOAPOperations() { - return (registeredSOAPOperations); - } - - public static List<RESTFromBioCatalogueServiceDescription> getRegisteredRESTMethods() { - return (registeredRESTMethods); - } - - - /** - * Clears internal lists of stored SOAP operations / REST methods. - * Therefore, once Taverna is restarted, the stored services will - * be effectively "forgotten". - */ - public static void clearRegisteredServices() { - registeredRESTMethods.clear(); - registeredSOAPOperations.clear(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/BioCatalogueWSDLOperationServiceProvider.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/BioCatalogueWSDLOperationServiceProvider.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/BioCatalogueWSDLOperationServiceProvider.java deleted file mode 100644 index fed906c..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/BioCatalogueWSDLOperationServiceProvider.java +++ /dev/null @@ -1,211 +0,0 @@ -package org.apache.taverna.ui.perspectives.biocatalogue.integration.service_panel; -/* - * 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. - */ - -import java.io.IOException; -import java.net.URI; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import javax.swing.Icon; -import javax.wsdl.Operation; -import javax.wsdl.WSDLException; -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.log4j.Logger; -import org.xml.sax.SAXException; - -import org.apache.taverna.biocatalogue.model.SoapOperationIdentity; -import org.apache.taverna.activities.wsdl.WSDLActivityHealthChecker; -import org.apache.taverna.servicedescriptions.AbstractConfigurableServiceProvider; -import org.apache.taverna.servicedescriptions.impl.ServiceDescriptionRegistryImpl; -import org.apache.taverna.wsdl.parser.UnknownOperationException; -import org.apache.taverna.wsdl.parser.WSDLParser; - -/** - * Service provider for WSDL operations added to the Service Panel through the - * BioCatalogue perspective. - * - * @author Alex Nenadic - */ -public class BioCatalogueWSDLOperationServiceProvider extends - AbstractConfigurableServiceProvider<WSDLOperationFromBioCatalogueServiceDescription> { - - public BioCatalogueWSDLOperationServiceProvider( - WSDLOperationFromBioCatalogueServiceDescription wsdlOperationDescription) { - super(wsdlOperationDescription); - } - - public BioCatalogueWSDLOperationServiceProvider() { - super(new WSDLOperationFromBioCatalogueServiceDescription(new SoapOperationIdentity("", "", ""))); - } - - public static final String PROVIDER_NAME = "Service Catalogue - selected services"; - - private static final URI providerId = URI - .create("http://taverna.sf.net/2010/service-provider/servicecatalogue/wsdl"); - - private static Logger logger = Logger.getLogger(BioCatalogueWSDLOperationServiceProvider.class); - - @Override - protected List<? extends Object> getIdentifyingData() { - return getConfiguration().getIdentifyingData(); - } - - @Override - public void findServiceDescriptionsAsync( - FindServiceDescriptionsCallBack callBack) { - callBack.status("Starting Service Catalogue WSDL Service Provider"); - registerWSDLOperation(getConfiguration(), callBack); - } - - @Override - public Icon getIcon() { - return getConfiguration().getIcon(); - } - - @Override - public String getId() { - return providerId.toString(); - } - - @Override - public String getName() { - return "Service Catalogue WSDL"; - } - - @Override - public String toString() { - return "Service Catalogue WSDL service " + getConfiguration().getName(); - } - - public static boolean registerWSDLOperation( - WSDLOperationFromBioCatalogueServiceDescription wsdlOperationDescription, - FindServiceDescriptionsCallBack callBack) { - - if (callBack == null) { - // We are not adding service through Taverna service registry's callback and - // findServiceDescriptionsAsync() - - // we are adding directly from the BioCatalogue perspective. - ServiceDescriptionRegistryImpl serviceDescriptionRegistry = ServiceDescriptionRegistryImpl - .getInstance(); - serviceDescriptionRegistry - .addServiceDescriptionProvider(new BioCatalogueWSDLOperationServiceProvider( - wsdlOperationDescription)); - return true; - } else { - // Add the WSDL operation to the Service Panel through the callback - callBack.partialResults(Collections - .singletonList(wsdlOperationDescription)); - callBack.finished(); - return (true); - } - } - - /** - * Adds a SOAP/WSDL service and all of its operations into the Taverna's Service Panel. - */ - public static boolean registerWSDLService(String wsdlURL, FindServiceDescriptionsCallBack callBack) - { - String errorMessage = null; - Exception ex = null; - - List<Operation> operations = null; - List<WSDLOperationFromBioCatalogueServiceDescription> items = null; - - // Do the same thing as in the WSDL service provider - WSDLParser parser = null; - try { - parser = new WSDLParser(wsdlURL); - operations = parser.getOperations(); - items = new ArrayList<WSDLOperationFromBioCatalogueServiceDescription>(); - for (Operation operation : operations) { - WSDLOperationFromBioCatalogueServiceDescription item; - try { - String operationName = operation.getName(); - String operationDesc = parser.getOperationDocumentation(operationName); - String use = parser.getUse(operationName); - String style = parser.getStyle(); - if (!WSDLActivityHealthChecker.checkStyleAndUse(style, use)) { - logger.warn("Unsupported style and use combination " + style + "/" + use + " for operation " + operationName + " from " + wsdlURL); - continue; - } - item = new WSDLOperationFromBioCatalogueServiceDescription(wsdlURL, operationName, operationDesc); - items.add(item); - } catch (UnknownOperationException e) { - errorMessage = "Encountered an unexpected operation name:" - + operation.getName(); - ex = e; - } - } - } catch (ParserConfigurationException e) { - errorMessage = "Error configuring the WSDL parser"; - ex = e; - } catch (WSDLException e) { - errorMessage = "There was an error with the wsdl: " + wsdlURL; - ex = e; - } catch (IOException e) { - errorMessage = "There was an IO error parsing the wsdl: " + wsdlURL - + " Possible reason: the wsdl location was incorrect."; - ex = e; - } catch (SAXException e) { - errorMessage = "There was an error with the XML in the wsdl: " - + wsdlURL; - ex = e; - } catch (IllegalArgumentException e) { // a problem with the wsdl url - errorMessage = "There was an error with the wsdl: " + wsdlURL + " " - + "Possible reason: the wsdl location was incorrect."; - ex = e; - } catch (Exception e) { // anything else we did not expect - errorMessage = "There was an error with the wsdl: " + wsdlURL; - ex = e; - } - - if (callBack == null) { - if (errorMessage != null){ - logger.error(errorMessage, ex); - return false; - } - else{ - // We are not adding service through Taverna service registry's callback and - // findServiceDescriptionsAsync() - - // we are adding directly from the BioCatalogue perspective. - ServiceDescriptionRegistryImpl serviceDescriptionRegistry = ServiceDescriptionRegistryImpl - .getInstance(); - for (WSDLOperationFromBioCatalogueServiceDescription item : items) { - serviceDescriptionRegistry - .addServiceDescriptionProvider(new BioCatalogueWSDLOperationServiceProvider( - item)); - } - return true; - } - } else { - if (errorMessage != null){ - callBack.fail(errorMessage, ex); - return false; - } - else{ - callBack.status("Found " + operations.size() + " WSDL operations of service " - + wsdlURL); - callBack.partialResults(items); - callBack.finished(); - return true; - } - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/RESTFromBioCatalogueServiceDescription.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/RESTFromBioCatalogueServiceDescription.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/RESTFromBioCatalogueServiceDescription.java deleted file mode 100644 index bed6d02..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/RESTFromBioCatalogueServiceDescription.java +++ /dev/null @@ -1,190 +0,0 @@ -package org.apache.taverna.ui.perspectives.biocatalogue.integration.service_panel; -/* - * 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. - */ - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.swing.Icon; - -import org.apache.taverna.lang.beans.PropertyAnnotation; -import org.apache.taverna.servicedescriptions.ServiceDescription; -import org.apache.taverna.workflowmodel.processor.activity.Activity; - -import org.apache.taverna.activities.rest.RESTActivity; -import org.apache.taverna.activities.rest.RESTActivity.DATA_FORMAT; -import org.apache.taverna.activities.rest.RESTActivity.HTTP_METHOD; -import org.apache.taverna.activities.rest.RESTActivityConfigurationBean; -import org.apache.taverna.activities.rest.ui.servicedescription.RESTActivityIcon; - -/** - * This class is solely intended to support import of REST services from BioCatalogue. - * - * @author Sergejs Aleksejevs - */ -public class RESTFromBioCatalogueServiceDescription extends ServiceDescription<RESTActivityConfigurationBean> -{ - private static final int SHORT_DESCRIPTION_MAX_LENGTH = 200; - - private static final String FULL_DESCRIPTION = "Full description"; - - public static final int AMBIGUOUS_ACCEPT_HEADER_VALUE = 100; - public static final int DEFAULT_ACCEPT_HEADER_VALUE = 110; - public static final int AMBIGUOUS_CONTENT_TYPE_HEADER_VALUE = 200; - public static final int DEFAULT_CONTENT_TYPE_HEADER_VALUE = 210; - - - private RESTActivityConfigurationBean serviceConfigBean; - private String serviceName; - private String description; - - private List<Integer> dataWarnings; - - - /** - * Constructor instantiates config bean and pre-populates - * it with default values. - */ - public RESTFromBioCatalogueServiceDescription() - { - // apply default name in case it won't be set manually later - this.serviceName = "REST Service"; - this.serviceConfigBean = RESTActivityConfigurationBean.getDefaultInstance(); - this.dataWarnings = new ArrayList<Integer>(); - } - - /** - * The subclass of Activity which should be instantiated when adding a service - * for this description. - */ - @Override - public Class<? extends Activity<RESTActivityConfigurationBean>> getActivityClass() { - return RESTActivity.class; - } - - /** - * The configuration bean which is to be used for configuring the instantiated activity. - * - * Values are to be set through individual setters provided in this class. - */ - @Override - public RESTActivityConfigurationBean getActivityConfiguration() { - return serviceConfigBean; - } - - /** - * An icon to represent this service type in the service palette. - */ - @Override - public Icon getIcon() { - return RESTActivityIcon.getRESTActivityIcon(); - } - - /** - * The display name that will be shown in service palette and will - * be used as a template for processor name when added to workflow. - */ - @Override - public String getName() { - return serviceName; - } - - - /** - * Truncates the description if necessary to {@link WSDLOperationFromBioCatalogueServiceDescription#SHORT_DESCRIPTION_MAX_LENGTH} -- - * to get full description, use {@link WSDLOperationFromBioCatalogueServiceDescription#getFullDescription()} - */ - public String getDescription() { - if (this.description != null && this.description.length() > SHORT_DESCRIPTION_MAX_LENGTH) { - return (this.description.substring(0, SHORT_DESCRIPTION_MAX_LENGTH) + "(...)"); - } - else { - return this.description; - } - } - - @PropertyAnnotation(displayName = FULL_DESCRIPTION) - public String getFullDescription() { - return this.description; - } - - - /** - * The path to this service description in the service palette. Folders - * will be created for each element of the returned path. - * - * (Shouldn't really be ever used, as instances of different type are - * added into the Service Panel). - */ - @Override - public List<String> getPath() { - // For deeper paths you may return several strings - return Arrays.asList(BioCatalogueRESTServiceProvider.PROVIDER_NAME, "REST @ " + serviceConfigBean.getUrlSignature()); - } - - /** - * Return a list of data values uniquely identifying this service - * description (to avoid duplicates). Include only primary key like fields, - * ie. ignore descriptions, icons, etc. - */ - @Override - protected List<? extends Object> getIdentifyingData() { - return Arrays.<Object>asList(serviceConfigBean.getUrlSignature(), serviceConfigBean.getHttpMethod()); - } - - - public List<Integer> getDataWarnings() { - return dataWarnings; - } - - - public void setURLSignature(String urlSignature) { - this.serviceConfigBean.setUrlSignature(urlSignature); - } - - - public void setHttpMethod(HTTP_METHOD httpMethod) { - this.serviceConfigBean.setHttpMethod(httpMethod); - } - - - public void setAcceptHeaderValue(String acceptHeaderValue) { - this.serviceConfigBean.setAcceptsHeaderValue(acceptHeaderValue); - } - - - public void setOutgoingContentType(String outgoingContentType) - { - this.serviceConfigBean.setUrlSignature(outgoingContentType); - - // automatically infer data format - string/binary from the content type - if (outgoingContentType.startsWith("text")) { this.serviceConfigBean.setOutgoingDataFormat(DATA_FORMAT.String); } - else { this.serviceConfigBean.setOutgoingDataFormat(DATA_FORMAT.Binary); } - } - - - public void setServiceName(String name) { - this.serviceName = name; - } - - - public void setDescription(String description) { - this.description = description; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/WSDLOperationFromBioCatalogueServiceDescription.java ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/WSDLOperationFromBioCatalogueServiceDescription.java b/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/WSDLOperationFromBioCatalogueServiceDescription.java deleted file mode 100644 index f070145..0000000 --- a/taverna-perspective-biocatalogue/src/main/java/org/apache/taverna/ui/perspectives/biocatalogue/integration/service_panel/WSDLOperationFromBioCatalogueServiceDescription.java +++ /dev/null @@ -1,112 +0,0 @@ -package org.apache.taverna.ui.perspectives.biocatalogue.integration.service_panel; -/* - * 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. - */ - -import java.util.Arrays; -import java.util.List; - -import javax.swing.Icon; - -import org.apache.taverna.biocatalogue.model.SoapOperationIdentity; -import org.apache.taverna.activities.wsdl.WSDLActivity; -import org.apache.taverna.activities.wsdl.WSDLActivityConfigurationBean; -import org.apache.taverna.activities.wsdl.servicedescriptions.WSDLActivityIcon; -import org.apache.taverna.lang.beans.PropertyAnnotation; -import org.apache.taverna.servicedescriptions.ServiceDescription; - -public class WSDLOperationFromBioCatalogueServiceDescription extends ServiceDescription<WSDLActivityConfigurationBean> -{ - private static final int SHORT_DESCRIPTION_MAX_LENGTH = 200; - - private static final String FULL_DESCRIPTION = "Full description"; - - - private final String wsdlLocation; - private final String operationName; - private final String description; - - - public WSDLOperationFromBioCatalogueServiceDescription(String wsdlLocation, String operationName, String description) - { - this.wsdlLocation = wsdlLocation; - this.operationName = operationName; - this.description = description; - } - - public WSDLOperationFromBioCatalogueServiceDescription(SoapOperationIdentity soapOpearationIdentity) - { - this.wsdlLocation = soapOpearationIdentity.getWsdlLocation(); - this.operationName = soapOpearationIdentity.getOperationName(); - this.description = soapOpearationIdentity.getDescription(); - } - - - @Override - public Class getActivityClass() { - return WSDLActivity.class; - } - - @Override - public WSDLActivityConfigurationBean getActivityConfiguration() { - WSDLActivityConfigurationBean bean = new WSDLActivityConfigurationBean(); - bean.setOperation(operationName); - bean.setWsdl(wsdlLocation); - return bean; - } - - @Override - public Icon getIcon() { - return WSDLActivityIcon.getWSDLIcon(); - } - - @Override - public String getName() { - return (this.operationName); - } - - /** - * Truncates the description if necessary to {@link WSDLOperationFromBioCatalogueServiceDescription#SHORT_DESCRIPTION_MAX_LENGTH} -- - * to get full description, use {@link WSDLOperationFromBioCatalogueServiceDescription#getFullDescription()} - */ - public String getDescription() { - if (this.description != null && this.description.length() > SHORT_DESCRIPTION_MAX_LENGTH) { - return (this.description.substring(0, SHORT_DESCRIPTION_MAX_LENGTH) + "(...)"); - } - else { - return this.description; - } - } - - @PropertyAnnotation(displayName = FULL_DESCRIPTION) - public String getFullDescription() { - return this.description; - } - - @Override - public List<String> getPath() { - return Arrays.asList(BioCatalogueWSDLOperationServiceProvider.PROVIDER_NAME, "WSDL @ " + this.wsdlLocation); - } - - @Override - protected List<? extends Object> getIdentifyingData() - { - // This is important - Taverna won't add identical operations - // into the Service Panel. These tokens distinguish added items. - return Arrays.asList(wsdlLocation, operationName); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-workbench/blob/52817a33/taverna-perspective-biocatalogue/src/main/resources/META-INF/services/net.sf.taverna.t2.servicedescriptions.ServiceDescriptionProvider ---------------------------------------------------------------------- diff --git a/taverna-perspective-biocatalogue/src/main/resources/META-INF/services/net.sf.taverna.t2.servicedescriptions.ServiceDescriptionProvider b/taverna-perspective-biocatalogue/src/main/resources/META-INF/services/net.sf.taverna.t2.servicedescriptions.ServiceDescriptionProvider deleted file mode 100644 index 0124d85..0000000 --- a/taverna-perspective-biocatalogue/src/main/resources/META-INF/services/net.sf.taverna.t2.servicedescriptions.ServiceDescriptionProvider +++ /dev/null @@ -1,2 +0,0 @@ -org.apache.taverna.ui.perspectives.biocatalogue.integration.service_panel.BioCatalogueWSDLOperationServiceProvider -org.apache.taverna.ui.perspectives.biocatalogue.integration.service_panel.BioCatalogueRESTServiceProvider