Search in sources :

Example 11 with XmlPullParserException

use of org.jivesoftware.smack.xml.XmlPullParserException in project Smack by igniterealtime.

the class WebSocketRemoteConnectionEndpointLookup method lookup.

public static Result lookup(DomainBareJid domainBareJid) {
    List<RemoteConnectionEndpointLookupFailure> lookupFailures = new ArrayList<>(1);
    List<URI> rcUriList = null;
    try {
        // Look for remote connection endpoints by making use of http lookup method described inside XEP-0156.
        rcUriList = HttpLookupMethod.lookup(domainBareJid, LinkRelation.WEBSOCKET);
    } catch (IOException | XmlPullParserException | URISyntaxException e) {
        lookupFailures.add(new RemoteConnectionEndpointLookupFailure.HttpLookupFailure(domainBareJid, e));
        return new Result(lookupFailures);
    }
    List<SecureWebSocketRemoteConnectionEndpoint> discoveredSecureEndpoints = new ArrayList<>(rcUriList.size());
    List<InsecureWebSocketRemoteConnectionEndpoint> discoveredInsecureEndpoints = new ArrayList<>(rcUriList.size());
    for (URI webSocketUri : rcUriList) {
        WebSocketRemoteConnectionEndpoint wsRce = WebSocketRemoteConnectionEndpoint.from(webSocketUri);
        if (wsRce instanceof SecureWebSocketRemoteConnectionEndpoint) {
            SecureWebSocketRemoteConnectionEndpoint secureWsRce = (SecureWebSocketRemoteConnectionEndpoint) wsRce;
            discoveredSecureEndpoints.add(secureWsRce);
        } else if (wsRce instanceof InsecureWebSocketRemoteConnectionEndpoint) {
            InsecureWebSocketRemoteConnectionEndpoint insecureWsRce = (InsecureWebSocketRemoteConnectionEndpoint) wsRce;
            discoveredInsecureEndpoints.add(insecureWsRce);
        } else {
            // WebSocketRemoteConnectionEndpoint.from() must return an instance which type is one of the above.
            throw new AssertionError();
        }
    }
    return new Result(discoveredSecureEndpoints, discoveredInsecureEndpoints, lookupFailures);
}
Also used : RemoteConnectionEndpointLookupFailure(org.jivesoftware.smack.util.rce.RemoteConnectionEndpointLookupFailure) ArrayList(java.util.ArrayList) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) XmlPullParserException(org.jivesoftware.smack.xml.XmlPullParserException)

Example 12 with XmlPullParserException

use of org.jivesoftware.smack.xml.XmlPullParserException in project Smack by igniterealtime.

the class Xpp3XmlPullParserFactory method newXmlPullParser.

@Override
public Xpp3XmlPullParser newXmlPullParser(Reader reader) throws XmlPullParserException {
    org.xmlpull.v1.XmlPullParser xpp3XmlPullParser;
    try {
        xpp3XmlPullParser = XPP3_XML_PULL_PARSER_FACTORY.newPullParser();
        xpp3XmlPullParser.setFeature(org.xmlpull.v1.XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
        xpp3XmlPullParser.setInput(reader);
    } catch (org.xmlpull.v1.XmlPullParserException e) {
        throw new XmlPullParserException(e);
    }
    if (XML_PULL_PARSER_SUPPORTS_ROUNDTRIP) {
        try {
            xpp3XmlPullParser.setFeature(FEATURE_XML_ROUNDTRIP, true);
        } catch (org.xmlpull.v1.XmlPullParserException e) {
            LOGGER.log(Level.SEVERE, "XmlPullParser does not support XML_ROUNDTRIP, although it was first determined to be supported", e);
        }
    }
    return new Xpp3XmlPullParser(xpp3XmlPullParser);
}
Also used : XmlPullParserException(org.jivesoftware.smack.xml.XmlPullParserException)

Example 13 with XmlPullParserException

use of org.jivesoftware.smack.xml.XmlPullParserException in project Smack by igniterealtime.

the class StaxXmlPullParser method nextTag.

@Override
public TagEvent nextTag() throws IOException, XmlPullParserException {
    preNextEvent();
    int staxEventInt;
    try {
        staxEventInt = xmlStreamReader.nextTag();
    } catch (XMLStreamException e) {
        throw new XmlPullParserException(e);
    }
    switch(staxEventInt) {
        case XMLStreamConstants.START_ELEMENT:
            depth++;
            return TagEvent.START_ELEMENT;
        case XMLStreamConstants.END_ELEMENT:
            delayedDepthDecrement = true;
            return TagEvent.END_ELEMENT;
        default:
            throw new AssertionError();
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) XmlPullParserException(org.jivesoftware.smack.xml.XmlPullParserException)

Example 14 with XmlPullParserException

use of org.jivesoftware.smack.xml.XmlPullParserException in project Smack by igniterealtime.

the class StaxXmlPullParser method next.

@Override
public Event next() throws XmlPullParserException {
    preNextEvent();
    int staxEventInt;
    try {
        staxEventInt = xmlStreamReader.next();
    } catch (XMLStreamException e) {
        throw new XmlPullParserException(e);
    }
    Event event = staxEventIntegerToEvent(staxEventInt);
    switch(event) {
        case START_ELEMENT:
            depth++;
            break;
        case END_ELEMENT:
            delayedDepthDecrement = true;
            break;
        default:
            // Catch all for incomplete switch (MissingCasesInEnumSwitch) statement.
            break;
    }
    return event;
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) XmlPullParserException(org.jivesoftware.smack.xml.XmlPullParserException)

Example 15 with XmlPullParserException

use of org.jivesoftware.smack.xml.XmlPullParserException in project Smack by igniterealtime.

the class StaxXmlPullParser method nextText.

@Override
public String nextText() throws IOException, XmlPullParserException {
    final String nextText;
    try {
        nextText = xmlStreamReader.getElementText();
    } catch (XMLStreamException e) {
        throw new XmlPullParserException(e);
    }
    // XMLStreamReader.getElementText() will forward to the next END_ELEMENT, hence we need to set
    // delayedDepthDecrement to true.
    delayedDepthDecrement = true;
    return nextText;
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) XmlPullParserException(org.jivesoftware.smack.xml.XmlPullParserException)

Aggregations

XmlPullParserException (org.jivesoftware.smack.xml.XmlPullParserException)15 IOException (java.io.IOException)10 XmlPullParser (org.jivesoftware.smack.xml.XmlPullParser)7 XMLStreamException (javax.xml.stream.XMLStreamException)3 SmackParsingException (org.jivesoftware.smack.parsing.SmackParsingException)3 ArrayList (java.util.ArrayList)2 StreamErrorException (org.jivesoftware.smack.XMPPException.StreamErrorException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1 ObjectInputStream (java.io.ObjectInputStream)1 Reader (java.io.Reader)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BOSHClientConfig (org.igniterealtime.jbosh.BOSHClientConfig)1 BOSHException (org.igniterealtime.jbosh.BOSHException)1 SmackException (org.jivesoftware.smack.SmackException)1 GenericConnectionException (org.jivesoftware.smack.SmackException.GenericConnectionException)1