Search in sources :

Example 1 with InvalidTopicExpressionFault

use of org.oasis_open.docs.wsn.bw_2.InvalidTopicExpressionFault in project cxf by apache.

the class AbstractNotificationBroker method handleSubscribe.

public SubscribeResponse handleSubscribe(Subscribe subscribeRequest, EndpointManager manager) throws // CHECKSTYLE:OFF - WS-Notification spec throws a lot of faults
InvalidFilterFault, InvalidMessageContentExpressionFault, InvalidProducerPropertiesExpressionFault, InvalidTopicExpressionFault, SubscribeCreationFailedFault, TopicExpressionDialectUnknownFault, TopicNotSupportedFault, UnacceptableInitialTerminationTimeFault, UnsupportedPolicyRequestFault, UnrecognizedPolicyRequestFault {
    // CHECKSTYLE:ON
    AbstractSubscription subscription = null;
    boolean success = false;
    try {
        subscription = createSubscription(idGenerator.generateSanitizedId());
        subscription.setBroker(this);
        subscriptions.put(subscription.getAddress(), subscription);
        subscription.create(subscribeRequest);
        if (manager != null) {
            subscription.setManager(manager);
        }
        subscription.register();
        SubscribeResponse response = new SubscribeResponse();
        response.setSubscriptionReference(subscription.getEpr());
        success = true;
        return response;
    } catch (EndpointRegistrationException e) {
        LOGGER.log(Level.WARNING, "Unable to register new endpoint", e);
        SubscribeCreationFailedFaultType fault = new SubscribeCreationFailedFaultType();
        throw new SubscribeCreationFailedFault("Unable to register new endpoint", fault, e);
    } finally {
        if (!success && subscription != null) {
            if (subscription.getAddress() != null) {
                subscriptions.remove(subscription.getAddress());
            }
            try {
                subscription.unsubscribe();
            } catch (UnableToDestroySubscriptionFault e) {
                LOGGER.log(Level.INFO, "Error destroying subscription", e);
            }
        }
    }
}
Also used : SubscribeCreationFailedFault(org.oasis_open.docs.wsn.bw_2.SubscribeCreationFailedFault) UnableToDestroySubscriptionFault(org.oasis_open.docs.wsn.bw_2.UnableToDestroySubscriptionFault) SubscribeCreationFailedFaultType(org.oasis_open.docs.wsn.b_2.SubscribeCreationFailedFaultType) SubscribeResponse(org.oasis_open.docs.wsn.b_2.SubscribeResponse)

Example 2 with InvalidTopicExpressionFault

use of org.oasis_open.docs.wsn.bw_2.InvalidTopicExpressionFault in project cxf by apache.

the class AbstractSubscription method validateSubscription.

protected void validateSubscription(Subscribe subscribeRequest) throws // CHECKSTYLE:OFF - WS-Notification spec throws a lot of faults
InvalidFilterFault, InvalidMessageContentExpressionFault, InvalidProducerPropertiesExpressionFault, InvalidTopicExpressionFault, SubscribeCreationFailedFault, TopicExpressionDialectUnknownFault, TopicNotSupportedFault, UnacceptableInitialTerminationTimeFault, UnrecognizedPolicyRequestFault, UnsupportedPolicyRequestFault {
    // CHECKSTYLE:ON
    // Check consumer reference
    consumerReference = subscribeRequest.getConsumerReference();
    // Check terminationTime
    if (subscribeRequest.getInitialTerminationTime() != null && !subscribeRequest.getInitialTerminationTime().isNil() && subscribeRequest.getInitialTerminationTime().getValue() != null) {
        String strTerminationTime = subscribeRequest.getInitialTerminationTime().getValue();
        terminationTime = validateInitialTerminationTime(strTerminationTime.trim());
    }
    // Check filter
    if (subscribeRequest.getFilter() != null) {
        for (Object f : subscribeRequest.getFilter().getAny()) {
            JAXBElement<?> e = null;
            if (f instanceof JAXBElement) {
                e = (JAXBElement<?>) f;
                f = e.getValue();
            }
            if (f instanceof TopicExpressionType) {
                if (!e.getName().equals(QNAME_TOPIC_EXPRESSION)) {
                    InvalidTopicExpressionFaultType fault = new InvalidTopicExpressionFaultType();
                    throw new InvalidTopicExpressionFault("Unrecognized TopicExpression: " + e, fault);
                }
                topic = (TopicExpressionType) f;
            } else if (f instanceof QueryExpressionType) {
                if (e != null && e.getName().equals(QNAME_PRODUCER_PROPERTIES)) {
                    InvalidProducerPropertiesExpressionFaultType fault = new InvalidProducerPropertiesExpressionFaultType();
                    throw new InvalidProducerPropertiesExpressionFault("ProducerProperties are not supported", fault);
                } else if (e != null && e.getName().equals(QNAME_MESSAGE_CONTENT)) {
                    if (contentFilter != null) {
                        InvalidMessageContentExpressionFaultType fault = new InvalidMessageContentExpressionFaultType();
                        throw new InvalidMessageContentExpressionFault("Only one MessageContent filter can be specified", fault);
                    }
                    contentFilter = (QueryExpressionType) f;
                    // Defaults to XPath 1.0
                    if (contentFilter.getDialect() == null) {
                        contentFilter.setDialect(XPATH1_URI);
                    }
                } else {
                    InvalidFilterFaultType fault = new InvalidFilterFaultType();
                    throw new InvalidFilterFault("Unrecognized filter: " + (e != null ? e.getName() : f), fault);
                }
            } else {
                InvalidFilterFaultType fault = new InvalidFilterFaultType();
                throw new InvalidFilterFault("Unrecognized filter: " + (e != null ? e.getName() : f), fault);
            }
        }
    }
    // Check policy
    if (subscribeRequest.getSubscriptionPolicy() != null) {
        for (Object p : subscribeRequest.getSubscriptionPolicy().getAny()) {
            JAXBElement<?> e = null;
            if (p instanceof JAXBElement) {
                e = (JAXBElement<?>) p;
                p = e.getValue();
            }
            if (p instanceof UseRaw) {
                useRaw = true;
            } else {
                UnrecognizedPolicyRequestFaultType fault = new UnrecognizedPolicyRequestFaultType();
                throw new UnrecognizedPolicyRequestFault("Unrecognized policy: " + p, fault);
            }
        }
    }
    // Check all parameters
    if (consumerReference == null) {
        SubscribeCreationFailedFaultType fault = new SubscribeCreationFailedFaultType();
        throw new SubscribeCreationFailedFault("Invalid ConsumerReference: null", fault);
    }
    // TODO check we can resolve endpoint
    if (topic == null) {
        InvalidFilterFaultType fault = new InvalidFilterFaultType();
        throw new InvalidFilterFault("Must specify a topic to subscribe on", fault);
    }
    if (contentFilter != null && !contentFilter.getDialect().equals(XPATH1_URI)) {
        InvalidMessageContentExpressionFaultType fault = new InvalidMessageContentExpressionFaultType();
        throw new InvalidMessageContentExpressionFault("Unsupported MessageContent dialect: '" + contentFilter.getDialect() + "'", fault);
    }
}
Also used : UnrecognizedPolicyRequestFaultType(org.oasis_open.docs.wsn.b_2.UnrecognizedPolicyRequestFaultType) UnrecognizedPolicyRequestFault(org.oasis_open.docs.wsn.bw_2.UnrecognizedPolicyRequestFault) SubscribeCreationFailedFault(org.oasis_open.docs.wsn.bw_2.SubscribeCreationFailedFault) InvalidMessageContentExpressionFaultType(org.oasis_open.docs.wsn.b_2.InvalidMessageContentExpressionFaultType) SubscribeCreationFailedFaultType(org.oasis_open.docs.wsn.b_2.SubscribeCreationFailedFaultType) QueryExpressionType(org.oasis_open.docs.wsn.b_2.QueryExpressionType) JAXBElement(javax.xml.bind.JAXBElement) InvalidFilterFault(org.oasis_open.docs.wsn.bw_2.InvalidFilterFault) UseRaw(org.oasis_open.docs.wsn.b_2.UseRaw) InvalidProducerPropertiesExpressionFaultType(org.oasis_open.docs.wsn.b_2.InvalidProducerPropertiesExpressionFaultType) InvalidFilterFaultType(org.oasis_open.docs.wsn.b_2.InvalidFilterFaultType) TopicExpressionType(org.oasis_open.docs.wsn.b_2.TopicExpressionType) InvalidProducerPropertiesExpressionFault(org.oasis_open.docs.wsn.bw_2.InvalidProducerPropertiesExpressionFault) InvalidTopicExpressionFaultType(org.oasis_open.docs.wsn.b_2.InvalidTopicExpressionFaultType) InvalidTopicExpressionFault(org.oasis_open.docs.wsn.bw_2.InvalidTopicExpressionFault) InvalidMessageContentExpressionFault(org.oasis_open.docs.wsn.bw_2.InvalidMessageContentExpressionFault)

Example 3 with InvalidTopicExpressionFault

use of org.oasis_open.docs.wsn.bw_2.InvalidTopicExpressionFault in project cxf by apache.

the class Publisher method subscribe.

public SubscribeResponse subscribe(@WebParam(partName = "SubscribeRequest", name = "Subscribe", targetNamespace = "http://docs.oasis-open.org/wsn/b-2") Subscribe subscribeRequest) throws // CHECKSTYLE:OFF - WS-Notification spec throws a lot of faults
InvalidTopicExpressionFault, ResourceUnknownFault, InvalidProducerPropertiesExpressionFault, UnrecognizedPolicyRequestFault, TopicExpressionDialectUnknownFault, NotifyMessageNotSupportedFault, InvalidFilterFault, UnsupportedPolicyRequestFault, InvalidMessageContentExpressionFault, SubscribeCreationFailedFault, TopicNotSupportedFault, UnacceptableInitialTerminationTimeFault {
    // CHECKSYTLE:ON
    TopicExpressionType topic = null;
    if (subscribeRequest.getFilter() != null) {
        for (Object f : subscribeRequest.getFilter().getAny()) {
            JAXBElement<?> e = null;
            if (f instanceof JAXBElement) {
                e = (JAXBElement<?>) f;
                f = e.getValue();
            }
            if (f instanceof TopicExpressionType) {
                if (!e.getName().equals(QNAME_TOPIC_EXPRESSION)) {
                    InvalidTopicExpressionFaultType fault = new InvalidTopicExpressionFaultType();
                    throw new InvalidTopicExpressionFault("Unrecognized TopicExpression: " + e, fault);
                }
                topic = (TopicExpressionType) f;
            }
        }
    }
    if (topic == null) {
        InvalidFilterFaultType fault = new InvalidFilterFaultType();
        throw new InvalidFilterFault("Must specify a topic to subscribe on", fault);
    }
    PublisherSubscription pub = new PublisherSubscription(topic);
    SubscribeResponse response = new SubscribeResponse();
    response.setSubscriptionReference(pub.getEpr());
    callback.subscribe(topic);
    return response;
}
Also used : InvalidFilterFaultType(org.oasis_open.docs.wsn.b_2.InvalidFilterFaultType) TopicExpressionType(org.oasis_open.docs.wsn.b_2.TopicExpressionType) InvalidTopicExpressionFaultType(org.oasis_open.docs.wsn.b_2.InvalidTopicExpressionFaultType) JAXBElement(javax.xml.bind.JAXBElement) SubscribeResponse(org.oasis_open.docs.wsn.b_2.SubscribeResponse) InvalidTopicExpressionFault(org.oasis_open.docs.wsn.bw_2.InvalidTopicExpressionFault) InvalidFilterFault(org.oasis_open.docs.wsn.bw_2.InvalidFilterFault)

Example 4 with InvalidTopicExpressionFault

use of org.oasis_open.docs.wsn.bw_2.InvalidTopicExpressionFault in project cxf by apache.

the class AbstractNotificationBroker method getCurrentMessage.

/**
 * @param getCurrentMessageRequest
 * @return returns org.oasis_open.docs.wsn.b_1.GetCurrentMessageResponse
 * @throws MultipleTopicsSpecifiedFault
 * @throws TopicNotSupportedFault
 * @throws InvalidTopicExpressionFault
 * @throws ResourceUnknownFault
 * @throws TopicExpressionDialectUnknownFault
 * @throws NoCurrentMessageOnTopicFault
 */
@WebMethod(operationName = "GetCurrentMessage")
@WebResult(name = "GetCurrentMessageResponse", targetNamespace = "http://docs.oasis-open.org/wsn/b-1", partName = "GetCurrentMessageResponse")
public GetCurrentMessageResponse getCurrentMessage(@WebParam(name = "GetCurrentMessage", targetNamespace = "http://docs.oasis-open.org/wsn/b-1", partName = "GetCurrentMessageRequest") GetCurrentMessage getCurrentMessageRequest) throws // CHECKSTYLE:OFF - WS-Notification spec throws a lot of faults
InvalidTopicExpressionFault, MultipleTopicsSpecifiedFault, NoCurrentMessageOnTopicFault, ResourceUnknownFault, TopicExpressionDialectUnknownFault, TopicNotSupportedFault {
    // CHECKSTYLE:ON
    LOGGER.finest("GetCurrentMessage");
    NoCurrentMessageOnTopicFaultType fault = new NoCurrentMessageOnTopicFaultType();
    throw new NoCurrentMessageOnTopicFault("There is no current message on this topic.", fault);
}
Also used : NoCurrentMessageOnTopicFaultType(org.oasis_open.docs.wsn.b_2.NoCurrentMessageOnTopicFaultType) NoCurrentMessageOnTopicFault(org.oasis_open.docs.wsn.bw_2.NoCurrentMessageOnTopicFault) WebMethod(javax.jws.WebMethod) WebResult(javax.jws.WebResult)

Example 5 with InvalidTopicExpressionFault

use of org.oasis_open.docs.wsn.bw_2.InvalidTopicExpressionFault in project cxf by apache.

the class AbstractPublisher method validatePublisher.

protected void validatePublisher(RegisterPublisher registerPublisherRequest) throws InvalidTopicExpressionFault, PublisherRegistrationFailedFault, PublisherRegistrationRejectedFault, ResourceUnknownFault, TopicNotSupportedFault {
    // Check consumer reference
    publisherReference = registerPublisherRequest.getPublisherReference();
    // Check topic
    topic = registerPublisherRequest.getTopic();
    // Check demand based
    demand = registerPublisherRequest.isDemand() != null ? registerPublisherRequest.isDemand().booleanValue() : false;
    // Check all parameters
    if (publisherReference == null && demand) {
        PublisherRegistrationFailedFaultType fault = new PublisherRegistrationFailedFaultType();
        throw new PublisherRegistrationFailedFault("Invalid PublisherReference: null", fault);
    }
    if (demand && (topic == null || topic.isEmpty())) {
        InvalidTopicExpressionFaultType fault = new InvalidTopicExpressionFaultType();
        throw new InvalidTopicExpressionFault("Must specify at least one topic for demand-based publishing", fault);
    }
}
Also used : PublisherRegistrationFailedFaultType(org.oasis_open.docs.wsn.br_2.PublisherRegistrationFailedFaultType) InvalidTopicExpressionFaultType(org.oasis_open.docs.wsn.b_2.InvalidTopicExpressionFaultType) InvalidTopicExpressionFault(org.oasis_open.docs.wsn.bw_2.InvalidTopicExpressionFault) PublisherRegistrationFailedFault(org.oasis_open.docs.wsn.brw_2.PublisherRegistrationFailedFault)

Aggregations

InvalidTopicExpressionFaultType (org.oasis_open.docs.wsn.b_2.InvalidTopicExpressionFaultType)3 InvalidTopicExpressionFault (org.oasis_open.docs.wsn.bw_2.InvalidTopicExpressionFault)3 JAXBElement (javax.xml.bind.JAXBElement)2 InvalidFilterFaultType (org.oasis_open.docs.wsn.b_2.InvalidFilterFaultType)2 SubscribeCreationFailedFaultType (org.oasis_open.docs.wsn.b_2.SubscribeCreationFailedFaultType)2 SubscribeResponse (org.oasis_open.docs.wsn.b_2.SubscribeResponse)2 TopicExpressionType (org.oasis_open.docs.wsn.b_2.TopicExpressionType)2 InvalidFilterFault (org.oasis_open.docs.wsn.bw_2.InvalidFilterFault)2 SubscribeCreationFailedFault (org.oasis_open.docs.wsn.bw_2.SubscribeCreationFailedFault)2 WebMethod (javax.jws.WebMethod)1 WebResult (javax.jws.WebResult)1 InvalidMessageContentExpressionFaultType (org.oasis_open.docs.wsn.b_2.InvalidMessageContentExpressionFaultType)1 InvalidProducerPropertiesExpressionFaultType (org.oasis_open.docs.wsn.b_2.InvalidProducerPropertiesExpressionFaultType)1 NoCurrentMessageOnTopicFaultType (org.oasis_open.docs.wsn.b_2.NoCurrentMessageOnTopicFaultType)1 QueryExpressionType (org.oasis_open.docs.wsn.b_2.QueryExpressionType)1 UnrecognizedPolicyRequestFaultType (org.oasis_open.docs.wsn.b_2.UnrecognizedPolicyRequestFaultType)1 UseRaw (org.oasis_open.docs.wsn.b_2.UseRaw)1 PublisherRegistrationFailedFaultType (org.oasis_open.docs.wsn.br_2.PublisherRegistrationFailedFaultType)1 PublisherRegistrationFailedFault (org.oasis_open.docs.wsn.brw_2.PublisherRegistrationFailedFault)1 InvalidMessageContentExpressionFault (org.oasis_open.docs.wsn.bw_2.InvalidMessageContentExpressionFault)1