Examples of InvalidMessageException


Examples of org.wso2.carbon.event.broker.builders.exceptions.InvalidMessageException

                        subscription.setEndpointUrl(ep);
                        subscription.setAddressUrl(notifyToElem.getFirstElement().getText().trim());
                    }
                } else {
                    log.error("NotifyTo element not found in the subscription message.");
                    throw new InvalidMessageException(
                            "NotifyTo element not found in the subscription message.");
                }
            } else {
                log.error("Delivery element is not found in the subscription message.");
                throw new InvalidMessageException(
                        "Delivery element is not found in the subscription message.");
            }

            OMElement filterElem = elem.getFirstChildWithName(FILTER_QNAME);
            if (subscription != null && filterElem != null) {
                OMAttribute dialectAttr = filterElem.getAttribute(ATT_DIALECT);
                if (dialectAttr != null && dialectAttr.getAttributeValue() != null) {
                  subscription.setFilterDesc(new EventFilterDesc(dialectAttr.getAttributeValue(),filterElem.getText().trim()));
                } else {
                    log.error("Error in creating subscription. Filter dialect not defined.");
                    throw new BuilderException(
                            "Error in creating subscription. Filter dialect not defined.");
                }
            } else if (subscription == null) {
                log.error("Error in creating subscription.");
                throw new BuilderException("Error in creating subscription.");
            }
            OMElement expiryElem = elem.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.");
                }
            }
           
            OMElement scriptElement = elem.getFirstChildWithName(new QName(EventingConstants.WSE_EXTENDED_EVENTING_NS,EventingConstants.EVENTING_EXECUTABLE_SCRIPT_ELEMENT));
            if(scriptElement != null){
                if(subscription.getSubscriptionData() != null){
                    subscription.setSubscriptionData(new SubscriptionData());
                }
                subscription.getSubscriptionData().setProperty(EventingConstants.EVENTING_EXECUTABLE_SCRIPT_ELEMENT, scriptElement.getText());   
            }
        } else {
            log.error("Subscribe element is required as the payload of the subscription message.");
            throw new InvalidMessageException(
                    "Subscribe element is required as the payload of the subscription message.");
        }
        return subscription;
    }
View Full Code Here

Examples of org.wso2.carbon.event.broker.builders.exceptions.InvalidMessageException

            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);
       
View Full Code Here

Examples of org.wso2.carbon.event.broker.builders.exceptions.InvalidMessageException

    public static Subscription createSubscription(String endpoint, String filterDialect,
                                                  String topic) throws InvalidMessageException {
        Subscription subscription = new Subscription();
        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.setFilterDesc(new EventFilterDesc(filterDialect,topic));
        return subscription;
    }
View Full Code Here

Examples of org.wso2.carbon.event.ws.internal.builders.exceptions.InvalidMessageException

            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);
View Full Code Here

Examples of org.wso2.carbon.event.ws.internal.builders.exceptions.InvalidMessageException

            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);
       
View Full Code Here

Examples of org.wso2.carbon.event.ws.internal.builders.exceptions.InvalidMessageException

                        subscription = new Subscription();
                        subscription.setEventSinkURL(ep);
                    }
                } else {
                    log.error("NotifyTo element not found in the subscription message.");
                    throw new InvalidMessageException(
                            "NotifyTo element not found in the subscription message.");
                }
            } else {
                log.error("Delivery element is not found in the subscription message.");
                throw new InvalidMessageException(
                        "Delivery element is not found in the subscription message.");
            }

            OMElement filterElem = elem.getFirstChildWithName(FILTER_QNAME);
            if (subscription != null && filterElem != null) {
                OMAttribute dialectAttribute = filterElem.getAttribute(ATT_DIALECT);
                if (dialectAttribute != null && dialectAttribute.getAttributeValue() != null) {
                    subscription.setEventFilter(
                            new EventFilter(dialectAttribute.getAttributeValue(),
                                    filterElem.getText().trim()));
                } else {
                    log.error("Error in creating subscription. Filter dialect not defined.");
                    throw new BuilderException(
                            "Error in creating subscription. Filter dialect not defined.");
                }
            } else if (subscription == null) {
                log.error("Error in creating subscription.");
                throw new BuilderException("Error in creating subscription.");
            }
            OMElement expiryElem = elem.getFirstChildWithName(EXPIRES);
            if (expiryElem != null) {
                Calendar calendarExpires;
                try {
                    String expiryText = expiryElem.getText().trim();
                    if (expiryText.startsWith("P")) {
                        calendarExpires = Calendar.getInstance();
                        Duration duration = ConverterUtil.convertToDuration(expiryText);
                        calendarExpires.add(Calendar.YEAR, duration.getYears());
                        calendarExpires.add(Calendar.MONTH, duration.getMonths());
                        calendarExpires.add(Calendar.DAY_OF_MONTH, duration.getDays());
                        calendarExpires.add(Calendar.HOUR_OF_DAY, duration.getHours());
                        calendarExpires.add(Calendar.MINUTE, duration.getMinutes());
                        calendarExpires.add(Calendar.SECOND, (int)duration.getSeconds());
                    } 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.");
                }
            }

            OMElement scriptElement = elem.getFirstChildWithName(new QName(EventingConstants.WSE_EXTENDED_EVENTING_NS, EventingConstants.EVENTING_EXECUTABLE_SCRIPT_ELEMENT));
            if (scriptElement != null) {
                subscription.getProperties().put(EventingConstants.EVENTING_EXECUTABLE_SCRIPT_ELEMENT, scriptElement.getText());
            }
        } else {
            log.error("Subscribe element is required as the payload of the subscription message.");
            throw new InvalidMessageException(
                    "Subscribe element is required as the payload of the subscription message.");
        }
        return subscription;
    }
View Full Code Here

Examples of org.wso2.carbon.event.ws.internal.builders.exceptions.InvalidMessageException

            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);
       
View Full Code Here

Examples of org.wso2.carbon.event.ws.internal.builders.exceptions.InvalidMessageException

    public static Subscription createSubscription(String endpoint, String filterDialect,
                                                  String topic) throws InvalidMessageException {
        Subscription subscription = new Subscription();
        if (endpoint == null) {
            throw new InvalidMessageException("Endpoint not found in the subscription request");
        }
        subscription.setEventSinkURL(endpoint);
        if (topic == null) {
            throw new InvalidMessageException("Error in creating subscription. Topic not defined");
        }
       
        subscription.setTopicName(topic);
        return subscription;
    }
View Full Code Here

Examples of org.wso2.carbon.eventing.broker.builders.exceptions.InvalidMessageException

    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.builders.exceptions.InvalidMessageException

            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);
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.