Search in sources :

Example 1 with JidPrepIq

use of org.jivesoftware.smackx.jid_prep.element.JidPrepIq in project Smack by igniterealtime.

the class JidPrepManager method requestJidPrep.

public String requestJidPrep(Jid jidPrepService, String jidToBePrepped) throws NoResponseException, NotConnectedException, InterruptedException, XMPPErrorException {
    JidPrepIq jidPrepRequest = new JidPrepIq(jidToBePrepped);
    jidPrepRequest.setTo(jidPrepService);
    JidPrepIq jidPrepResponse;
    try {
        jidPrepResponse = connection().sendIqRequestAndWaitForResponse(jidPrepRequest);
    } catch (XMPPErrorException e) {
        StanzaError stanzaError = e.getStanzaError();
        if (stanzaError.getCondition() == StanzaError.Condition.jid_malformed) {
            // or if the JID to prep was malformed. Assume the later is the case and return 'null'.
            return null;
        }
        throw e;
    }
    return jidPrepResponse.getJid();
}
Also used : XMPPErrorException(org.jivesoftware.smack.XMPPException.XMPPErrorException) JidPrepIq(org.jivesoftware.smackx.jid_prep.element.JidPrepIq) StanzaError(org.jivesoftware.smack.packet.StanzaError)

Aggregations

XMPPErrorException (org.jivesoftware.smack.XMPPException.XMPPErrorException)1 StanzaError (org.jivesoftware.smack.packet.StanzaError)1 JidPrepIq (org.jivesoftware.smackx.jid_prep.element.JidPrepIq)1