http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/messagebroker/src/test/java/org/apache/airavata/wsmg/util/TestUtilServer.java ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/messagebroker/src/test/java/org/apache/airavata/wsmg/util/TestUtilServer.java b/modules/ws-messenger/messagebroker/src/test/java/org/apache/airavata/wsmg/util/TestUtilServer.java deleted file mode 100644 index 29fdbdf..0000000 --- a/modules/ws-messenger/messagebroker/src/test/java/org/apache/airavata/wsmg/util/TestUtilServer.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.wsmg.util; - -import javax.xml.namespace.QName; - -import org.apache.airavata.wsmg.broker.BrokerServiceLifeCycle; -import org.apache.axis2.AxisFault; -import org.apache.axis2.context.ConfigurationContext; -import org.apache.axis2.context.ConfigurationContextFactory; -import org.apache.axis2.description.AxisService; -import org.apache.axis2.description.InOutAxisOperation; -import org.apache.axis2.engine.MessageReceiver; -import org.apache.axis2.engine.ServiceLifeCycle; -import org.apache.axis2.transport.http.SimpleHTTPServer; - -import java.io.IOException; -import java.net.ServerSocket; -import java.nio.channels.ServerSocketChannel; - -public class TestUtilServer { - private static int count = 0; - - private static SimpleHTTPServer receiver; - - public static int TESTING_PORT = 5555; - - public static final String FAILURE_MESSAGE = "Intentional Failure"; - - public static synchronized void deployService(AxisService service) throws AxisFault { - receiver.getConfigurationContext().getAxisConfiguration().addService(service); - } - - public static synchronized void unDeployService(QName service) throws AxisFault { - receiver.getConfigurationContext().getAxisConfiguration().removeService(service.getLocalPart()); - } - - public static synchronized void unDeployClientService() throws AxisFault { - if (receiver.getConfigurationContext().getAxisConfiguration() != null) { - receiver.getConfigurationContext().getAxisConfiguration().removeService("AnonymousService"); - } - } - - public static synchronized void start(String repository, String axis2xml) throws Exception { - if (count == 0) { - ConfigurationContext er = getNewConfigurationContext(repository, axis2xml); - TESTING_PORT = getAvailablePort(); - receiver = new SimpleHTTPServer(er, TESTING_PORT); - - try { - receiver.start(); - System.out.print("Server started on port " + TESTING_PORT + "....."); - } catch (Exception e) { - throw AxisFault.makeFault(e); - } - - try { - Thread.sleep(2000); - } catch (InterruptedException e1) { - throw new AxisFault("Thread interuptted", e1); - } - startBroker(); - } - count++; - } - - public static void startBroker() throws Exception { - - ServiceLifeCycle brokerLifeCycle = new BrokerServiceLifeCycle(); - - final String configFileParam = "configuration.file.name"; - final String configFileValue = "airavata-server.properties"; - - AxisService notificationService = getNotificationService(); - notificationService.addParameter(configFileParam, configFileValue); - notificationService.setServiceLifeCycle(brokerLifeCycle); - TestUtilServer.deployService(notificationService); - brokerLifeCycle.startUp(TestUtilServer.getConfigurationContext(), notificationService); - - AxisService eventingService = getEventingService(); - eventingService.addParameter(configFileParam, configFileValue); - eventingService.setServiceLifeCycle(brokerLifeCycle); - TestUtilServer.deployService(eventingService); - brokerLifeCycle.startUp(TestUtilServer.getConfigurationContext(), eventingService); - - } - - public static AxisService getEventingService() { - - AxisService eventingService = new AxisService("EventingService"); - - createOperation(eventingService, "renew", - new org.apache.airavata.wsmg.broker.wseventing.WSEventingMsgReceiver(), - "http://schemas.xmlsoap.org/ws/2004/08/eventing/Renew", - "http://schemas.xmlsoap.org/ws/2004/08/eventing/RenewResponse"); - createOperation(eventingService, "getStatus", - new org.apache.airavata.wsmg.broker.wseventing.WSEventingMsgReceiver(), - "http://schemas.xmlsoap.org/ws/2004/08/eventing/GetStatus", - "http://schemas.xmlsoap.org/ws/2004/08/eventing/GetStatusResponse"); - - createOperation(eventingService, "subscriptionEnd", - new org.apache.airavata.wsmg.broker.wseventing.WSEventingMsgReceiver(), - "http://schemas.xmlsoap.org/ws/2004/08/eventing/SubscriptionEnd", null); - - createOperation(eventingService, "subscribe", - new org.apache.airavata.wsmg.broker.wseventing.WSEventingMsgReceiver(), - "http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe", - "http://schemas.xmlsoap.org/ws/2004/08/eventing/SubscribeResponse"); - createOperation(eventingService, "unsubscribe", - new org.apache.airavata.wsmg.broker.wseventing.WSEventingMsgReceiver(), - "http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe", - "http://schemas.xmlsoap.org/ws/2004/08/eventing/UnsubscribeResponse"); - createOperation(eventingService, "publish", - new org.apache.airavata.wsmg.broker.wseventing.WSEventingPublishMsgReceiver(), - "http://org.apache.airavata/WseNotification", null); - - return eventingService; - } - - public static AxisService getNotificationService() { - - AxisService notificationService = new AxisService("NotificationService"); - - createOperation(notificationService, "notify", - new org.apache.airavata.wsmg.broker.wsnotification.WSNotificationMsgReceiver(), - "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/Notify", - "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/NotifyResponse"); - - createOperation(notificationService, "subscribe", - new org.apache.airavata.wsmg.broker.wsnotification.WSNotificationMsgReceiver(), - "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/SubscribeRequest", - "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/SubscribeRequestResponse"); - - createOperation(notificationService, "getCurrentMessage", - new org.apache.airavata.wsmg.broker.wsnotification.WSNotificationMsgReceiver(), - "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/GetCurrentMessageRequest", - "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/GetCurrentMessageResponse"); - - createOperation(notificationService, "pauseSubscription", - new org.apache.airavata.wsmg.broker.wsnotification.WSNotificationMsgReceiver(), - "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/PauseSubsriptionRequest", - "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/PauseSubscriptionResponse"); - - createOperation(notificationService, "resumeSubscription", - new org.apache.airavata.wsmg.broker.wsnotification.WSNotificationMsgReceiver(), - "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/ResumeSubsriptionRequest", - "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/ResumeSubscriptionResponse"); - - createOperation(notificationService, "unsubscribe", - new org.apache.airavata.wsmg.broker.wsnotification.WSNotificationMsgReceiver(), - "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/UnsubsribeRequest", - "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification/UnsubscribeResponse"); - - return notificationService; - - } - - public static void createOperation(AxisService axisService, String name, MessageReceiver messageReceiver, - String inputAction, String outputAction) { - InOutAxisOperation operation1 = new InOutAxisOperation(new QName(name)); - operation1.setMessageReceiver(messageReceiver); - operation1.setOutputAction(outputAction); - axisService.addOperation(operation1); - if (inputAction != null) { - axisService.mapActionToOperation(inputAction, operation1); - } - } - - public static ConfigurationContext getNewConfigurationContext(String repository, String axis2xml) throws Exception { - return ConfigurationContextFactory.createConfigurationContextFromFileSystem(repository, axis2xml); - } - - public static synchronized void stop() throws AxisFault { - if (count == 1) { - receiver.stop(); - while (receiver.isRunning()) { - try { - Thread.sleep(1000); - } catch (InterruptedException e1) { - // nothing to do here - } - } - count = 0; - // tp.doStop(); - System.out.print("Server stopped ....."); - } else { - count--; - } - receiver.getConfigurationContext().terminate(); - } - - public static ConfigurationContext getConfigurationContext() { - return receiver.getConfigurationContext(); - } - - public static int getAvailablePort(){ - ServerSocket serverSocket = null; - try { - serverSocket = new ServerSocket(0); - serverSocket.close(); - } catch (IOException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } - return serverSocket.getLocalPort(); - } -}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/messagebroker/src/test/resources/unit_tests.properties ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/messagebroker/src/test/resources/unit_tests.properties b/modules/ws-messenger/messagebroker/src/test/resources/unit_tests.properties deleted file mode 100644 index 33b6161..0000000 --- a/modules/ws-messenger/messagebroker/src/test/resources/unit_tests.properties +++ /dev/null @@ -1,24 +0,0 @@ -# -# -# 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. -# -# -consumer.port=2222 -consumer.location=http://localhost:2222 -topic.simple=MySimpleTestTopic -topic.xpath=MyXpathTextTopic http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/pom.xml ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/pom.xml b/modules/ws-messenger/pom.xml deleted file mode 100644 index d994c89..0000000 --- a/modules/ws-messenger/pom.xml +++ /dev/null @@ -1,162 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!--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. --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <parent> - <groupId>org.apache.airavata</groupId> - <artifactId>airavata</artifactId> - <version>0.15-SNAPSHOT</version> - <relativePath>../../pom.xml</relativePath> - </parent> - - <modelVersion>4.0.0</modelVersion> - <artifactId>airavata-ws-messenger</artifactId> - <packaging>pom</packaging> - <name>Airavata WS Messenger</name> - <url>http://airavata.apache.org/</url> - - <dependencyManagement> - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.7</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.apache.ws.commons.axiom</groupId> - <artifactId>axiom-api</artifactId> - <version>1.2.8</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.apache.ws.commons.axiom</groupId> - <artifactId>axiom-impl</artifactId> - <type>jar</type> - <version>1.2.8</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.apache.axis2</groupId> - <artifactId>axis2</artifactId> - <version>${axis2.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - <version>3.0.1</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>${slf4j.version}</version> - </dependency> - <dependency> - <groupId>mysql</groupId> - <artifactId>mysql-connector-java</artifactId> - <version>${mysql.connector.version}</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.apache.axis2</groupId> - <artifactId>axis2-transport-local</artifactId> - <version>${axis2.version}</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.apache.axis2</groupId> - <artifactId>axis2-transport-http</artifactId> - <version>${axis2.version}</version> - <scope>compile</scope> - </dependency> - - </dependencies> - </dependencyManagement> - - <profiles> - <profile> - <id>profile-messenger-client</id> - <activation> - <property> - <name>module</name> - <value>client</value> - </property> - </activation> - <modules> - <module>commons</module> - <module>client</module> - </modules> - </profile> - <profile> - <id>profile-messagebox</id> - <activation> - <property> - <name>module</name> - <value>messagebox</value> - </property> - </activation> - <modules> - <module>commons</module> - <module>messagebox</module> - </modules> - </profile> - <profile> - <id>profile-messagebroker</id> - <activation> - <property> - <name>module</name> - <value>messagebroker</value> - </property> - </activation> - <modules> - <module>commons</module> - <module>messagebroker</module> - </modules> - </profile> - <profile> - <id>profile-messenger</id> - <activation> - <property> - <name>module</name> - <value>messenger</value> - </property> - </activation> - <modules> - <module>messenger</module> - </modules> - </profile> - <profile> - <id>default</id> - <activation> - <activeByDefault>true</activeByDefault> - </activation> - <modules> - <module>commons</module> - <module>client</module> - <module>message-monitor</module> - </modules> - </profile> - </profiles> - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <slf4j.version>1.6.1</slf4j.version> - <release.version>1.1.1</release.version> - <axis2.version>1.5.1</axis2.version> - <derby.version>10.7.1.1</derby.version> - </properties> - -</project> http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/jython/lib/NotificationSender.java ---------------------------------------------------------------------- diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/jython/lib/NotificationSender.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/jython/lib/NotificationSender.java index f478e18..9b26fee 100644 --- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/jython/lib/NotificationSender.java +++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/jython/lib/NotificationSender.java @@ -1,289 +1,289 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.xbaya.jython.lib; - -import java.net.URI; -import java.util.Properties; - -import org.apache.airavata.common.utils.StringUtil; -import org.apache.airavata.common.utils.XMLUtil; -import org.apache.airavata.workflow.tracking.NotifierFactory; -import org.apache.airavata.workflow.tracking.WorkflowNotifier; -import org.apache.airavata.workflow.tracking.common.InvocationContext; -import org.apache.airavata.workflow.tracking.common.InvocationEntity; -import org.apache.airavata.workflow.tracking.common.WorkflowTrackingContext; -import org.apache.axis2.addressing.EndpointReference; -import org.python.core.PyObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.xmlpull.infoset.XmlElement; - -public class NotificationSender implements WorkflowNotifiable { - - protected static final Logger logger = LoggerFactory.getLogger(NotificationSender.class); - - protected WorkflowNotifier notifier; - - protected String brokerURL; - - protected String topic; - - protected URI workflowID; - - protected InvocationEntity initiator; - - protected InvocationEntity receiver; - - protected InvocationContext invocationContext; - - protected EndpointReference eventSink; - - protected WorkflowTrackingContext context; - - /** - * Constructs a NotificationSender. - * - * @param brokerURL - * @param topic - */ - public NotificationSender(URI brokerURL, String topic) { - this(brokerURL.toString(), topic); - } - - /** - * Creates a NotificationSender. - * - * @param brokerURL - * The location of notification brokerUrl. - * @param topic - * The notification topic. - */ - public NotificationSender(String brokerURL, String topic) { - logger.debug("brokerURL:" + brokerURL + "topic:" + topic); - this.topic = topic; - this.brokerURL = brokerURL; - this.workflowID = URI.create(StringUtil.convertToJavaIdentifier(this.topic)); - this.eventSink = new EndpointReference(this.brokerURL); - Properties props = new Properties(); - - this.notifier = NotifierFactory.createNotifier(); - URI initiatorWorkflowID = null; - URI initiatorServiceID = URI.create(StringUtil.convertToJavaIdentifier(topic)); - String initiatorWorkflowNodeID = null; - Integer initiatorWorkflowTimeStep = null; - this.context = this.notifier.createTrackingContext(props, brokerURL, initiatorWorkflowID, initiatorServiceID, - initiatorWorkflowNodeID, initiatorWorkflowTimeStep); - this.context.setTopic(topic); - this.initiator = this.notifier.createEntity(initiatorWorkflowID, initiatorServiceID, initiatorWorkflowNodeID, - initiatorWorkflowTimeStep); - - URI receiverWorkflowID = this.workflowID; - URI receiverServiceID = this.workflowID; - String receiverWorkflowNodeID = null; - Integer receiverWorkflowTimeStep = null; - this.receiver = this.notifier.createEntity(receiverWorkflowID, receiverServiceID, receiverWorkflowNodeID, - receiverWorkflowTimeStep); - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#getEventSink() - */ - @Override - public EndpointReference getEventSink() { - return this.eventSink; - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#workflowStarted(org.python.core.PyObject[], - * java.lang.String[]) - */ - @Override - public void workflowStarted(PyObject[] args, String[] keywords) { - String message = ""; - for (int i = 0; i < args.length; i++) { - if (i != 0) { - message += ", "; - } - message += keywords[i] + "=" + args[i]; - } - this.invocationContext = this.notifier.workflowInvoked(this.context, this.initiator, message); - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#workflowStarted(java.lang.Object[], - * java.lang.String[]) - */ - @Override - public void workflowStarted(Object[] args, String[] keywords) { - String message = ""; - for (int i = 0; i < args.length; i++) { - if (i != 0) { - message += ", "; - } - message += keywords[i] + "=" + args[i]; - } - this.invocationContext = this.notifier.workflowInvoked(this.context, this.initiator, message); - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#workflowFinished(java.lang.Object[], - * java.lang.String[]) - */ - @Override - public void workflowFinished(Object[] args, String[] keywords) { - String message = ""; - for (int i = 0; i < args.length; i++) { - if (i != 0) { - message += ", "; - } - message += keywords[i] + "=" + args[i]; - } - this.notifier.sendingResult(context, this.invocationContext, message); - this.notifier.workflowTerminated(context, this.workflowID, "Workflow finished successfully."); - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#sendingPartialResults(java.lang.Object[], - * java.lang.String[]) - */ - @Override - public void sendingPartialResults(Object[] args, String[] keywords) { - String message = ""; - for (int i = 0; i < args.length; i++) { - if (i != 0) { - message += ", "; - } - message += keywords[i] + "=" + args[i]; - } - this.notifier.sendingResult(context, this.invocationContext, message); - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#workflowFinished(org.python.core.PyObject[], - * java.lang.String[]) - */ - @Override - public void workflowFinished(PyObject[] args, String[] keywords) { - String message = ""; - for (int i = 0; i < args.length; i++) { - if (i != 0) { - message += ", "; - } - message += keywords[i] + "=" + args[i]; - } - this.notifier.sendingResult(context, this.invocationContext, message); - this.notifier.workflowTerminated(context, this.workflowID, "Workflow Execution Finished."); - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#workflowTerminated() - */ - @Override - public void workflowTerminated() { - this.notifier.workflowTerminated(context, this.workflowID, "Workflow Execution Finished."); - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#workflowFailed(java.lang.String) - */ - @Override - public void workflowFailed(String message) { - workflowFailed(message, null); - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#workflowFailed(java.lang.Throwable) - */ - @Override - public void workflowFailed(Throwable e) { - workflowFailed(null, e); - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#workflowFailed(java.lang.String, - * java.lang.Throwable) - */ - @Override - public void workflowFailed(String message, Throwable e) { - if(e != null) - logger.error(e.getMessage(), e); - if (message == null || "".equals(message)) { - message = "Error"; - } - if (e != null) { - message += ": " + e.toString(); - } - if (e != null) { - String stackTrace = StringUtil.getStackTraceInString(e); - XmlElement stackTraceElement = XMLUtil.BUILDER.newFragment("stackTrace"); - stackTraceElement.addChild(stackTrace); - this.notifier.sendingFault(context, this.invocationContext, message, - XMLUtil.xmlElementToString(stackTraceElement)); - } else { - this.notifier.sendingFault(context, this.invocationContext, message); - } - } - - public void info(String message) { - this.notifier.info(context, message); - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#createServiceNotificationSender(java.lang.String) - */ - @Override - public ServiceNotifiable createServiceNotificationSender(String nodeID) { - return new ServiceNotificationSender(this.notifier, this.eventSink, this.initiator, this.workflowID, nodeID, - this.context,this.invocationContext); - } - - @Override - public void cleanup(){ - this.notifier.delete(); - } - - public String getTopic() { - return topic; - } -} \ No newline at end of file +///* +// * +// * Licensed to the Apache Software Foundation (ASF) under one +// * or more contributor license agreements. See the NOTICE file +// * distributed with this work for additional information +// * regarding copyright ownership. The ASF licenses this file +// * to you under the Apache License, Version 2.0 (the +// * "License"); you may not use this file except in compliance +// * with the License. You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, +// * software distributed under the License is distributed on an +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// * KIND, either express or implied. See the License for the +// * specific language governing permissions and limitations +// * under the License. +// * +// */ +// +//package org.apache.airavata.xbaya.jython.lib; +// +//import java.net.URI; +//import java.util.Properties; +// +//import org.apache.airavata.common.utils.StringUtil; +//import org.apache.airavata.common.utils.XMLUtil; +//import org.apache.airavata.workflow.tracking.NotifierFactory; +//import org.apache.airavata.workflow.tracking.WorkflowNotifier; +//import org.apache.airavata.workflow.tracking.common.InvocationContext; +//import org.apache.airavata.workflow.tracking.common.InvocationEntity; +//import org.apache.airavata.workflow.tracking.common.WorkflowTrackingContext; +//import org.apache.axis2.addressing.EndpointReference; +//import org.python.core.PyObject; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.xmlpull.infoset.XmlElement; +// +//public class NotificationSender implements WorkflowNotifiable { +// +// protected static final Logger logger = LoggerFactory.getLogger(NotificationSender.class); +// +// protected WorkflowNotifier notifier; +// +// protected String brokerURL; +// +// protected String topic; +// +// protected URI workflowID; +// +// protected InvocationEntity initiator; +// +// protected InvocationEntity receiver; +// +// protected InvocationContext invocationContext; +// +// protected EndpointReference eventSink; +// +// protected WorkflowTrackingContext context; +// +// /** +// * Constructs a NotificationSender. +// * +// * @param brokerURL +// * @param topic +// */ +// public NotificationSender(URI brokerURL, String topic) { +// this(brokerURL.toString(), topic); +// } +// +// /** +// * Creates a NotificationSender. +// * +// * @param brokerURL +// * The location of notification brokerUrl. +// * @param topic +// * The notification topic. +// */ +// public NotificationSender(String brokerURL, String topic) { +// logger.debug("brokerURL:" + brokerURL + "topic:" + topic); +// this.topic = topic; +// this.brokerURL = brokerURL; +// this.workflowID = URI.create(StringUtil.convertToJavaIdentifier(this.topic)); +// this.eventSink = new EndpointReference(this.brokerURL); +// Properties props = new Properties(); +// +// this.notifier = NotifierFactory.createNotifier(); +// URI initiatorWorkflowID = null; +// URI initiatorServiceID = URI.create(StringUtil.convertToJavaIdentifier(topic)); +// String initiatorWorkflowNodeID = null; +// Integer initiatorWorkflowTimeStep = null; +// this.context = this.notifier.createTrackingContext(props, brokerURL, initiatorWorkflowID, initiatorServiceID, +// initiatorWorkflowNodeID, initiatorWorkflowTimeStep); +// this.context.setTopic(topic); +// this.initiator = this.notifier.createEntity(initiatorWorkflowID, initiatorServiceID, initiatorWorkflowNodeID, +// initiatorWorkflowTimeStep); +// +// URI receiverWorkflowID = this.workflowID; +// URI receiverServiceID = this.workflowID; +// String receiverWorkflowNodeID = null; +// Integer receiverWorkflowTimeStep = null; +// this.receiver = this.notifier.createEntity(receiverWorkflowID, receiverServiceID, receiverWorkflowNodeID, +// receiverWorkflowTimeStep); +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#getEventSink() +// */ +// @Override +// public EndpointReference getEventSink() { +// return this.eventSink; +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#workflowStarted(org.python.core.PyObject[], +// * java.lang.String[]) +// */ +// @Override +// public void workflowStarted(PyObject[] args, String[] keywords) { +// String message = ""; +// for (int i = 0; i < args.length; i++) { +// if (i != 0) { +// message += ", "; +// } +// message += keywords[i] + "=" + args[i]; +// } +// this.invocationContext = this.notifier.workflowInvoked(this.context, this.initiator, message); +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#workflowStarted(java.lang.Object[], +// * java.lang.String[]) +// */ +// @Override +// public void workflowStarted(Object[] args, String[] keywords) { +// String message = ""; +// for (int i = 0; i < args.length; i++) { +// if (i != 0) { +// message += ", "; +// } +// message += keywords[i] + "=" + args[i]; +// } +// this.invocationContext = this.notifier.workflowInvoked(this.context, this.initiator, message); +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#workflowFinished(java.lang.Object[], +// * java.lang.String[]) +// */ +// @Override +// public void workflowFinished(Object[] args, String[] keywords) { +// String message = ""; +// for (int i = 0; i < args.length; i++) { +// if (i != 0) { +// message += ", "; +// } +// message += keywords[i] + "=" + args[i]; +// } +// this.notifier.sendingResult(context, this.invocationContext, message); +// this.notifier.workflowTerminated(context, this.workflowID, "Workflow finished successfully."); +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#sendingPartialResults(java.lang.Object[], +// * java.lang.String[]) +// */ +// @Override +// public void sendingPartialResults(Object[] args, String[] keywords) { +// String message = ""; +// for (int i = 0; i < args.length; i++) { +// if (i != 0) { +// message += ", "; +// } +// message += keywords[i] + "=" + args[i]; +// } +// this.notifier.sendingResult(context, this.invocationContext, message); +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#workflowFinished(org.python.core.PyObject[], +// * java.lang.String[]) +// */ +// @Override +// public void workflowFinished(PyObject[] args, String[] keywords) { +// String message = ""; +// for (int i = 0; i < args.length; i++) { +// if (i != 0) { +// message += ", "; +// } +// message += keywords[i] + "=" + args[i]; +// } +// this.notifier.sendingResult(context, this.invocationContext, message); +// this.notifier.workflowTerminated(context, this.workflowID, "Workflow Execution Finished."); +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#workflowTerminated() +// */ +// @Override +// public void workflowTerminated() { +// this.notifier.workflowTerminated(context, this.workflowID, "Workflow Execution Finished."); +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#workflowFailed(java.lang.String) +// */ +// @Override +// public void workflowFailed(String message) { +// workflowFailed(message, null); +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#workflowFailed(java.lang.Throwable) +// */ +// @Override +// public void workflowFailed(Throwable e) { +// workflowFailed(null, e); +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#workflowFailed(java.lang.String, +// * java.lang.Throwable) +// */ +// @Override +// public void workflowFailed(String message, Throwable e) { +// if(e != null) +// logger.error(e.getMessage(), e); +// if (message == null || "".equals(message)) { +// message = "Error"; +// } +// if (e != null) { +// message += ": " + e.toString(); +// } +// if (e != null) { +// String stackTrace = StringUtil.getStackTraceInString(e); +// XmlElement stackTraceElement = XMLUtil.BUILDER.newFragment("stackTrace"); +// stackTraceElement.addChild(stackTrace); +// this.notifier.sendingFault(context, this.invocationContext, message, +// XMLUtil.xmlElementToString(stackTraceElement)); +// } else { +// this.notifier.sendingFault(context, this.invocationContext, message); +// } +// } +// +// public void info(String message) { +// this.notifier.info(context, message); +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.WorkflowNotifiable#createServiceNotificationSender(java.lang.String) +// */ +// @Override +// public ServiceNotifiable createServiceNotificationSender(String nodeID) { +// return new ServiceNotificationSender(this.notifier, this.eventSink, this.initiator, this.workflowID, nodeID, +// this.context,this.invocationContext); +// } +// +// @Override +// public void cleanup(){ +// this.notifier.delete(); +// } +// +// public String getTopic() { +// return topic; +// } +//} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/jython/lib/ServiceNotificationSender.java ---------------------------------------------------------------------- diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/jython/lib/ServiceNotificationSender.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/jython/lib/ServiceNotificationSender.java index 36b79bf..1c44c33 100644 --- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/jython/lib/ServiceNotificationSender.java +++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/jython/lib/ServiceNotificationSender.java @@ -1,293 +1,293 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.xbaya.jython.lib; - -import java.net.URI; -import java.util.Iterator; - -import org.apache.airavata.common.utils.StringUtil; -import org.apache.airavata.common.utils.XMLUtil; -import org.apache.airavata.workflow.tracking.WorkflowNotifier; -import org.apache.airavata.workflow.tracking.common.InvocationContext; -import org.apache.airavata.workflow.tracking.common.InvocationEntity; -import org.apache.airavata.workflow.tracking.common.WorkflowTrackingContext; -import org.apache.airavata.workflow.tracking.impl.state.InvocationContextImpl; -import org.apache.axis2.addressing.EndpointReference; -import org.apache.xmlbeans.XmlException; -import org.apache.xmlbeans.XmlObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.xmlpull.infoset.XmlElement; - -import xsul.wsif.WSIFMessage; - -public class ServiceNotificationSender implements ServiceNotifiable { - - private static final Logger logger = LoggerFactory.getLogger(ServiceNotificationSender.class); - - private WorkflowNotifier notifier; - - private URI workflowID; - - private String nodeID; - - private String serviceID; - - private InvocationEntity receiver; - - private InvocationEntity initiator; - - private InvocationContext invocationContext; - - private WorkflowTrackingContext context; - - private EndpointReference eventSink; - - /** - * Constructs a ServiceNotificationSender. - * - * @param notifier - * @param eventSink - * @param initiator - * @param workflowID - * @param nodeID - */ - protected ServiceNotificationSender(WorkflowNotifier notifier, EndpointReference eventSink, - InvocationEntity initiator, URI workflowID, String nodeID, WorkflowTrackingContext context, InvocationContext invocationContext) { - this.notifier = notifier; - this.eventSink = eventSink; - this.initiator = initiator; - this.workflowID = workflowID; - this.nodeID = nodeID; - this.context = context; - // In case of creating a service on the fly, there is no serviceID at - // the beginning. - this.serviceID = ""; - this.invocationContext = invocationContext; - URI receiverWorkflowID = this.workflowID; - URI receiverServiceID = URI.create(this.serviceID); - String receiverWorkflowNodeID = this.nodeID; - Integer workflowTimeStep = new Integer(0); - this.receiver = this.notifier.createEntity(receiverWorkflowID, receiverServiceID, receiverWorkflowNodeID, - workflowTimeStep); - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.ServiceNotifiable#setServiceID(java.lang.String) - */ - @Override - public void setServiceID(String serviceID) { - logger.debug("SerivceID:" + serviceID); - this.serviceID = serviceID; - - URI receiverWorkflowID = this.workflowID; - URI receiverServiceID = URI.create(this.serviceID); - String receiverWorkflowNodeID = this.nodeID; - Integer workflowTimeStep = new Integer(0); - this.receiver = this.notifier.createEntity(receiverWorkflowID, receiverServiceID, receiverWorkflowNodeID, - workflowTimeStep); - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.ServiceNotifiable#getEventSink() - */ - @Override - public EndpointReference getEventSink() { - return this.eventSink; - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.ServiceNotifiable#getWorkflowID() - */ - @Override - public URI getWorkflowID() { - return this.workflowID; - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.ServiceNotifiable#invokingService(xsul.wsif.WSIFMessage) - */ - @Override - public void invokingService(WSIFMessage inputs) { - String message = ""; - Iterator partIt = inputs.partNames().iterator(); - boolean first = true; - while (partIt.hasNext()) { - if (first) { - first = false; - } else { - message += ", "; - } - - String name = (String) partIt.next(); - Object value = inputs.getObjectPart(name); - if(value instanceof org.xmlpull.v1.builder.XmlElement){ - message += name + "="; - Iterator children = ((org.xmlpull.v1.builder.XmlElement) value).children(); - while (children.hasNext()){ - message += children.next(); - } - }else{ - message += name + "=" + value; - } - } - XmlObject header = null; - XmlObject body; - try { - body = XmlObject.Factory.parse(inputs.toString()); - } catch (XmlException e) { - logger.warn("Failed to parse " + inputs.toString(), e); - body = null; // Send notification anyway. - } - this.invocationContext = this.notifier.invokingService(this.context, this.receiver, header, body, message); - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.ServiceNotifiable#serviceFinished(xsul.wsif.WSIFMessage) - */ - @Override - public void serviceFinished(WSIFMessage outputs) { - String message = ""; - Iterator partIt = outputs.partNames().iterator(); - boolean first = true; - while (partIt.hasNext()) { - if (first) { - first = false; - } else { - message += ", "; - } - String name = (String) partIt.next(); - Object value = outputs.getObjectPart(name); - if(value instanceof org.xmlpull.v1.builder.XmlElement){ - message += name + "="; - Iterator children = ((org.xmlpull.v1.builder.XmlElement) value).children(); - while (children.hasNext()){ - message += children.next(); - } - }else{ - message += name + "=" + value; - } - } - XmlObject header = null; - XmlObject body; - try { - body = XmlObject.Factory.parse(outputs.toString()); - } catch (XmlException e) { - logger.warn("Failed to parse " + outputs.toString(), e); - body = null; // Send notification anyway. - } - this.notifier.receivedResult(this.context, this.invocationContext, header, body, message); - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.ServiceNotifiable#invocationFailed(java.lang.String, - * java.lang.Throwable) - */ - @Override - public void invocationFailed(String message, Throwable e) { - - // TODO there are two types of error messages. - // The first one is while creating a service. (No API) - // The second is while invoking a service. - // e.g. notifier.invokingServiceFailed(). - - // XXX If error occurs before invoking a service, create a fake - // invocation context. - if (this.invocationContext == null) { - this.invocationContext = new InvocationContextImpl(this.initiator, this.receiver); - } - - logger.error(e.getMessage(), e); - if (message == null || "".equals(message)) { - message = "Error"; - } - if (e != null) { - message += ": " + e.toString(); - } - if (e != null) { - String stackTrace = StringUtil.getStackTraceInString(e); - XmlElement stackTraceElement = XMLUtil.BUILDER.newFragment("stackTrace"); - stackTraceElement.addChild(stackTrace); - String annotation = XMLUtil.xmlElementToString(stackTraceElement); - this.notifier.invokingServiceFailed(this.context, this.invocationContext, e, message, annotation); - } else { - this.notifier.invokingServiceFailed(this.context, this.invocationContext, message); - } - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.ServiceNotifiable#receivedFault(java.lang.String) - */ - @Override - @Deprecated - public void receivedFault(String message) { - // XXX If error occurs before invoking a service, create a fake - // invocation context. - if (this.invocationContext == null) { - this.invocationContext = new InvocationContextImpl(this.initiator, this.receiver); - } - - if (message == null || "".equals(message)) { - message = "Error"; - } - this.notifier.receivedFault(this.context, this.invocationContext, message); - } - - /* - * (non-Javadoc) - * - * @see org.apache.airavata.xbaya.jython.lib.ServiceNotifiable#receivedFault(xsul.wsif.WSIFMessage) - */ - @Override - public void receivedFault(WSIFMessage fault) { - // XXX If error occurs before invoking a service, create a fake - // invocation context. - if (this.invocationContext == null) { - this.invocationContext = new InvocationContextImpl(this.initiator, this.receiver); - } - - String message = "Received a fault message from the service"; - XmlObject header = null; - XmlObject body; - try { - body = XmlObject.Factory.parse(fault.toString()); - } catch (XmlException e) { - logger.warn("Failed to parse " + fault.toString(), e); - body = null; // Send notification anyway. - } - this.notifier.receivedFault(this.context, this.invocationContext, header, body, message); - } -} \ No newline at end of file +///* +// * +// * Licensed to the Apache Software Foundation (ASF) under one +// * or more contributor license agreements. See the NOTICE file +// * distributed with this work for additional information +// * regarding copyright ownership. The ASF licenses this file +// * to you under the Apache License, Version 2.0 (the +// * "License"); you may not use this file except in compliance +// * with the License. You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, +// * software distributed under the License is distributed on an +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// * KIND, either express or implied. See the License for the +// * specific language governing permissions and limitations +// * under the License. +// * +// */ +// +//package org.apache.airavata.xbaya.jython.lib; +// +//import java.net.URI; +//import java.util.Iterator; +// +//import org.apache.airavata.common.utils.StringUtil; +//import org.apache.airavata.common.utils.XMLUtil; +//import org.apache.airavata.workflow.tracking.WorkflowNotifier; +//import org.apache.airavata.workflow.tracking.common.InvocationContext; +//import org.apache.airavata.workflow.tracking.common.InvocationEntity; +//import org.apache.airavata.workflow.tracking.common.WorkflowTrackingContext; +//import org.apache.airavata.workflow.tracking.impl.state.InvocationContextImpl; +//import org.apache.axis2.addressing.EndpointReference; +//import org.apache.xmlbeans.XmlException; +//import org.apache.xmlbeans.XmlObject; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.xmlpull.infoset.XmlElement; +// +//import xsul.wsif.WSIFMessage; +// +//public class ServiceNotificationSender implements ServiceNotifiable { +// +// private static final Logger logger = LoggerFactory.getLogger(ServiceNotificationSender.class); +// +// private WorkflowNotifier notifier; +// +// private URI workflowID; +// +// private String nodeID; +// +// private String serviceID; +// +// private InvocationEntity receiver; +// +// private InvocationEntity initiator; +// +// private InvocationContext invocationContext; +// +// private WorkflowTrackingContext context; +// +// private EndpointReference eventSink; +// +// /** +// * Constructs a ServiceNotificationSender. +// * +// * @param notifier +// * @param eventSink +// * @param initiator +// * @param workflowID +// * @param nodeID +// */ +// protected ServiceNotificationSender(WorkflowNotifier notifier, EndpointReference eventSink, +// InvocationEntity initiator, URI workflowID, String nodeID, WorkflowTrackingContext context, InvocationContext invocationContext) { +// this.notifier = notifier; +// this.eventSink = eventSink; +// this.initiator = initiator; +// this.workflowID = workflowID; +// this.nodeID = nodeID; +// this.context = context; +// // In case of creating a service on the fly, there is no serviceID at +// // the beginning. +// this.serviceID = ""; +// this.invocationContext = invocationContext; +// URI receiverWorkflowID = this.workflowID; +// URI receiverServiceID = URI.create(this.serviceID); +// String receiverWorkflowNodeID = this.nodeID; +// Integer workflowTimeStep = new Integer(0); +// this.receiver = this.notifier.createEntity(receiverWorkflowID, receiverServiceID, receiverWorkflowNodeID, +// workflowTimeStep); +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.ServiceNotifiable#setServiceID(java.lang.String) +// */ +// @Override +// public void setServiceID(String serviceID) { +// logger.debug("SerivceID:" + serviceID); +// this.serviceID = serviceID; +// +// URI receiverWorkflowID = this.workflowID; +// URI receiverServiceID = URI.create(this.serviceID); +// String receiverWorkflowNodeID = this.nodeID; +// Integer workflowTimeStep = new Integer(0); +// this.receiver = this.notifier.createEntity(receiverWorkflowID, receiverServiceID, receiverWorkflowNodeID, +// workflowTimeStep); +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.ServiceNotifiable#getEventSink() +// */ +// @Override +// public EndpointReference getEventSink() { +// return this.eventSink; +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.ServiceNotifiable#getWorkflowID() +// */ +// @Override +// public URI getWorkflowID() { +// return this.workflowID; +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.ServiceNotifiable#invokingService(xsul.wsif.WSIFMessage) +// */ +// @Override +// public void invokingService(WSIFMessage inputs) { +// String message = ""; +// Iterator partIt = inputs.partNames().iterator(); +// boolean first = true; +// while (partIt.hasNext()) { +// if (first) { +// first = false; +// } else { +// message += ", "; +// } +// +// String name = (String) partIt.next(); +// Object value = inputs.getObjectPart(name); +// if(value instanceof org.xmlpull.v1.builder.XmlElement){ +// message += name + "="; +// Iterator children = ((org.xmlpull.v1.builder.XmlElement) value).children(); +// while (children.hasNext()){ +// message += children.next(); +// } +// }else{ +// message += name + "=" + value; +// } +// } +// XmlObject header = null; +// XmlObject body; +// try { +// body = XmlObject.Factory.parse(inputs.toString()); +// } catch (XmlException e) { +// logger.warn("Failed to parse " + inputs.toString(), e); +// body = null; // Send notification anyway. +// } +// this.invocationContext = this.notifier.invokingService(this.context, this.receiver, header, body, message); +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.ServiceNotifiable#serviceFinished(xsul.wsif.WSIFMessage) +// */ +// @Override +// public void serviceFinished(WSIFMessage outputs) { +// String message = ""; +// Iterator partIt = outputs.partNames().iterator(); +// boolean first = true; +// while (partIt.hasNext()) { +// if (first) { +// first = false; +// } else { +// message += ", "; +// } +// String name = (String) partIt.next(); +// Object value = outputs.getObjectPart(name); +// if(value instanceof org.xmlpull.v1.builder.XmlElement){ +// message += name + "="; +// Iterator children = ((org.xmlpull.v1.builder.XmlElement) value).children(); +// while (children.hasNext()){ +// message += children.next(); +// } +// }else{ +// message += name + "=" + value; +// } +// } +// XmlObject header = null; +// XmlObject body; +// try { +// body = XmlObject.Factory.parse(outputs.toString()); +// } catch (XmlException e) { +// logger.warn("Failed to parse " + outputs.toString(), e); +// body = null; // Send notification anyway. +// } +// this.notifier.receivedResult(this.context, this.invocationContext, header, body, message); +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.ServiceNotifiable#invocationFailed(java.lang.String, +// * java.lang.Throwable) +// */ +// @Override +// public void invocationFailed(String message, Throwable e) { +// +// // TODO there are two types of error messages. +// // The first one is while creating a service. (No API) +// // The second is while invoking a service. +// // e.g. notifier.invokingServiceFailed(). +// +// // XXX If error occurs before invoking a service, create a fake +// // invocation context. +// if (this.invocationContext == null) { +// this.invocationContext = new InvocationContextImpl(this.initiator, this.receiver); +// } +// +// logger.error(e.getMessage(), e); +// if (message == null || "".equals(message)) { +// message = "Error"; +// } +// if (e != null) { +// message += ": " + e.toString(); +// } +// if (e != null) { +// String stackTrace = StringUtil.getStackTraceInString(e); +// XmlElement stackTraceElement = XMLUtil.BUILDER.newFragment("stackTrace"); +// stackTraceElement.addChild(stackTrace); +// String annotation = XMLUtil.xmlElementToString(stackTraceElement); +// this.notifier.invokingServiceFailed(this.context, this.invocationContext, e, message, annotation); +// } else { +// this.notifier.invokingServiceFailed(this.context, this.invocationContext, message); +// } +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.ServiceNotifiable#receivedFault(java.lang.String) +// */ +// @Override +// @Deprecated +// public void receivedFault(String message) { +// // XXX If error occurs before invoking a service, create a fake +// // invocation context. +// if (this.invocationContext == null) { +// this.invocationContext = new InvocationContextImpl(this.initiator, this.receiver); +// } +// +// if (message == null || "".equals(message)) { +// message = "Error"; +// } +// this.notifier.receivedFault(this.context, this.invocationContext, message); +// } +// +// /* +// * (non-Javadoc) +// * +// * @see org.apache.airavata.xbaya.jython.lib.ServiceNotifiable#receivedFault(xsul.wsif.WSIFMessage) +// */ +// @Override +// public void receivedFault(WSIFMessage fault) { +// // XXX If error occurs before invoking a service, create a fake +// // invocation context. +// if (this.invocationContext == null) { +// this.invocationContext = new InvocationContextImpl(this.initiator, this.receiver); +// } +// +// String message = "Received a fault message from the service"; +// XmlObject header = null; +// XmlObject body; +// try { +// body = XmlObject.Factory.parse(fault.toString()); +// } catch (XmlException e) { +// logger.warn("Failed to parse " + fault.toString(), e); +// body = null; // Send notification anyway. +// } +// this.notifier.receivedFault(this.context, this.invocationContext, header, body, message); +// } +//} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/Listener.java ---------------------------------------------------------------------- diff --git a/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/Listener.java b/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/Listener.java index 4298692..2d5af0b 100644 --- a/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/Listener.java +++ b/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/Listener.java @@ -1,32 +1,32 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.xbaya.interpreter; - - -import org.apache.airavata.xbaya.messaging.NotificationHandler; - -public class Listener implements NotificationHandler { - - public void handleNotification(String message) { - System.out.println("MessageRecieved: " + message); - } - -} +///* +// * +// * Licensed to the Apache Software Foundation (ASF) under one +// * or more contributor license agreements. See the NOTICE file +// * distributed with this work for additional information +// * regarding copyright ownership. The ASF licenses this file +// * to you under the Apache License, Version 2.0 (the +// * "License"); you may not use this file except in compliance +// * with the License. You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, +// * software distributed under the License is distributed on an +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// * KIND, either express or implied. See the License for the +// * specific language governing permissions and limitations +// * under the License. +// * +//*/ +//package org.apache.airavata.xbaya.interpreter; +// +// +//import org.apache.airavata.xbaya.messaging.NotificationHandler; +// +//public class Listener implements NotificationHandler { +// +// public void handleNotification(String message) { +// System.out.println("MessageRecieved: " + message); +// } +// +//} http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/NotificationSender.java ---------------------------------------------------------------------- diff --git a/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/NotificationSender.java b/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/NotificationSender.java index 261b07f..d953e84 100644 --- a/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/NotificationSender.java +++ b/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/NotificationSender.java @@ -1,204 +1,204 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ -package org.apache.airavata.xbaya.interpreter; - - -import org.apache.airavata.workflow.tracking.NotifierFactory; -import org.apache.airavata.workflow.tracking.WorkflowNotifier; -import org.apache.airavata.workflow.tracking.common.InvocationContext; -import org.apache.airavata.workflow.tracking.common.InvocationEntity; -import org.apache.airavata.workflow.tracking.common.WorkflowTrackingContext; -import org.apache.axis2.addressing.EndpointReference; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.net.URI; -import java.util.Properties; - -public class NotificationSender { - - protected WorkflowNotifier notifier; - - protected String brokerURL; - - protected String topic; - - protected URI workflowID; - - protected InvocationEntity initiator; - - protected InvocationEntity receiver; - - protected InvocationContext invocationContext; - - protected EndpointReference eventSink; - - protected WorkflowTrackingContext context; - - /** - * Constructs a NotificationSender. - * - * @param brokerURL - * @param topic - */ - public NotificationSender(URI brokerURL, String topic) { - this(brokerURL.toString(), topic); - } - - /** - * Creates a NotificationSender. - * - * @param brokerURL The location of notification brokerUrl. - * @param topic The notification topic. - */ - public NotificationSender(String brokerURL, String topic) { - this.topic = topic; - this.brokerURL = brokerURL; - this.workflowID = URI.create(this.convertToJavaIdentifier(this.topic)); - this.eventSink = new EndpointReference(this.brokerURL); - Properties props = new Properties(); - - this.notifier = NotifierFactory.createNotifier(); - URI initiatorWorkflowID = null; - URI initiatorServiceID = URI.create(this.convertToJavaIdentifier(topic)); - String initiatorWorkflowNodeID = null; - Integer initiatorWorkflowTimeStep = null; - this.context = this.notifier.createTrackingContext(props, brokerURL, initiatorWorkflowID, - initiatorServiceID, initiatorWorkflowNodeID, initiatorWorkflowTimeStep); - this.context.setTopic(topic); - this.initiator = this.notifier.createEntity(initiatorWorkflowID, initiatorServiceID, initiatorWorkflowNodeID, - initiatorWorkflowTimeStep); - - URI receiverWorkflowID = this.workflowID; - URI receiverServiceID = this.workflowID; - String receiverWorkflowNodeID = null; - Integer receiverWorkflowTimeStep = null; - this.receiver = this.notifier.createEntity(receiverWorkflowID, receiverServiceID, receiverWorkflowNodeID, - receiverWorkflowTimeStep); - } - - /** - * @return The event sink EPR. - */ - public EndpointReference getEventSink() { - return this.eventSink; - } - - - public void workflowStarted(String message) { - this.invocationContext = this.notifier.workflowInvoked(this.context, this.initiator, message); - } - - - public void workflowFinished(String message) { - this.notifier.sendingResult(context, this.invocationContext, message); - this.notifier.workflowTerminated(context, this.workflowID, "Workflow finished successfully."); - } - - public void sendingPartialResults(Object[] args, String[] keywords) { - String message = ""; - for (int i = 0; i < args.length; i++) { - if (i != 0) { - message += ", "; - } - message += keywords[i] + "=" + args[i]; - } - this.notifier.sendingResult(context, this.invocationContext, message); - } - - - public void workflowTerminated() { - this.notifier.workflowTerminated(context, this.workflowID, "Workflow finished successfully."); - } - - /** - * Sends a START_INCOMPLETED notification message. - * - * @param message The message to send - */ - public void workflowFailed(String message) { - workflowFailed(message, null); - } - - /** - * Sends a START_INCOMPLETED notification message. - * - * @param e - */ - public void workflowFailed(Throwable e) { - workflowFailed(null, e); - } - - /** - * Sends a START_INCOMPLETED notification message. - * - * @param message The message to send - * @param e - */ - public void workflowFailed(String message, Throwable e) { - this.notifier.sendingFault(context, this.invocationContext, message); - } - - public void info(String message) { - this.notifier.info(context, message); - } - - /** - * @param throwable - * @return The stackTrace in String - */ - public static String getStackTraceInString(Throwable throwable) { - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - PrintStream printStream = new PrintStream(byteArrayOutputStream); - throwable.printStackTrace(printStream); - printStream.flush(); - return byteArrayOutputStream.toString(); - } - - public static String convertToJavaIdentifier(String name) { - - final char REPLACE_CHAR = '_'; - - if (name == null || name.length() == 0) { - return "" + REPLACE_CHAR; - } - - StringBuilder buf = new StringBuilder(); - - char c = name.charAt(0); - if (!Character.isJavaIdentifierStart(c)) { - // Add _ at the beggining instead of replacing it to _. This is - // more readable if the name is like 3D_Model. - buf.append(REPLACE_CHAR); - } - - for (int i = 0; i < name.length(); i++) { - c = name.charAt(i); - if (Character.isJavaIdentifierPart(c)) { - buf.append(c); - } else { - buf.append(REPLACE_CHAR); - } - } - - return buf.toString(); - } -} \ No newline at end of file +///* +// * +// * Licensed to the Apache Software Foundation (ASF) under one +// * or more contributor license agreements. See the NOTICE file +// * distributed with this work for additional information +// * regarding copyright ownership. The ASF licenses this file +// * to you under the Apache License, Version 2.0 (the +// * "License"); you may not use this file except in compliance +// * with the License. You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, +// * software distributed under the License is distributed on an +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// * KIND, either express or implied. See the License for the +// * specific language governing permissions and limitations +// * under the License. +// * +//*/ +//package org.apache.airavata.xbaya.interpreter; +// +// +//import org.apache.airavata.workflow.tracking.NotifierFactory; +//import org.apache.airavata.workflow.tracking.WorkflowNotifier; +//import org.apache.airavata.workflow.tracking.common.InvocationContext; +//import org.apache.airavata.workflow.tracking.common.InvocationEntity; +//import org.apache.airavata.workflow.tracking.common.WorkflowTrackingContext; +//import org.apache.axis2.addressing.EndpointReference; +// +//import java.io.ByteArrayOutputStream; +//import java.io.PrintStream; +//import java.net.URI; +//import java.util.Properties; +// +//public class NotificationSender { +// +// protected WorkflowNotifier notifier; +// +// protected String brokerURL; +// +// protected String topic; +// +// protected URI workflowID; +// +// protected InvocationEntity initiator; +// +// protected InvocationEntity receiver; +// +// protected InvocationContext invocationContext; +// +// protected EndpointReference eventSink; +// +// protected WorkflowTrackingContext context; +// +// /** +// * Constructs a NotificationSender. +// * +// * @param brokerURL +// * @param topic +// */ +// public NotificationSender(URI brokerURL, String topic) { +// this(brokerURL.toString(), topic); +// } +// +// /** +// * Creates a NotificationSender. +// * +// * @param brokerURL The location of notification brokerUrl. +// * @param topic The notification topic. +// */ +// public NotificationSender(String brokerURL, String topic) { +// this.topic = topic; +// this.brokerURL = brokerURL; +// this.workflowID = URI.create(this.convertToJavaIdentifier(this.topic)); +// this.eventSink = new EndpointReference(this.brokerURL); +// Properties props = new Properties(); +// +// this.notifier = NotifierFactory.createNotifier(); +// URI initiatorWorkflowID = null; +// URI initiatorServiceID = URI.create(this.convertToJavaIdentifier(topic)); +// String initiatorWorkflowNodeID = null; +// Integer initiatorWorkflowTimeStep = null; +// this.context = this.notifier.createTrackingContext(props, brokerURL, initiatorWorkflowID, +// initiatorServiceID, initiatorWorkflowNodeID, initiatorWorkflowTimeStep); +// this.context.setTopic(topic); +// this.initiator = this.notifier.createEntity(initiatorWorkflowID, initiatorServiceID, initiatorWorkflowNodeID, +// initiatorWorkflowTimeStep); +// +// URI receiverWorkflowID = this.workflowID; +// URI receiverServiceID = this.workflowID; +// String receiverWorkflowNodeID = null; +// Integer receiverWorkflowTimeStep = null; +// this.receiver = this.notifier.createEntity(receiverWorkflowID, receiverServiceID, receiverWorkflowNodeID, +// receiverWorkflowTimeStep); +// } +// +// /** +// * @return The event sink EPR. +// */ +// public EndpointReference getEventSink() { +// return this.eventSink; +// } +// +// +// public void workflowStarted(String message) { +// this.invocationContext = this.notifier.workflowInvoked(this.context, this.initiator, message); +// } +// +// +// public void workflowFinished(String message) { +// this.notifier.sendingResult(context, this.invocationContext, message); +// this.notifier.workflowTerminated(context, this.workflowID, "Workflow finished successfully."); +// } +// +// public void sendingPartialResults(Object[] args, String[] keywords) { +// String message = ""; +// for (int i = 0; i < args.length; i++) { +// if (i != 0) { +// message += ", "; +// } +// message += keywords[i] + "=" + args[i]; +// } +// this.notifier.sendingResult(context, this.invocationContext, message); +// } +// +// +// public void workflowTerminated() { +// this.notifier.workflowTerminated(context, this.workflowID, "Workflow finished successfully."); +// } +// +// /** +// * Sends a START_INCOMPLETED notification message. +// * +// * @param message The message to send +// */ +// public void workflowFailed(String message) { +// workflowFailed(message, null); +// } +// +// /** +// * Sends a START_INCOMPLETED notification message. +// * +// * @param e +// */ +// public void workflowFailed(Throwable e) { +// workflowFailed(null, e); +// } +// +// /** +// * Sends a START_INCOMPLETED notification message. +// * +// * @param message The message to send +// * @param e +// */ +// public void workflowFailed(String message, Throwable e) { +// this.notifier.sendingFault(context, this.invocationContext, message); +// } +// +// public void info(String message) { +// this.notifier.info(context, message); +// } +// +// /** +// * @param throwable +// * @return The stackTrace in String +// */ +// public static String getStackTraceInString(Throwable throwable) { +// ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); +// PrintStream printStream = new PrintStream(byteArrayOutputStream); +// throwable.printStackTrace(printStream); +// printStream.flush(); +// return byteArrayOutputStream.toString(); +// } +// +// public static String convertToJavaIdentifier(String name) { +// +// final char REPLACE_CHAR = '_'; +// +// if (name == null || name.length() == 0) { +// return "" + REPLACE_CHAR; +// } +// +// StringBuilder buf = new StringBuilder(); +// +// char c = name.charAt(0); +// if (!Character.isJavaIdentifierStart(c)) { +// // Add _ at the beggining instead of replacing it to _. This is +// // more readable if the name is like 3D_Model. +// buf.append(REPLACE_CHAR); +// } +// +// for (int i = 0; i < name.length(); i++) { +// c = name.charAt(i); +// if (Character.isJavaIdentifierPart(c)) { +// buf.append(c); +// } else { +// buf.append(REPLACE_CHAR); +// } +// } +// +// return buf.toString(); +// } +//} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index ebc35a1..8e16e40 100644 --- a/pom.xml +++ b/pom.xml @@ -519,9 +519,9 @@ <module>modules/orchestrator</module> <module>tools</module> <module>modules/server</module> - <module>modules/test-suite</module> + <!--<module>modules/test-suite</module>--> <module>modules/distribution</module> - <module>modules/ws-messenger</module> + <!--<module>modules/ws-messenger</module>--> <module>modules/messaging</module> <module>modules/integration-tests</module> <module>modules/xbaya-gui</module> @@ -597,7 +597,7 @@ <module>airavata-api</module> <module>modules/commons</module> <module>modules/gfac</module> - <module>modules/ws-messenger</module> + <!--<module>modules/ws-messenger</module>--> <module>modules/workflow-model</module> <module>modules/registry</module> <module>modules/security</module> @@ -605,7 +605,7 @@ <module>modules/orchestrator</module> <module>tools</module> <module>modules/server</module> - <module>modules/test-suite</module> + <!--<module>modules/test-suite</module>--> <module>modules/distribution</module> <module>modules/integration-tests</module> </modules>
