Author: asankaa Date: Mon Nov 24 02:56:36 2008 New Revision: 24699 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=24699
Log: message builder updated to create incoming reqests Modified: branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/Subscription.java branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/SubscriptionMessageBuilder.java Modified: branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/Subscription.java URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/Subscription.java?rev=24699&r1=24698&r2=24699&view=diff ============================================================================== --- branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/Subscription.java (original) +++ branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/Subscription.java Mon Nov 24 02:56:36 2008 @@ -24,6 +24,7 @@ import org.wso2.eventing.EventingConstants; import java.util.Date; +import java.util.Calendar; /** * @@ -34,7 +35,7 @@ private Endpoint endpoint; private String deliveryMode; private String id = null; - private Date expires = null; + private Calendar expires = null; public Subscription() { this.id = UUIDGenerator.getUUID(); @@ -78,11 +79,11 @@ this.id = id; } - public Date getExpires() { + public Calendar getExpires() { return expires; } - public void setExpires(Date expires) { + public void setExpires(Calendar expires) { this.expires = expires; } } Modified: branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/SubscriptionMessageBuilder.java URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/SubscriptionMessageBuilder.java?rev=24699&r1=24698&r2=24699&view=diff ============================================================================== --- branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/SubscriptionMessageBuilder.java (original) +++ branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/builders/SubscriptionMessageBuilder.java Mon Nov 24 02:56:36 2008 @@ -21,6 +21,7 @@ import org.apache.axiom.om.OMAttribute; import org.apache.axiom.om.OMElement; +import org.apache.axis2.databinding.utils.ConverterUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.synapse.MessageContext; @@ -30,12 +31,14 @@ import org.apache.synapse.endpoints.AddressEndpoint; import org.apache.synapse.endpoints.Endpoint; import org.apache.synapse.endpoints.EndpointDefinition; -import org.apache.synapse.eventing.filters.XPathBasedEventFilter; import org.apache.synapse.eventing.Subscription; +import org.apache.synapse.eventing.filters.XPathBasedEventFilter; import org.apache.synapse.util.xpath.SynapseXPath; import org.jaxen.JaxenException; import org.wso2.eventing.EventingConstants; + import javax.xml.namespace.QName; +import java.util.Calendar; /** * @@ -44,13 +47,68 @@ private static final Log log = LogFactory.getLog(SubscriptionMessageBuilder.class); - private static final QName SUBSCRIBE_QNAME = new QName(EventingConstants.WSE_EVENTING_NS, EventingConstants.WSE_EN_SUBSCRIBE); - private static final QName DELIVERY_QNAME = new QName(EventingConstants.WSE_EVENTING_NS, EventingConstants.WSE_EN_DELIVERY); - private static final QName FILTER_QNAME = new QName(EventingConstants.WSE_EVENTING_NS, EventingConstants.WSE_EN_FILTER); - private static final QName NOTIFY_TO_QNAME = new QName(EventingConstants.WSE_EVENTING_NS, EventingConstants.WSE_EN_NOTIFY_TO); - private static final QName ATT_DIALECT = new QName(XMLConfigConstants.NULL_NAMESPACE, EventingConstants.WSE_EN_DIALECT); - private static final QName ATT_XPATH = new QName(XMLConfigConstants.NULL_NAMESPACE, EventingConstants.WSE_EN_XPATH); - private static final QName IDENTIFIER = new QName(EventingConstants.WSE_EVENTING_NS, EventingConstants.WSE_EN_IDENTIFIER); + private static final QName SUBSCRIBE_QNAME = new QName(EventingConstants.WSE_EVENTING_NS, EventingConstants.WSE_EN_SUBSCRIBE); + private static final QName DELIVERY_QNAME = new QName(EventingConstants.WSE_EVENTING_NS, EventingConstants.WSE_EN_DELIVERY); + private static final QName FILTER_QNAME = new QName(EventingConstants.WSE_EVENTING_NS, EventingConstants.WSE_EN_FILTER); + private static final QName NOTIFY_TO_QNAME = new QName(EventingConstants.WSE_EVENTING_NS, EventingConstants.WSE_EN_NOTIFY_TO); + private static final QName ATT_DIALECT = new QName(XMLConfigConstants.NULL_NAMESPACE, EventingConstants.WSE_EN_DIALECT); + private static final QName ATT_XPATH = new QName(XMLConfigConstants.NULL_NAMESPACE, EventingConstants.WSE_EN_XPATH); + private static final QName IDENTIFIER = new QName(EventingConstants.WSE_EVENTING_NS, EventingConstants.WSE_EN_IDENTIFIER); + private static final QName EXPIRES = new QName(EventingConstants.WSE_EVENTING_NS, EventingConstants.WSE_EN_EXPIRES); + + /** + * (01) <s12:Envelope + * (02) xmlns:s12="http://www.w3.org/2003/05/soap-envelope" + * (03) xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" + * (04) xmlns:wse="http://schemas.xmlsoap.org/ws/2004/08/eventing" + * (05) xmlns:ew="http://www.example.com/warnings" > + * (06) <s12:Header> + * (07) <wsa:Action> + * (08) http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe + * (09) </wsa:Action> + * (10) <wsa:MessageID> + * (11) uuid:e1886c5c-5e86-48d1-8c77-fc1c28d47180 + * (12) </wsa:MessageID> + * (13) <wsa:ReplyTo> + * (14) <wsa:Address>http://www.example.com/MyEvEntsink</wsa:Address> + * (15) <wsa:ReferenceProperties> + * (16) <ew:MySubscription>2597</ew:MySubscription> + * (17) </wsa:ReferenceProperties> + * (18) </wsa:ReplyTo> + * (19) <wsa:To>http://www.example.org/oceanwatch/EventSource</wsa:To> + * (20) </s12:Header> + * (21) <s12:Body> + * (22) <wse:Subscribe> + * (23) <wse:EndTo> + * (24) <wsa:Address> + * (25) http://www.example.com/MyEventSink + * (26) </wsa:Address> + * (27) <wsa:ReferenceProperties> + * (28) <ew:MySubscription>2597</ew:MySubscription> + * (29) </wsa:ReferenceProperties> + * (30) </wse:EndTo> + * (31) <wse:Delivery> + * (32) <wse:NotifyTo> + * (33) <wsa:Address> + * (34) http://www.other.example.com/OnStormWarning + * (35) </wsa:Address> + * (36) <wsa:ReferenceProperties> + * (37) <ew:MySubscription>2597</ew:MySubscription> + * (38) </wsa:ReferenceProperties> + * (39) </wse:NotifyTo> + * (40) </wse:Delivery> + * (41) <wse:Expires>2004-06-26T21:07:00.000-08:00</wse:Expires> + * (42) <wse:Filter xmlns:ow="http://www.example.org/oceanwatch" + * (43) Dialect="http://www.example.org/topicFilter" > + * (44) weather.storms + * (45) </wse:Filter> + * (46) </wse:Subscribe> + * (47) </s12:Body> + * (48) </s12:Envelope> + * + * @param mc + * @return + */ public static Subscription createSubscription(MessageContext mc) { //TODO: add expiration time Subscription subscription = null; @@ -93,6 +151,11 @@ handleException("Error in creating subscription. Filter dialect not defined"); } } + OMElement expiryElem = elem.getFirstChildWithName(EXPIRES); + if (expiryElem != null) { + Calendar calendar = ConverterUtil.convertToDateTime(expiryElem.getText()); + subscription.setExpires(calendar); + } } else { handleException("Subscribe element is required as the payload of the subscription message"); } @@ -119,14 +182,125 @@ /** * create request for unsubscribr request + * (01) <s12:Envelope + * (02) xmlns:s12="http://www.w3.org/2003/05/soap-envelope" + * (03) xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" + * (04) xmlns:wse="http://schemas.xmlsoap.org/ws/2004/08/eventing" + * (05) xmlns:ow="http://www.example.org/oceanwatch" > + * (06) <s12:Header> + * (07) <wsa:Action> + * (08) http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe + * (09) </wsa:Action> + * (10) <wsa:MessageID> + * (11) uuid:2653f89f-25bc-4c2a-a7c4-620504f6b216 + * (12) </wsa:MessageID> + * (13) <wsa:ReplyTo> + * (14) <wsa:Address>http://www.example.com/MyEventSink</wsa:Address> + * (15) </wsa:ReplyTo> + * (16) <wsa:To> + * (17) http://www.example.org/oceanwatch/SubscriptionManager + * (18) </wsa:To> + * (19) <wse:Identifier> + * (20) uuid:22e8a584-0d18-4228-b2a8-3716fa2097fa + * (21) </wse:Identifier> + * (22) </s12:Header> + * (23) <s12:Body> + * (24) <wse:Unsubscribe /> + * (25) </s12:Body> + * (26) </s12:Envelope> + * * @param mc * @return */ - public static Subscription createUnSubscribeMessage(MessageContext mc){ - Subscription subscription = new Subscription(); - OMElement elem = mc.getEnvelope().getHeader().getFirstChildWithName(IDENTIFIER); - String id = (String) elem.getText(); - subscription.setId(id); - return subscription; + public static Subscription createUnSubscribeMessage(MessageContext mc) { + Subscription subscription = new Subscription(); + OMElement elem = mc.getEnvelope().getHeader().getFirstChildWithName(IDENTIFIER); + String id = (String) elem.getText(); + subscription.setId(id); + return subscription; + } + + /** + * (01) <s12:Envelope + * (02) xmlns:s12="http://www.w3.org/2003/05/soap-envelope" + * (03) xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" + * (04) xmlns:wse="http://schemas.xmlsoap.org/ws/2004/08/eventing" + * (05) xmlns:ow="http://www.example.org/oceanwatch" > + * (06) <s12:Header> + * (07) <wsa:Action> + * (08) http://schemas.xmlsoap.org/ws/2004/08/eventing/Renew + * (09) </wsa:Action> + * (10) <wsa:MessageID> + * (11) uuid:bd88b3df-5db4-4392-9621-aee9160721f6 + * (12) </wsa:MessageID> + * (13) <wsa:ReplyTo> + * (14) <wsa:Address>http://www.example.com/MyEventSink</wsa:Address> + * (15) </wsa:ReplyTo> + * (16) <wsa:To> + * (17) http://www.example.org/oceanwatch/SubscriptionManager + * (18) </wsa:To> + * (19) <wse:Identifier> + * (20) uuid:22e8a584-0d18-4228-b2a8-3716fa2097fa + * (21) </wse:Identifier> + * (22) </s12:Header> + * (23) <s12:Body> + * (24) <wse:Renew> + * (25) <wse:Expires>2004-06-26T21:07:00.000-08:00</wse:Expires> + * (26) </wse:Renew> + * (27) </s12:Body> + * (28) </s12:Envelope> + * + * @param mc + * @return + */ + public static Subscription createRenewSubscribeMessage(MessageContext mc) { + Subscription subscription = new Subscription(); + OMElement elem = mc.getEnvelope().getHeader().getFirstChildWithName(IDENTIFIER); + String id = (String) elem.getText(); + subscription.setId(id); + OMElement expiryElem = elem.getFirstChildWithName(EXPIRES); + if (expiryElem != null) { + Calendar calendar = ConverterUtil.convertToDateTime(expiryElem.getText()); + subscription.setExpires(calendar); + } + return subscription; + } + + /** + * (01) <s12:Envelope + * (02) xmlns:s12="http://www.w3.org/2003/05/soap-envelope" + * (03) xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" + * (04) xmlns:wse="http://schemas.xmlsoap.org/ws/2004/08/eventing" + * (05) xmlns:ow="http://www.example.org/oceanwatch" > + * (06) <s12:Header> + * (07) <wsa:Action> + * (08) http://schemas.xmlsoap.org/ws/2004/08/eventing/GetStatus + * (09) </wsa:Action> + * (10) <wsa:MessageID> + * (11) uuid:bd88b3df-5db4-4392-9621-aee9160721f6 + * (12) </wsa:MessageID> + * (13) <wsa:ReplyTo> + * (14) <wsa:Address>http://www.example.com/MyEventSink</wsa:Address> + * (15) </wsa:ReplyTo> + * (16) <wsa:To> + * (17) http://www.example.org/oceanwatch/SubscriptionManager + * (18) </wsa:To> + * (19) <wse:Identifier> + * (20) uuid:22e8a584-0d18-4228-b2a8-3716fa2097fa + * (21) </wse:Identifier> + * (22) </s12:Header> + * (23) <s12:Body> + * (24) <wse:GetStatus /> + * (25) </s12:Body> + * (26) </s12:Envelope> + * @param mc + * @return + */ + public static Subscription createGetStatusMessage(MessageContext mc) { + Subscription subscription = new Subscription(); + OMElement elem = mc.getEnvelope().getHeader().getFirstChildWithName(IDENTIFIER); + String id = (String) elem.getText(); + subscription.setId(id); + return subscription; } } _______________________________________________ Esb-java-dev mailing list [email protected] https://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev
