Examples of CarbonSubscription


Examples of org.wso2.carbon.eventing.broker.CarbonSubscription

        }
    }

    public static Subscription createSubscription(String endpoint, String filterDialect,
                                                  String topic) throws InvalidMessageException {
        Subscription subscription = new CarbonSubscription();
        subscription.setDeliveryMode(CommandBuilderConstants.WSE_DEFAULT_DELIVERY_MODE);
        if (endpoint == null) {
            throw new InvalidMessageException("Endpoint not found in the subscription request");
        }
        subscription.setEndpointUrl(endpoint.trim());
        subscription.setAddressUrl(endpoint);
        if (topic == null) {
            throw new InvalidMessageException("Error in creating subscription. Topic not defined");
        }
        subscription.setFilterDialect(filterDialect);
        subscription.setFilterValue(topic);
        return subscription;
    }
View Full Code Here

Examples of org.wso2.carbon.eventing.broker.CarbonSubscription

        assertEquals("Invalid response for the get status request", RESPONSE_PAYLOAD_SOAP11_WITH_EXPIRY,
                payload.toString());
    }

    public void testCarbonSubscriptionToSOAP12Envelope() throws Exception {
        Subscription subscription = new CarbonSubscription();
        subscription.setSubManUrl("http://www.example.org/oceanwatch/SubscriptionManager");
        String id = subscription.getId();
        MessageContext mc = CommandBuilderTestUtils.getMCWithSOAP12Envelope();
        SubscribeCommandBuilder builder = new  SubscribeCommandBuilder(mc);

        OMElement payload = builder.fromSubscription(subscription);
View Full Code Here

Examples of org.wso2.carbon.eventing.broker.CarbonSubscription

        assertEquals("Invalid response for the get status request", expectPayload,
                payload.toString());
    }

    public void testCarbonSubscriptionToSOAP11Envelope() throws Exception {
        Subscription subscription = new CarbonSubscription();
        subscription.setSubManUrl("http://www.example.org/oceanwatch/SubscriptionManager");
        String id = subscription.getId();
        MessageContext mc = CommandBuilderTestUtils.getMCWithSOAP11Envelope();
        SubscribeCommandBuilder builder = new  SubscribeCommandBuilder(mc);

        OMElement payload = builder.fromSubscription(subscription);
View Full Code Here

Examples of org.wso2.carbon.eventing.broker.CarbonSubscription

    public Subscription toSubscription(SOAPEnvelope envelope) throws InvalidMessageException {
        if (envelope == null) {
            log.error("No SOAP envelope was provided.");
            throw new BuilderException("No SOAP envelope was provided.");
        }
        Subscription subscription = new CarbonSubscription();
        OMElement elem = null;
        if (envelope.getHeader() != null) {
            elem = envelope.getHeader().getFirstChildWithName(IDENTIFIER);
        }
        if (elem == null) {
            log.error(
                    "Subscription Identifier is required as a header of the subscription message.");
            throw new InvalidMessageException(
                    "Subscription Identifier is required as a header of the subscription message.");
        }
        String id = elem.getText().trim();
        subscription.setId(id);

        return subscription;
    }
View Full Code Here

Examples of org.wso2.carbon.eventing.broker.CarbonSubscription

    public Subscription toSubscription(SOAPEnvelope envelope) throws InvalidMessageException {
        if (envelope == null) {
            log.error("No SOAP envelope was provided.");
            throw new BuilderException("No SOAP envelope was provided.");
        }
        Subscription subscription = new CarbonSubscription();
        OMElement elem = null;
        if (envelope.getHeader() != null) {
            elem = envelope.getHeader().getFirstChildWithName(IDENTIFIER);
        }
        if (elem == null) {
            log.error(
                    "Subscription Identifier is required as a header of the subscription message.");
            throw new InvalidMessageException(
                    "Subscription Identifier is required as a header of the subscription message.");
        }
        String id = elem.getText().trim();
        subscription.setId(id);
       
        return subscription;
    }
View Full Code Here

Examples of org.wso2.carbon.eventing.broker.CarbonSubscription

                notifyToElem = deliveryElem.getFirstChildWithName(NOTIFY_TO_QNAME);
                if (notifyToElem != null) {
                    String ep = BuilderUtils.getEndpointFromWSAAddress(
                            notifyToElem.getFirstElement());
                    if (ep != null) {
                        subscription = new CarbonSubscription();
                        subscription.setDeliveryMode(WSE_DEFAULT_DELIVERY_MODE);
                        subscription.setEndpointUrl(ep);
                        subscription.setAddressUrl(notifyToElem.getFirstElement().getText().trim());
                    }
                } else {
View Full Code Here

Examples of org.wso2.carbon.eventing.broker.CarbonSubscription

        InvalidExpirationTimeException {
        if (envelope == null) {
            log.error("No SOAP envelope was provided.");
            throw new BuilderException("No SOAP envelope was provided.");
        }
        Subscription subscription = new CarbonSubscription();
        OMElement elem = null;
        if (envelope.getHeader() != null) {
            elem = envelope.getHeader().getFirstChildWithName(IDENTIFIER);
        }
        if (elem == null) {
            log.error(
                    "Subscription Identifier is required as a header of the subscription message.");
            throw new InvalidMessageException(
                    "Subscription Identifier is required as a header of the subscription message.");
        }
        String id = elem.getText().trim();
        subscription.setId(id);
       
        OMElement renewElem = envelope.getBody().getFirstChildWithName(RENEW);
        if (renewElem != null) {
            OMElement expiryElem = renewElem.getFirstChildWithName(EXPIRES);
            if (expiryElem != null) {
                Calendar calendarExpires;
                try {
                    String expiryText = expiryElem.getText().trim();
                    if (expiryText.startsWith("P")) {
                        calendarExpires = ConverterUtil.convertToDuration(expiryText)
                                .getAsCalendar();
                    } else {
                        calendarExpires = ConverterUtil.convertToDateTime(expiryText);
                    }
                } catch (Exception e) {
                    log.error("Error converting the expiration date", e);
                    throw new InvalidExpirationTimeException(
                            "Error converting the expiration date", e);
                }
                Calendar calendarNow = Calendar.getInstance();
                if (calendarNow.before(calendarExpires)) {
                    subscription.setExpires(calendarExpires);
                } else {
                    log.error("The expiration time has passed");
                    throw new InvalidExpirationTimeException("The expiration time has passed");
                }

                subscription.setExpires(calendarExpires);
            } else {
                log.error("The expiration time was not given");
                throw new InvalidExpirationTimeException("The expiration time was not given");
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.