public TopicExpressionType toTopicExpression(String name) { TopicExpressionType answer = new TopicExpressionType(); answer.getContent().add(name); answer.setDialect(SIMPLE_DIALECT); return answer; }
public static List<String> topicExpressionToList(TopicExpressionType te) { List<String> items = new ArrayList<String>(); if (te == null) { return items; } if (te.getDialect().equalsIgnoreCase(WSNConstants.WST_TOPICEXPRESSION_SIMPLE)) { for (int k = 0; k < te.getContent().size(); k++) { items.add(((String) te.getContent().get(k)).trim()); } } return items; }
/** * Creates a topic expression type from the specified topic information. * * @param topic * the QName associated to the topic of the topic expression type * to build. * * @return a topic expression type from the specified topic information. */ public static TopicExpressionType createTopicExpressionType(QName topic) { TopicExpressionType topicExpressionType = new TopicExpressionType(); topicExpressionType.getOtherAttributes().put( topic, topic.getNamespaceURI()); topicExpressionType.setDialect(WsnConstants.TOPIC_EXPRESSION_DIALECT); topicExpressionType.getContent().add( topic.getPrefix() + ":" + topic.getLocalPart()); return topicExpressionType; }
public List<Object> getCurrentMessage(String topic) //CHECKSTYLE:OFF - WS-Notification spec throws a lot of faults throws TopicNotSupportedFault, TopicExpressionDialectUnknownFault, MultipleTopicsSpecifiedFault, InvalidTopicExpressionFault, ResourceUnknownFault, NoCurrentMessageOnTopicFault { //CHECKSTYLE:ON GetCurrentMessage getCurrentMessageRequest = new GetCurrentMessage(); if (topic != null) { TopicExpressionType topicExp = new TopicExpressionType(); topicExp.getContent().add(topic); getCurrentMessageRequest.setTopic(topicExp); } GetCurrentMessageResponse response = getBroker().getCurrentMessage(getCurrentMessageRequest); return response.getAny(); }
/** * Create an instance of {@link TopicExpressionType } * */ public TopicExpressionType createTopicExpressionType() { return new TopicExpressionType(); }
private static boolean hasSimpleTopicExpression(TopicExpressionType topicExpressionType) { List<Object> content = topicExpressionType.getContent(); if (content.size() > 0) { try { Element topicElement = (Element) content.get(0); return topicElement.getLocalName() .equals( WsnConstants.SIMPLE_TOPIC_EXPRESSION_QNAME.getLocalPart()); } catch (ClassCastException cce) { return false; } } else { throw new IllegalArgumentException("No topic content set"); } }
private static QName getTopic(TopicExpressionType topicExpressionType) { List<Object> content = topicExpressionType.getContent(); if (content.size() > 0) { String topicLocalPart = null; topicPrefix = org.apache.xml.utils.QName.getPrefixPart(topic); for (Entry<QName, String> entry : topicExpressionType.getOtherAttributes() .entrySet()) {
JAXBElement<TopicExpressionType> item = (JAXBElement<TopicExpressionType>) subscribeRequest.getFilter().getAny().get(i); org.oasis_open.docs.wsn.b_2.TopicExpressionType te = item.getValue(); if (!te.getDialect().equalsIgnoreCase(WSNConstants.WST_TOPICEXPRESSION_SIMPLE)) { InvalidFilterFault iff = new InvalidFilterFault("Only TopicExpressions with the dialect of " + WSNConstants.WST_TOPICEXPRESSION_SIMPLE + " are supported.", new InvalidFilterFaultType()); throw iff;
public Registration registerPublisher(Referencable publisher, List<String> topics, boolean demand) //CHECKSTYLE:OFF - WS-Notification spec throws a lot of faults throws 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()); }
/** * Create an instance of {@link TopicExpressionType } * */ public TopicExpressionType createTopicExpressionType() { return new TopicExpressionType(); }
static String GetTopicList(Notify n) { String s = new String(); if (n == null) { return s; } for (int i = 0; i < n.getNotificationMessage().size(); i++) { if (n.getNotificationMessage().get(i).getTopic() != null) { if (n.getNotificationMessage().get(i).getTopic().getContent() != null) { for (int k = 0; k < n.getNotificationMessage().get(i).getTopic().getContent().size(); k++) { s = s + " " + n.getNotificationMessage().get(i).getTopic().getContent().get(k).toString(); } } } } return s.trim(); }
/** * Creates a topic expression type with a {@code simpleExpressionType} * element from the specified topic information. * * @param topic * the QName associated to the topic of the topic expression type * to build. * * @return a topic expression type with a {@code simpleExpressionType} * element from the specified topic information. */ public static TopicExpressionType createTopicExpressionTypeWithSimpleExpressionType(QName topic) { TopicExpressionType topicExpressionType = new TopicExpressionType(); topicExpressionType.setDialect(WsnConstants.SIMPLE_TOPIC_EXPRESSION_DIALECT); JAXBElement<QName> simpleTopicExpression = new JAXBElement<QName>( WsnConstants.SIMPLE_TOPIC_EXPRESSION_QNAME, QName.class, null, topic); topicExpressionType.getContent().add(simpleTopicExpression); return topicExpressionType; }
public void notify(Referencable publisher, String topic, Object msg) { getBroker(); if (this.context != null) { try { DOMResult result = new DOMResult(); context.createMarshaller().marshal(msg, result); msg = result.getNode(); if (msg instanceof Document) { msg = ((Document)msg).getDocumentElement(); } } catch (JAXBException e) { //ignore, we'll try and let the runtime handle it as is } } Notify notify = new Notify(); NotificationMessageHolderType holder = new NotificationMessageHolderType(); if (publisher != null) { holder.setProducerReference(publisher.getEpr()); } if (topic != null) { TopicExpressionType topicExp = new TopicExpressionType(); topicExp.getContent().add(topic); holder.setTopic(topicExp); } holder.setMessage(new NotificationMessageHolderType.Message()); holder.getMessage().setAny(msg); notify.getNotificationMessage().add(holder); getBroker().notify(notify); }
public ActiveMQTopic toActiveMQTopic(TopicExpressionType topic) throws InvalidTopicException { String dialect = topic.getDialect(); if (dialect == null || SIMPLE_DIALECT.equals(dialect)) { for (Iterator<Object> iter = topic.getContent().iterator(); iter.hasNext();) { ActiveMQTopic answer = createActiveMQTopicFromContent(iter.next()); if (answer != null) { return answer; } } throw new InvalidTopicException("No topic name available topic: " + topic); } throw new InvalidTopicException("Topic dialect: " + dialect + " not supported"); }
/** * Create an instance of {@link TopicExpressionType } * */ public TopicExpressionType createTopicExpressionType() { return new TopicExpressionType(); }
private static void RegisterProducer(String t) { try { RegisterPublisher req = new RegisterPublisher(); TopicExpressionType localtopic = new TopicExpressionType(); if (Utility.stringIsNullOrEmpty(configuredWSN_DIALECT)) { localtopic.setDialect(WSNConstants.WST_TOPICEXPRESSION_SIMPLE); } else { localtopic.setDialect(configuredWSN_DIALECT); } if (Utility.stringIsNullOrEmpty(t)) { localtopic.getContent().add("fgsmsAlerts"); } else { localtopic.getContent().add(t); } req.getTopic().add(localtopic); RegisterPublisherResponse registerPublisher = notificationPort.registerPublisher(req); log.log(Level.INFO, String.format(SLACommon.getBundleString("WSNTopicRegisteredSuccess"), t)); isMainTopicRegistered = true; } catch (Exception ex) { log.log(Level.ERROR, String.format(SLACommon.getBundleString("WSNTopicRegisteredFailed"), t), ex); } }
TopicExpressionType topicExpression = new TopicExpressionType(); if (hasSimpleExpressionType) { JAXBElement<QName> simpleTopicExpression = WsnConstants.SIMPLE_TOPIC_EXPRESSION_QNAME, QName.class, null, new QName(topic)); topicExpression.getContent().add(simpleTopicExpression); } else { topicExpression.getContent().add(topic);
private static void logTopic(TopicExpressionType topicExpressionType, String indentation) { List<Object> topicContent = topicExpressionType.getContent(); if (topicContent != null) { log.info( indentation + "topicContent(dialect={}):", topicExpressionType.getDialect()); for (Object obj2 : topicContent) { if (obj2 instanceof String) { log.info(indentation + " * " + obj2 + " (class " + obj2.getClass().getName() + ")"); } else { Element topicElement = (Element) obj2; String topic = topicElement.getTextContent().trim().replaceAll( "\n", ""); log.info(indentation + " * " + topic + " (namespace " + topicElement.lookupNamespaceURI(org.apache.xml.utils.QName.getPrefixPart(topic)) + ") (class " + obj2.getClass().getName() + ")"); } } logAttributes( " topicAttribute", topicExpressionType, "otherAttributes"); } else { log.info(" topicContent is null"); } }
NotificationMessageHolderType msg = new NotificationMessageHolderType(); TopicExpressionType tet = new TopicExpressionType(); if (Utility.stringIsNullOrEmpty(configuredWSN_DIALECT) && Utility.stringIsNullOrEmpty(dialect)) { tet.setDialect(WSNConstants.WST_TOPICEXPRESSION_SIMPLE); } else { if (!Utility.stringIsNullOrEmpty(dialect)) { tet.setDialect(dialect); } else { tet.setDialect(configuredWSN_DIALECT); tet.getContent().add("fgsmsAlerts"); } else if (!Utility.stringIsNullOrEmpty(Destination)) { tet.getContent().add(Destination); } else { tet.getContent().add(topic); RegisterProducer((String) tet.getContent().get(0));
subscribeRequest.setFilter(new FilterType()); if (topic != null) { TopicExpressionType topicExp = new TopicExpressionType(); topicExp.getContent().add(topic); subscribeRequest.getFilter().getAny().add( new JAXBElement<TopicExpressionType>(QNAME_TOPIC_EXPRESSION,