Search in sources :

Example 1 with PublisherRegistrationFailedFaultType

use of org.oasis_open.docs.wsn.br_2.PublisherRegistrationFailedFaultType in project cxf by apache.

the class AbstractNotificationBroker method handleRegisterPublisher.

public RegisterPublisherResponse handleRegisterPublisher(RegisterPublisher registerPublisherRequest) throws InvalidTopicExpressionFault, PublisherRegistrationFailedFault, PublisherRegistrationRejectedFault, ResourceUnknownFault, TopicNotSupportedFault {
    AbstractPublisher publisher = null;
    boolean success = false;
    try {
        publisher = createPublisher(idGenerator.generateSanitizedId());
        publisher.register();
        publisher.create(registerPublisherRequest);
        RegisterPublisherResponse response = new RegisterPublisherResponse();
        response.setPublisherRegistrationReference(publisher.getEpr());
        if (publisher.getPublisherReference() != null) {
            publishers.put(WSNHelper.getInstance().getWSAAddress(publisher.getPublisherReference()), publisher);
        } else {
            nonContactPublishers.add(publisher);
        }
        success = true;
        return response;
    } catch (EndpointRegistrationException e) {
        LOGGER.log(Level.WARNING, "Unable to register new endpoint", e);
        PublisherRegistrationFailedFaultType fault = new PublisherRegistrationFailedFaultType();
        throw new PublisherRegistrationFailedFault("Unable to register new endpoint", fault, e);
    } finally {
        if (!success && publisher != null) {
            try {
                publisher.destroy();
            } catch (ResourceNotDestroyedFault e) {
                LOGGER.log(Level.INFO, "Error destroying publisher", e);
            }
        }
    }
}
Also used : PublisherRegistrationFailedFaultType(org.oasis_open.docs.wsn.br_2.PublisherRegistrationFailedFaultType) ResourceNotDestroyedFault(org.oasis_open.docs.wsn.brw_2.ResourceNotDestroyedFault) RegisterPublisherResponse(org.oasis_open.docs.wsn.br_2.RegisterPublisherResponse) PublisherRegistrationFailedFault(org.oasis_open.docs.wsn.brw_2.PublisherRegistrationFailedFault)

Example 2 with PublisherRegistrationFailedFaultType

use of org.oasis_open.docs.wsn.br_2.PublisherRegistrationFailedFaultType in project cxf by apache.

the class JmsPublisher method start.

@Override
protected void start() throws PublisherRegistrationFailedFault {
    if (demand) {
        try {
            producers = new HashMap<>();
            advisories = new ArrayList<>();
            for (TopicExpressionType topic : this.topic) {
                ConsumerEventSource advisory = new ConsumerEventSource(connection, topicConverter.toActiveMQTopic(topic));
                advisory.setConsumerListener(this);
                advisory.start();
                advisories.add(advisory);
            }
        } catch (Exception e) {
            PublisherRegistrationFailedFaultType fault = new PublisherRegistrationFailedFaultType();
            throw new PublisherRegistrationFailedFault("Error starting demand-based publisher", fault, e);
        }
    }
}
Also used : PublisherRegistrationFailedFaultType(org.oasis_open.docs.wsn.br_2.PublisherRegistrationFailedFaultType) TopicExpressionType(org.oasis_open.docs.wsn.b_2.TopicExpressionType) ConsumerEventSource(org.apache.activemq.advisory.ConsumerEventSource) PublisherRegistrationFailedFault(org.oasis_open.docs.wsn.brw_2.PublisherRegistrationFailedFault) JMSException(javax.jms.JMSException) JAXBException(javax.xml.bind.JAXBException)

Example 3 with PublisherRegistrationFailedFaultType

use of org.oasis_open.docs.wsn.br_2.PublisherRegistrationFailedFaultType 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

PublisherRegistrationFailedFaultType (org.oasis_open.docs.wsn.br_2.PublisherRegistrationFailedFaultType)3 PublisherRegistrationFailedFault (org.oasis_open.docs.wsn.brw_2.PublisherRegistrationFailedFault)3 JMSException (javax.jms.JMSException)1 JAXBException (javax.xml.bind.JAXBException)1 ConsumerEventSource (org.apache.activemq.advisory.ConsumerEventSource)1 InvalidTopicExpressionFaultType (org.oasis_open.docs.wsn.b_2.InvalidTopicExpressionFaultType)1 TopicExpressionType (org.oasis_open.docs.wsn.b_2.TopicExpressionType)1 RegisterPublisherResponse (org.oasis_open.docs.wsn.br_2.RegisterPublisherResponse)1 ResourceNotDestroyedFault (org.oasis_open.docs.wsn.brw_2.ResourceNotDestroyedFault)1 InvalidTopicExpressionFault (org.oasis_open.docs.wsn.bw_2.InvalidTopicExpressionFault)1