use of org.oasis_open.docs.wsn.b_2.TopicExpressionType in project cxf by apache.
the class NotificationBroker method registerPublisher.
public Registration registerPublisher(Referencable publisher, List<String> topics, boolean demand) throws // CHECKSTYLE:OFF - WS-Notification spec throws a lot of faults
TopicNotSupportedFault, PublisherRegistrationFailedFault, UnacceptableInitialTerminationTimeFault, InvalidTopicExpressionFault, ResourceUnknownFault, PublisherRegistrationRejectedFault {
// CHECKSTYLE:ON
RegisterPublisher registerPublisherRequest = new RegisterPublisher();
registerPublisherRequest.setPublisherReference(publisher.getEpr());
if (topics != null) {
for (String topic : topics) {
TopicExpressionType topicExp = new TopicExpressionType();
topicExp.getContent().add(topic);
registerPublisherRequest.getTopic().add(topicExp);
}
}
registerPublisherRequest.setDemand(demand);
RegisterPublisherResponse response = getBroker().registerPublisher(registerPublisherRequest);
return new Registration(response.getPublisherRegistrationReference());
}
use of org.oasis_open.docs.wsn.b_2.TopicExpressionType 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;
}
use of org.oasis_open.docs.wsn.b_2.TopicExpressionType in project cxf by apache.
the class JmsTopicExpressionConverter method toTopicExpression.
public TopicExpressionType toTopicExpression(String name) {
TopicExpressionType answer = new TopicExpressionType();
answer.getContent().add(name);
answer.setDialect(SIMPLE_DIALECT);
return answer;
}
use of org.oasis_open.docs.wsn.b_2.TopicExpressionType in project cxf by apache.
the class JaxwsPublisher method startSubscription.
@Override
protected Object startSubscription(TopicExpressionType topic) {
try {
Subscribe subscribeRequest = new Subscribe();
subscribeRequest.setConsumerReference(notificationBroker.getEpr());
subscribeRequest.setFilter(new FilterType());
subscribeRequest.getFilter().getAny().add(new JAXBElement<TopicExpressionType>(AbstractSubscription.QNAME_TOPIC_EXPRESSION, TopicExpressionType.class, topic));
SubscribeResponse response = notificationProducer.subscribe(subscribeRequest);
return WSNHelper.getInstance().getPort(response.getSubscriptionReference(), SubscriptionManager.class);
} catch (Exception e) {
LOGGER.log(Level.INFO, "Error while subscribing on-demand publisher", e);
return null;
}
}
Aggregations