1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 06:12:05 +01:00

Rework exceptions in the parsing / provider subsystem

This commit is contained in:
Florian Schmaus 2019-02-05 10:41:50 +01:00
parent 4c42d0cd32
commit 083dac8b83
130 changed files with 504 additions and 342 deletions

View file

@ -33,6 +33,7 @@ import java.security.SecureRandom;
import java.security.Security; import java.security.Security;
import java.security.UnrecoverableKeyException; import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
@ -124,6 +125,7 @@ import org.jxmpp.jid.parts.Resourcepart;
import org.jxmpp.util.XmppStringUtils; import org.jxmpp.util.XmppStringUtils;
import org.minidns.dnsname.DnsName; import org.minidns.dnsname.DnsName;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
@ -1161,7 +1163,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
return successNonza; return successNonza;
} }
protected final void parseAndProcessNonza(XmlPullParser parser) throws SmackException { protected final void parseAndProcessNonza(XmlPullParser parser) throws IOException, XmlPullParserException, ParseException {
final String element = parser.getName(); final String element = parser.getName();
final String namespace = parser.getNamespace(); final String namespace = parser.getNamespace();
final String key = XmppStringUtils.generateKey(element, namespace); final String key = XmppStringUtils.generateKey(element, namespace);
@ -1181,18 +1183,13 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
return; return;
} }
Nonza nonza; Nonza nonza = nonzaProvider.parse(parser);
try {
nonza = nonzaProvider.parse(parser);
}
catch (Exception e) {
throw new SmackException(e);
}
nonzaCallback.onNonzaReceived(nonza); nonzaCallback.onNonzaReceived(nonza);
} }
protected void parseAndProcessStanza(XmlPullParser parser) throws Exception { protected void parseAndProcessStanza(XmlPullParser parser)
throws XmlPullParserException, IOException, InterruptedException {
ParserUtils.assertAtStartTag(parser); ParserUtils.assertAtStartTag(parser);
int parserDepth = parser.getDepth(); int parserDepth = parser.getDepth();
Stanza stanza = null; Stanza stanza = null;
@ -1566,7 +1563,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
return this.fromMode; return this.fromMode;
} }
protected final void parseFeatures(XmlPullParser parser) throws Exception { protected final void parseFeatures(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
streamFeatures.clear(); streamFeatures.clear();
final int initialDepth = parser.getDepth(); final int initialDepth = parser.getDepth();
while (true) { while (true) {

View file

@ -16,6 +16,8 @@
*/ */
package org.jivesoftware.smack.compress.provider; package org.jivesoftware.smack.compress.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.compress.packet.Failure; import org.jivesoftware.smack.compress.packet.Failure;
@ -25,6 +27,7 @@ import org.jivesoftware.smack.provider.NonzaProvider;
import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.PacketParserUtils;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public final class FailureProvider extends NonzaProvider<Failure> { public final class FailureProvider extends NonzaProvider<Failure> {
@ -36,7 +39,7 @@ public final class FailureProvider extends NonzaProvider<Failure> {
} }
@Override @Override
public Failure parse(XmlPullParser parser, int initialDepth) throws Exception { public Failure parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
Failure.CompressFailureError compressFailureError = null; Failure.CompressFailureError compressFailureError = null;
StanzaError stanzaError = null; StanzaError stanzaError = null;

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smack.fsm; package org.jivesoftware.smack.fsm;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -59,6 +60,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
import org.jxmpp.jid.parts.Resourcepart; import org.jxmpp.jid.parts.Resourcepart;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public abstract class AbstractXmppStateMachineConnection extends AbstractXMPPConnection { public abstract class AbstractXmppStateMachineConnection extends AbstractXMPPConnection {
@ -301,7 +303,8 @@ public abstract class AbstractXmppStateMachineConnection extends AbstractXMPPCon
} }
} }
protected final void parseAndProcessElement(String element) throws Exception { protected final void parseAndProcessElement(String element) throws XmlPullParserException, IOException,
InterruptedException, StreamErrorException, SmackException, ParseException {
XmlPullParser parser = PacketParserUtils.getParserFor(element); XmlPullParser parser = PacketParserUtils.getParserFor(element);
// Skip the enclosing stream open what is guaranteed to be there. // Skip the enclosing stream open what is guaranteed to be there.

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2013-2015 Florian Schmaus. * Copyright 2013-2019 Florian Schmaus.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -32,7 +32,7 @@ public class ExceptionLoggingCallback implements ParsingExceptionCallback {
private static final Logger LOGGER = Logger.getLogger(ExceptionLoggingCallback.class.getName()); private static final Logger LOGGER = Logger.getLogger(ExceptionLoggingCallback.class.getName());
@Override @Override
public void handleUnparsableStanza(UnparseableStanza unparsed) throws Exception { public void handleUnparsableStanza(UnparseableStanza unparsed) {
LOGGER.log(Level.SEVERE, "Smack message parsing exception. Content: '" + unparsed.getContent() + "'", unparsed.getParsingException()); LOGGER.log(Level.SEVERE, "Smack message parsing exception. Content: '" + unparsed.getContent() + "'", unparsed.getParsingException());
} }
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2013-2015 Florian Schmaus. * Copyright 2013-2019 Florian Schmaus.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,6 +17,8 @@
package org.jivesoftware.smack.parsing; package org.jivesoftware.smack.parsing;
import java.io.IOException;
import org.jivesoftware.smack.ConnectionListener; import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.UnparseableStanza; import org.jivesoftware.smack.UnparseableStanza;
@ -30,7 +32,7 @@ import org.jivesoftware.smack.UnparseableStanza;
public class ExceptionThrowingCallback implements ParsingExceptionCallback { public class ExceptionThrowingCallback implements ParsingExceptionCallback {
@Override @Override
public void handleUnparsableStanza(UnparseableStanza packetData) throws Exception { public void handleUnparsableStanza(UnparseableStanza packetData) throws IOException {
throw packetData.getParsingException(); throw new IOException(packetData.getParsingException());
} }
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2018 Florian Schmaus. * Copyright 2018-2019 Florian Schmaus.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@
package org.jivesoftware.smack.parsing; package org.jivesoftware.smack.parsing;
import java.io.IOException;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.UnparseableStanza; import org.jivesoftware.smack.UnparseableStanza;
@ -32,7 +33,7 @@ public class ExceptionThrowingCallbackWithHint extends ExceptionThrowingCallback
private static final Logger LOGGER = Logger.getLogger(ExceptionThrowingCallbackWithHint.class.getName()); private static final Logger LOGGER = Logger.getLogger(ExceptionThrowingCallbackWithHint.class.getName());
@Override @Override
public void handleUnparsableStanza(UnparseableStanza packetData) throws Exception { public void handleUnparsableStanza(UnparseableStanza packetData) throws IOException {
LOGGER.warning("Parsing exception encountered." LOGGER.warning("Parsing exception encountered."
+ " This exception will be re-thrown, leading to a disconnect." + " This exception will be re-thrown, leading to a disconnect."
+ " You can change this behavior by setting a different ParsingExceptionCallback using setParsingExceptionCallback()." + " You can change this behavior by setting a different ParsingExceptionCallback using setParsingExceptionCallback()."

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2013-2015 Florian Schmaus. * Copyright 2013-2019 Florian Schmaus.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,6 +16,8 @@
*/ */
package org.jivesoftware.smack.parsing; package org.jivesoftware.smack.parsing;
import java.io.IOException;
import org.jivesoftware.smack.UnparseableStanza; import org.jivesoftware.smack.UnparseableStanza;
/** /**
@ -37,8 +39,8 @@ public interface ParsingExceptionCallback {
* Called when parsing a stanza caused an exception. * Called when parsing a stanza caused an exception.
* *
* @param stanzaData the raw stanza data that caused the exception * @param stanzaData the raw stanza data that caused the exception
* @throws Exception * @throws IOException
*/ */
void handleUnparsableStanza(UnparseableStanza stanzaData) throws Exception; void handleUnparsableStanza(UnparseableStanza stanzaData) throws IOException;
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2003-2007 Jive Software, 2014 Florian Schmaus * Copyright © 2003-2007 Jive Software, 2014-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package org.jivesoftware.smack.provider;
import java.io.IOException; import java.io.IOException;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.packet.Bind; import org.jivesoftware.smack.packet.Bind;
import org.jxmpp.jid.EntityFullJid; import org.jxmpp.jid.EntityFullJid;
@ -30,8 +29,7 @@ import org.xmlpull.v1.XmlPullParserException;
public class BindIQProvider extends IQProvider<Bind> { public class BindIQProvider extends IQProvider<Bind> {
@Override @Override
public Bind parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, public Bind parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
SmackException {
String name; String name;
Bind bind = null; Bind bind = null;
outerloop: while (true) { outerloop: while (true) {

View file

@ -18,15 +18,18 @@ package org.jivesoftware.smack.provider;
import static org.jivesoftware.smack.util.PacketParserUtils.parseElementText; import static org.jivesoftware.smack.util.PacketParserUtils.parseElementText;
import java.io.IOException;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public class BodyElementProvider extends ExtensionElementProvider<Message.Body> { public class BodyElementProvider extends ExtensionElementProvider<Message.Body> {
@Override @Override
public Message.Body parse(XmlPullParser parser, int initialDepth) throws Exception { public Message.Body parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
String xmlLang = ParserUtils.getXmlLang(parser); String xmlLang = ParserUtils.getXmlLang(parser);
String body = parseElementText(parser); String body = parseElementText(parser);

View file

@ -16,6 +16,8 @@
*/ */
package org.jivesoftware.smack.provider; package org.jivesoftware.smack.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -25,6 +27,7 @@ import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.PacketParserUtils;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* *
@ -82,7 +85,7 @@ import org.xmlpull.v1.XmlPullParser;
public abstract class EmbeddedExtensionProvider<PE extends ExtensionElement> extends ExtensionElementProvider<PE> { public abstract class EmbeddedExtensionProvider<PE extends ExtensionElement> extends ExtensionElementProvider<PE> {
@Override @Override
public final PE parse(XmlPullParser parser, int initialDepth) throws Exception { public final PE parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
final String namespace = parser.getNamespace(); final String namespace = parser.getNamespace();
final String name = parser.getName(); final String name = parser.getName();
final int attributeCount = parser.getAttributeCount(); final int attributeCount = parser.getAttributeCount();

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2014-2018 Florian Schmaus * Copyright © 2014-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package org.jivesoftware.smack.provider;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
@ -40,14 +39,14 @@ public class IntrospectionProvider{
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public I parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, public I parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
SmackException {
try { try {
return (I) parseWithIntrospection(elementClass, parser, initialDepth); return (I) parseWithIntrospection(elementClass, parser, initialDepth);
} }
catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException | ClassNotFoundException e) { | IllegalArgumentException | InvocationTargetException | ClassNotFoundException e) {
throw new SmackException(e); // TODO: Should probably be SmackParsingException (once it exists).
throw new IOException(e);
} }
} }
} }
@ -61,14 +60,14 @@ public class IntrospectionProvider{
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public PE parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, public PE parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
SmackException {
try { try {
return (PE) parseWithIntrospection(elementClass, parser, initialDepth); return (PE) parseWithIntrospection(elementClass, parser, initialDepth);
} }
catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException | ClassNotFoundException e) { | IllegalArgumentException | InvocationTargetException | ClassNotFoundException e) {
throw new SmackException(e); // TODO: Should probably be SmackParsingException (once it exists).
throw new IOException(e);
} }
} }
} }

View file

@ -17,13 +17,16 @@
package org.jivesoftware.smack.provider; package org.jivesoftware.smack.provider;
import java.io.IOException;
import java.lang.reflect.ParameterizedType; import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.text.ParseException;
import org.jivesoftware.smack.packet.Element; import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Smack provider are the parsers used to deserialize raw XMPP into the according Java {@link Element}s. * Smack provider are the parsers used to deserialize raw XMPP into the according Java {@link Element}s.
@ -58,7 +61,7 @@ public abstract class Provider<E extends Element> {
return elementClass; return elementClass;
} }
public final E parse(XmlPullParser parser) throws Exception { public final E parse(XmlPullParser parser) throws IOException, XmlPullParserException, ParseException {
// XPP3 calling convention assert: Parser should be at start tag // XPP3 calling convention assert: Parser should be at start tag
ParserUtils.assertAtStartTag(parser); ParserUtils.assertAtStartTag(parser);
@ -70,5 +73,5 @@ public abstract class Provider<E extends Element> {
return e; return e;
} }
public abstract E parse(XmlPullParser parser, int initialDepth) throws Exception; public abstract E parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException;
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2018 Florian Schmaus * Copyright 2018-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,7 +28,7 @@ public final class TlsFailureProvider extends NonzaProvider<TlsProceed> {
} }
@Override @Override
public TlsProceed parse(XmlPullParser parser, int initialDepth) throws Exception { public TlsProceed parse(XmlPullParser parser, int initialDepth) {
return TlsProceed.INSTANCE; return TlsProceed.INSTANCE;
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2018 Florian Schmaus * Copyright 2018-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,7 +28,7 @@ public final class TlsProceedProvider extends NonzaProvider<TlsFailure> {
} }
@Override @Override
public TlsFailure parse(XmlPullParser parser, int initialDepth) throws Exception { public TlsFailure parse(XmlPullParser parser, int initialDepth) {
return TlsFailure.INSTANCE; return TlsFailure.INSTANCE;
} }

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smack.util;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
import java.io.StringReader; import java.io.StringReader;
import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
@ -215,10 +216,11 @@ public class PacketParserUtils {
* *
* @param parser the XML parser, positioned at the start of a message packet. * @param parser the XML parser, positioned at the start of a message packet.
* @return a Message packet. * @return a Message packet.
* @throws Exception * @throws XmlPullParserException
* @throws IOException
* @throws ParseException
*/ */
public static Message parseMessage(XmlPullParser parser) public static Message parseMessage(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
throws Exception {
ParserUtils.assertAtStartTag(parser); ParserUtils.assertAtStartTag(parser);
assert (parser.getName().equals(Message.ELEMENT)); assert (parser.getName().equals(Message.ELEMENT));
@ -500,10 +502,11 @@ public class PacketParserUtils {
* *
* @param parser the XML parser, positioned at the start of a presence packet. * @param parser the XML parser, positioned at the start of a presence packet.
* @return a Presence packet. * @return a Presence packet.
* @throws Exception * @throws IOException
* @throws XmlPullParserException
* @throws ParseException
*/ */
public static Presence parsePresence(XmlPullParser parser) public static Presence parsePresence(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
throws Exception {
ParserUtils.assertAtStartTag(parser); ParserUtils.assertAtStartTag(parser);
final int initialDepth = parser.getDepth(); final int initialDepth = parser.getDepth();
@ -786,9 +789,11 @@ public class PacketParserUtils {
* *
* @param parser the XML parser. * @param parser the XML parser.
* @return an stream error packet. * @return an stream error packet.
* @throws Exception if an exception occurs while parsing the packet. * @throws IOException
* @throws XmlPullParserException
* @throws ParseException
*/ */
public static StreamError parseStreamError(XmlPullParser parser) throws Exception { public static StreamError parseStreamError(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
final int initialDepth = parser.getDepth(); final int initialDepth = parser.getDepth();
List<ExtensionElement> extensions = new ArrayList<>(); List<ExtensionElement> extensions = new ArrayList<>();
Map<String, String> descriptiveTexts = null; Map<String, String> descriptiveTexts = null;
@ -836,10 +841,11 @@ public class PacketParserUtils {
* *
* @param parser the XML parser. * @param parser the XML parser.
* @return an error sub-packet. * @return an error sub-packet.
* @throws Exception * @throws IOException
* @throws XmlPullParserException
* @throws ParseException
*/ */
public static StanzaError.Builder parseError(XmlPullParser parser) public static StanzaError.Builder parseError(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
throws Exception {
final int initialDepth = parser.getDepth(); final int initialDepth = parser.getDepth();
Map<String, String> descriptiveTexts = null; Map<String, String> descriptiveTexts = null;
List<ExtensionElement> extensions = new ArrayList<>(); List<ExtensionElement> extensions = new ArrayList<>();
@ -908,10 +914,12 @@ public class PacketParserUtils {
* @param parser the XML parser, positioned at the starting element of the extension. * @param parser the XML parser, positioned at the starting element of the extension.
* *
* @return an extension element. * @return an extension element.
* @throws Exception when an error occurs during parsing. * @throws XmlPullParserException
* @throws IOException
* @throws ParseException
*/ */
public static ExtensionElement parseExtensionElement(String elementName, String namespace, public static ExtensionElement parseExtensionElement(String elementName, String namespace,
XmlPullParser parser) throws Exception { XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
ParserUtils.assertAtStartTag(parser); ParserUtils.assertAtStartTag(parser);
// See if a provider is registered to handle the extension. // See if a provider is registered to handle the extension.
ExtensionElementProvider<ExtensionElement> provider = ProviderManager.getExtensionProvider(elementName, namespace); ExtensionElementProvider<ExtensionElement> provider = ProviderManager.getExtensionProvider(elementName, namespace);
@ -980,25 +988,24 @@ public class PacketParserUtils {
} }
public static void addExtensionElement(Stanza packet, XmlPullParser parser) public static void addExtensionElement(Stanza packet, XmlPullParser parser)
throws Exception { throws XmlPullParserException, IOException, ParseException {
ParserUtils.assertAtStartTag(parser); ParserUtils.assertAtStartTag(parser);
addExtensionElement(packet, parser, parser.getName(), parser.getNamespace()); addExtensionElement(packet, parser, parser.getName(), parser.getNamespace());
} }
public static void addExtensionElement(Stanza packet, XmlPullParser parser, String elementName, public static void addExtensionElement(Stanza packet, XmlPullParser parser, String elementName,
String namespace) throws Exception { String namespace) throws XmlPullParserException, IOException, ParseException {
ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser); ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser);
packet.addExtension(packetExtension); packet.addExtension(packetExtension);
} }
public static void addExtensionElement(Collection<ExtensionElement> collection, public static void addExtensionElement(Collection<ExtensionElement> collection, XmlPullParser parser)
XmlPullParser parser) throws Exception { throws XmlPullParserException, IOException, ParseException {
addExtensionElement(collection, parser, parser.getName(), parser.getNamespace()); addExtensionElement(collection, parser, parser.getName(), parser.getNamespace());
} }
public static void addExtensionElement(Collection<ExtensionElement> collection, public static void addExtensionElement(Collection<ExtensionElement> collection, XmlPullParser parser,
XmlPullParser parser, String elementName, String namespace) String elementName, String namespace) throws XmlPullParserException, IOException, ParseException {
throws Exception {
ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser); ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser);
collection.add(packetExtension); collection.add(packetExtension);
} }

View file

@ -26,8 +26,6 @@ import java.util.Locale;
import javax.xml.XMLConstants; import javax.xml.XMLConstants;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import org.jivesoftware.smack.SmackException;
import org.jxmpp.jid.EntityBareJid; import org.jxmpp.jid.EntityBareJid;
import org.jxmpp.jid.EntityFullJid; import org.jxmpp.jid.EntityFullJid;
import org.jxmpp.jid.EntityJid; import org.jxmpp.jid.EntityJid;
@ -176,10 +174,12 @@ public class ParserUtils {
} }
} }
public static int getIntegerAttributeOrThrow(XmlPullParser parser, String name, String throwMessage) throws SmackException { public static int getIntegerAttributeOrThrow(XmlPullParser parser, String name, String throwMessage)
throws IOException {
Integer res = getIntegerAttribute(parser, name); Integer res = getIntegerAttribute(parser, name);
if (res == null) { if (res == null) {
throw new SmackException(throwMessage); // TODO Should be SmackParseException.
throw new IOException(throwMessage);
} }
return res; return res;
} }
@ -266,9 +266,15 @@ public class ParserUtils {
return XmppDateTime.parseDate(dateString); return XmppDateTime.parseDate(dateString);
} }
public static URI getUriFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException, URISyntaxException { public static URI getUriFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException {
String uriString = parser.nextText(); String uriString = parser.nextText();
return new URI(uriString); try {
return new URI(uriString);
}
catch (URISyntaxException e) {
// TODO: Should be SmackParseException (or subclass of).
throw new IOException(e);
}
} }
public static String getRequiredAttribute(XmlPullParser parser, String name) throws IOException { public static String getRequiredAttribute(XmlPullParser parser, String name) throws IOException {

View file

@ -19,7 +19,8 @@ package org.jivesoftware.smack.parsing;
import static org.jivesoftware.smack.test.util.CharSequenceEquals.equalsCharSequence; import static org.jivesoftware.smack.test.util.CharSequenceEquals.equalsCharSequence;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import org.jivesoftware.smack.SmackException; import java.io.IOException;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.provider.ProviderManager; import org.jivesoftware.smack.provider.ProviderManager;
@ -78,8 +79,8 @@ public class ParsingExceptionTest {
public static final String NAMESPACE = "http://smack.jivesoftware.org/exception"; public static final String NAMESPACE = "http://smack.jivesoftware.org/exception";
@Override @Override
public ExtensionElement parse(XmlPullParser parser, int initialDepth) throws SmackException { public ExtensionElement parse(XmlPullParser parser, int initialDepth) throws IOException {
throw new SmackException("Test Exception"); throw new IOException("Test Exception");
} }
} }

View file

@ -16,7 +16,9 @@
*/ */
package org.jivesoftware.smackx.carbons.provider; package org.jivesoftware.smackx.carbons.provider;
import org.jivesoftware.smack.SmackException; import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.carbons.packet.CarbonExtension; import org.jivesoftware.smackx.carbons.packet.CarbonExtension;
@ -25,6 +27,7 @@ import org.jivesoftware.smackx.forward.packet.Forwarded;
import org.jivesoftware.smackx.forward.provider.ForwardedProvider; import org.jivesoftware.smackx.forward.provider.ForwardedProvider;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* This class implements the {@link ExtensionElementProvider} to parse * This class implements the {@link ExtensionElementProvider} to parse
@ -38,8 +41,7 @@ public class CarbonManagerProvider extends ExtensionElementProvider<CarbonExtens
private static final ForwardedProvider FORWARDED_PROVIDER = new ForwardedProvider(); private static final ForwardedProvider FORWARDED_PROVIDER = new ForwardedProvider();
@Override @Override
public CarbonExtension parse(XmlPullParser parser, int initialDepth) public CarbonExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
throws Exception {
Direction dir = Direction.valueOf(parser.getName()); Direction dir = Direction.valueOf(parser.getName());
Forwarded fwd = null; Forwarded fwd = null;
@ -52,8 +54,10 @@ public class CarbonManagerProvider extends ExtensionElementProvider<CarbonExtens
else if (eventType == XmlPullParser.END_TAG && dir == Direction.valueOf(parser.getName())) else if (eventType == XmlPullParser.END_TAG && dir == Direction.valueOf(parser.getName()))
done = true; done = true;
} }
if (fwd == null) if (fwd == null) {
throw new SmackException("sent/received must contain exactly one <forwarded> tag"); // TODO: Should be SmackParseException.
throw new IOException("sent/received must contain exactly one <forwarded> tag");
}
return new CarbonExtension(dir, fwd); return new CarbonExtension(dir, fwd);
} }
} }

View file

@ -33,7 +33,7 @@ import org.xmlpull.v1.XmlPullParser;
public class AcknowledgedProvider extends ExtensionElementProvider<AcknowledgedExtension> { public class AcknowledgedProvider extends ExtensionElementProvider<AcknowledgedExtension> {
@Override @Override
public AcknowledgedExtension parse(XmlPullParser parser, int initialDepth) throws Exception { public AcknowledgedExtension parse(XmlPullParser parser, int initialDepth) {
String id = parser.getAttributeValue("", "id"); String id = parser.getAttributeValue("", "id");
return new AcknowledgedExtension(id); return new AcknowledgedExtension(id);
} }

View file

@ -33,7 +33,7 @@ import org.xmlpull.v1.XmlPullParser;
public class DisplayedProvider extends ExtensionElementProvider<DisplayedExtension> { public class DisplayedProvider extends ExtensionElementProvider<DisplayedExtension> {
@Override @Override
public DisplayedExtension parse(XmlPullParser parser, int initialDepth) throws Exception { public DisplayedExtension parse(XmlPullParser parser, int initialDepth) {
String id = parser.getAttributeValue("", "id"); String id = parser.getAttributeValue("", "id");
return new DisplayedExtension(id); return new DisplayedExtension(id);
} }

View file

@ -33,7 +33,7 @@ import org.xmlpull.v1.XmlPullParser;
public class MarkableProvider extends ExtensionElementProvider<MarkableExtension> { public class MarkableProvider extends ExtensionElementProvider<MarkableExtension> {
@Override @Override
public MarkableExtension parse(XmlPullParser parser, int initialDepth) throws Exception { public MarkableExtension parse(XmlPullParser parser, int initialDepth) {
return MarkableExtension.INSTANCE; return MarkableExtension.INSTANCE;
} }

View file

@ -33,7 +33,7 @@ import org.xmlpull.v1.XmlPullParser;
public class ReceivedProvider extends ExtensionElementProvider<ReceivedExtension> { public class ReceivedProvider extends ExtensionElementProvider<ReceivedExtension> {
@Override @Override
public ReceivedExtension parse(XmlPullParser parser, int initialDepth) throws Exception { public ReceivedExtension parse(XmlPullParser parser, int initialDepth) {
String id = parser.getAttributeValue("", "id"); String id = parser.getAttributeValue("", "id");
return new ReceivedExtension(id); return new ReceivedExtension(id);
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2014 Florian Schmaus * Copyright © 2014-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package org.jivesoftware.smackx.csi.provider;
import java.io.IOException; import java.io.IOException;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.csi.packet.ClientStateIndication; import org.jivesoftware.smackx.csi.packet.ClientStateIndication;
@ -30,7 +29,7 @@ public class ClientStateIndicationFeatureProvider extends ExtensionElementProvid
@Override @Override
public ClientStateIndication.Feature parse(XmlPullParser parser, int initialDepth) public ClientStateIndication.Feature parse(XmlPullParser parser, int initialDepth)
throws XmlPullParserException, IOException, SmackException { throws XmlPullParserException, IOException {
return ClientStateIndication.Feature.INSTANCE; return ClientStateIndication.Feature.INSTANCE;
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2017 Florian Schmaus * Copyright 2017-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,7 +25,7 @@ import org.xmlpull.v1.XmlPullParser;
public class ExplicitMessageEncryptionProvider extends ExtensionElementProvider<ExplicitMessageEncryptionElement> { public class ExplicitMessageEncryptionProvider extends ExtensionElementProvider<ExplicitMessageEncryptionElement> {
@Override @Override
public ExplicitMessageEncryptionElement parse(XmlPullParser parser, int initialDepth) throws Exception { public ExplicitMessageEncryptionElement parse(XmlPullParser parser, int initialDepth) {
String namespace = parser.getAttributeValue(null, "namespace"); String namespace = parser.getAttributeValue(null, "namespace");
String name = parser.getAttributeValue(null, "name"); String name = parser.getAttributeValue(null, "name");
return new ExplicitMessageEncryptionElement(namespace, name); return new ExplicitMessageEncryptionElement(namespace, name);

View file

@ -16,12 +16,15 @@
*/ */
package org.jivesoftware.smackx.hashes.provider; package org.jivesoftware.smackx.hashes.provider;
import java.io.IOException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.hashes.HashManager; import org.jivesoftware.smackx.hashes.HashManager;
import org.jivesoftware.smackx.hashes.element.HashElement; import org.jivesoftware.smackx.hashes.element.HashElement;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Provider for HashElements. * Provider for HashElements.
@ -29,7 +32,7 @@ import org.xmlpull.v1.XmlPullParser;
public class HashElementProvider extends ExtensionElementProvider<HashElement> { public class HashElementProvider extends ExtensionElementProvider<HashElement> {
@Override @Override
public HashElement parse(XmlPullParser parser, int initialDepth) throws Exception { public HashElement parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
String algo = parser.getAttributeValue(null, HashElement.ATTR_ALGO); String algo = parser.getAttributeValue(null, HashElement.ATTR_ALGO);
String hashB64 = parser.nextText(); String hashB64 = parser.nextText();
return new HashElement(HashManager.ALGORITHM.valueOfName(algo), hashB64); return new HashElement(HashManager.ALGORITHM.valueOfName(algo), hashB64);

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2017 Florian Schmaus * Copyright 2017-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,7 +25,7 @@ import org.xmlpull.v1.XmlPullParser;
public abstract class MessageProcessingHintProvider<H extends MessageProcessingHint> extends ExtensionElementProvider<H> { public abstract class MessageProcessingHintProvider<H extends MessageProcessingHint> extends ExtensionElementProvider<H> {
@Override @Override
public H parse(XmlPullParser parser, int initialDepth) throws Exception { public H parse(XmlPullParser parser, int initialDepth) {
return getHint(); return getHint();
} }

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.hoxt.provider; package org.jivesoftware.smackx.hoxt.provider;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.NamedElement; import org.jivesoftware.smack.packet.NamedElement;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
@ -55,9 +56,11 @@ public abstract class AbstractHttpOverXmppProvider<H extends AbstractHttpOverXmp
* *
* @param parser parser * @param parser parser
* @return HeadersExtension or null if no headers * @return HeadersExtension or null if no headers
* @throws Exception * @throws ParseException
* @throws XmlPullParserException
* @throws IOException
*/ */
protected HeadersExtension parseHeaders(XmlPullParser parser) throws Exception { protected HeadersExtension parseHeaders(XmlPullParser parser) throws IOException, XmlPullParserException, ParseException {
HeadersExtension headersExtension = null; HeadersExtension headersExtension = null;
/* We are either at start of headers, start of data or end of req/res */ /* We are either at start of headers, start of data or end of req/res */
if (parser.next() == XmlPullParser.START_TAG && parser.getName().equals(HeadersExtension.ELEMENT)) { if (parser.next() == XmlPullParser.START_TAG && parser.getName().equals(HeadersExtension.ELEMENT)) {

View file

@ -16,12 +16,16 @@
*/ */
package org.jivesoftware.smackx.hoxt.provider; package org.jivesoftware.smackx.hoxt.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smackx.hoxt.packet.HttpMethod; import org.jivesoftware.smackx.hoxt.packet.HttpMethod;
import org.jivesoftware.smackx.hoxt.packet.HttpOverXmppReq; import org.jivesoftware.smackx.hoxt.packet.HttpOverXmppReq;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Req stanza provider. * Req stanza provider.
@ -36,7 +40,7 @@ public class HttpOverXmppReqProvider extends AbstractHttpOverXmppProvider<HttpOv
private static final String ATTRIBUTE_MAX_CHUNK_SIZE = "maxChunkSize"; private static final String ATTRIBUTE_MAX_CHUNK_SIZE = "maxChunkSize";
@Override @Override
public HttpOverXmppReq parse(XmlPullParser parser, int initialDepth) throws Exception { public HttpOverXmppReq parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException, ParseException {
HttpOverXmppReq.Builder builder = HttpOverXmppReq.builder(); HttpOverXmppReq.Builder builder = HttpOverXmppReq.builder();
builder.setResource(parser.getAttributeValue("", ATTRIBUTE_RESOURCE)); builder.setResource(parser.getAttributeValue("", ATTRIBUTE_RESOURCE));
builder.setVersion(parser.getAttributeValue("", ATTRIBUTE_VERSION)); builder.setVersion(parser.getAttributeValue("", ATTRIBUTE_VERSION));

View file

@ -16,11 +16,15 @@
*/ */
package org.jivesoftware.smackx.hoxt.provider; package org.jivesoftware.smackx.hoxt.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smackx.hoxt.packet.AbstractHttpOverXmpp; import org.jivesoftware.smackx.hoxt.packet.AbstractHttpOverXmpp;
import org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp; import org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp;
import org.jivesoftware.smackx.shim.packet.HeadersExtension; import org.jivesoftware.smackx.shim.packet.HeadersExtension;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Resp stanza provider. * Resp stanza provider.
@ -34,7 +38,7 @@ public class HttpOverXmppRespProvider extends AbstractHttpOverXmppProvider<HttpO
private static final String ATTRIBUTE_STATUS_CODE = "statusCode"; private static final String ATTRIBUTE_STATUS_CODE = "statusCode";
@Override @Override
public HttpOverXmppResp parse(XmlPullParser parser, int initialDepth) throws Exception { public HttpOverXmppResp parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException, ParseException {
String version = parser.getAttributeValue("", ATTRIBUTE_VERSION); String version = parser.getAttributeValue("", ATTRIBUTE_VERSION);
String statusMessage = parser.getAttributeValue("", ATTRIBUTE_STATUS_MESSAGE); String statusMessage = parser.getAttributeValue("", ATTRIBUTE_STATUS_MESSAGE);
String statusCodeString = parser.getAttributeValue("", ATTRIBUTE_STATUS_CODE); String statusCodeString = parser.getAttributeValue("", ATTRIBUTE_STATUS_CODE);

View file

@ -16,12 +16,15 @@
*/ */
package org.jivesoftware.smackx.httpfileupload.provider; package org.jivesoftware.smackx.httpfileupload.provider;
import java.io.IOException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.httpfileupload.element.FileTooLargeError; import org.jivesoftware.smackx.httpfileupload.element.FileTooLargeError;
import org.jivesoftware.smackx.httpfileupload.element.FileTooLargeError_V0_2; import org.jivesoftware.smackx.httpfileupload.element.FileTooLargeError_V0_2;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Provider for File Too Large error extension. * Provider for File Too Large error extension.
@ -32,7 +35,7 @@ import org.xmlpull.v1.XmlPullParser;
public class FileTooLargeErrorProvider extends ExtensionElementProvider<FileTooLargeError> { public class FileTooLargeErrorProvider extends ExtensionElementProvider<FileTooLargeError> {
@Override @Override
public FileTooLargeError parse(XmlPullParser parser, int initialDepth) throws Exception { public FileTooLargeError parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
final String namespace = parser.getNamespace(); final String namespace = parser.getNamespace();
Long maxFileSize = null; Long maxFileSize = null;

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2017 Grigory Fedorov, Florian Schmaus * Copyright © 2017 Grigory Fedorov, 2017-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,7 +21,6 @@ import java.net.URL;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
@ -42,7 +41,7 @@ import org.xmlpull.v1.XmlPullParserException;
public class SlotProvider extends IQProvider<Slot> { public class SlotProvider extends IQProvider<Slot> {
@Override @Override
public Slot parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { public Slot parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
final String namespace = parser.getNamespace(); final String namespace = parser.getNamespace();
final UploadService.Version version = HttpFileUploadManager.namespaceToVersion(namespace); final UploadService.Version version = HttpFileUploadManager.namespaceToVersion(namespace);

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2016 Florian Schmaus * Copyright © 2016-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.iot.control.provider; package org.jivesoftware.smackx.iot.control.provider;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -29,11 +30,12 @@ import org.jivesoftware.smackx.iot.control.element.SetIntData;
import org.jivesoftware.smackx.iot.control.element.SetLongData; import org.jivesoftware.smackx.iot.control.element.SetLongData;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public class IoTSetRequestProvider extends IQProvider<IoTSetRequest> { public class IoTSetRequestProvider extends IQProvider<IoTSetRequest> {
@Override @Override
public IoTSetRequest parse(XmlPullParser parser, int initialDepth) throws Exception { public IoTSetRequest parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
List<SetData> data = new ArrayList<>(4); List<SetData> data = new ArrayList<>(4);
outerloop: while (true) { outerloop: while (true) {
final int eventType = parser.next(); final int eventType = parser.next();

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2016 Florian Schmaus * Copyright © 2016-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,7 +25,7 @@ import org.xmlpull.v1.XmlPullParser;
public class IoTSetResponseProvider extends IQProvider<IoTSetResponse> { public class IoTSetResponseProvider extends IQProvider<IoTSetResponse> {
@Override @Override
public IoTSetResponse parse(XmlPullParser parser, int initialDepth) throws Exception { public IoTSetResponse parse(XmlPullParser parser, int initialDepth) {
return new IoTSetResponse(); return new IoTSetResponse();
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2016 Florian Schmaus * Copyright © 2016-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,6 +16,8 @@
*/ */
package org.jivesoftware.smackx.iot.data.provider; package org.jivesoftware.smackx.iot.data.provider;
import java.io.IOException;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
@ -26,7 +28,7 @@ import org.xmlpull.v1.XmlPullParser;
public class IoTDataReadOutAcceptedProvider extends IQProvider<IoTDataReadOutAccepted> { public class IoTDataReadOutAcceptedProvider extends IQProvider<IoTDataReadOutAccepted> {
@Override @Override
public IoTDataReadOutAccepted parse(XmlPullParser parser, int initialDepth) throws Exception { public IoTDataReadOutAccepted parse(XmlPullParser parser, int initialDepth) throws IOException {
int seqNr = ParserUtils.getIntegerAttributeOrThrow(parser, "seqnr", "IoT data request <accepted/> without sequence number"); int seqNr = ParserUtils.getIntegerAttributeOrThrow(parser, "seqnr", "IoT data request <accepted/> without sequence number");
boolean queued = ParserUtils.getBooleanAttribute(parser, "queued", false); boolean queued = ParserUtils.getBooleanAttribute(parser, "queued", false);
return new IoTDataReadOutAccepted(seqNr, queued); return new IoTDataReadOutAccepted(seqNr, queued);

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2016 Florian Schmaus * Copyright © 2016-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,6 +16,8 @@
*/ */
package org.jivesoftware.smackx.iot.data.provider; package org.jivesoftware.smackx.iot.data.provider;
import java.io.IOException;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
@ -26,7 +28,7 @@ import org.xmlpull.v1.XmlPullParser;
public class IoTDataRequestProvider extends IQProvider<IoTDataRequest> { public class IoTDataRequestProvider extends IQProvider<IoTDataRequest> {
@Override @Override
public IoTDataRequest parse(XmlPullParser parser, int initialDepth) throws Exception { public IoTDataRequest parse(XmlPullParser parser, int initialDepth) throws IOException {
int seqNr = ParserUtils.getIntegerAttributeOrThrow(parser, "seqnr", "IoT data request without sequence number"); int seqNr = ParserUtils.getIntegerAttributeOrThrow(parser, "seqnr", "IoT data request without sequence number");
boolean momentary = ParserUtils.getBooleanAttribute(parser, "momentary", false); boolean momentary = ParserUtils.getBooleanAttribute(parser, "momentary", false);
return new IoTDataRequest(seqNr, momentary); return new IoTDataRequest(seqNr, momentary);

View file

@ -42,7 +42,7 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
private static final Logger LOGGER = Logger.getLogger(IoTFieldsExtensionProvider.class.getName()); private static final Logger LOGGER = Logger.getLogger(IoTFieldsExtensionProvider.class.getName());
@Override @Override
public IoTFieldsExtension parse(XmlPullParser parser, int initialDepth) throws Exception { public IoTFieldsExtension parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException, ParseException {
int seqNr = ParserUtils.getIntegerAttributeOrThrow(parser, "seqnr", "IoT data request <accepted/> without sequence number"); int seqNr = ParserUtils.getIntegerAttributeOrThrow(parser, "seqnr", "IoT data request <accepted/> without sequence number");
boolean done = ParserUtils.getBooleanAttribute(parser, "done", false); boolean done = ParserUtils.getBooleanAttribute(parser, "done", false);
List<NodeElement> nodes = new ArrayList<>(); List<NodeElement> nodes = new ArrayList<>();

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2016 Florian Schmaus * Copyright 2016-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,12 +24,13 @@ import org.jivesoftware.smackx.iot.element.NodeInfo;
import org.jivesoftware.smackx.iot.parser.NodeInfoParser; import org.jivesoftware.smackx.iot.parser.NodeInfoParser;
import org.jxmpp.jid.Jid; import org.jxmpp.jid.Jid;
import org.jxmpp.stringprep.XmppStringprepException;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
public class IoTClaimedProvider extends IQProvider<IoTClaimed> { public class IoTClaimedProvider extends IQProvider<IoTClaimed> {
@Override @Override
public IoTClaimed parse(XmlPullParser parser, int initialDepth) throws Exception { public IoTClaimed parse(XmlPullParser parser, int initialDepth) throws XmppStringprepException {
Jid jid = ParserUtils.getJidAttribute(parser); Jid jid = ParserUtils.getJidAttribute(parser);
NodeInfo nodeInfo = NodeInfoParser.parse(parser); NodeInfo nodeInfo = NodeInfoParser.parse(parser);
return new IoTClaimed(jid, nodeInfo); return new IoTClaimed(jid, nodeInfo);

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2016 Florian Schmaus * Copyright 2016-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,12 +24,13 @@ import org.jivesoftware.smackx.iot.element.NodeInfo;
import org.jivesoftware.smackx.iot.parser.NodeInfoParser; import org.jivesoftware.smackx.iot.parser.NodeInfoParser;
import org.jxmpp.jid.Jid; import org.jxmpp.jid.Jid;
import org.jxmpp.stringprep.XmppStringprepException;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
public class IoTDisownProvider extends IQProvider<IoTDisown> { public class IoTDisownProvider extends IQProvider<IoTDisown> {
@Override @Override
public IoTDisown parse(XmlPullParser parser, int initialDepth) throws Exception { public IoTDisown parse(XmlPullParser parser, int initialDepth) throws XmppStringprepException {
Jid jid = ParserUtils.getJidAttribute(parser); Jid jid = ParserUtils.getJidAttribute(parser);
NodeInfo nodeInfo = NodeInfoParser.parse(parser); NodeInfo nodeInfo = NodeInfoParser.parse(parser);
return new IoTDisown(jid, nodeInfo); return new IoTDisown(jid, nodeInfo);

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2016 Florian Schmaus * Copyright 2016-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,7 @@ import org.xmlpull.v1.XmlPullParser;
public class IoTDisownedProvider extends IQProvider<IoTDisowned> { public class IoTDisownedProvider extends IQProvider<IoTDisowned> {
@Override @Override
public IoTDisowned parse(XmlPullParser parser, int initialDepth) throws Exception { public IoTDisowned parse(XmlPullParser parser, int initialDepth) {
NodeInfo nodeInfo = NodeInfoParser.parse(parser); NodeInfo nodeInfo = NodeInfoParser.parse(parser);
return new IoTDisowned(nodeInfo); return new IoTDisowned(nodeInfo);
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2016 Florian Schmaus * Copyright 2016-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.iot.discovery.provider; package org.jivesoftware.smackx.iot.discovery.provider;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -28,11 +29,12 @@ import org.jivesoftware.smackx.iot.element.NodeInfo;
import org.jivesoftware.smackx.iot.parser.NodeInfoParser; import org.jivesoftware.smackx.iot.parser.NodeInfoParser;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public class IoTRegisterProvider extends IQProvider<IoTRegister> { public class IoTRegisterProvider extends IQProvider<IoTRegister> {
@Override @Override
public IoTRegister parse(XmlPullParser parser, int initialDepth) throws Exception { public IoTRegister parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
boolean selfOwned = ParserUtils.getBooleanAttribute(parser, "selfOwned", false); boolean selfOwned = ParserUtils.getBooleanAttribute(parser, "selfOwned", false);
NodeInfo nodeInfo = NodeInfoParser.parse(parser); NodeInfo nodeInfo = NodeInfoParser.parse(parser);
List<Tag> tags = new ArrayList<>(); List<Tag> tags = new ArrayList<>();

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2016 Florian Schmaus * Copyright 2016-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,8 @@
*/ */
package org.jivesoftware.smackx.iot.discovery.provider; package org.jivesoftware.smackx.iot.discovery.provider;
import org.jivesoftware.smack.SmackException; import java.io.IOException;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
@ -31,10 +32,11 @@ import org.xmlpull.v1.XmlPullParser;
public class IoTRemoveProvider extends IQProvider<IoTRemove> { public class IoTRemoveProvider extends IQProvider<IoTRemove> {
@Override @Override
public IoTRemove parse(XmlPullParser parser, int initialDepth) throws Exception { public IoTRemove parse(XmlPullParser parser, int initialDepth) throws IOException {
Jid jid = ParserUtils.getJidAttribute(parser); Jid jid = ParserUtils.getJidAttribute(parser);
if (jid.hasResource()) { if (jid.hasResource()) {
throw new SmackException("JID must be without resourcepart"); // TODO: Should be SmackParseException.
throw new IOException("JID must be without resourcepart");
} }
BareJid bareJid = jid.asBareJid(); BareJid bareJid = jid.asBareJid();
NodeInfo nodeInfo = NodeInfoParser.parse(parser); NodeInfo nodeInfo = NodeInfoParser.parse(parser);

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2016 Florian Schmaus * Copyright 2016-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,7 @@ import org.xmlpull.v1.XmlPullParser;
public class IoTRemovedProvider extends IQProvider<IoTRemoved> { public class IoTRemovedProvider extends IQProvider<IoTRemoved> {
@Override @Override
public IoTRemoved parse(XmlPullParser parser, int initialDepth) throws Exception { public IoTRemoved parse(XmlPullParser parser, int initialDepth) {
NodeInfo nodeInfo = NodeInfoParser.parse(parser); NodeInfo nodeInfo = NodeInfoParser.parse(parser);
return new IoTRemoved(nodeInfo); return new IoTRemoved(nodeInfo);
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2016 Florian Schmaus * Copyright 2016-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,7 @@ import org.xmlpull.v1.XmlPullParser;
public class IoTUnregisterProvider extends IQProvider<IoTUnregister> { public class IoTUnregisterProvider extends IQProvider<IoTUnregister> {
@Override @Override
public IoTUnregister parse(XmlPullParser parser, int initialDepth) throws Exception { public IoTUnregister parse(XmlPullParser parser, int initialDepth) {
NodeInfo nodeInfo = NodeInfoParser.parse(parser); NodeInfo nodeInfo = NodeInfoParser.parse(parser);
return new IoTUnregister(nodeInfo); return new IoTUnregister(nodeInfo);
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2016 Florian Schmaus * Copyright 2016-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,7 +25,7 @@ import org.xmlpull.v1.XmlPullParser;
public class ClearCacheProvider extends IQProvider<ClearCache> { public class ClearCacheProvider extends IQProvider<ClearCache> {
@Override @Override
public ClearCache parse(XmlPullParser parser, int initialDepth) throws Exception { public ClearCache parse(XmlPullParser parser, int initialDepth) {
return new ClearCache(); return new ClearCache();
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2016 Florian Schmaus * Copyright 2016-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,7 +25,7 @@ import org.xmlpull.v1.XmlPullParser;
public class ClearCacheResponseProvider extends IQProvider<ClearCacheResponse> { public class ClearCacheResponseProvider extends IQProvider<ClearCacheResponse> {
@Override @Override
public ClearCacheResponse parse(XmlPullParser parser, int initialDepth) throws Exception { public ClearCacheResponse parse(XmlPullParser parser, int initialDepth) {
return new ClearCacheResponse(); return new ClearCacheResponse();
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2016 Florian Schmaus * Copyright 2016-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,12 +22,13 @@ import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smackx.iot.provisioning.element.IoTIsFriend; import org.jivesoftware.smackx.iot.provisioning.element.IoTIsFriend;
import org.jxmpp.jid.Jid; import org.jxmpp.jid.Jid;
import org.jxmpp.stringprep.XmppStringprepException;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
public class IoTIsFriendProvider extends IQProvider<IoTIsFriend> { public class IoTIsFriendProvider extends IQProvider<IoTIsFriend> {
@Override @Override
public IoTIsFriend parse(XmlPullParser parser, int initialDepth) throws Exception { public IoTIsFriend parse(XmlPullParser parser, int initialDepth) throws XmppStringprepException {
Jid jid = ParserUtils.getJidAttribute(parser); Jid jid = ParserUtils.getJidAttribute(parser);
return new IoTIsFriend(jid); return new IoTIsFriend(jid);
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2016 Florian Schmaus * Copyright 2016-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,12 +23,13 @@ import org.jivesoftware.smackx.iot.provisioning.element.IoTIsFriendResponse;
import org.jxmpp.jid.BareJid; import org.jxmpp.jid.BareJid;
import org.jxmpp.jid.Jid; import org.jxmpp.jid.Jid;
import org.jxmpp.stringprep.XmppStringprepException;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
public class IoTIsFriendResponseProvider extends IQProvider<IoTIsFriendResponse> { public class IoTIsFriendResponseProvider extends IQProvider<IoTIsFriendResponse> {
@Override @Override
public IoTIsFriendResponse parse(XmlPullParser parser, int initialDepth) throws Exception { public IoTIsFriendResponse parse(XmlPullParser parser, int initialDepth) throws XmppStringprepException {
Jid jid = ParserUtils.getJidAttribute(parser); Jid jid = ParserUtils.getJidAttribute(parser);
BareJid bareJid = jid.asBareJid(); BareJid bareJid = jid.asBareJid();
boolean result = ParserUtils.getBooleanAttribute(parser, "result"); boolean result = ParserUtils.getBooleanAttribute(parser, "result");

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2016 Florian Schmaus * Copyright © 2016-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,12 +22,13 @@ import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smackx.iot.provisioning.element.Unfriend; import org.jivesoftware.smackx.iot.provisioning.element.Unfriend;
import org.jxmpp.jid.BareJid; import org.jxmpp.jid.BareJid;
import org.jxmpp.stringprep.XmppStringprepException;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
public class UnfriendProvider extends ExtensionElementProvider<Unfriend> { public class UnfriendProvider extends ExtensionElementProvider<Unfriend> {
@Override @Override
public Unfriend parse(XmlPullParser parser, int initialDepth) throws Exception { public Unfriend parse(XmlPullParser parser, int initialDepth) throws XmppStringprepException {
BareJid jid = ParserUtils.getBareJidAttribute(parser); BareJid jid = ParserUtils.getBareJidAttribute(parser);
return new Unfriend(jid); return new Unfriend(jid);
} }

View file

@ -19,6 +19,9 @@ package org.jivesoftware.smackx.jingle_filetransfer.provider;
import static org.xmlpull.v1.XmlPullParser.END_TAG; import static org.xmlpull.v1.XmlPullParser.END_TAG;
import static org.xmlpull.v1.XmlPullParser.START_TAG; import static org.xmlpull.v1.XmlPullParser.START_TAG;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.hashes.element.HashElement; import org.jivesoftware.smackx.hashes.element.HashElement;
import org.jivesoftware.smackx.hashes.provider.HashElementProvider; import org.jivesoftware.smackx.hashes.provider.HashElementProvider;
@ -28,13 +31,14 @@ import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChi
import org.jivesoftware.smackx.jingle_filetransfer.element.Range; import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Provider for the Checksum element. * Provider for the Checksum element.
*/ */
public class ChecksumProvider extends ExtensionElementProvider<Checksum> { public class ChecksumProvider extends ExtensionElementProvider<Checksum> {
@Override @Override
public Checksum parse(XmlPullParser parser, int initialDepth) throws Exception { public Checksum parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
JingleContent.Creator creator = null; JingleContent.Creator creator = null;
String creatorString = parser.getAttributeValue(null, Checksum.ATTR_CREATOR); String creatorString = parser.getAttributeValue(null, Checksum.ATTR_CREATOR);
if (creatorString != null) { if (creatorString != null) {

View file

@ -19,6 +19,8 @@ package org.jivesoftware.smackx.jingle_filetransfer.provider;
import static org.xmlpull.v1.XmlPullParser.END_TAG; import static org.xmlpull.v1.XmlPullParser.END_TAG;
import static org.xmlpull.v1.XmlPullParser.START_TAG; import static org.xmlpull.v1.XmlPullParser.START_TAG;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import org.jivesoftware.smackx.hashes.element.HashElement; import org.jivesoftware.smackx.hashes.element.HashElement;
@ -31,6 +33,7 @@ import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
import org.jxmpp.util.XmppDateTime; import org.jxmpp.util.XmppDateTime;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Provider for JingleContentDescriptionFileTransfer elements. * Provider for JingleContentDescriptionFileTransfer elements.
@ -39,7 +42,7 @@ public class JingleFileTransferProvider
extends JingleContentDescriptionProvider<JingleFileTransfer> { extends JingleContentDescriptionProvider<JingleFileTransfer> {
@Override @Override
public JingleFileTransfer parse(XmlPullParser parser, int initialDepth) throws Exception { public JingleFileTransfer parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
ArrayList<JingleContentDescriptionChildElement> payloads = new ArrayList<>(); ArrayList<JingleContentDescriptionChildElement> payloads = new ArrayList<>();
boolean inRange = false; boolean inRange = false;
JingleFileTransferChild.Builder builder = JingleFileTransferChild.getBuilder(); JingleFileTransferChild.Builder builder = JingleFileTransferChild.getBuilder();

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2014-2018 Florian Schmaus * Copyright 2014-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package org.jivesoftware.smackx.json.provider;
import java.io.IOException; import java.io.IOException;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.PacketParserUtils;
@ -31,7 +30,7 @@ public abstract class AbstractJsonExtensionProvider<J extends AbstractJsonPacket
@Override @Override
public J parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, public J parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException,
IOException, SmackException { IOException {
String json = PacketParserUtils.parseElementText(parser); String json = PacketParserUtils.parseElementText(parser);
return from(json); return from(json);
} }

View file

@ -16,6 +16,9 @@
*/ */
package org.jivesoftware.smackx.mam.provider; package org.jivesoftware.smackx.mam.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
@ -24,6 +27,7 @@ import org.jivesoftware.smackx.rsm.packet.RSMSet;
import org.jivesoftware.smackx.rsm.provider.RSMSetProvider; import org.jivesoftware.smackx.rsm.provider.RSMSetProvider;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* MAM Fin IQ Provider class. * MAM Fin IQ Provider class.
@ -36,7 +40,7 @@ import org.xmlpull.v1.XmlPullParser;
public class MamFinIQProvider extends IQProvider<MamFinIQ> { public class MamFinIQProvider extends IQProvider<MamFinIQ> {
@Override @Override
public MamFinIQ parse(XmlPullParser parser, int initialDepth) throws Exception { public MamFinIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
String queryId = parser.getAttributeValue("", "queryid"); String queryId = parser.getAttributeValue("", "queryid");
boolean complete = ParserUtils.getBooleanAttribute(parser, "complete", false); boolean complete = ParserUtils.getBooleanAttribute(parser, "complete", false);
boolean stable = ParserUtils.getBooleanAttribute(parser, "stable", true); boolean stable = ParserUtils.getBooleanAttribute(parser, "stable", true);

View file

@ -16,6 +16,9 @@
*/ */
package org.jivesoftware.smackx.mam.provider; package org.jivesoftware.smackx.mam.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smackx.mam.element.MamQueryIQ; import org.jivesoftware.smackx.mam.element.MamQueryIQ;
@ -23,6 +26,7 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.xdata.provider.DataFormProvider; import org.jivesoftware.smackx.xdata.provider.DataFormProvider;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* MAM Query IQ Provider class. * MAM Query IQ Provider class.
@ -35,7 +39,8 @@ import org.xmlpull.v1.XmlPullParser;
public class MamQueryIQProvider extends IQProvider<MamQueryIQ> { public class MamQueryIQProvider extends IQProvider<MamQueryIQ> {
@Override @Override
public MamQueryIQ parse(XmlPullParser parser, int initialDepth) throws Exception { public MamQueryIQ parse(XmlPullParser parser, int initialDepth)
throws XmlPullParserException, IOException, ParseException {
DataForm dataForm = null; DataForm dataForm = null;
String queryId = parser.getAttributeValue("", "queryid"); String queryId = parser.getAttributeValue("", "queryid");
String node = parser.getAttributeValue("", "node"); String node = parser.getAttributeValue("", "node");

View file

@ -16,6 +16,9 @@
*/ */
package org.jivesoftware.smackx.mam.provider; package org.jivesoftware.smackx.mam.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.forward.packet.Forwarded; import org.jivesoftware.smackx.forward.packet.Forwarded;
@ -23,6 +26,7 @@ import org.jivesoftware.smackx.forward.provider.ForwardedProvider;
import org.jivesoftware.smackx.mam.element.MamElements.MamResultExtension; import org.jivesoftware.smackx.mam.element.MamElements.MamResultExtension;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* MAM Result Provider class. * MAM Result Provider class.
@ -35,7 +39,7 @@ import org.xmlpull.v1.XmlPullParser;
public class MamResultProvider extends ExtensionElementProvider<MamResultExtension> { public class MamResultProvider extends ExtensionElementProvider<MamResultExtension> {
@Override @Override
public MamResultExtension parse(XmlPullParser parser, int initialDepth) throws Exception { public MamResultExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
Forwarded forwarded = null; Forwarded forwarded = null;
String queryId = parser.getAttributeValue("", "queryid"); String queryId = parser.getAttributeValue("", "queryid");
String id = parser.getAttributeValue("", "id"); String id = parser.getAttributeValue("", "id");

View file

@ -19,12 +19,12 @@ package org.jivesoftware.smackx.message_markup.provider;
import static org.xmlpull.v1.XmlPullParser.END_TAG; import static org.xmlpull.v1.XmlPullParser.END_TAG;
import static org.xmlpull.v1.XmlPullParser.START_TAG; import static org.xmlpull.v1.XmlPullParser.START_TAG;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smackx.message_markup.element.BlockQuoteElement; import org.jivesoftware.smackx.message_markup.element.BlockQuoteElement;
@ -34,11 +34,12 @@ import org.jivesoftware.smackx.message_markup.element.MarkupElement;
import org.jivesoftware.smackx.message_markup.element.SpanElement; import org.jivesoftware.smackx.message_markup.element.SpanElement;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public class MarkupElementProvider extends ExtensionElementProvider<MarkupElement> { public class MarkupElementProvider extends ExtensionElementProvider<MarkupElement> {
@Override @Override
public MarkupElement parse(XmlPullParser parser, int initialDepth) throws Exception { public MarkupElement parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException {
MarkupElement.Builder markup = MarkupElement.getBuilder(); MarkupElement.Builder markup = MarkupElement.getBuilder();
@ -117,7 +118,8 @@ public class MarkupElementProvider extends ExtensionElementProvider<MarkupElemen
case ListElement.ELEMENT: case ListElement.ELEMENT:
MarkupElement.Builder.ListBuilder listBuilder = markup.beginList(); MarkupElement.Builder.ListBuilder listBuilder = markup.beginList();
if (lis.size() > 0 && lis.get(0).getStart() != listStart) { if (lis.size() > 0 && lis.get(0).getStart() != listStart) {
throw new SmackException("Error while parsing incoming MessageMarkup ListElement: " + // TODO: Should be SmackParseException.
throw new IOException("Error while parsing incoming MessageMarkup ListElement: " +
"'start' attribute of first 'li' element must equal 'start' attribute of list."); "'start' attribute of first 'li' element must equal 'start' attribute of list.");
} }
for (int i = 0; i < lis.size(); i++) { for (int i = 0; i < lis.size(); i++) {

View file

@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.muclight.provider; package org.jivesoftware.smackx.muclight.provider;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
@ -26,6 +27,7 @@ import org.jivesoftware.smackx.muclight.element.MUCLightElements.AffiliationsCha
import org.jxmpp.jid.Jid; import org.jxmpp.jid.Jid;
import org.jxmpp.jid.impl.JidCreate; import org.jxmpp.jid.impl.JidCreate;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* MUC Light Affiliations Change Provider class. * MUC Light Affiliations Change Provider class.
@ -36,7 +38,7 @@ import org.xmlpull.v1.XmlPullParser;
public class MUCLightAffiliationsChangeProvider extends ExtensionElementProvider<AffiliationsChangeExtension> { public class MUCLightAffiliationsChangeProvider extends ExtensionElementProvider<AffiliationsChangeExtension> {
@Override @Override
public AffiliationsChangeExtension parse(XmlPullParser parser, int initialDepth) throws Exception { public AffiliationsChangeExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
HashMap<Jid, MUCLightAffiliation> affiliations = new HashMap<>(); HashMap<Jid, MUCLightAffiliation> affiliations = new HashMap<>();
String prevVersion = null; String prevVersion = null;
String version = null; String version = null;

View file

@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.muclight.provider; package org.jivesoftware.smackx.muclight.provider;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
@ -26,6 +27,7 @@ import org.jivesoftware.smackx.muclight.element.MUCLightAffiliationsIQ;
import org.jxmpp.jid.Jid; import org.jxmpp.jid.Jid;
import org.jxmpp.jid.impl.JidCreate; import org.jxmpp.jid.impl.JidCreate;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* MUC Light affiliations IQ provider class. * MUC Light affiliations IQ provider class.
@ -36,7 +38,7 @@ import org.xmlpull.v1.XmlPullParser;
public class MUCLightAffiliationsIQProvider extends IQProvider<MUCLightAffiliationsIQ> { public class MUCLightAffiliationsIQProvider extends IQProvider<MUCLightAffiliationsIQ> {
@Override @Override
public MUCLightAffiliationsIQ parse(XmlPullParser parser, int initialDepth) throws Exception { public MUCLightAffiliationsIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
String version = null; String version = null;
HashMap<Jid, MUCLightAffiliation> occupants = new HashMap<>(); HashMap<Jid, MUCLightAffiliation> occupants = new HashMap<>();

View file

@ -39,7 +39,7 @@ import org.xmlpull.v1.XmlPullParserException;
public class MUCLightBlockingIQProvider extends IQProvider<MUCLightBlockingIQ> { public class MUCLightBlockingIQProvider extends IQProvider<MUCLightBlockingIQ> {
@Override @Override
public MUCLightBlockingIQ parse(XmlPullParser parser, int initialDepth) throws Exception { public MUCLightBlockingIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
HashMap<Jid, Boolean> rooms = null; HashMap<Jid, Boolean> rooms = null;
HashMap<Jid, Boolean> users = null; HashMap<Jid, Boolean> users = null;

View file

@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.muclight.provider; package org.jivesoftware.smackx.muclight.provider;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
@ -24,6 +25,7 @@ import org.jivesoftware.smackx.muclight.MUCLightRoomConfiguration;
import org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ; import org.jivesoftware.smackx.muclight.element.MUCLightConfigurationIQ;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* MUC Light configuration IQ provider class. * MUC Light configuration IQ provider class.
@ -34,7 +36,7 @@ import org.xmlpull.v1.XmlPullParser;
public class MUCLightConfigurationIQProvider extends IQProvider<MUCLightConfigurationIQ> { public class MUCLightConfigurationIQProvider extends IQProvider<MUCLightConfigurationIQ> {
@Override @Override
public MUCLightConfigurationIQ parse(XmlPullParser parser, int initialDepth) throws Exception { public MUCLightConfigurationIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
String version = null; String version = null;
String roomName = null; String roomName = null;
String subject = null; String subject = null;

View file

@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.muclight.provider; package org.jivesoftware.smackx.muclight.provider;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
@ -23,6 +24,7 @@ import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.muclight.element.MUCLightElements.ConfigurationsChangeExtension; import org.jivesoftware.smackx.muclight.element.MUCLightElements.ConfigurationsChangeExtension;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* MUC Light configurations change provider class. * MUC Light configurations change provider class.
@ -33,7 +35,7 @@ import org.xmlpull.v1.XmlPullParser;
public class MUCLightConfigurationsChangeProvider extends ExtensionElementProvider<ConfigurationsChangeExtension> { public class MUCLightConfigurationsChangeProvider extends ExtensionElementProvider<ConfigurationsChangeExtension> {
@Override @Override
public ConfigurationsChangeExtension parse(XmlPullParser parser, int initialDepth) throws Exception { public ConfigurationsChangeExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
String prevVersion = null; String prevVersion = null;
String version = null; String version = null;
String roomName = null; String roomName = null;

View file

@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.muclight.provider; package org.jivesoftware.smackx.muclight.provider;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
@ -27,6 +28,7 @@ import org.jivesoftware.smackx.muclight.element.MUCLightInfoIQ;
import org.jxmpp.jid.Jid; import org.jxmpp.jid.Jid;
import org.jxmpp.jid.impl.JidCreate; import org.jxmpp.jid.impl.JidCreate;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* MUC Light info IQ provider class. * MUC Light info IQ provider class.
@ -37,7 +39,7 @@ import org.xmlpull.v1.XmlPullParser;
public class MUCLightInfoIQProvider extends IQProvider<MUCLightInfoIQ> { public class MUCLightInfoIQProvider extends IQProvider<MUCLightInfoIQ> {
@Override @Override
public MUCLightInfoIQ parse(XmlPullParser parser, int initialDepth) throws Exception { public MUCLightInfoIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
String version = null; String version = null;
String roomName = null; String roomName = null;
String subject = null; String subject = null;
@ -93,7 +95,7 @@ public class MUCLightInfoIQProvider extends IQProvider<MUCLightInfoIQ> {
return new MUCLightInfoIQ(version, new MUCLightRoomConfiguration(roomName, subject, customConfigs), occupants); return new MUCLightInfoIQ(version, new MUCLightRoomConfiguration(roomName, subject, customConfigs), occupants);
} }
private static HashMap<Jid, MUCLightAffiliation> iterateOccupants(XmlPullParser parser) throws Exception { private static HashMap<Jid, MUCLightAffiliation> iterateOccupants(XmlPullParser parser) throws XmlPullParserException, IOException {
HashMap<Jid, MUCLightAffiliation> occupants = new HashMap<>(); HashMap<Jid, MUCLightAffiliation> occupants = new HashMap<>();
int depth = parser.getDepth(); int depth = parser.getDepth();

View file

@ -16,6 +16,8 @@
*/ */
package org.jivesoftware.smackx.push_notifications.provider; package org.jivesoftware.smackx.push_notifications.provider;
import java.io.IOException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.push_notifications.element.PushNotificationsElements.RemoteDisablingExtension; import org.jivesoftware.smackx.push_notifications.element.PushNotificationsElements.RemoteDisablingExtension;
@ -23,6 +25,7 @@ import org.jivesoftware.smackx.push_notifications.element.PushNotificationsEleme
import org.jxmpp.jid.Jid; import org.jxmpp.jid.Jid;
import org.jxmpp.jid.impl.JidCreate; import org.jxmpp.jid.impl.JidCreate;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Push Notifications Remote Disabling Provider class. * Push Notifications Remote Disabling Provider class.
@ -34,7 +37,7 @@ import org.xmlpull.v1.XmlPullParser;
public class RemoteDisablingProvider extends ExtensionElementProvider<RemoteDisablingExtension> { public class RemoteDisablingProvider extends ExtensionElementProvider<RemoteDisablingExtension> {
@Override @Override
public RemoteDisablingExtension parse(XmlPullParser parser, int initialDepth) throws Exception { public RemoteDisablingExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
Jid userJid = null; Jid userJid = null;
String node = parser.getAttributeValue("", "node"); String node = parser.getAttributeValue("", "node");

View file

@ -16,7 +16,10 @@
*/ */
package org.jivesoftware.smackx.reference.provider; package org.jivesoftware.smackx.reference.provider;
import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
@ -25,20 +28,28 @@ import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smackx.reference.element.ReferenceElement; import org.jivesoftware.smackx.reference.element.ReferenceElement;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public class ReferenceProvider extends ExtensionElementProvider<ReferenceElement> { public class ReferenceProvider extends ExtensionElementProvider<ReferenceElement> {
public static final ReferenceProvider TEST_PROVIDER = new ReferenceProvider(); public static final ReferenceProvider TEST_PROVIDER = new ReferenceProvider();
@Override @Override
public ReferenceElement parse(XmlPullParser parser, int initialDepth) throws Exception { public ReferenceElement parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
Integer begin = ParserUtils.getIntegerAttribute(parser, ReferenceElement.ATTR_BEGIN); Integer begin = ParserUtils.getIntegerAttribute(parser, ReferenceElement.ATTR_BEGIN);
Integer end = ParserUtils.getIntegerAttribute(parser, ReferenceElement.ATTR_END); Integer end = ParserUtils.getIntegerAttribute(parser, ReferenceElement.ATTR_END);
String typeString = parser.getAttributeValue(null, ReferenceElement.ATTR_TYPE); String typeString = parser.getAttributeValue(null, ReferenceElement.ATTR_TYPE);
ReferenceElement.Type type = ReferenceElement.Type.valueOf(typeString); ReferenceElement.Type type = ReferenceElement.Type.valueOf(typeString);
String anchor = parser.getAttributeValue(null, ReferenceElement.ATTR_ANCHOR); String anchor = parser.getAttributeValue(null, ReferenceElement.ATTR_ANCHOR);
String uriString = parser.getAttributeValue(null, ReferenceElement.ATTR_URI); String uriString = parser.getAttributeValue(null, ReferenceElement.ATTR_URI);
URI uri = uriString != null ? new URI(uriString) : null; URI uri;
try {
uri = uriString != null ? new URI(uriString) : null;
}
catch (URISyntaxException e) {
// TODO: Should be SmackParseException and probably be factored into ParserUtils.
throw new IOException(e);
}
ExtensionElement child = null; ExtensionElement child = null;
outerloop: while (true) { outerloop: while (true) {
int eventType = parser.next(); int eventType = parser.next();

View file

@ -26,7 +26,7 @@ public class OriginIdProvider extends ExtensionElementProvider<OriginIdElement>
public static final OriginIdProvider TEST_INSTANCE = new OriginIdProvider(); public static final OriginIdProvider TEST_INSTANCE = new OriginIdProvider();
@Override @Override
public OriginIdElement parse(XmlPullParser parser, int initialDepth) throws Exception { public OriginIdElement parse(XmlPullParser parser, int initialDepth) {
return new OriginIdElement(parser.getAttributeValue(null, OriginIdElement.ATTR_ID)); return new OriginIdElement(parser.getAttributeValue(null, OriginIdElement.ATTR_ID));
} }
} }

View file

@ -26,7 +26,7 @@ public class StanzaIdProvider extends ExtensionElementProvider<StanzaIdElement>
public static StanzaIdProvider TEST_INSTANCE = new StanzaIdProvider(); public static StanzaIdProvider TEST_INSTANCE = new StanzaIdProvider();
@Override @Override
public StanzaIdElement parse(XmlPullParser parser, int initialDepth) throws Exception { public StanzaIdElement parse(XmlPullParser parser, int initialDepth) {
String id = parser.getAttributeValue(null, StanzaIdElement.ATTR_ID); String id = parser.getAttributeValue(null, StanzaIdElement.ATTR_ID);
String by = parser.getAttributeValue(null, StanzaIdElement.ATTR_BY); String by = parser.getAttributeValue(null, StanzaIdElement.ATTR_BY);
return new StanzaIdElement(id, by); return new StanzaIdElement(id, by);

View file

@ -19,18 +19,21 @@ package org.jivesoftware.smackx.spoiler.provider;
import static org.xmlpull.v1.XmlPullParser.END_TAG; import static org.xmlpull.v1.XmlPullParser.END_TAG;
import static org.xmlpull.v1.XmlPullParser.TEXT; import static org.xmlpull.v1.XmlPullParser.TEXT;
import java.io.IOException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smackx.spoiler.element.SpoilerElement; import org.jivesoftware.smackx.spoiler.element.SpoilerElement;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public class SpoilerProvider extends ExtensionElementProvider<SpoilerElement> { public class SpoilerProvider extends ExtensionElementProvider<SpoilerElement> {
public static SpoilerProvider INSTANCE = new SpoilerProvider(); public static SpoilerProvider INSTANCE = new SpoilerProvider();
@Override @Override
public SpoilerElement parse(XmlPullParser parser, int initialDepth) throws Exception { public SpoilerElement parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
String lang = ParserUtils.getXmlLang(parser); String lang = ParserUtils.getXmlLang(parser);
String hint = null; String hint = null;

View file

@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.blocking.provider; package org.jivesoftware.smackx.blocking.provider;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -26,6 +27,7 @@ import org.jivesoftware.smackx.blocking.element.BlockContactsIQ;
import org.jxmpp.jid.Jid; import org.jxmpp.jid.Jid;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Block contact IQ provider class. * Block contact IQ provider class.
@ -37,7 +39,7 @@ import org.xmlpull.v1.XmlPullParser;
public class BlockContactsIQProvider extends IQProvider<BlockContactsIQ> { public class BlockContactsIQProvider extends IQProvider<BlockContactsIQ> {
@Override @Override
public BlockContactsIQ parse(XmlPullParser parser, int initialDepth) throws Exception { public BlockContactsIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
List<Jid> jids = new ArrayList<>(); List<Jid> jids = new ArrayList<>();
outerloop: while (true) { outerloop: while (true) {

View file

@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.blocking.provider; package org.jivesoftware.smackx.blocking.provider;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -27,6 +28,7 @@ import org.jivesoftware.smackx.blocking.element.BlockListIQ;
import org.jxmpp.jid.Jid; import org.jxmpp.jid.Jid;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Block list IQ provider class. * Block list IQ provider class.
@ -38,7 +40,7 @@ import org.xmlpull.v1.XmlPullParser;
public class BlockListIQProvider extends IQProvider<BlockListIQ> { public class BlockListIQProvider extends IQProvider<BlockListIQ> {
@Override @Override
public BlockListIQ parse(XmlPullParser parser, int initialDepth) throws Exception { public BlockListIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
List<Jid> jids = null; List<Jid> jids = null;
outerloop: while (true) { outerloop: while (true) {

View file

@ -32,7 +32,7 @@ import org.xmlpull.v1.XmlPullParser;
public class BlockedErrorExtensionProvider extends ExtensionElementProvider<BlockedErrorExtension> { public class BlockedErrorExtensionProvider extends ExtensionElementProvider<BlockedErrorExtension> {
@Override @Override
public BlockedErrorExtension parse(XmlPullParser parser, int initialDepth) throws Exception { public BlockedErrorExtension parse(XmlPullParser parser, int initialDepth) {
return new BlockedErrorExtension(); return new BlockedErrorExtension();
} }

View file

@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.blocking.provider; package org.jivesoftware.smackx.blocking.provider;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -26,6 +27,7 @@ import org.jivesoftware.smackx.blocking.element.UnblockContactsIQ;
import org.jxmpp.jid.Jid; import org.jxmpp.jid.Jid;
import org.jxmpp.jid.impl.JidCreate; import org.jxmpp.jid.impl.JidCreate;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Unblock contact IQ provider class. * Unblock contact IQ provider class.
@ -37,7 +39,7 @@ import org.xmlpull.v1.XmlPullParser;
public class UnblockContactsIQProvider extends IQProvider<UnblockContactsIQ> { public class UnblockContactsIQProvider extends IQProvider<UnblockContactsIQ> {
@Override @Override
public UnblockContactsIQ parse(XmlPullParser parser, int initialDepth) throws Exception { public UnblockContactsIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
List<Jid> jids = null; List<Jid> jids = null;
outerloop: while (true) { outerloop: while (true) {

View file

@ -16,6 +16,8 @@
*/ */
package org.jivesoftware.smackx.bob.provider; package org.jivesoftware.smackx.bob.provider;
import java.io.IOException;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
@ -24,6 +26,7 @@ import org.jivesoftware.smackx.bob.BoBHash;
import org.jivesoftware.smackx.bob.element.BoBIQ; import org.jivesoftware.smackx.bob.element.BoBIQ;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Bits of Binary IQ provider class. * Bits of Binary IQ provider class.
@ -35,7 +38,7 @@ import org.xmlpull.v1.XmlPullParser;
public class BoBIQProvider extends IQProvider<BoBIQ> { public class BoBIQProvider extends IQProvider<BoBIQ> {
@Override @Override
public BoBIQ parse(XmlPullParser parser, int initialDepth) throws Exception { public BoBIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
String cid = parser.getAttributeValue("", "cid"); String cid = parser.getAttributeValue("", "cid");
BoBHash bobHash = BoBHash.fromCid(cid); BoBHash bobHash = BoBHash.fromCid(cid);

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.bytestreams.ibb.provider; package org.jivesoftware.smackx.bytestreams.ibb.provider;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data; import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension; import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
@ -38,7 +39,7 @@ public class DataPacketProvider {
@Override @Override
public Data parse(XmlPullParser parser, int initialDepth) public Data parse(XmlPullParser parser, int initialDepth)
throws Exception { throws IOException, XmlPullParserException, ParseException {
DataPacketExtension data = packetExtensionProvider.parse(parser); DataPacketExtension data = packetExtensionProvider.parse(parser);
return new Data(data); return new Data(data);
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright © 2009 Jonas Ådahl, 2011-2014 Florian Schmaus * Copyright © 2009 Jonas Ådahl, 2011-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package org.jivesoftware.smackx.caps.provider;
import java.io.IOException; import java.io.IOException;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.caps.EntityCapsManager; import org.jivesoftware.smackx.caps.EntityCapsManager;
@ -30,8 +29,7 @@ import org.xmlpull.v1.XmlPullParserException;
public class CapsExtensionProvider extends ExtensionElementProvider<CapsExtension> { public class CapsExtensionProvider extends ExtensionElementProvider<CapsExtension> {
@Override @Override
public CapsExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, public CapsExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
SmackException {
String hash, version, node; String hash, version, node;
if (parser.getEventType() == XmlPullParser.START_TAG if (parser.getEventType() == XmlPullParser.START_TAG
&& parser.getName().equalsIgnoreCase(EntityCapsManager.ELEMENT)) { && parser.getName().equalsIgnoreCase(EntityCapsManager.ELEMENT)) {
@ -39,20 +37,23 @@ public class CapsExtensionProvider extends ExtensionElementProvider<CapsExtensio
version = parser.getAttributeValue(null, "ver"); version = parser.getAttributeValue(null, "ver");
node = parser.getAttributeValue(null, "node"); node = parser.getAttributeValue(null, "node");
} else { } else {
throw new SmackException("Malformed Caps element"); // TODO: Should be SmackParsingException.
throw new IOException("Malformed Caps element");
} }
parser.next(); parser.next();
if (!(parser.getEventType() == XmlPullParser.END_TAG if (!(parser.getEventType() == XmlPullParser.END_TAG
&& parser.getName().equalsIgnoreCase(EntityCapsManager.ELEMENT))) { && parser.getName().equalsIgnoreCase(EntityCapsManager.ELEMENT))) {
throw new SmackException("Malformed nested Caps element"); // TODO: Should be SmackParsingException.
throw new IOException("Malformed nested Caps element");
} }
if (hash != null && version != null && node != null) { if (hash != null && version != null && node != null) {
return new CapsExtension(node, version, hash); return new CapsExtension(node, version, hash);
} else { } else {
throw new SmackException("Caps element with missing attributes. Attributes: hash=" + hash + " version=" // TODO: Should be SmackParsingException.
throw new IOException("Caps element with missing attributes. Attributes: hash=" + hash + " version="
+ version + " node=" + node); + version + " node=" + node);
} }
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2017 Florian Schmaus * Copyright 2017-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,7 +26,7 @@ import org.xmlpull.v1.XmlPullParser;
public class ChatStateExtensionProvider extends ExtensionElementProvider<ChatStateExtension> { public class ChatStateExtensionProvider extends ExtensionElementProvider<ChatStateExtension> {
@Override @Override
public ChatStateExtension parse(XmlPullParser parser, int initialDepth) throws Exception { public ChatStateExtension parse(XmlPullParser parser, int initialDepth) {
String chatStateString = parser.getName(); String chatStateString = parser.getName();
ChatState state = ChatState.valueOf(chatStateString); ChatState state = ChatState.valueOf(chatStateString);

View file

@ -17,6 +17,9 @@
package org.jivesoftware.smackx.commands.provider; package org.jivesoftware.smackx.commands.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.StanzaError; import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
@ -29,6 +32,7 @@ import org.jivesoftware.smackx.commands.packet.AdHocCommandData;
import org.jivesoftware.smackx.xdata.provider.DataFormProvider; import org.jivesoftware.smackx.xdata.provider.DataFormProvider;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* The AdHocCommandDataProvider parses AdHocCommandData packets. * The AdHocCommandDataProvider parses AdHocCommandData packets.
@ -38,8 +42,7 @@ import org.xmlpull.v1.XmlPullParser;
public class AdHocCommandDataProvider extends IQProvider<AdHocCommandData> { public class AdHocCommandDataProvider extends IQProvider<AdHocCommandData> {
@Override @Override
public AdHocCommandData parse(XmlPullParser parser, int initialDepth) public AdHocCommandData parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
throws Exception {
boolean done = false; boolean done = false;
AdHocCommandData adHocCommandData = new AdHocCommandData(); AdHocCommandData adHocCommandData = new AdHocCommandData();
DataFormProvider dataFormProvider = new DataFormProvider(); DataFormProvider dataFormProvider = new DataFormProvider();

View file

@ -20,7 +20,6 @@ import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import java.util.Date; import java.util.Date;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.delay.packet.DelayInformation; import org.jivesoftware.smackx.delay.packet.DelayInformation;
@ -33,7 +32,7 @@ public abstract class AbstractDelayInformationProvider extends ExtensionElementP
@Override @Override
public final DelayInformation parse(XmlPullParser parser, public final DelayInformation parse(XmlPullParser parser,
int initialDepth) throws XmlPullParserException, int initialDepth) throws XmlPullParserException,
IOException, SmackException { IOException, ParseException {
String stampString = (parser.getAttributeValue("", "stamp")); String stampString = (parser.getAttributeValue("", "stamp"));
String from = parser.getAttributeValue("", "from"); String from = parser.getAttributeValue("", "from");
String reason = null; String reason = null;
@ -48,17 +47,14 @@ public abstract class AbstractDelayInformationProvider extends ExtensionElementP
reason = ""; reason = "";
break; break;
default: default:
throw new IllegalStateException("Unexpected event: " + event); // TODO: Should be SmackParseException.
throw new IOException("Unexpected event: " + event);
} }
} else { } else {
parser.next(); parser.next();
} }
Date stamp;
try { Date stamp = parseDate(stampString);
stamp = parseDate(stampString);
} catch (ParseException e) {
throw new SmackException(e);
}
return new DelayInformation(stamp, from, reason); return new DelayInformation(stamp, from, reason);
} }

View file

@ -17,12 +17,16 @@
package org.jivesoftware.smackx.disco.provider; package org.jivesoftware.smackx.disco.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.disco.packet.DiscoverInfo; import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* The DiscoverInfoProvider parses Service Discovery information packets. * The DiscoverInfoProvider parses Service Discovery information packets.
@ -32,8 +36,7 @@ import org.xmlpull.v1.XmlPullParser;
public class DiscoverInfoProvider extends IQProvider<DiscoverInfo> { public class DiscoverInfoProvider extends IQProvider<DiscoverInfo> {
@Override @Override
public DiscoverInfo parse(XmlPullParser parser, int initialDepth) public DiscoverInfo parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
throws Exception {
DiscoverInfo discoverInfo = new DiscoverInfo(); DiscoverInfo discoverInfo = new DiscoverInfo();
boolean done = false; boolean done = false;
DiscoverInfo.Identity identity; DiscoverInfo.Identity identity;

View file

@ -16,9 +16,10 @@
*/ */
package org.jivesoftware.smackx.forward.provider; package org.jivesoftware.smackx.forward.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Stanza; import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
@ -29,6 +30,7 @@ import org.jivesoftware.smackx.delay.provider.DelayInformationProvider;
import org.jivesoftware.smackx.forward.packet.Forwarded; import org.jivesoftware.smackx.forward.packet.Forwarded;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* This class implements the {@link ExtensionElementProvider} to parse * This class implements the {@link ExtensionElementProvider} to parse
@ -43,7 +45,7 @@ public class ForwardedProvider extends ExtensionElementProvider<Forwarded> {
private static final Logger LOGGER = Logger.getLogger(ForwardedProvider.class.getName()); private static final Logger LOGGER = Logger.getLogger(ForwardedProvider.class.getName());
@Override @Override
public Forwarded parse(XmlPullParser parser, int initialDepth) throws Exception { public Forwarded parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
DelayInformation di = null; DelayInformation di = null;
Stanza packet = null; Stanza packet = null;
@ -77,8 +79,10 @@ public class ForwardedProvider extends ExtensionElementProvider<Forwarded> {
} }
} }
if (packet == null) if (packet == null) {
throw new SmackException("forwarded extension must contain a packet"); // TODO: Should be SmackParseException.
throw new IOException("forwarded extension must contain a packet");
}
return new Forwarded(di, packet); return new Forwarded(di, packet);
} }
} }

View file

@ -17,7 +17,6 @@
package org.jivesoftware.smackx.geoloc.provider; package org.jivesoftware.smackx.geoloc.provider;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException;
import java.text.ParseException; import java.text.ParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
@ -32,7 +31,7 @@ public class GeoLocationProvider extends ExtensionElementProvider<GeoLocation> {
@Override @Override
public GeoLocation parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, public GeoLocation parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
ParseException, URISyntaxException { ParseException {
GeoLocation.Builder builder = GeoLocation.builder(); GeoLocation.Builder builder = GeoLocation.builder();

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2003-2007 Jive Software, 2014 Florian Schmaus * Copyright 2003-2007 Jive Software, 2014-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package org.jivesoftware.smackx.iqlast.packet;
import java.io.IOException; import java.io.IOException;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
@ -103,21 +102,18 @@ public class LastActivity extends IQ {
public static class Provider extends IQProvider<LastActivity> { public static class Provider extends IQProvider<LastActivity> {
@Override @Override
public LastActivity parse(XmlPullParser parser, int initialDepth) throws SmackException, XmlPullParserException { public LastActivity parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
LastActivity lastActivity = new LastActivity(); LastActivity lastActivity = new LastActivity();
String seconds = parser.getAttributeValue("", "seconds"); String seconds = parser.getAttributeValue("", "seconds");
if (seconds != null) { if (seconds != null) {
try { try {
lastActivity.setLastActivity(Long.parseLong(seconds)); lastActivity.setLastActivity(Long.parseLong(seconds));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new SmackException("Could not parse last activity number", e); // TODO: Should be SmackParseException (or a SmackParseNumberException subclass of).
throw new IOException("Could not parse last activity number", e);
} }
} }
try { lastActivity.setMessage(parser.nextText());
lastActivity.setMessage(parser.nextText());
} catch (IOException e) {
throw new SmackException(e);
}
return lastActivity; return lastActivity;
} }
} }

View file

@ -23,7 +23,6 @@ import java.util.Map;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import org.jivesoftware.smack.Manager; import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
@ -237,7 +236,7 @@ public final class PrivateDataManager extends Manager {
@Override @Override
public PrivateDataIQ parse(XmlPullParser parser, int initialDepth) public PrivateDataIQ parse(XmlPullParser parser, int initialDepth)
throws XmlPullParserException, IOException, SmackException { throws XmlPullParserException, IOException {
PrivateData privateData = null; PrivateData privateData = null;
boolean done = false; boolean done = false;
while (!done) { while (!done) {

View file

@ -19,8 +19,6 @@ package org.jivesoftware.smackx.iqprivate.provider;
import java.io.IOException; import java.io.IOException;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smackx.iqprivate.packet.PrivateData; import org.jivesoftware.smackx.iqprivate.packet.PrivateData;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
@ -45,7 +43,6 @@ public interface PrivateDataProvider {
* @return a new PrivateData instance. * @return a new PrivateData instance.
* @throws XmlPullParserException * @throws XmlPullParserException
* @throws IOException * @throws IOException
* @throws SmackException
*/ */
PrivateData parsePrivateData(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException; PrivateData parsePrivateData(XmlPullParser parser) throws XmlPullParserException, IOException;
} }

View file

@ -16,6 +16,8 @@
*/ */
package org.jivesoftware.smackx.iqregister.provider; package org.jivesoftware.smackx.iqregister.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -29,12 +31,12 @@ import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.iqregister.packet.Registration; import org.jivesoftware.smackx.iqregister.packet.Registration;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public class RegistrationProvider extends IQProvider<Registration> { public class RegistrationProvider extends IQProvider<Registration> {
@Override @Override
public Registration parse(XmlPullParser parser, int initialDepth) public Registration parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
throws Exception {
String instruction = null; String instruction = null;
Map<String, String> fields = new HashMap<>(); Map<String, String> fields = new HashMap<>();
List<ExtensionElement> packetExtensions = new LinkedList<>(); List<ExtensionElement> packetExtensions = new LinkedList<>();

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2017 Florian Schmaus * Copyright 2017-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,16 +16,20 @@
*/ */
package org.jivesoftware.smackx.jingle.provider; package org.jivesoftware.smackx.jingle.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.jingle.element.JingleContentDescription; import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public abstract class JingleContentDescriptionProvider<D extends JingleContentDescription> public abstract class JingleContentDescriptionProvider<D extends JingleContentDescription>
extends ExtensionElementProvider<D> { extends ExtensionElementProvider<D> {
@Override @Override
public abstract D parse(XmlPullParser parser, int initialDepth) throws Exception; public abstract D parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException;
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2017 Florian Schmaus * Copyright 2017-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,16 +16,19 @@
*/ */
package org.jivesoftware.smackx.jingle.provider; package org.jivesoftware.smackx.jingle.provider;
import java.io.IOException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.jingle.element.JingleContentTransport; import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public abstract class JingleContentTransportProvider<T extends JingleContentTransport> public abstract class JingleContentTransportProvider<T extends JingleContentTransport>
extends ExtensionElementProvider<T> { extends ExtensionElementProvider<T> {
@Override @Override
public abstract T parse(XmlPullParser parser, int initialDepth) throws Exception; public abstract T parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException;
} }

View file

@ -1,6 +1,6 @@
/** /**
* *
* Copyright 2017 Florian Schmaus * Copyright 2017-2019 Florian Schmaus
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,7 +25,7 @@ import org.xmlpull.v1.XmlPullParser;
public class JingleErrorProvider extends ExtensionElementProvider<JingleError> { public class JingleErrorProvider extends ExtensionElementProvider<JingleError> {
@Override @Override
public JingleError parse(XmlPullParser parser, int initialDepth) throws Exception { public JingleError parse(XmlPullParser parser, int initialDepth) {
String errorName = parser.getName(); String errorName = parser.getName();
return JingleError.fromString(errorName); return JingleError.fromString(errorName);
} }

View file

@ -16,6 +16,8 @@
*/ */
package org.jivesoftware.smackx.jingle.provider; package org.jivesoftware.smackx.jingle.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.jivesoftware.smack.packet.StandardExtensionElement; import org.jivesoftware.smack.packet.StandardExtensionElement;
@ -35,13 +37,14 @@ import org.jivesoftware.smackx.jingle.element.UnknownJingleContentTransport;
import org.jxmpp.jid.FullJid; import org.jxmpp.jid.FullJid;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public class JingleProvider extends IQProvider<Jingle> { public class JingleProvider extends IQProvider<Jingle> {
private static final Logger LOGGER = Logger.getLogger(JingleProvider.class.getName()); private static final Logger LOGGER = Logger.getLogger(JingleProvider.class.getName());
@Override @Override
public Jingle parse(XmlPullParser parser, int initialDepth) throws Exception { public Jingle parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
Jingle.Builder builder = Jingle.getBuilder(); Jingle.Builder builder = Jingle.getBuilder();
String actionString = parser.getAttributeValue("", Jingle.ACTION_ATTRIBUTE_NAME); String actionString = parser.getAttributeValue("", Jingle.ACTION_ATTRIBUTE_NAME);
@ -99,7 +102,7 @@ public class JingleProvider extends IQProvider<Jingle> {
} }
public static JingleContent parseJingleContent(XmlPullParser parser, final int initialDepth) public static JingleContent parseJingleContent(XmlPullParser parser, final int initialDepth)
throws Exception { throws XmlPullParserException, IOException, ParseException {
JingleContent.Builder builder = JingleContent.getBuilder(); JingleContent.Builder builder = JingleContent.getBuilder();
String creatorString = parser.getAttributeValue("", JingleContent.CREATOR_ATTRIBUTE_NAME); String creatorString = parser.getAttributeValue("", JingleContent.CREATOR_ATTRIBUTE_NAME);

View file

@ -26,7 +26,7 @@ import org.xmlpull.v1.XmlPullParser;
*/ */
public class JingleIBBTransportProvider extends JingleContentTransportProvider<JingleIBBTransport> { public class JingleIBBTransportProvider extends JingleContentTransportProvider<JingleIBBTransport> {
@Override @Override
public JingleIBBTransport parse(XmlPullParser parser, int initialDepth) throws Exception { public JingleIBBTransport parse(XmlPullParser parser, int initialDepth) {
String blockSizeString = parser.getAttributeValue(null, JingleIBBTransport.ATTR_BLOCK_SIZE); String blockSizeString = parser.getAttributeValue(null, JingleIBBTransport.ATTR_BLOCK_SIZE);
String sid = parser.getAttributeValue(null, JingleIBBTransport.ATTR_SID); String sid = parser.getAttributeValue(null, JingleIBBTransport.ATTR_SID);

View file

@ -27,6 +27,8 @@ import static org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.Jing
import static org.xmlpull.v1.XmlPullParser.END_TAG; import static org.xmlpull.v1.XmlPullParser.END_TAG;
import static org.xmlpull.v1.XmlPullParser.START_TAG; import static org.xmlpull.v1.XmlPullParser.START_TAG;
import java.io.IOException;
import org.jivesoftware.smackx.jingle.element.JingleContentTransport; import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
import org.jivesoftware.smackx.jingle.provider.JingleContentTransportProvider; import org.jivesoftware.smackx.jingle.provider.JingleContentTransportProvider;
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransport; import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransport;
@ -35,6 +37,7 @@ import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTr
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportInfo.JingleS5BCandidateTransportInfo; import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransportInfo.JingleS5BCandidateTransportInfo;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Provider for JingleSocks5BytestreamTransport elements. * Provider for JingleSocks5BytestreamTransport elements.
@ -42,7 +45,7 @@ import org.xmlpull.v1.XmlPullParser;
public class JingleS5BTransportProvider extends JingleContentTransportProvider<JingleS5BTransport> { public class JingleS5BTransportProvider extends JingleContentTransportProvider<JingleS5BTransport> {
@Override @Override
public JingleS5BTransport parse(XmlPullParser parser, int initialDepth) throws Exception { public JingleS5BTransport parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
JingleS5BTransport.Builder builder = JingleS5BTransport.getBuilder(); JingleS5BTransport.Builder builder = JingleS5BTransport.getBuilder();
String streamId = parser.getAttributeValue(null, JingleS5BTransport.ATTR_SID); String streamId = parser.getAttributeValue(null, JingleS5BTransport.ATTR_SID);

View file

@ -16,6 +16,7 @@
*/ */
package org.jivesoftware.smackx.last_interaction.provider; package org.jivesoftware.smackx.last_interaction.provider;
import java.text.ParseException;
import java.util.Date; import java.util.Date;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
@ -28,11 +29,8 @@ public class IdleProvider extends ExtensionElementProvider<IdleElement> {
public static final IdleProvider TEST_INSTANCE = new IdleProvider(); public static final IdleProvider TEST_INSTANCE = new IdleProvider();
/**
* {@inheritDoc}
*/
@Override @Override
public IdleElement parse(XmlPullParser parser, int initialDepth) throws Exception { public IdleElement parse(XmlPullParser parser, int initialDepth) throws ParseException {
String dateString = parser.getAttributeValue(null, IdleElement.ATTR_SINCE); String dateString = parser.getAttributeValue(null, IdleElement.ATTR_SINCE);
Date since = XmppDateTime.parseXEP0082Date(dateString); Date since = XmppDateTime.parseXEP0082Date(dateString);
return new IdleElement(since); return new IdleElement(since);

View file

@ -16,15 +16,11 @@
*/ */
package org.jivesoftware.smackx.message_correct.provider; package org.jivesoftware.smackx.message_correct.provider;
import java.io.IOException;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.message_correct.element.MessageCorrectExtension; import org.jivesoftware.smackx.message_correct.element.MessageCorrectExtension;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* A ExtensionElementProvider for the MessageCorrectExtension. As * A ExtensionElementProvider for the MessageCorrectExtension. As
@ -35,8 +31,7 @@ import org.xmlpull.v1.XmlPullParserException;
public class MessageCorrectProvider extends ExtensionElementProvider<MessageCorrectExtension> { public class MessageCorrectProvider extends ExtensionElementProvider<MessageCorrectExtension> {
@Override @Override
public MessageCorrectExtension parse(XmlPullParser parser, int initialDepth) public MessageCorrectExtension parse(XmlPullParser parser, int initialDepth) {
throws XmlPullParserException, IOException, SmackException {
String idMessageToReplace = parser.getAttributeValue("", MessageCorrectExtension.ID_TAG); String idMessageToReplace = parser.getAttributeValue("", MessageCorrectExtension.ID_TAG);
return new MessageCorrectExtension(idMessageToReplace); return new MessageCorrectExtension(idMessageToReplace);
} }

View file

@ -16,13 +16,17 @@
*/ */
package org.jivesoftware.smackx.mood.provider; package org.jivesoftware.smackx.mood.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.mood.element.MoodConcretisation; import org.jivesoftware.smackx.mood.element.MoodConcretisation;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public abstract class MoodConcretisationProvider<C extends MoodConcretisation> extends ExtensionElementProvider<C> { public abstract class MoodConcretisationProvider<C extends MoodConcretisation> extends ExtensionElementProvider<C> {
@Override @Override
public abstract C parse(XmlPullParser parser, int initialDepth) throws Exception; public abstract C parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException, ParseException;
} }

View file

@ -19,6 +19,8 @@ package org.jivesoftware.smackx.mood.provider;
import static org.xmlpull.v1.XmlPullParser.END_TAG; import static org.xmlpull.v1.XmlPullParser.END_TAG;
import static org.xmlpull.v1.XmlPullParser.START_TAG; import static org.xmlpull.v1.XmlPullParser.START_TAG;
import java.io.IOException;
import java.text.ParseException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -37,7 +39,8 @@ public class MoodProvider extends ExtensionElementProvider<MoodElement> {
public static final MoodProvider INSTANCE = new MoodProvider(); public static final MoodProvider INSTANCE = new MoodProvider();
@Override @Override
public MoodElement parse(XmlPullParser parser, int initialDepth) throws Exception { public MoodElement parse(XmlPullParser parser, int initialDepth)
throws XmlPullParserException, IOException, ParseException {
String text = null; String text = null;
Mood mood = null; Mood mood = null;
MoodConcretisation concretisation = null; MoodConcretisation concretisation = null;

View file

@ -16,9 +16,13 @@
*/ */
package org.jivesoftware.smackx.mood.provider; package org.jivesoftware.smackx.mood.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smackx.mood.element.MoodConcretisation; import org.jivesoftware.smackx.mood.element.MoodConcretisation;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Simple {@link MoodConcretisationProvider} implementation, suitable for really simple {@link MoodConcretisation}s, * Simple {@link MoodConcretisationProvider} implementation, suitable for really simple {@link MoodConcretisation}s,
@ -30,7 +34,7 @@ import org.xmlpull.v1.XmlPullParser;
public abstract class SimpleMoodConcretisationProvider<C extends MoodConcretisation> extends MoodConcretisationProvider<C> { public abstract class SimpleMoodConcretisationProvider<C extends MoodConcretisation> extends MoodConcretisationProvider<C> {
@Override @Override
public C parse(XmlPullParser parser, int initialDepth) throws Exception { public C parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException, ParseException {
// Since the elements name and namespace is known, we can just return an instance of the MoodConcretisation. // Since the elements name and namespace is known, we can just return an instance of the MoodConcretisation.
return simpleExtension(); return simpleExtension();
} }

View file

@ -17,12 +17,16 @@
package org.jivesoftware.smackx.muc.provider; package org.jivesoftware.smackx.muc.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.muc.packet.MUCOwner; import org.jivesoftware.smackx.muc.packet.MUCOwner;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* The MUCOwnerProvider parses MUCOwner packets. (@see MUCOwner) * The MUCOwnerProvider parses MUCOwner packets. (@see MUCOwner)
@ -32,8 +36,7 @@ import org.xmlpull.v1.XmlPullParser;
public class MUCOwnerProvider extends IQProvider<MUCOwner> { public class MUCOwnerProvider extends IQProvider<MUCOwner> {
@Override @Override
public MUCOwner parse(XmlPullParser parser, int initialDepth) public MUCOwner parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
throws Exception {
MUCOwner mucOwner = new MUCOwner(); MUCOwner mucOwner = new MUCOwner();
boolean done = false; boolean done = false;
while (!done) { while (!done) {

View file

@ -19,7 +19,6 @@ package org.jivesoftware.smackx.privacy.provider;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
@ -41,7 +40,7 @@ public class PrivacyProvider extends IQProvider<Privacy> {
@Override @Override
public Privacy parse(XmlPullParser parser, int initialDepth) public Privacy parse(XmlPullParser parser, int initialDepth)
throws XmlPullParserException, IOException, SmackException { throws XmlPullParserException, IOException {
Privacy privacy = new Privacy(); Privacy privacy = new Privacy();
boolean done = false; boolean done = false;
while (!done) { while (!done) {
@ -80,7 +79,7 @@ public class PrivacyProvider extends IQProvider<Privacy> {
} }
// Parse the list complex type // Parse the list complex type
private static void parseList(XmlPullParser parser, Privacy privacy) throws XmlPullParserException, IOException, SmackException { private static void parseList(XmlPullParser parser, Privacy privacy) throws XmlPullParserException, IOException {
boolean done = false; boolean done = false;
String listName = parser.getAttributeValue("", "name"); String listName = parser.getAttributeValue("", "name");
ArrayList<PrivacyItem> items = new ArrayList<>(); ArrayList<PrivacyItem> items = new ArrayList<>();
@ -105,7 +104,7 @@ public class PrivacyProvider extends IQProvider<Privacy> {
} }
// Parse the list complex type // Parse the list complex type
private static PrivacyItem parseItem(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException { private static PrivacyItem parseItem(XmlPullParser parser) throws XmlPullParserException, IOException {
// CHECKSTYLE:ON // CHECKSTYLE:ON
// Retrieves the required attributes // Retrieves the required attributes
String actionValue = parser.getAttributeValue("", "action"); String actionValue = parser.getAttributeValue("", "action");
@ -128,7 +127,8 @@ public class PrivacyProvider extends IQProvider<Privacy> {
allow = false; allow = false;
break; break;
default: default:
throw new SmackException("Unknown action value '" + actionValue + "'"); // TODO: Should be SmackParsingException.
throw new IOException("Unknown action value '" + actionValue + "'");
} }
PrivacyItem item; PrivacyItem item;

View file

@ -16,7 +16,8 @@
*/ */
package org.jivesoftware.smackx.pubsub.provider; package org.jivesoftware.smackx.pubsub.provider;
import org.jivesoftware.smack.SmackException; import java.io.IOException;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.ParserUtils; import org.jivesoftware.smack.util.ParserUtils;
@ -35,8 +36,7 @@ import org.xmlpull.v1.XmlPullParser;
public class AffiliationProvider extends ExtensionElementProvider<Affiliation> { public class AffiliationProvider extends ExtensionElementProvider<Affiliation> {
@Override @Override
public Affiliation parse(XmlPullParser parser, int initialDepth) public Affiliation parse(XmlPullParser parser, int initialDepth) throws IOException {
throws Exception {
String node = parser.getAttributeValue(null, "node"); String node = parser.getAttributeValue(null, "node");
BareJid jid = ParserUtils.getBareJidAttribute(parser); BareJid jid = ParserUtils.getBareJidAttribute(parser);
String namespaceString = parser.getNamespace(); String namespaceString = parser.getNamespace();
@ -56,7 +56,8 @@ public class AffiliationProvider extends ExtensionElementProvider<Affiliation> {
affiliation = new Affiliation(jid, affiliationType, namespace); affiliation = new Affiliation(jid, affiliationType, namespace);
} }
else { else {
throw new SmackException("Invalid affililation. Either one of 'node' or 'jid' must be set" // TODO: Should be SmackParsingException.
throw new IOException("Invalid affililation. Either one of 'node' or 'jid' must be set"
+ ". Node: " + node + ". Node: " + node
+ ". Jid: " + jid + ". Jid: " + jid
+ '.'); + '.');

View file

@ -16,6 +16,9 @@
*/ */
package org.jivesoftware.smackx.pubsub.provider; package org.jivesoftware.smackx.pubsub.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.provider.ProviderManager; import org.jivesoftware.smack.provider.ProviderManager;
@ -28,6 +31,7 @@ import org.jivesoftware.smackx.pubsub.SimplePayload;
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Parses an <b>item</b> element as is defined in both the {@link PubSubNamespace#basic} and * Parses an <b>item</b> element as is defined in both the {@link PubSubNamespace#basic} and
@ -40,7 +44,7 @@ import org.xmlpull.v1.XmlPullParser;
public class ItemProvider extends ExtensionElementProvider<Item> { public class ItemProvider extends ExtensionElementProvider<Item> {
@Override @Override
public Item parse(XmlPullParser parser, int initialDepth) public Item parse(XmlPullParser parser, int initialDepth)
throws Exception { throws XmlPullParserException, IOException, ParseException {
String id = parser.getAttributeValue(null, "id"); String id = parser.getAttributeValue(null, "id");
String node = parser.getAttributeValue(null, "node"); String node = parser.getAttributeValue(null, "node");
String xmlns = parser.getNamespace(); String xmlns = parser.getNamespace();

View file

@ -16,6 +16,9 @@
*/ */
package org.jivesoftware.smackx.pubsub.provider; package org.jivesoftware.smackx.pubsub.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.PacketParserUtils;
@ -24,6 +27,7 @@ import org.jivesoftware.smackx.pubsub.packet.PubSub;
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace; import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Parses the root PubSub stanza extensions of the {@link IQ} stanza and returns * Parses the root PubSub stanza extensions of the {@link IQ} stanza and returns
@ -33,8 +37,7 @@ import org.xmlpull.v1.XmlPullParser;
*/ */
public class PubSubProvider extends IQProvider<PubSub> { public class PubSubProvider extends IQProvider<PubSub> {
@Override @Override
public PubSub parse(XmlPullParser parser, int initialDepth) public PubSub parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
throws Exception {
String namespace = parser.getNamespace(); String namespace = parser.getNamespace();
PubSubNamespace pubSubNamespace = PubSubNamespace.valueOfFromXmlns(namespace); PubSubNamespace pubSubNamespace = PubSubNamespace.valueOfFromXmlns(namespace);
PubSub pubsub = new PubSub(pubSubNamespace); PubSub pubsub = new PubSub(pubSubNamespace);

View file

@ -16,6 +16,9 @@
*/ */
package org.jivesoftware.smackx.search; package org.jivesoftware.smackx.search;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.SmackException.NoResponseException; import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException; import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPConnection;
@ -31,6 +34,7 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jxmpp.jid.DomainBareJid; import org.jxmpp.jid.DomainBareJid;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/** /**
* Implements the protocol currently used to search information repositories on the Jabber network. To date, the jabber:iq:search protocol * Implements the protocol currently used to search information repositories on the Jabber network. To date, the jabber:iq:search protocol
@ -125,7 +129,7 @@ public class UserSearch extends SimpleIQ {
// FIXME this provider does return two different types of IQs // FIXME this provider does return two different types of IQs
@Override @Override
public IQ parse(XmlPullParser parser, int initialDepth) throws Exception { public IQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
UserSearch search = null; UserSearch search = null;
SimpleUserSearch simpleUserSearch = new SimpleUserSearch(); SimpleUserSearch simpleUserSearch = new SimpleUserSearch();
@ -160,8 +164,7 @@ public class UserSearch extends SimpleIQ {
} }
private static void buildDataForm(SimpleUserSearch search, private static void buildDataForm(SimpleUserSearch search,
String instructions, XmlPullParser parser) String instructions, XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
throws Exception {
DataForm dataForm = new DataForm(DataForm.Type.form); DataForm dataForm = new DataForm(DataForm.Type.form);
boolean done = false; boolean done = false;
dataForm.setTitle("User Search"); dataForm.setTitle("User Search");

Some files were not shown because too many files have changed in this diff Show more