Package rocks.xmpp.extensions.bob.model

Examples of rocks.xmpp.extensions.bob.model.Data


        xmppSession.addIQListener(new IQListener() {
            @Override
            public void handle(IQEvent e) {
                IQ iq = e.getIQ();
                if (e.isIncoming() && isEnabled() && !e.isConsumed() && iq.getType() == IQ.Type.GET) {
                    Data data = iq.getExtension(Data.class);
                    if (data != null) {
                        // The recipient then would either return an error (e.g., <item-not-found/> if it does not have data matching the Content-ID) or return the data.
                        Data cachedData = dataCache.get(data.getContentId());
                        if (cachedData != null) {
                            IQ result = iq.createResult();
                            result.setExtension(cachedData);
                            xmppSession.send(result);
                        } else {
View Full Code Here


     * @return The data.
     * @throws rocks.xmpp.core.stanza.model.StanzaException If the entity returned a stanza error, e.g. {@link rocks.xmpp.core.stanza.model.errors.ItemNotFound}, if the data was not found.
     * @throws rocks.xmpp.core.session.NoResponseException  If the entity did not respond.
     */
    public Data getData(String contentId, Jid to) throws XmppException {
        IQ result = xmppSession.query(new IQ(to, IQ.Type.GET, new Data(contentId)));
        Data data = result.getExtension(Data.class);
//        // Only cache the data, if the max-age attribute absent or not zero.
//        if (data != null && (data.getMaxAge() != null && data.getMaxAge() != 0 || data.getMaxAge() == null)) {
//            dataCache.put(contentId, data);
//        }
        return data;
View Full Code Here

                "    vr4MkhoXe0rZigAAAABJRU5ErkJggg==\n" +
                "  </data>\n" +
                "</iq>";
        IQ iq = unmarshal(xml, IQ.class);

        Data data = iq.getExtension(Data.class);
        Assert.assertNotNull(data);
        Assert.assertEquals(data.getContentId(), "sha1+8f35fef110ffc5df08d579a50083ff9308fb6242@bob.xmpp.org");
        Assert.assertEquals(data.getMaxAge(), (Integer) 86400);
        Assert.assertEquals(data.getType(), "image/png");
        Assert.assertNotNull(data.getBytes());
    }
View Full Code Here

TOP

Related Classes of rocks.xmpp.extensions.bob.model.Data

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.