http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/msgbox/MsgboxHandler.java ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/msgbox/MsgboxHandler.java b/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/msgbox/MsgboxHandler.java deleted file mode 100644 index 5b06610..0000000 --- a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/msgbox/MsgboxHandler.java +++ /dev/null @@ -1,122 +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.client.msgbox; - -import java.rmi.RemoteException; - -import javax.xml.namespace.QName; - -import org.apache.airavata.wsmg.client.MsgBrokerClientException; -import org.apache.airavata.wsmg.client.NotificationHandler; -import org.apache.airavata.wsmg.commons.MsgBoxQNameConstants; -import org.apache.airavata.wsmg.msgbox.client.MsgBoxClient; -import org.apache.axis2.addressing.EndpointReference; - -public class MsgboxHandler { - - protected MsgBoxClient msgBoxUser = null; - - public EndpointReference createPullMsgBox(String msgBoxLocation, long timeout) throws MsgBrokerClientException { - msgBoxUser = new MsgBoxClient(); - EndpointReference msgBoxAddr = null; - - try { - msgBoxAddr = msgBoxUser.createMessageBox(msgBoxLocation, timeout); - } catch (RemoteException e) { - throw new MsgBrokerClientException("unable to create msgbox", e); - } - - return msgBoxAddr; - } - - public EndpointReference createPullMsgBox(String msgBoxServerLoc) throws MsgBrokerClientException { - return createPullMsgBox(msgBoxServerLoc, 12000L); - } - - public MessagePuller startPullingEventsFromMsgBox(EndpointReference msgBoxEpr, NotificationHandler handler, - long interval, long timeout) throws MsgBrokerClientException { - if (msgBoxUser == null) { - throw new MsgBrokerClientException("Unable start pulling, the messagebox client was not initialized"); - } - - MessagePuller messagePuller = new MessagePuller(msgBoxUser, msgBoxEpr, handler, interval, timeout); - messagePuller.startPulling(); - return messagePuller; - } - - public MessagePuller startPullingFromExistingMsgBox(EndpointReference msgBoxAddr, NotificationHandler handler, - long interval, long timeout) throws MsgBrokerClientException { - - String toAddress = msgBoxAddr.getAddress(); - int biginIndex = toAddress.indexOf("clientid"); - String clientId = toAddress.substring(biginIndex + "clientid".length() + 1); - - if ((msgBoxAddr.getAllReferenceParameters() == null || msgBoxAddr.getAllReferenceParameters() - .get(MsgBoxQNameConstants.MSG_BOXID_QNAME).getText() == null) - && biginIndex == -1) - throw new MsgBrokerClientException("Invalid Message Box Address"); - this.msgBoxUser = new MsgBoxClient(); - MessagePuller messagePuller = new MessagePuller(msgBoxUser, msgBoxAddr, handler, interval, timeout); - messagePuller.startPulling(); - return messagePuller; - } - - public String deleteMsgBox(EndpointReference msgBoxEpr, long timeout) throws MsgBrokerClientException { - - String msgBoxEventSink = msgBoxEpr.getAddress(); - - String formattedEventSink = null; - - if (msgBoxEpr.getAddress().contains("clientid")) { - formattedEventSink = msgBoxEventSink; - } else { - if (msgBoxEpr.getAllReferenceParameters() == null) - throw new MsgBrokerClientException("Invalid Message Box EPR, no reference parameters found"); - String msgBoxId = msgBoxEpr.getAllReferenceParameters().get(MsgBoxQNameConstants.MSG_BOXID_QNAME).getText(); - if (msgBoxId == null) - throw new MsgBrokerClientException( - "Invalid Message Box EPR, reference parameter MsgBoxAddress is missing"); - String format = msgBoxEventSink.endsWith("/") ? "%sclientid/%s" : "%s/clientid/%s"; - - formattedEventSink = String.format(format, msgBoxEventSink, msgBoxId); - - } - - if (this.msgBoxUser == null) { - this.msgBoxUser = new MsgBoxClient(); - } - - String resp = null; - try { - resp = msgBoxUser.deleteMsgBox(msgBoxEpr, timeout); - } catch (RemoteException e) { - throw new MsgBrokerClientException("unable to delete the msg box", e); - } - - return resp; - } - - public void stopPullingEventsFromMsgBox(MessagePuller msgPuller) { - msgPuller.stopPulling(); - } - -}
http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/protocol/WSEProtocolClient.java ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/protocol/WSEProtocolClient.java b/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/protocol/WSEProtocolClient.java deleted file mode 100644 index c8f4d31..0000000 --- a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/protocol/WSEProtocolClient.java +++ /dev/null @@ -1,146 +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.client.protocol; - -import javax.xml.namespace.QName; - -import org.apache.airavata.wsmg.commons.WsmgCommonConstants; -import org.apache.airavata.wsmg.commons.NameSpaceConstants; -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.axis2.AxisFault; -import org.apache.axis2.addressing.EndpointReference; -import org.apache.axis2.addressing.EndpointReferenceHelper; - -public class WSEProtocolClient { - - public static EndpointReference createEndpointReference(String brokerURL, String topic) { - if (brokerURL == null) { - throw new IllegalArgumentException("Broker URL is null."); - } - if (topic == null) { - throw new IllegalArgumentException("Topic is null."); - } - - String sinkLocation = brokerURL.endsWith("/") ? brokerURL + "topic/" + topic : brokerURL + "/topic/" + topic; - - EndpointReference eventSinkReference = new EndpointReference(sinkLocation); - return eventSinkReference; - } - - private static OMElement createFilter(String topicExpression, String xpathExpression) { - - boolean hasTopicExpression = (topicExpression != null && topicExpression.length() != 0); - boolean hasXPathExpression = (xpathExpression != null && xpathExpression.length() != 0); - - OMFactory factory = OMAbstractFactory.getOMFactory(); - OMElement filterEl = null; - - if (hasTopicExpression && hasXPathExpression) { - filterEl = factory.createOMElement("Filter", NameSpaceConstants.WSE_NS); - - filterEl.addAttribute("Dialect", WsmgCommonConstants.TOPIC_AND_XPATH_DIALECT, null); - OMElement topicExpressionEl = factory.createOMElement("TopicExpression", NameSpaceConstants.WSNT_NS); - topicExpressionEl.addAttribute("Dialect", WsmgCommonConstants.TOPIC_EXPRESSION_SIMPLE_DIALECT, null); - topicExpressionEl.declareNamespace(NameSpaceConstants.WIDGET_NS); - topicExpressionEl.setText(NameSpaceConstants.WIDGET_NS.getPrefix() + ":" + topicExpression); - filterEl.addChild(topicExpressionEl); - OMElement xpathEl = factory.createOMElement("MessageContent", NameSpaceConstants.WSNT_NS); - xpathEl.addAttribute("Dialect", WsmgCommonConstants.XPATH_DIALECT, null); - xpathEl.setText(xpathExpression); - filterEl.addChild(xpathEl); - } else if (hasTopicExpression) { - filterEl = factory.createOMElement("Filter", NameSpaceConstants.WSE_NS); - - filterEl.addAttribute("Dialect", WsmgCommonConstants.TOPIC_EXPRESSION_SIMPLE_DIALECT, null); - filterEl.declareNamespace(NameSpaceConstants.WIDGET_NS); - filterEl.setText(NameSpaceConstants.WIDGET_NS.getPrefix() + ":" + topicExpression); - } else if (hasXPathExpression) { - filterEl = factory.createOMElement("Filter", NameSpaceConstants.WSE_NS); - - filterEl.addAttribute("Dialect", WsmgCommonConstants.XPATH_DIALECT, null); - filterEl.setText(xpathExpression); - } - - return filterEl; - } - - public static OMElement createSubscription(EndpointReference eventSink, String topicExpression, - String xpathExpression, long expireTime) throws AxisFault { - - OMFactory factory = OMAbstractFactory.getOMFactory(); - OMElement subscribeMsg = factory.createOMElement("Subscribe", NameSpaceConstants.WSE_NS); - - OMElement delivery = factory.createOMElement("Delivery", NameSpaceConstants.WSE_NS); - - OMElement expires = factory.createOMElement("Expires", NameSpaceConstants.WSE_NS); - expires.setText(Long.toString(expireTime)); - subscribeMsg.addChild(expires); - - OMElement notifyTo = EndpointReferenceHelper.toOM(factory, eventSink, - new QName(NameSpaceConstants.WSE_NS.getNamespaceURI(), "NotifyTo"), - NameSpaceConstants.WSA_NS.getNamespaceURI()); - - delivery.addChild(notifyTo); - subscribeMsg.addChild(delivery); - - OMElement filterEl = createFilter(topicExpression, xpathExpression); - - if (filterEl != null) { - subscribeMsg.addChild(filterEl); - } - - subscribeMsg.declareNamespace(NameSpaceConstants.WSA_NS); - - return subscribeMsg; - } - - public static String decodeSubscribeResponse(OMElement responseSubscriptionsManagerElement) throws AxisFault { - String subscriptionId = null; - OMElement referencePropertiesEl = responseSubscriptionsManagerElement.getFirstChildWithName(new QName( - NameSpaceConstants.WSA_NS.getNamespaceURI(), "ReferenceProperties")); - - if (referencePropertiesEl == null) { - referencePropertiesEl = responseSubscriptionsManagerElement.getFirstChildWithName(new QName( - NameSpaceConstants.WSA_NS.getNamespaceURI(), "ReferenceParameters")); - } - - OMElement identifierEl = referencePropertiesEl.getFirstChildWithName(new QName(NameSpaceConstants.WSE_NS - .getNamespaceURI(), WsmgCommonConstants.SUBSCRIPTION_ID)); - - if (identifierEl == null) { - throw new AxisFault("invalid response message, subscription id was not sent by broker"); - } - - subscriptionId = identifierEl.getText(); - return subscriptionId; - } - - public static OMElement createUnsubscribeMsg() { - OMFactory factory = OMAbstractFactory.getOMFactory(); - OMElement message = factory.createOMElement("Unsubscribe", NameSpaceConstants.WSE_NS); - - return message; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/protocol/WSNTProtocolClient.java ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/protocol/WSNTProtocolClient.java b/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/protocol/WSNTProtocolClient.java deleted file mode 100644 index a582e72..0000000 --- a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/protocol/WSNTProtocolClient.java +++ /dev/null @@ -1,127 +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.client.protocol; - -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.apache.airavata.wsmg.commons.WsmgCommonConstants; -import org.apache.airavata.wsmg.commons.NameSpaceConstants; -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.axis2.AxisFault; -import org.apache.axis2.addressing.EndpointReference; -import org.apache.axis2.addressing.EndpointReferenceHelper; - -public class WSNTProtocolClient { - - public static OMElement createSubscriptionMsg(EndpointReference eventSinkLocation, String topicExpression, - String xpathExpression) throws AxisFault { - OMFactory factory = OMAbstractFactory.getOMFactory(); - - OMElement message = factory.createOMElement("SubscribeRequest", NameSpaceConstants.WSNT_NS); - - if (topicExpression != null) { - OMElement topicExpEl = factory.createOMElement("TopicExpression", NameSpaceConstants.WSNT_NS, message); - - topicExpEl.addAttribute("Dialect", WsmgCommonConstants.TOPIC_EXPRESSION_SIMPLE_DIALECT, - NameSpaceConstants.WSNT_NS); - topicExpEl.declareNamespace(NameSpaceConstants.WIDGET_NS); - topicExpEl.setText(NameSpaceConstants.WIDGET_NS.getPrefix() + ":" + topicExpression); - } - - if (xpathExpression != null) { - OMElement xpathExpEl = factory.createOMElement("Selector", NameSpaceConstants.WSNT_NS, message); - xpathExpEl.addAttribute("Dialect", WsmgCommonConstants.XPATH_DIALECT, null); - xpathExpEl.setText(xpathExpression); - } - - OMElement useNotifyEl = factory.createOMElement("UseNotify", message.getNamespace(), message); - useNotifyEl.setText("true");// check wether we still need this - - OMElement eprCrEl = EndpointReferenceHelper.toOM(factory, eventSinkLocation, new QName("ConsumerReference"), - NameSpaceConstants.WSA_NS.getNamespaceURI()); - - message.addChild(eprCrEl); - eprCrEl.setNamespace(message.getNamespace()); - - return message; - } - - public static String decodeSubscriptionResponse(OMElement subscriptionReference) throws AxisFault { - - String subscriptionId = null; - - EndpointReference subscriptionReferenceEPR = EndpointReferenceHelper.fromOM(subscriptionReference); - - Map<QName, OMElement> referenceParams = subscriptionReferenceEPR.getAllReferenceParameters(); - - if (referenceParams != null) { - QName identifierQName = new QName(NameSpaceConstants.WSNT_NS.getNamespaceURI(), - WsmgCommonConstants.SUBSCRIPTION_ID); - - OMElement identifierEl = referenceParams.get(identifierQName); - subscriptionId = (identifierEl != null) ? identifierEl.getText() : null; - - } - - return subscriptionId; - } - - public static OMElement createUnsubscribeMsg() { - OMFactory factory = OMAbstractFactory.getOMFactory(); - OMElement message = factory.createOMElement("UnsubsribeRequest", NameSpaceConstants.WSNT_NS); - - return message; - } - - public static OMElement encodeNotification(String topic, OMElement message, EndpointReference producerReference) - throws AxisFault { - OMFactory factory = OMAbstractFactory.getOMFactory(); - - OMElement topicExpEl = factory.createOMElement("Topic", NameSpaceConstants.WSNT_NS); - topicExpEl.addAttribute("Dialect", WsmgCommonConstants.TOPIC_EXPRESSION_SIMPLE_DIALECT, null); - topicExpEl.declareNamespace(NameSpaceConstants.WIDGET_NS); - topicExpEl.setText(NameSpaceConstants.WIDGET_NS.getPrefix() + ":" + topic); - - OMElement messageToNotify = factory.createOMElement("Notify", NameSpaceConstants.WSNT_NS); - messageToNotify.declareNamespace(NameSpaceConstants.WSNT_NS); - messageToNotify.declareNamespace(NameSpaceConstants.WSA_NS); - OMElement notificationMesssageEl = factory.createOMElement("NotificationMessage", - messageToNotify.getNamespace(), messageToNotify); - - notificationMesssageEl.addChild(topicExpEl); - - notificationMesssageEl.addChild(EndpointReferenceHelper.toOM(factory, producerReference, new QName( - notificationMesssageEl.getNamespace().getNamespaceURI(), "ProducerReference", notificationMesssageEl - .getNamespace().getPrefix()), NameSpaceConstants.WSA_NS.getNamespaceURI())); - - OMElement messageEl = factory.createOMElement("Message", notificationMesssageEl.getNamespace(), - notificationMesssageEl); - - messageEl.addChild(message); - return messageToNotify; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/util/ClientUtil.java ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/util/ClientUtil.java b/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/util/ClientUtil.java deleted file mode 100644 index 5937898..0000000 --- a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/util/ClientUtil.java +++ /dev/null @@ -1,58 +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.client.util; - -import java.net.InetAddress; -import java.net.UnknownHostException; - -public class ClientUtil { - - public static final long EXPIRE_TIME = 1000 * 60 * 60 * 72l; - - public static String formatMessageBoxUrl(String msgBoxServiceUrl, String msgboxId) { - return msgBoxServiceUrl.endsWith("/") ? msgBoxServiceUrl + "clientid/" + msgboxId : msgBoxServiceUrl - + "/clientid/" + msgboxId; - } - - public static String formatURLString(String url) { - if (url == null) { - throw new IllegalArgumentException("url can't be null"); - } - if (url.indexOf("//") < 0) { - url = "http://" + url; // use default http - } - return url; - } - - public static String getHostIP() { - InetAddress localAddress = null; - try { - localAddress = InetAddress.getLocalHost(); - } catch (UnknownHostException ex) { - System.out.println("Error - unable to resolve localhost"); - } - // Use IP address since DNS entry cannot update the laptop's entry - // promptly - String hostIP = localAddress.getHostAddress(); - return hostIP; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/util/DcDate.java ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/util/DcDate.java b/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/util/DcDate.java deleted file mode 100644 index 24b57cf..0000000 --- a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/client/util/DcDate.java +++ /dev/null @@ -1,472 +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.client.util; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.Iterator; -import java.util.List; -import java.util.TimeZone; - -//TODO: support for fractional seconds - -/** - * Represent dc:date as an immutable value object. http://www.w3.org/TR/NOTE-datetime - * http://www.sics.se/~preben/DC/date_help.html - * - */ -public final class DcDate implements Cloneable { - - public Object clone() throws CloneNotSupportedException { - // it is easy as object is immutable - DcDate dd = (DcDate) super.clone(); - return dd; - } - - private String canonical; - - // private Date date; - private int year; - - private int month; // 1-12 - - private int day; // 1-31 - - private int hh = -1; // 00-23 - - private int mm = -1; // 00-59 - - private int ss = -1; // 00-59 - - private String decimalFraction = null; // decimal fraction - - private int zoneOffset; // in minutes +/-(12*60) ??? - - private Calendar instant; - - private int millisOffset = -1; // milliseconds - - // public DcDate() throws SException { - // - // this(System.currentTimeMillis()); - // } - // - // public DcDate(long timeMillis) throws SException { - // this(timeMillis, null); - // Calendar local = new GregorianCalendar(); - // local.setTimeInMillis(timeMillis); - // } - - // public DcDate(String tzName) throws SException { - // TimeZone tz = tzName != null ? TimeZone.getTimeZone(tzName) : - // TimeZone.getDefault(); - // TimeZone.getTimeZone("GMT") - public DcDate(TimeZone tz) throws RuntimeException { - - // based on http://javaalmanac.com/egs/java.util/GetAllZones.html?l=rel - - Calendar cal = new GregorianCalendar(tz); - init(cal, tz); - } - - public DcDate(Calendar cal) throws RuntimeException { - init(cal, cal.getTimeZone()); - } - - private void init(Calendar cal, TimeZone tz) throws RuntimeException { - // Get the number of hours from GMT - int rawOffset = tz.getRawOffset(); - zoneOffset = rawOffset / (60 * 1000); - - instant = cal; - // http://javaalmanac.com/egs/java.util/GetCurDate.html - year = cal.get(Calendar.YEAR); - month = cal.get(Calendar.MONTH) + 1; // 0=Jan, 1=Feb, ... - day = cal.get(Calendar.DAY_OF_MONTH); - hh = cal.get(Calendar.HOUR_OF_DAY); // 0..23 - mm = cal.get(Calendar.MINUTE); // 0..59 - ss = cal.get(Calendar.SECOND); // 0..59 - // int ms = cal.get(Calendar.MILLISECOND); // 0..999 - // date = cal.getTime(); - canonical = computeCanonical(); - } - - public DcDate(String dcDate) throws RuntimeException { - // try { - // synchronized(sdf) { //TODO REVISIT: SimpleFormat is not multi-thread - // safe! - // d = sdf.parse(dcDate); - // } - // } catch (ParseException e) { - // throw new SException("could not parse dc:date "+dcDate+getCtx(pp), - // e); - // } - // 2003-05-06T23:07:04Z - // 2003-08-09T18:36:00-05:00 - // 1234567890123456789012345 - // 2004-02-02T19:09:46-05:00 - // 1997 - // 1997-07 - // 1997-07-16 - // 1997-07-16T19:20+01:00 - // 1997-07-16T19:20:30+01:00 - // 1997-07-16T19:20:30.45+01:00 - assert dcDate != null; - // assert pp != null; - canonical = dcDate; - year = getInt(dcDate, 1, 4); // add min, max check for all getInt - if (dcDate.length() == 4) { - return; - } - check(dcDate, 5, '-'); - month = getInt(dcDate, 6, 2); - if (dcDate.length() == 7) { - return; - } - check(dcDate, 8, '-'); - day = getInt(dcDate, 9, 2); - if (dcDate.length() == 10) { - return; - } - check(dcDate, 11, 'T'); - hh = getInt(dcDate, 12, 2); - check(dcDate, 14, ':'); - mm = getInt(dcDate, 15, 2); - if (dcDate.length() == 16) { - throw new RuntimeException("expected date formatted as YYYY-MM-DDThh:mm[:ss[.mmm]]TZD and not " + dcDate); - } - int pos = 17; - char c17 = dcDate.charAt(pos - 1); - if (c17 == ':') { - check(dcDate, 17, ':'); - ss = getInt(dcDate, 18, 2); - pos = 20; - } - char zoneIndicator = dcDate.charAt(pos - 1); - if (zoneIndicator == '.') { // OK we have yet millliseocnds to parse - // (and ignore ...) - // Ex: 2004-04-13T11:53:15.4362784-04:00 - // eat digits - char d; - int oldPos = pos; - do { - d = dcDate.charAt(pos); - ++pos; - } while (d >= '0' && d <= '9'); - if (oldPos + 1 == pos) { - throw new RuntimeException("expected date formtted as YYYY-MM-DDThh:mm[:ss[.s]]TZD and not " + dcDate); - - } - zoneIndicator = d; - int newPos = pos; - decimalFraction = dcDate.substring(oldPos, newPos - 1); - if (newPos - oldPos >= 3) { - newPos = oldPos + 3; - } - int len = newPos - (oldPos + 1); - int ii = getInt(dcDate, oldPos + 1, len); - if (len == 1) { - millisOffset = 100 * ii; - } else if (len == 2) { - millisOffset = 10 * ii; - } else if (len == 3) { - millisOffset = ii; - } - } - if (zoneIndicator == 'Z') { - // done - } else if (zoneIndicator == '-' || zoneIndicator == '+') { - int zoneHH = getInt(dcDate, pos + 1, 2); - check(dcDate, pos + 3, ':'); - int zoneMM = getInt(dcDate, pos + 4, 2); - zoneOffset = 60 * zoneHH + zoneMM; - if (zoneIndicator == '-') { - zoneOffset *= -1; - } - } else { - throw new RuntimeException("unknown zone indicator " + zoneIndicator + " in " + dcDate); - } - // Get the number of hours from GMT - - // TimeZone tz = TimeZone. - instant = new GregorianCalendar(); - int rawOffset = zoneOffset * 60 * 1000; - instant.set(Calendar.ZONE_OFFSET, rawOffset); - instant.set(Calendar.YEAR, year); - instant.set(Calendar.MONTH, month - 1); // 0=Jan, 1=Feb, ... - instant.set(Calendar.DAY_OF_MONTH, day); - instant.set(Calendar.HOUR_OF_DAY, hh); // 0..23 - instant.set(Calendar.MINUTE, mm); // 0..59 - instant.set(Calendar.SECOND, ss); // 0..59 - instant.set(Calendar.MILLISECOND, millisOffset); // /0..999 ? - instant.getTimeInMillis(); // full time in ms -- test? - } - - public long getTimeInMillis() { - return instant.getTimeInMillis(); - } - - public int getYear() { - return year; - } - - public int getMonth() { - return month; - } - - public int getDay() { - return day; - } - - public int getHour() { - return hh; - } - - public int getMinute() { - return mm; - } - - public int getSecond() { - return ss; - } - - public int getTimeZoneOffset() { - return zoneOffset; - } - - public String getDcDate() { - return canonical; - } - - public String getDecimalFraction() { - return decimalFraction; - } - - private String computeCanonical() { - // 2003-08-09T18:36:00-05:00 - // 1234567890123456789012345 - StringBuffer sb = new StringBuffer(); - fill(sb, year, 4); - if (month > 0) { - sb.append('-'); - fill(sb, month, 2); - if (day > 0) { - sb.append('-'); - fill(sb, day, 2); - if (hh > -1) { - sb.append('T'); - fill(sb, hh, 2); - sb.append(':'); - fill(sb, mm, 2); - if (ss > -1) { - sb.append(':'); - fill(sb, ss, 2); - } - if (decimalFraction != null) { - sb.append('.'); - sb.append(decimalFraction); - } - if (zoneOffset == 0) { - sb.append('Z'); - } else { - int off = zoneOffset; - if (zoneOffset > 0) { - sb.append('+'); - } else { - sb.append('-'); - off *= -1; - } - int zoneHH = off / 60; - int zoneMM = off % 60; - fill(sb, zoneHH, 2); - sb.append(':'); - fill(sb, zoneMM, 2); - } - } - } - } - return sb.toString(); - } - - public String toString() { - return canonical; - } - - public final static String LOCATION_PROPERTY = "http://xmlpull.org/v1/doc/properties.html#location"; - - public static String printable(char ch) { - return "'" + escape(ch) + "'"; - } - - public static String printable(String s) { - return "\"" + escape(s) + "\""; - } - - public static String escape(char ch) { - if (ch == '\n') { - return "\\n"; - } else if (ch == '\r') { - return "\\r"; - } else if (ch == '\t') { - return "\\t"; - } else if (ch == '\'') { - return "\\'"; - } - if (ch > 127 || ch < 32) { - return "\\u" + Integer.toHexString((int) ch); - } - return "" + ch; - } - - public static String escape(String s) { - if (s == null) { - return null; - } - final int sLen = s.length(); - StringBuffer buf = new StringBuffer(sLen + 10); - for (int i = 0; i < sLen; ++i) { - buf.append(escape(s.charAt(i))); - } - s = buf.toString(); - return s; - } - - private static final int LOOKUP_10S[] = { 1, 10, 10 * 10, 10 * 100, 100 * 100 }; - - public static void fill(StringBuffer sb, int value, int fields) { - assert fields > 0; - assert fields <= 4; - assert value >= 0; - int mm = LOOKUP_10S[fields]; - assert value < mm; - // assert mm > 0 - // TODO: optimize it ... - while (fields-- > 0) { - mm /= 10; - if (value >= mm) { - sb.append((value / mm) % 10); - // i /= 10; - } else { - sb.append('0'); - } - } - - // String s = sb.toString(); - // assert s.toString().length == fields; - // return s; - } - - public static void check(String dcDate, int pos, char ch) { - if (pos > dcDate.length()) { - throw new RuntimeException("expected " + printable(ch) + " at position " + pos + " but " + dcDate - + " is too short"); - } - char c = dcDate.charAt(pos - 1); - if (c != ch) { - throw new RuntimeException("expected " + printable(ch) + " but got " + printable(c) + " in " + dcDate); - } - } - - public static int getInt(String dcDate, int pos, int len) throws RuntimeException { - assert len > 0; - int end = pos + len - 1; - String s = dcDate.substring(pos - 1, end); - try { - int i = Integer.parseInt(s); - return i; - } catch (NumberFormatException e) { - throw new RuntimeException("expected number for " + printable(s) + " in " + dcDate, e); - - } - } - - /** - * Take string and return string that has no spaces, only alpahnumerics, each word is capitalized (like WikiWords) - * sometimes called CamelCase?!. - */ - public static String getWikiTitle(String title) { - StringBuffer sb = new StringBuffer(); - List<String> words = breakIntoWords(title); - boolean start = true; - for (Iterator<String> it = words.iterator(); it.hasNext();) { - String word = it.next(); - boolean wordStart = true; - for (int i = 0; i < word.length(); i++) { - char c = word.charAt(i); - if (Character.isLetterOrDigit(c)) { - if (wordStart && !start) { - sb.append(Character.toUpperCase(c)); - } else { - sb.append(c); - } - wordStart = false; - } - } - start = false; - } - return sb.toString(); - } - - public static List<String> breakIntoWords(String s) { - List<String> words = new ArrayList<String>(s.length() / 5); - boolean inWord = true; - int wordStart = 0; - for (int pos = 0; pos < s.length(); ++pos) { - char ch = s.charAt(pos); - boolean isWordSeparator = Character.isWhitespace(ch); - if (ch == ',') { - isWordSeparator = true; - } - if (ch == '.') { - isWordSeparator = true; - } - if (isWordSeparator) { - if (inWord) { - words.add(s.substring(wordStart, pos)); - inWord = false; - } - } else { - if (!inWord) { - inWord = true; - wordStart = pos; - } - } - assert inWord == !isWordSeparator; - } - if (inWord) { - words.add(s.substring(wordStart)); - } - return words; - } - - public static String makeTwoDigit(int oneOrTwoDigits) { - if (oneOrTwoDigits < 0 || oneOrTwoDigits > 99) { - throw new IllegalArgumentException(); - } - if (oneOrTwoDigits < 10) { - return "0" + oneOrTwoDigits; - } - return "" + oneOrTwoDigits; - } - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/NotificationViewer.java ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/NotificationViewer.java b/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/NotificationViewer.java deleted file mode 100644 index def3f20..0000000 --- a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/NotificationViewer.java +++ /dev/null @@ -1,82 +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.gui; - -import java.awt.Dimension; -import java.awt.Toolkit; - -import javax.swing.SwingUtilities; -import javax.swing.UIManager; - -public class NotificationViewer { - - boolean packFrame = false; - - /** - * Construct and show the application. - */ - public NotificationViewer() { - NotificationViewerFrame frame = new NotificationViewerFrame(); - /* - * Validate frames that have preset sizes Pack frames that have useful preferred size info, e.g. from their - * layout - */ - if (packFrame) { - frame.pack(); - } else { - frame.validate(); - } - - // Center the window - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - Dimension frameSize = frame.getSize(); - if (frameSize.height > screenSize.height) { - frameSize.height = screenSize.height; - } - if (frameSize.width > screenSize.width) { - frameSize.width = screenSize.width; - } - - frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); - frame.setVisible(true); - } - - /** - * Application entry point. - * - * @param args - * String[] - */ - public static void main(String[] args) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (Exception exception) { - exception.printStackTrace(); - } - - new NotificationViewer(); - } - }); - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/NotificationViewerFrame.java ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/NotificationViewerFrame.java b/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/NotificationViewerFrame.java deleted file mode 100644 index c735fee..0000000 --- a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/NotificationViewerFrame.java +++ /dev/null @@ -1,328 +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.gui; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTabbedPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import javax.swing.border.Border; - -import org.apache.airavata.wsmg.client.ConsumerServer; -import org.apache.airavata.wsmg.client.WsntMsgBrokerClient; -import org.apache.axis2.AxisFault; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class NotificationViewerFrame extends JFrame { - - private static final long serialVersionUID = -4924241323165353343L; - - private static final Logger logger = LoggerFactory.getLogger(NotificationViewerFrame.class); - - JPanel contentPane; - - BorderLayout borderLayout1 = new BorderLayout(); - - JPanel jPanel1 = new JPanel(); - - Border border1 = BorderFactory.createLineBorder(Color.gray, 2); - - JLabel jLabel1 = new JLabel(); - - JButton jButtonStart = new JButton(); - - JLabel jLabel2 = new JLabel(); - - JTextField jTextBrokerUrl = new JTextField(); - - JLabel jLabel3 = new JLabel(); - - JTextField jTextPort = new JTextField(); - - JLabel jLabel4 = new JLabel(); - - JTextField jTextTopic = new JTextField(); - - JTabbedPane jTabbedPane1 = new JTabbedPane(); - - JScrollPane jScrollPane1 = new JScrollPane(); - - JTextArea jTextAreaBrief = new JTextArea(); - - JScrollPane jScrollPane2 = new JScrollPane(); - - JTextArea jTextAreaWhole = new JTextArea(); - - JButton jButtonClear = new JButton(); - - ConsumerServer consumerServer = null; - - WsntMsgBrokerClient client; - - String subId = null; - - JButton jButtonStop = new JButton(); - - GridBagLayout gridBagLayout1 = new GridBagLayout(); - - public NotificationViewerFrame() { - try { - setDefaultCloseOperation(EXIT_ON_CLOSE); - jbInit(); - } catch (Exception exception) { - exception.printStackTrace(); - } - - client = new WsntMsgBrokerClient(); - - } - - /** - * Component initialization. - * - * @throws java.lang.Exception - */ - private void jbInit() throws Exception { - contentPane = (JPanel) getContentPane(); - contentPane.setLayout(borderLayout1); - setSize(new Dimension(547, 429)); - setTitle("WS-Notification Viewer"); - jPanel1.setBackground(Color.white); - jPanel1.setBorder(border1); - jPanel1.setMaximumSize(new Dimension(180000, 180000)); - jPanel1.setLayout(gridBagLayout1); - jLabel1.setFont(new java.awt.Font("Serif", Font.BOLD | Font.ITALIC, 28)); - jLabel1.setForeground(Color.blue); - jLabel1.setText("WS-Notification Listener"); - jButtonStart.setToolTipText("Subscribe to the topic and start listening"); - jButtonStart.setText("Start"); - jButtonStart.addActionListener(new NotificationViewerFrame_jButton1_actionAdapter(this)); - jLabel2.setFont(new java.awt.Font("Dialog", Font.BOLD, 11)); - jLabel2.setText("BrokerURL"); - jTextBrokerUrl.setToolTipText("Enter Broker URL here."); - jTextBrokerUrl.setText("http://localhost:8080/axis2/services/NotificationService"); - jLabel3.setFont(new java.awt.Font("Dialog", Font.BOLD, 11)); - jLabel3.setText("Listening Port"); - jTextPort.setToolTipText("Enter the port this listener will be listening to."); - jTextPort.setText("19999"); - jLabel4.setFont(new java.awt.Font("Dialog", Font.BOLD, 11)); - jLabel4.setText("Topic"); - jTextTopic.setToolTipText("Enter the topic to subscribe."); - jTextTopic.setText("topic"); - jTextAreaBrief.setToolTipText("Summary of the messages received."); - jTextAreaBrief.setLineWrap(true); - // jTextAreaWhole.setMinimumSize(new Dimension(490, 17)); - // jTextAreaWhole.setPreferredSize(new Dimension(490, 17)); - jTextAreaWhole.setToolTipText("Full content of the SOAP messages."); - // jTextAreaWhole.setText(""); - jButtonClear.setToolTipText("Clear messages in the two message panes."); - jButtonClear.setText("Clear Messages"); - jButtonClear.addActionListener(new NotificationViewerFrame_jButtonClear_actionAdapter(this)); - jButtonStop.setEnabled(false); - jButtonStop.setToolTipText("Unsubscribe to the topic and stop listening."); - jButtonStop.setText("Stop"); - jButtonStop.addActionListener(new NotificationViewerFrame_jButtonStop_actionAdapter(this)); - jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - jScrollPane1.setAutoscrolls(true); - jScrollPane1.setToolTipText("Summary of the messages received."); - jScrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - jScrollPane2.setAutoscrolls(true); - jScrollPane2.setToolTipText("Full content of the SOAP messages."); - jTabbedPane1.add(jScrollPane1, "Brief Messages"); - jTabbedPane1.add(jScrollPane2, "Whole Messages"); - jPanel1.add(jLabel1, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, - GridBagConstraints.NONE, new Insets(7, 10, 0, 107), 20, -5)); - jPanel1.add(jButtonStop, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, - GridBagConstraints.NONE, new Insets(0, 48, 0, 80), 55, -4)); - jPanel1.add(jLabel4, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, - GridBagConstraints.NONE, new Insets(0, 36, 0, 8), 43, 4)); - jPanel1.add(jLabel3, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, - GridBagConstraints.NONE, new Insets(0, 36, 0, 0), 1, 4)); - jPanel1.add(jTextPort, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, - GridBagConstraints.HORIZONTAL, new Insets(7, 0, 0, 0), 144, -1)); - jPanel1.add(jButtonClear, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, - GridBagConstraints.NONE, new Insets(0, 46, 0, 78), 3, -4)); - jPanel1.add(jTextTopic, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.SOUTHWEST, - GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 149, -1)); - jPanel1.add(jTextBrokerUrl, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.HORIZONTAL, new Insets(6, -1, 5, 1), 10, -1)); - jPanel1.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, - GridBagConstraints.NONE, new Insets(6, 37, 5, 0), 21, 4)); - jPanel1.add(jButtonStart, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, - GridBagConstraints.NONE, new Insets(8, 47, 0, 79), 57, -4)); - jScrollPane2.getViewport().add(jTextAreaWhole); - jScrollPane1.getViewport().add(jTextAreaBrief); - - jPanel1.add(jTabbedPane1, new GridBagConstraints(0, 4, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER, - GridBagConstraints.BOTH, new Insets(0, 18, 57, 30), 0, 206)); - contentPane.add(jPanel1, java.awt.BorderLayout.CENTER); - } - - public void jButtonStart_actionPerformed(ActionEvent event) { - // jLabel1.setForeground(new Color(255,0,0)); - String brokerUrl = jTextBrokerUrl.getText().trim(); - String topic = jTextTopic.getText(); - - String listeningPort = jTextPort.getText(); - - int port = -1; - - try { - port = Integer.parseInt(listeningPort); - } catch (NumberFormatException nfe) { - - JOptionPane.showMessageDialog(this, nfe, "invalid port specified", JOptionPane.ERROR_MESSAGE); - return; - } - - client.init(brokerUrl);// important - // Create a handler to handle the notifications arrived - WsntViewerConsumerNotificationHandler handler = new WsntViewerConsumerNotificationHandler(this); - - String consumerUrl = null; - - try { - String[] eprs = client.startConsumerService(port, handler); - - if (eprs.length > 0) { - consumerUrl = eprs[0]; - } else { - throw new AxisFault("no consumer url given by wse client api"); - } - - } catch (Exception e) { - JOptionPane.showMessageDialog(this, e, "Unable to start consumer service", JOptionPane.ERROR_MESSAGE); - return; - } - - try { - subId = client.subscribe(consumerUrl, topic, null); - } catch (Exception e) { - - JOptionPane.showMessageDialog(this, e, "Unable to subscribe to topic", JOptionPane.ERROR_MESSAGE); - - client.shutdownConsumerService(); - return; - } - - jButtonStart.setEnabled(false); - jTextBrokerUrl.setEnabled(false); - jTextTopic.setEnabled(false); - jTextPort.setEnabled(false); - jButtonStop.setEnabled(true); - jTextAreaBrief.append("Listener started...\n"); - jTextAreaWhole.append("Listener started...\n"); - - } - - public void jButtonStop_actionPerformed(ActionEvent e) { - if (subId != null) { - try { - client.init(jTextBrokerUrl.getText().trim()); - client.unSubscribe(subId); - } catch (Exception e1) { - JOptionPane.showMessageDialog(this, e, "Unable to unsubscribe from topic", JOptionPane.ERROR_MESSAGE); - }// TODO: add with replyTo URL - subId = null; - } - - client.shutdownConsumerService(); - - jButtonStop.setEnabled(false); - jButtonStart.setEnabled(true); - jTextBrokerUrl.setEnabled(true); - jTextTopic.setEnabled(true); - jTextPort.setEnabled(true); - jTextAreaBrief.append("Listener stoped.\n"); - jTextAreaWhole.append("Listener stoped.\n"); - - } - - public void addBriefMessage(String message) { - jTextAreaBrief.append(message + "\n"); - jTextAreaBrief.selectAll(); - } - - public void addWholeMessage(String message) { - jTextAreaWhole.append(message + "\n"); - jTextAreaWhole.selectAll(); - } - - public void jButtonClear_actionPerformed(ActionEvent e) { - jTextAreaBrief.setText(""); - jTextAreaWhole.setText(""); - } -} - -class NotificationViewerFrame_jButtonStop_actionAdapter implements ActionListener { - private NotificationViewerFrame adaptee; - - NotificationViewerFrame_jButtonStop_actionAdapter(NotificationViewerFrame adaptee) { - this.adaptee = adaptee; - } - - public void actionPerformed(ActionEvent e) { - adaptee.jButtonStop_actionPerformed(e); - } -} - -class NotificationViewerFrame_jButtonClear_actionAdapter implements ActionListener { - private NotificationViewerFrame adaptee; - - NotificationViewerFrame_jButtonClear_actionAdapter(NotificationViewerFrame adaptee) { - this.adaptee = adaptee; - } - - public void actionPerformed(ActionEvent e) { - adaptee.jButtonClear_actionPerformed(e); - } -} - -class NotificationViewerFrame_jButton1_actionAdapter implements ActionListener { - private NotificationViewerFrame adaptee; - - NotificationViewerFrame_jButton1_actionAdapter(NotificationViewerFrame adaptee) { - this.adaptee = adaptee; - } - - public void actionPerformed(ActionEvent e) { - adaptee.jButtonStart_actionPerformed(e); - - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/README.txt ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/README.txt b/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/README.txt deleted file mode 100644 index 4244b93..0000000 --- a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/README.txt +++ /dev/null @@ -1,15 +0,0 @@ -USING Notification Listener GUI. - -It is designed for Airavata project. The expected message XML schema in Airavata Workflow Management schema. It can also accept String messages. - - 1, Use ant to compile the package. - 2, Then run -source setenv.sh -Or setenv.bat in Windows. - to setup CLASSPATH. It looks better in Windows. - - 3, Then run: - java wsnt.wsntviewapp.NotificationViewer - to start the GUI. - -You need to enter Broker URL, topic and listening port. http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/WsntViewerConsumerNotificationHandler.java ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/WsntViewerConsumerNotificationHandler.java b/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/WsntViewerConsumerNotificationHandler.java deleted file mode 100644 index f1a4feb..0000000 --- a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/gui/WsntViewerConsumerNotificationHandler.java +++ /dev/null @@ -1,114 +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.gui; - -import java.util.Iterator; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -import org.apache.airavata.wsmg.client.ConsumerNotificationHandler; -import org.apache.airavata.wsmg.commons.NameSpaceConstants; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.soap.SOAPEnvelope; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class WsntViewerConsumerNotificationHandler implements ConsumerNotificationHandler { - private final static Logger logger = LoggerFactory.getLogger(WsntViewerConsumerNotificationHandler.class); - - public NotificationViewerFrame frame = null; - - public WsntViewerConsumerNotificationHandler() { - } - - public WsntViewerConsumerNotificationHandler(NotificationViewerFrame f) { - this.frame = f; - } - - public void handleNotification(SOAPEnvelope msgEnvelope) { - logger.debug("*******lead message handler Received message********"); - logger.debug(msgEnvelope.toString()); - try { - addBriefMsg(msgEnvelope); - addWholeMsg(msgEnvelope); - } catch (XMLStreamException e) { - logger.error("invalid message received", e); - throw new RuntimeException("invalid message recieved", e); - } - } - - private void addBriefMsg(SOAPEnvelope env) throws XMLStreamException { - - QName notify = new QName(NameSpaceConstants.WSNT_NS.getNamespaceURI(), "Notify", - NameSpaceConstants.WSNT_NS.getPrefix()); - - QName notifyMsg = new QName(NameSpaceConstants.WSNT_NS.getNamespaceURI(), "NotificationMessage", - NameSpaceConstants.WSNT_NS.getPrefix()); - - QName msg = new QName(NameSpaceConstants.WSNT_NS.getNamespaceURI(), "Message", - NameSpaceConstants.WSNT_NS.getPrefix()); - - if (env.getBody() == null) { - throw new RuntimeException("invalid soap envelope - no soap body"); - } - - Iterator ite = env.getBody().getChildrenWithName(notify); - - if (!ite.hasNext()) { - throw new RuntimeException(notify.getLocalPart() + " tag is not found"); - } - - OMElement ele = (OMElement) ite.next(); - ite = ele.getChildrenWithName(notifyMsg); - - if (!ite.hasNext()) { - throw new RuntimeException(notifyMsg.getLocalPart() + " tag is not found"); - } - - ele = (OMElement) ite.next(); - - ite = ele.getChildrenWithName(msg); - - if (!ite.hasNext()) { - throw new RuntimeException(msg.getLocalPart() + " tags are not found"); - } - - while (ite.hasNext()) { - ele = (OMElement) ite.next(); - - if (ele.getFirstElement() != null) { - frame.addBriefMessage(ele.getFirstElement().toString()); - } else { - throw new RuntimeException("raw message is not found"); - } - - } - - } - - private void addWholeMsg(SOAPEnvelope envelope) throws XMLStreamException { - frame.addWholeMessage(envelope.toStringWithConsume()); - - } - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/CreateMsgBox.java ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/CreateMsgBox.java b/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/CreateMsgBox.java deleted file mode 100644 index ae66997..0000000 --- a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/CreateMsgBox.java +++ /dev/null @@ -1,118 +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.msgbox.client; - -import javax.xml.namespace.QName; - -import org.apache.airavata.wsmg.client.util.ClientUtil; -import org.apache.airavata.wsmg.commons.MsgBoxQNameConstants; -import org.apache.airavata.wsmg.commons.NameSpaceConstants; -import org.apache.airavata.wsmg.commons.WsmgCommonConstants; -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.axiom.om.util.UUIDGenerator; -import org.apache.axis2.AxisFault; -import org.apache.axis2.addressing.EndpointReference; -import org.apache.axis2.client.Options; -import org.apache.axis2.client.ServiceClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This class can be used to invoke createMsgBox operation of msgBoxService and returns the resultant messageBoxId as - * EndpointReference - */ -public class CreateMsgBox { - private static final Logger logger = LoggerFactory.getLogger(CreateMsgBox.class); - private final OMFactory factory = OMAbstractFactory.getOMFactory(); - protected String msgBoxEndPointReference; - protected long timeoutInMilliSeconds; - private String msgBoxId; - private OMElement responseEl; - - public CreateMsgBox(String msgBoxLocation, long timeout) { - this.msgBoxEndPointReference = msgBoxLocation; - responseEl = OMAbstractFactory.getOMFactory().createOMElement(MsgBoxQNameConstants.MSG_BOXID_QNAME); - - timeoutInMilliSeconds = timeout; - } - - public long getTimeoutInMilliSeconds() { - return timeoutInMilliSeconds; - } - - public void setTimeoutInMilliSeconds(long timeout) { - timeoutInMilliSeconds = timeout; - } - - public EndpointReference execute() throws AxisFault { - ServiceClient serviceClient = createServiceClient(); - OMElement responseMessage = null; - try { - responseMessage = serviceClient.sendReceive(createMessageEl()); - } finally { - serviceClient.cleanup(); - serviceClient.cleanupTransport(); - } - - if (responseMessage == null) { - throw AxisFault.makeFault(new RuntimeException("no response recieved for subscription message")); - } - String response = responseMessage.getFirstElement().getText(); - this.responseEl.setText(response); - this.msgBoxEndPointReference = ClientUtil.formatMessageBoxUrl(this.msgBoxEndPointReference, response); - return new EndpointReference(this.msgBoxEndPointReference); - } - - private OMElement createMessageEl() throws AxisFault { - OMElement message = factory.createOMElement("createMsgBox", NameSpaceConstants.MSG_BOX); - OMElement msgBoxId = factory.createOMElement("MsgBoxId", NameSpaceConstants.MSG_BOX); - msgBoxId.setText("Create message box"); - message.addChild(msgBoxId); - message.declareNamespace(NameSpaceConstants.MSG_BOX); - return message; - } - - private ServiceClient createServiceClient() throws AxisFault { - String uuid = UUIDGenerator.getUUID(); - Options opts = new Options(); - opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE); - opts.setTo(new EndpointReference(this.msgBoxEndPointReference)); - opts.setMessageId(uuid); - opts.setAction(NameSpaceConstants.MSG_BOX.getNamespaceURI() + "/" + "createMsgBox"); - - opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds()); - ServiceClient client = new ServiceClient(); - try { - client.engageModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING); - if (logger.isDebugEnabled()) - logger.debug("Addressing module engaged"); - } catch (AxisFault e) { - if (logger.isDebugEnabled()) - logger.debug("Addressing module not engaged :" + e); - } - client.setOptions(opts); - return client; - } - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/DestroyMsgBox.java ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/DestroyMsgBox.java b/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/DestroyMsgBox.java deleted file mode 100644 index 057acdf..0000000 --- a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/DestroyMsgBox.java +++ /dev/null @@ -1,120 +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.msgbox.client; - -import org.apache.airavata.wsmg.commons.NameSpaceConstants; -import org.apache.airavata.wsmg.commons.WsmgCommonConstants; -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.axiom.om.util.UUIDGenerator; -import org.apache.axis2.AxisFault; -import org.apache.axis2.addressing.EndpointReference; -import org.apache.axis2.client.Options; -import org.apache.axis2.client.ServiceClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This class can be used to invoke destroyMsgBox operation of msgBoxService and returns the resultant messageBoxId as - * EndpointReference - */ -public class DestroyMsgBox { - private static final Logger logger = LoggerFactory.getLogger(DestroyMsgBox.class); - - private EndpointReference msgBoxEndPointReference = null; - private long timeoutInMilliSeconds = 0; - private String msgBoxId = null; - private final OMFactory factory = OMAbstractFactory.getOMFactory(); - - public DestroyMsgBox(EndpointReference msgBoxEpr, long timeout) throws AxisFault { - this.msgBoxEndPointReference = msgBoxEpr; - this.timeoutInMilliSeconds = timeout; - String address = msgBoxEpr.getAddress(); - int biginIndex = address.indexOf("clientid"); - if (biginIndex != -1) { - msgBoxId = address.substring(biginIndex + "clientid".length() + 1); - } else { - throw new AxisFault("Invalid Message Box EPR cannot find message box ID"); - } - } - - public long getTimeoutInMilliSeconds() { - return timeoutInMilliSeconds; - } - - public void setTimeoutInMilliSeconds(long timeout) { - timeoutInMilliSeconds = timeout; - } - - public String execute() throws AxisFault { - OMElement message = createMessageEl(this.msgBoxId); - ServiceClient serviceClient = createServiceClient(message); - - OMElement responseMessage = null; - try { - responseMessage = serviceClient.sendReceive(message); - } finally { - serviceClient.cleanup(); - serviceClient.cleanupTransport(); - } - - responseMessage = serviceClient.sendReceive(message); - if (responseMessage == null) { - throw AxisFault.makeFault(new RuntimeException("no response recieved for subscription message")); - } - return responseMessage.getFirstElement().getText(); - } - - private OMElement createMessageEl(String msgboxid) throws AxisFault { - OMElement message = factory.createOMElement("destroyMsgBox", NameSpaceConstants.MSG_BOX); - OMElement msgBoxId = factory.createOMElement("MsgBoxId", NameSpaceConstants.MSG_BOX); - msgBoxId.setText(msgboxid); - message.addChild(msgBoxId); - message.declareNamespace(NameSpaceConstants.MSG_BOX); - return message; - } - - private ServiceClient createServiceClient(OMElement message) throws AxisFault { - String uuid = UUIDGenerator.getUUID(); - Options opts = new Options(); - opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE); - opts.setTo(msgBoxEndPointReference); - opts.setMessageId(uuid); - opts.setAction(message.getNamespace().getNamespaceURI() + "/" + message.getLocalName()); - - opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds()); - - ServiceClient client = new ServiceClient(); - try { - client.engageModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING); - if (logger.isDebugEnabled()) - logger.debug("Addressing module engaged"); - } catch (AxisFault e) { - if (logger.isDebugEnabled()) - logger.debug("Addressing module not engaged :" + e); - } - - client.setOptions(opts); - return client; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/MsgBoxClient.java ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/MsgBoxClient.java b/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/MsgBoxClient.java deleted file mode 100644 index 422c978..0000000 --- a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/MsgBoxClient.java +++ /dev/null @@ -1,63 +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.msgbox.client; - -import java.rmi.RemoteException; -import java.util.Iterator; - -import org.apache.axiom.om.OMElement; -import org.apache.axis2.addressing.EndpointReference; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This is the client class to invoke MsgBoxService this is using four separate classes to invoke four methods - * createMsgBox,destroyMsgBox,takeMessages and storeMessages operations of the service. - */ -public class MsgBoxClient { - - int msgsAtOnce = 10; - static Logger logger = LoggerFactory.getLogger(MsgBoxClient.class); - - public MsgBoxClient() { - } - - public EndpointReference createMessageBox(String msgBoxLocation, long timeout) throws RemoteException { - CreateMsgBox msgBox = new CreateMsgBox(msgBoxLocation, timeout); - return msgBox.execute(); - } - - public String storeMessage(EndpointReference msgBoxEpr, long timeout, OMElement messageIn) throws RemoteException { - StoreMessage strMsg = new StoreMessage(msgBoxEpr, timeout); - return strMsg.execute(messageIn); - } - - public Iterator<OMElement> takeMessagesFromMsgBox(EndpointReference msgBoxEpr, long timeout) throws RemoteException { - TakeMessages takeMsgs = new TakeMessages(msgBoxEpr, timeout); - return takeMsgs.execute(); - } - - public String deleteMsgBox(EndpointReference msgBoxEpr, long timeout) throws RemoteException { - DestroyMsgBox destroyMsgBox = new DestroyMsgBox(msgBoxEpr, timeout); - return destroyMsgBox.execute(); - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/StoreMessage.java ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/StoreMessage.java b/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/StoreMessage.java deleted file mode 100644 index daa62ef..0000000 --- a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/StoreMessage.java +++ /dev/null @@ -1,106 +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.msgbox.client; - -import org.apache.airavata.wsmg.commons.NameSpaceConstants; -import org.apache.airavata.wsmg.commons.WsmgCommonConstants; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.util.UUIDGenerator; -import org.apache.axis2.AxisFault; -import org.apache.axis2.addressing.EndpointReference; -import org.apache.axis2.client.Options; -import org.apache.axis2.client.ServiceClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This class can be used to invoke destroyMsgBox operation of msgBoxService and returns the resultant operation status - * as EndpointReference - */ -public class StoreMessage { - private static final Logger logger = LoggerFactory.getLogger(StoreMessage.class); - - protected EndpointReference msgBoxEndPointReference; - protected long timeoutInMilliSeconds; - - public StoreMessage(EndpointReference msgBoxEpr, long timeout) throws AxisFault { - this.msgBoxEndPointReference = msgBoxEpr; - this.timeoutInMilliSeconds = timeout; - String address = msgBoxEpr.getAddress(); - - /* - * Validate - */ - int biginIndex = address.indexOf("clientid"); - if (biginIndex == -1) { - throw new AxisFault("Invalid Message Box EPR cannot find message box ID"); - } - } - - public long getTimeoutInMilliSeconds() { - return timeoutInMilliSeconds; - } - - public void setTimeoutInMilliSeconds(long timeout) { - timeoutInMilliSeconds = timeout; - } - - public String execute(OMElement messageIn) throws AxisFault { - ServiceClient serviceClient = createServiceClient(); - - OMElement responseMessage = null; - - try { - responseMessage = serviceClient.sendReceive(messageIn); - } finally { - serviceClient.cleanup(); - serviceClient.cleanupTransport(); - } - - if (responseMessage == null) { - throw AxisFault.makeFault(new RuntimeException("no response recieved for subscription message")); - } - return responseMessage.getFirstElement().getText(); - } - - private ServiceClient createServiceClient() throws AxisFault { - String uuid = UUIDGenerator.getUUID(); - Options opts = new Options(); - opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE); - opts.setTo(msgBoxEndPointReference); - opts.setMessageId(uuid); - opts.setAction(NameSpaceConstants.MSG_BOX.getNamespaceURI() + "/" + "storeMessages"); - - opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds()); - ServiceClient client = new ServiceClient(); - try { - client.engageModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING); - if (logger.isDebugEnabled()) - logger.debug("Addressing module engaged"); - } catch (AxisFault e) { - if (logger.isDebugEnabled()) - logger.debug("Addressing module not engaged :" + e); - } - client.setOptions(opts); - return client; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/TakeMessages.java ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/TakeMessages.java b/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/TakeMessages.java deleted file mode 100644 index 8acf348..0000000 --- a/modules/ws-messenger/client/src/main/java/org/apache/airavata/wsmg/msgbox/client/TakeMessages.java +++ /dev/null @@ -1,123 +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.msgbox.client; - -import java.util.Iterator; - -import org.apache.airavata.wsmg.commons.NameSpaceConstants; -import org.apache.airavata.wsmg.commons.WsmgCommonConstants; -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.axiom.om.util.UUIDGenerator; -import org.apache.axis2.AxisFault; -import org.apache.axis2.addressing.EndpointReference; -import org.apache.axis2.client.Options; -import org.apache.axis2.client.ServiceClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This class can be used to invoke takeMessages operation of msgBoxService and returns the resultant operation status - * - */ -public class TakeMessages { - private static final Logger logger = LoggerFactory.getLogger(TakeMessages.class); - private final OMFactory factory = OMAbstractFactory.getOMFactory(); - protected EndpointReference msgBoxEndPointReference; - protected long timeoutInMilliSeconds; - private String msgBoxId; - - public TakeMessages(EndpointReference msgBoxEpr, long timeout) throws AxisFault { - this.msgBoxEndPointReference = msgBoxEpr; - this.timeoutInMilliSeconds = timeout; - String address = msgBoxEpr.getAddress(); - int biginIndex = address.indexOf("clientid"); - if (biginIndex != -1) { - msgBoxId = address.substring(biginIndex + "clientid".length() + 1); - } else { - throw new AxisFault("Invalid Message Box EPR cannot find message box ID"); - } - } - - public long getTimeoutInMilliSeconds() { - return timeoutInMilliSeconds; - } - - public void setTimeoutInMilliSeconds(long timeout) { - timeoutInMilliSeconds = timeout; - } - - public Iterator<OMElement> execute() throws AxisFault { - OMElement message = createMessageEl(this.msgBoxId); - ServiceClient serviceClient = createServiceClient(message); - - OMElement responseMessage = null; - try { - responseMessage = serviceClient.sendReceive(message); - - if (responseMessage == null) { - throw AxisFault.makeFault(new RuntimeException("no response recieved for subscription message")); - } - - responseMessage.build(); // free the input stream. - - } finally { - serviceClient.cleanup(); - serviceClient.cleanupTransport(); - } - - return (Iterator<OMElement>) responseMessage.getFirstElement().getChildren(); - } - - private OMElement createMessageEl(String msgboxid) throws AxisFault { - OMElement message = factory.createOMElement("takeMessages", NameSpaceConstants.MSG_BOX); - OMElement msgBoxId = factory.createOMElement("MsgBoxId", NameSpaceConstants.MSG_BOX); - msgBoxId.setText(msgboxid); - message.addChild(msgBoxId); - message.declareNamespace(NameSpaceConstants.MSG_BOX); - return message; - } - - private ServiceClient createServiceClient(OMElement message) throws AxisFault { - String uuid = UUIDGenerator.getUUID(); - Options opts = new Options(); - opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE); - opts.setTo(msgBoxEndPointReference); - opts.setMessageId(uuid); - opts.setAction(message.getNamespace().getNamespaceURI() + "/" + message.getLocalName()); - - opts.setTimeOutInMilliSeconds(getTimeoutInMilliSeconds()); - ServiceClient client = new ServiceClient(); - try { - client.engageModule(WsmgCommonConstants.AXIS_MODULE_NAME_ADDRESSING); - if (logger.isDebugEnabled()) - logger.debug("Addressing module engaged"); - } catch (AxisFault e) { - if (logger.isDebugEnabled()) - logger.debug("Addressing module not engaged :" + e); - } - - client.setOptions(opts); - return client; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/main/resources/amqp-routing-keys.xml ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/client/src/main/resources/amqp-routing-keys.xml b/modules/ws-messenger/client/src/main/resources/amqp-routing-keys.xml deleted file mode 100644 index 74ef675..0000000 --- a/modules/ws-messenger/client/src/main/resources/amqp-routing-keys.xml +++ /dev/null @@ -1,40 +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. --> -<routingKeys> - <!-- Routing keys for "workflowInvoked" event --> - <event name="workflowInvoked"> - <key name="primaryKey"> - <segment name="serviceID">notificationSource/@serviceID</segment> - </key> - </event> - <!-- Routing keys for "invokingService" event --> - <event name="invokingService"> - <key name="primaryKey"> - <segment name="serviceID">notificationSource/@serviceID</segment> - </key> - </event> - <!-- Routing keys for "receivedResult" event --> - <event name="receivedResult"> - <key name="primaryKey"> - <segment name="serviceID">notificationSource/@serviceID</segment> - </key> - </event> - <!-- Routing keys for "sendingResult" event --> - <event name="sendingResult"> - <key name="primaryKey"> - <segment name="serviceID">notificationSource/@serviceID</segment> - </key> - </event> - <!-- Routing keys for "workflowTerminated" event --> - <event name="workflowTerminated"> - <key name="primaryKey"> - <segment name="serviceID">notificationSource/@serviceID</segment> - </key> - </event> -</routingKeys> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/cab15715/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/amqp/BroadcastSubscriber.java ---------------------------------------------------------------------- diff --git a/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/amqp/BroadcastSubscriber.java b/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/amqp/BroadcastSubscriber.java deleted file mode 100644 index 5dbeb1c..0000000 --- a/modules/ws-messenger/client/src/test/java/org/apache/airavata/wsmg/client/amqp/BroadcastSubscriber.java +++ /dev/null @@ -1,54 +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.client.amqp; - -import java.util.Properties; - -import org.apache.airavata.common.utils.ApplicationSettings; -import org.apache.airavata.wsmg.client.amqp.rabbitmq.AMQPBroadcastReceiverImpl; - -public class BroadcastSubscriber { - public static void main(String args[]) throws AMQPException { - String host = ApplicationSettings.getSetting(AMQPUtil.CONFIG_AMQP_PROVIDER_HOST, "localhost"); - String port = ApplicationSettings.getSetting(AMQPUtil.CONFIG_AMQP_PROVIDER_PORT, "5672"); - String username = ApplicationSettings.getSetting(AMQPUtil.CONFIG_AMQP_PROVIDER_USERNAME, "guest"); - String password = ApplicationSettings.getSetting(AMQPUtil.CONFIG_AMQP_PROVIDER_PASSWORD, "guest"); - - Properties properties = new Properties(); - properties.setProperty(AMQPUtil.CONFIG_AMQP_PROVIDER_HOST, host); - properties.setProperty(AMQPUtil.CONFIG_AMQP_PROVIDER_PORT, port); - properties.setProperty(AMQPUtil.CONFIG_AMQP_PROVIDER_USERNAME, username); - properties.setProperty(AMQPUtil.CONFIG_AMQP_PROVIDER_PASSWORD, password); - - MessageConsumer consumer = new MessageConsumer(); - AMQPBroadcastReceiver receiver = new AMQPBroadcastReceiverImpl(properties, consumer); - System.out.println("Waiting for broadcast messages : \n"); - - receiver.Subscribe(); - } - - public static class MessageConsumer implements AMQPCallback { - public void onMessage(String message) { - System.out.println("Received : " + message); - } - } -}
