Package rocks.xmpp.extensions.pubsub.model

Examples of rocks.xmpp.extensions.pubsub.model.PubSub$Subscribe


    Subscribe subscribe = getSubscription("subscribe-no-itt.xml");
    subscription.validateSubscription(subscribe);
  }
 
  public void testWithUseRaw() throws Exception {
    Subscribe subscribe = getSubscription("subscribe-raw.xml");
    subscription.validateSubscription(subscribe);
  }
View Full Code Here


    Subscribe subscribe = getSubscription("subscribe-raw.xml");
    subscription.validateSubscription(subscribe);
  }
 
  public void testWithProducerProperties() throws Exception {
    Subscribe subscribe = getSubscription("subscribe-pp.xml");
    try {
      subscription.validateSubscription(subscribe);
      fail("ProducerProperties used. Fault was expected.");
    } catch (InvalidProducerPropertiesExpressionFault e) {
      // OK
View Full Code Here

      // OK
    }
  }
 
  public void testWithNoTopic() throws Exception {
    Subscribe subscribe = getSubscription("subscribe-no-topic.xml");
    try {
      subscription.validateSubscription(subscribe);
      fail("ProducerProperties used. Fault was expected.");
    } catch (InvalidFilterFault e) {
      // OK
View Full Code Here

      // OK
    }
  }
 
  public void testWithEPR() throws Exception {
    Subscribe subscribe = getSubscription("subscribe-epr.xml");
    subscription.validateSubscription(subscribe);
  }
View Full Code Here

  public Subscription subscribe(EndpointReferenceType consumer,
                    String topic,
                    String xpath,
                    boolean raw) throws JBIException {
   
    Subscribe subscribeRequest = new Subscribe();
    subscribeRequest.setConsumerReference(consumer);
    subscribeRequest.setFilter(new FilterType());
    if (topic != null) {
      TopicExpressionType topicExp = new TopicExpressionType();
      topicExp.getContent().add(topic);
      subscribeRequest.getFilter().getAny().add(new JAXBElement<TopicExpressionType>(AbstractSubscription.QNAME_TOPIC_EXPRESSION, TopicExpressionType.class, topicExp));
    }
    if (xpath != null) {
      QueryExpressionType xpathExp = new QueryExpressionType();
      xpathExp.setDialect(AbstractSubscription.XPATH1_URI);
      xpathExp.getContent().add(xpath);
      subscribeRequest.getFilter().getAny().add(new JAXBElement<QueryExpressionType>(AbstractSubscription.QNAME_MESSAGE_CONTENT, QueryExpressionType.class, xpathExp));
    }
    if (raw) {
      subscribeRequest.setSubscriptionPolicy(new Subscribe.SubscriptionPolicy());
      subscribeRequest.getSubscriptionPolicy().getAny().add(new UseRaw());
    }
    SubscribeResponse response = (SubscribeResponse) request(subscribeRequest);
    return new Subscription(response.getSubscriptionReference(), getClient());
  }
View Full Code Here

        InvalidMessageContentExpressionFault, InvalidTopicExpressionFault, UnrecognizedPolicyRequestFault,
        UnsupportedPolicyRequestFault, ResourceUnknownFault, NotifyMessageNotSupportedFault,
        InvalidProducerPropertiesExpressionFault {
        //CHECKSTYLE:ON

        Subscribe subscribeRequest = new Subscribe();
        subscribeRequest.setConsumerReference(consumer.getEpr());
        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,
                            TopicExpressionType.class, topicExp));
        }
        if (xpath != null) {
            QueryExpressionType xpathExp = new QueryExpressionType();
            xpathExp.setDialect(XPATH1_URI);
            xpathExp.getContent().add(xpath);
            subscribeRequest.getFilter().getAny().add(
                    new JAXBElement<QueryExpressionType>(QNAME_MESSAGE_CONTENT,
                            QueryExpressionType.class, xpathExp));
        }
        if (raw) {
            subscribeRequest.setSubscriptionPolicy(new Subscribe.SubscriptionPolicy());
            subscribeRequest.getSubscriptionPolicy().getAny().add(new UseRaw());
        }
        SubscribeResponse response = getBroker().subscribe(subscribeRequest);
        return new Subscription(response.getSubscriptionReference());
    }
View Full Code Here

    }

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

     * @throws rocks.xmpp.core.session.NoResponseException  If the entity did not respond.
     * @see <a href="http://xmpp.org/extensions/xep-0060.html#entity-subscriptions">5.6 Retrieve Subscriptions</a>
     */
    private List<Subscription> getSubscriptions() throws XmppException {
        IQ result = xmppSession.query(new IQ(service, IQ.Type.GET, PubSub.withSubscriptions()));
        PubSub pubSub = result.getExtension(PubSub.class);
        return pubSub.getSubscriptions();
    }
View Full Code Here

     * @throws rocks.xmpp.core.session.NoResponseException  If the entity did not respond.
     * @see <a href="http://xmpp.org/extensions/xep-0060.html#entity-affiliations">5.7 Retrieve Affiliations</a>
     */
    private List<Affiliation> getAffiliations() throws XmppException {
        IQ result = xmppSession.query(new IQ(service, IQ.Type.GET, PubSub.withAffiliations()));
        PubSub pubSub = result.getExtension(PubSub.class);
        return pubSub.getAffiliations();
    }
View Full Code Here

     * @throws rocks.xmpp.core.session.NoResponseException  If the entity did not respond.
     * @see <a href="http://xmpp.org/extensions/xep-0060.html#subscriber-configure-submit">6.4 Request Default Subscription Configuration Options</a>
     */
    private DataForm getDefaultSubscriptionOptions() throws XmppException {
        IQ result = xmppSession.query(new IQ(service, IQ.Type.GET, PubSub.withDefault()));
        PubSub pubSub = result.getExtension(PubSub.class);
        return pubSub.getDefault().getDataForm();
    }
View Full Code Here

TOP

Related Classes of rocks.xmpp.extensions.pubsub.model.PubSub$Subscribe

Copyright © 2018 www.massapicom. 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.