mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
Make Provider.parse() just throw Exception
instead of throwing XmlPullParserException, IOException and SmackException. Add a guard to AbstractXMPPConnection.processPacket() to always re-throw RuntimeExceptions.
This commit is contained in:
parent
4d9bd6f216
commit
bc093b620d
29 changed files with 63 additions and 156 deletions
|
@ -85,7 +85,6 @@ import org.jxmpp.jid.FullJid;
|
|||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
||||
public abstract class AbstractXMPPConnection implements XMPPConnection {
|
||||
|
@ -960,6 +959,10 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
stanza = PacketParserUtils.parseStanza(parser);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Always re-throw runtime exceptions, they are fatal
|
||||
if (e instanceof RuntimeException) {
|
||||
throw (RuntimeException) e;
|
||||
}
|
||||
CharSequence content = PacketParserUtils.parseContentDepth(parser,
|
||||
parserDepth);
|
||||
UnparsablePacket message = new UnparsablePacket(content, e);
|
||||
|
@ -1315,8 +1318,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
}
|
||||
|
||||
protected final void parseFeatures(XmlPullParser parser) throws XmlPullParserException,
|
||||
IOException, SmackException, InterruptedException {
|
||||
protected final void parseFeatures(XmlPullParser parser) throws Exception {
|
||||
streamFeatures.clear();
|
||||
final int initialDepth = parser.getDepth();
|
||||
while (true) {
|
||||
|
|
|
@ -16,17 +16,14 @@
|
|||
*/
|
||||
package org.jivesoftware.smack.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -84,8 +81,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
public abstract class EmbeddedExtensionProvider<PE extends ExtensionElement> extends ExtensionElementProvider<PE> {
|
||||
|
||||
@Override
|
||||
public final PE parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
|
||||
SmackException {
|
||||
public final PE parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||
final String namespace = parser.getNamespace();
|
||||
final String name = parser.getName();
|
||||
final int attributeCount = parser.getAttributeCount();
|
||||
|
|
|
@ -17,17 +17,13 @@
|
|||
|
||||
package org.jivesoftware.smack.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.Element;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public abstract class Provider<E extends Element> {
|
||||
|
||||
public final E parse(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException {
|
||||
public final E parse(XmlPullParser parser) throws Exception{
|
||||
// XPP3 calling convention assert: Parser should be at start tag
|
||||
ParserUtils.assertAtStartTag(parser);
|
||||
|
||||
|
@ -39,5 +35,5 @@ public abstract class Provider<E extends Element> {
|
|||
return e;
|
||||
}
|
||||
|
||||
public abstract E parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException;
|
||||
public abstract E parse(XmlPullParser parser, int initialDepth) throws Exception;
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ public class PacketParserUtils {
|
|||
return parser;
|
||||
}
|
||||
|
||||
public static Stanza parseStanza(String stanza) throws XmlPullParserException, IOException, SmackException {
|
||||
public static Stanza parseStanza(String stanza) throws Exception {
|
||||
return parseStanza(getParserFor(stanza));
|
||||
}
|
||||
|
||||
|
@ -140,11 +140,9 @@ public class PacketParserUtils {
|
|||
*
|
||||
* @param parser
|
||||
* @return a packet which is either a Message, IQ or Presence.
|
||||
* @throws XmlPullParserException
|
||||
* @throws SmackException
|
||||
* @throws IOException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static Stanza parseStanza(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException {
|
||||
public static Stanza parseStanza(XmlPullParser parser) throws Exception {
|
||||
ParserUtils.assertAtStartTag(parser);
|
||||
final String name = parser.getName();
|
||||
switch (name) {
|
||||
|
@ -211,12 +209,10 @@ public class PacketParserUtils {
|
|||
*
|
||||
* @param parser the XML parser, positioned at the start of a message packet.
|
||||
* @return a Message packet.
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
* @throws SmackException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static Message parseMessage(XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
ParserUtils.assertAtStartTag(parser);
|
||||
assert(parser.getName().equals(Message.ELEMENT));
|
||||
|
||||
|
@ -513,12 +509,10 @@ public class PacketParserUtils {
|
|||
*
|
||||
* @param parser the XML parser, positioned at the start of a presence packet.
|
||||
* @return a Presence packet.
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
* @throws SmackException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static Presence parsePresence(XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
ParserUtils.assertAtStartTag(parser);
|
||||
final int initialDepth = parser.getDepth();
|
||||
|
||||
|
@ -600,7 +594,7 @@ public class PacketParserUtils {
|
|||
* @throws IOException
|
||||
* @throws SmackException
|
||||
*/
|
||||
public static IQ parseIQ(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException {
|
||||
public static IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
ParserUtils.assertAtStartTag(parser);
|
||||
final int initialDepth = parser.getDepth();
|
||||
IQ iqPacket = null;
|
||||
|
@ -792,11 +786,9 @@ public class PacketParserUtils {
|
|||
*
|
||||
* @param parser the XML parser.
|
||||
* @return an stream error packet.
|
||||
* @throws XmlPullParserException if an exception occurs while parsing the packet.
|
||||
* @throws SmackException
|
||||
* @throws Exception if an exception occurs while parsing the packet.
|
||||
*/
|
||||
public static StreamError parseStreamError(XmlPullParser parser) throws IOException, XmlPullParserException,
|
||||
SmackException {
|
||||
public static StreamError parseStreamError(XmlPullParser parser) throws Exception {
|
||||
final int initialDepth = parser.getDepth();
|
||||
List<ExtensionElement> extensions = new ArrayList<ExtensionElement>();
|
||||
Map<String, String> descriptiveTexts = null;
|
||||
|
@ -844,12 +836,10 @@ public class PacketParserUtils {
|
|||
*
|
||||
* @param parser the XML parser.
|
||||
* @return an error sub-packet.
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
* @throws SmackException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static XMPPError parseError(XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
final int initialDepth = parser.getDepth();
|
||||
Map<String, String> descriptiveTexts = null;
|
||||
XMPPError.Condition condition = null;
|
||||
|
@ -898,8 +888,7 @@ public class PacketParserUtils {
|
|||
*/
|
||||
@Deprecated
|
||||
public static ExtensionElement parsePacketExtension(String elementName, String namespace,
|
||||
XmlPullParser parser) throws XmlPullParserException,
|
||||
IOException, SmackException {
|
||||
XmlPullParser parser) throws Exception {
|
||||
return parseExtensionElement(elementName, namespace, parser);
|
||||
}
|
||||
|
||||
|
@ -912,8 +901,7 @@ public class PacketParserUtils {
|
|||
* @return an extension element.
|
||||
*/
|
||||
public static ExtensionElement parseExtensionElement(String elementName, String namespace,
|
||||
XmlPullParser parser) throws XmlPullParserException,
|
||||
IOException, SmackException {
|
||||
XmlPullParser parser) throws Exception {
|
||||
ParserUtils.assertAtStartTag(parser);
|
||||
// See if a provider is registered to handle the extension.
|
||||
ExtensionElementProvider<ExtensionElement> provider = ProviderManager.getExtensionProvider(elementName, namespace);
|
||||
|
@ -1017,51 +1005,49 @@ public class PacketParserUtils {
|
|||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addPacketExtension(Stanza packet, XmlPullParser parser) throws XmlPullParserException,
|
||||
IOException, SmackException {
|
||||
public static void addPacketExtension(Stanza packet, XmlPullParser parser) throws Exception {
|
||||
addExtensionElement(packet, parser);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addPacketExtension(Stanza packet, XmlPullParser parser, String elementName, String namespace)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
addExtensionElement(packet, parser, elementName, namespace);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addPacketExtension(Collection<ExtensionElement> collection, XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
addExtensionElement(collection, parser, parser.getName(), parser.getNamespace());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addPacketExtension(Collection<ExtensionElement> collection, XmlPullParser parser,
|
||||
String elementName, String namespace) throws XmlPullParserException, IOException, SmackException {
|
||||
String elementName, String namespace) throws Exception {
|
||||
addExtensionElement(collection, parser, elementName, namespace);
|
||||
}
|
||||
|
||||
|
||||
public static void addExtensionElement(Stanza packet, XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
ParserUtils.assertAtStartTag(parser);
|
||||
addExtensionElement(packet, parser, parser.getName(), parser.getNamespace());
|
||||
}
|
||||
|
||||
public static void addExtensionElement(Stanza packet, XmlPullParser parser, String elementName,
|
||||
String namespace) throws XmlPullParserException, IOException, SmackException {
|
||||
String namespace) throws Exception{
|
||||
ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser);
|
||||
packet.addExtension(packetExtension);
|
||||
}
|
||||
|
||||
public static void addExtensionElement(Collection<ExtensionElement> collection,
|
||||
XmlPullParser parser) throws XmlPullParserException, IOException,
|
||||
SmackException {
|
||||
XmlPullParser parser) throws Exception {
|
||||
addExtensionElement(collection, parser, parser.getName(), parser.getNamespace());
|
||||
}
|
||||
|
||||
public static void addExtensionElement(Collection<ExtensionElement> collection,
|
||||
XmlPullParser parser, String elementName, String namespace)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser);
|
||||
collection.add(packetExtension);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.io.IOException;
|
|||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
|
@ -79,13 +78,13 @@ final public class TestUtils {
|
|||
}
|
||||
|
||||
public static <EE extends ExtensionElement> EE parseExtensionElement(String elementString)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
return parseExtensionElement(getParser(elementString));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <EE extends ExtensionElement> EE parseExtensionElement(XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
ParserUtils.assertAtStartTag(parser);
|
||||
final String elementName = parser.getName();
|
||||
final String namespace = parser.getNamespace();
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.carbons.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.carbons.packet.CarbonExtension;
|
||||
|
@ -25,7 +23,6 @@ import org.jivesoftware.smackx.carbons.packet.CarbonExtension.Direction;
|
|||
import org.jivesoftware.smackx.forward.packet.Forwarded;
|
||||
import org.jivesoftware.smackx.forward.provider.ForwardedProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* This class implements the {@link ExtensionElementProvider} to parse
|
||||
|
@ -40,7 +37,7 @@ public class CarbonManagerProvider extends ExtensionElementProvider<CarbonExtens
|
|||
|
||||
@Override
|
||||
public CarbonExtension parse(XmlPullParser parser, int initialDepth)
|
||||
throws SmackException, XmlPullParserException, IOException {
|
||||
throws Exception {
|
||||
Direction dir = Direction.valueOf(parser.getName());
|
||||
Forwarded fwd = null;
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.hoxt.provider;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
@ -55,11 +54,9 @@ public abstract class AbstractHttpOverXmppProvider<H extends AbstractHttpOverXmp
|
|||
* @param parser parser
|
||||
* @param elementName name of concrete implementation of this element
|
||||
* @param body parent Body element
|
||||
* @throws IOException
|
||||
* @throws XmlPullParserException
|
||||
* @throws SmackException
|
||||
* @throws Exception
|
||||
*/
|
||||
protected void parseHeadersAndData(XmlPullParser parser, String elementName, AbstractHttpOverXmpp body) throws XmlPullParserException, IOException, SmackException {
|
||||
protected void parseHeadersAndData(XmlPullParser parser, String elementName, AbstractHttpOverXmpp body) throws Exception {
|
||||
boolean done = false;
|
||||
|
||||
while (!done) {
|
||||
|
|
|
@ -16,13 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.hoxt.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smackx.hoxt.packet.HttpMethod;
|
||||
import org.jivesoftware.smackx.hoxt.packet.HttpOverXmppReq;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Req packet provider.
|
||||
|
@ -38,7 +34,7 @@ public class HttpOverXmppReqProvider extends AbstractHttpOverXmppProvider<HttpOv
|
|||
|
||||
@Override
|
||||
public HttpOverXmppReq parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
String method = parser.getAttributeValue("", ATTRIBUTE_METHOD);
|
||||
String resource = parser.getAttributeValue("", ATTRIBUTE_RESOURCE);
|
||||
String version = parser.getAttributeValue("", ATTRIBUTE_VERSION);
|
||||
|
|
|
@ -16,12 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.hoxt.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smackx.hoxt.packet.HttpOverXmppResp;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Resp packet provider.
|
||||
|
@ -36,7 +32,7 @@ public class HttpOverXmppRespProvider extends AbstractHttpOverXmppProvider<HttpO
|
|||
|
||||
@Override
|
||||
public HttpOverXmppResp parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
String version = parser.getAttributeValue("", ATTRIBUTE_VERSION);
|
||||
String statusMessage = parser.getAttributeValue("", ATTRIBUTE_STATUS_MESSAGE);
|
||||
String statusCodeString = parser.getAttributeValue("", ATTRIBUTE_STATUS_CODE);
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.jivesoftware.smackx.bytestreams.ibb.provider;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
@ -38,8 +37,7 @@ public class DataPacketProvider {
|
|||
|
||||
@Override
|
||||
public Data parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException,
|
||||
SmackException {
|
||||
throws Exception {
|
||||
DataPacketExtension data = packetExtensionProvider.parse(parser);
|
||||
Data iq = new Data(data);
|
||||
return iq;
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
|
||||
package org.jivesoftware.smackx.commands.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
|
@ -31,7 +28,6 @@ import org.jivesoftware.smackx.commands.AdHocCommandNote;
|
|||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jivesoftware.smackx.xdata.provider.DataFormProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* The AdHocCommandDataProvider parses AdHocCommandData packets.
|
||||
|
@ -42,7 +38,7 @@ public class AdHocCommandDataProvider extends IQProvider<AdHocCommandData> {
|
|||
|
||||
@Override
|
||||
public AdHocCommandData parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
boolean done = false;
|
||||
AdHocCommandData adHocCommandData = new AdHocCommandData();
|
||||
DataFormProvider dataFormProvider = new DataFormProvider();
|
||||
|
|
|
@ -17,14 +17,10 @@
|
|||
|
||||
package org.jivesoftware.smackx.disco.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* The DiscoverInfoProvider parses Service Discovery information packets.
|
||||
|
@ -35,7 +31,7 @@ public class DiscoverInfoProvider extends IQProvider<DiscoverInfo> {
|
|||
|
||||
@Override
|
||||
public DiscoverInfo parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
DiscoverInfo discoverInfo = new DiscoverInfo();
|
||||
boolean done = false;
|
||||
DiscoverInfo.Identity identity = null;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.forward.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
|
@ -28,7 +27,6 @@ import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
|||
import org.jivesoftware.smackx.delay.provider.DelayInformationProvider;
|
||||
import org.jivesoftware.smackx.forward.packet.Forwarded;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* This class implements the {@link ExtensionElementProvider} to parse
|
||||
|
@ -41,7 +39,7 @@ public class ForwardedProvider extends ExtensionElementProvider<Forwarded> {
|
|||
private static final Logger LOGGER = Logger.getLogger(ForwardedProvider.class.getName());
|
||||
|
||||
@Override
|
||||
public Forwarded parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
|
||||
public Forwarded parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||
DelayInformation di = null;
|
||||
Stanza packet = null;
|
||||
|
||||
|
|
|
@ -16,26 +16,23 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.iqregister.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.iqregister.packet.Registration;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class RegistrationProvider extends IQProvider<Registration> {
|
||||
|
||||
@Override
|
||||
public Registration parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
String instruction = null;
|
||||
Map<String, String> fields = new HashMap<String, String>();
|
||||
List<ExtensionElement> packetExtensions = new LinkedList<ExtensionElement>();
|
||||
|
|
|
@ -17,14 +17,10 @@
|
|||
|
||||
package org.jivesoftware.smackx.muc.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCOwner;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* The MUCOwnerProvider parses MUCOwner packets. (@see MUCOwner)
|
||||
|
@ -35,7 +31,7 @@ public class MUCOwnerProvider extends IQProvider<MUCOwner> {
|
|||
|
||||
@Override
|
||||
public MUCOwner parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
MUCOwner mucOwner = new MUCOwner();
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
|
|
|
@ -61,7 +61,7 @@ public class PEPProvider extends ExtensionElementProvider<ExtensionElement> {
|
|||
*/
|
||||
@Override
|
||||
public ExtensionElement parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
ExtensionElement pepItem = null;
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.provider.ProviderManager;
|
||||
|
@ -28,7 +25,6 @@ import org.jivesoftware.smackx.pubsub.PayloadItem;
|
|||
import org.jivesoftware.smackx.pubsub.SimplePayload;
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
|
||||
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
|
||||
|
@ -42,7 +38,7 @@ public class ItemProvider extends ExtensionElementProvider<Item>
|
|||
{
|
||||
@Override
|
||||
public Item parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
String id = parser.getAttributeValue(null, "id");
|
||||
String node = parser.getAttributeValue(null, "node");
|
||||
|
||||
|
|
|
@ -16,16 +16,12 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSub;
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSubNamespace;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Parses the root pubsub packet extensions of the {@link IQ} packet and returns
|
||||
|
@ -37,7 +33,7 @@ public class PubSubProvider extends IQProvider<PubSub>
|
|||
{
|
||||
@Override
|
||||
public PubSub parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
String namespace = parser.getNamespace();
|
||||
PubSubNamespace pubSubNamespace = PubSubNamespace.valueOfFromXmlns(namespace);
|
||||
PubSub pubsub = new PubSub(pubSubNamespace);
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.search;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
|
@ -32,7 +29,6 @@ import org.jivesoftware.smackx.xdata.FormField;
|
|||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jxmpp.jid.DomainBareJid;
|
||||
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
|
||||
|
@ -127,7 +123,7 @@ public class UserSearch extends SimpleIQ {
|
|||
|
||||
// FIXME this provider does return two different types of IQs
|
||||
@Override
|
||||
public IQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
|
||||
public IQ parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||
UserSearch search = null;
|
||||
SimpleUserSearch simpleUserSearch = new SimpleUserSearch();
|
||||
|
||||
|
@ -163,7 +159,7 @@ public class UserSearch extends SimpleIQ {
|
|||
|
||||
private static void buildDataForm(SimpleUserSearch search,
|
||||
String instructions, XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
DataForm dataForm = new DataForm(DataForm.Type.form);
|
||||
boolean done = false;
|
||||
dataForm.setTitle("User Search");
|
||||
|
|
|
@ -16,13 +16,11 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.si.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||
|
@ -30,7 +28,6 @@ import org.jivesoftware.smackx.si.packet.StreamInitiation.File;
|
|||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jivesoftware.smackx.xdata.provider.DataFormProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* The StreamInitiationProvider parses StreamInitiation packets.
|
||||
|
@ -43,7 +40,7 @@ public class StreamInitiationProvider extends IQProvider<StreamInitiation> {
|
|||
|
||||
@Override
|
||||
public StreamInitiation parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
boolean done = false;
|
||||
|
||||
// si
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package org.jivesoftware.smackx.xdata.provider;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.roster.packet.RosterPacket;
|
||||
import org.jivesoftware.smack.roster.provider.RosterPacketProvider;
|
||||
|
@ -42,8 +41,8 @@ import java.util.List;
|
|||
public class DataFormProvider extends ExtensionElementProvider<DataForm> {
|
||||
|
||||
@Override
|
||||
public DataForm parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
|
||||
SmackException {
|
||||
public DataForm parse(XmlPullParser parser, int initialDepth) throws
|
||||
Exception {
|
||||
DataForm.Type dataFormType = DataForm.Type.fromString(parser.getAttributeValue("", "type"));
|
||||
DataForm dataForm = new DataForm(dataFormType);
|
||||
outerloop: while (true) {
|
||||
|
|
|
@ -18,19 +18,15 @@ package org.jivesoftware.smackx.caps.provider;
|
|||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.caps.packet.CapsExtension;
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class CapsExtensionProviderTest extends InitExtensions {
|
||||
|
||||
@Test
|
||||
public void parseTest() throws XmlPullParserException, IOException, SmackException {
|
||||
public void parseTest() throws Exception {
|
||||
// @formatter:off
|
||||
final String capsExtensionString =
|
||||
"<c xmlns='http://jabber.org/protocol/caps'"
|
||||
|
|
|
@ -19,9 +19,6 @@ package org.jivesoftware.smackx.xdata.packet;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.Element;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
|
@ -35,7 +32,6 @@ import org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement;
|
|||
import org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement.RangeValidateElement;
|
||||
import org.junit.Test;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* Unit tests for DataForm reading and parsing.
|
||||
|
@ -51,7 +47,7 @@ public class DataFormTest {
|
|||
DataFormProvider pr = new DataFormProvider();
|
||||
|
||||
@Test
|
||||
public void test() throws XmlPullParserException, IOException, SmackException {
|
||||
public void test() throws Exception {
|
||||
//Build a Form
|
||||
DataForm df = new DataForm(DataForm.Type.submit);
|
||||
String instruction = "InstructionTest1";
|
||||
|
@ -78,7 +74,7 @@ public class DataFormTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLayout() throws XmlPullParserException, IOException, SmackException {
|
||||
public void testLayout() throws Exception {
|
||||
//Build a Form
|
||||
DataForm df = new DataForm(DataForm.Type.submit);
|
||||
String instruction = "InstructionTest1";
|
||||
|
@ -120,7 +116,7 @@ public class DataFormTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testValidation() throws XmlPullParserException, IOException, SmackException {
|
||||
public void testValidation() throws Exception {
|
||||
//Build a Form
|
||||
DataForm df = new DataForm(DataForm.Type.submit);
|
||||
String instruction = "InstructionTest1";
|
||||
|
@ -154,7 +150,7 @@ public class DataFormTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFixedField() throws XmlPullParserException, IOException, SmackException {
|
||||
public void testFixedField() throws Exception {
|
||||
final String formWithFixedField = "<x xmlns='jabber:x:data' type='submit'><instructions>InstructionTest1</instructions><field type='fixed'></field></x>";
|
||||
DataForm df = pr.parse(PacketParserUtils.getParserFor(formWithFixedField));
|
||||
assertEquals(Type.fixed, df.getFields().get(0).getType());
|
||||
|
|
|
@ -47,7 +47,7 @@ public class DataLayoutTest {
|
|||
private static final String TEST_INPUT_1 = "xdata-layout-sample.xml";
|
||||
|
||||
@Test
|
||||
public void testLayout() throws XmlPullParserException, IOException, SmackException {
|
||||
public void testLayout() throws Exception {
|
||||
DataLayout layout = new DataLayout("Label");
|
||||
Fieldref reffield = new Fieldref("testField1");
|
||||
layout.getPageLayout().add(reffield);
|
||||
|
@ -116,7 +116,7 @@ public class DataLayoutTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLayoutFromFile() throws XmlPullParserException, IOException, SmackException {
|
||||
public void testLayoutFromFile() throws Exception {
|
||||
DataFormProvider pr = new DataFormProvider();
|
||||
|
||||
XmlPullParser parser = PacketParserUtils.newXmppParser();
|
||||
|
|
|
@ -48,7 +48,7 @@ public class JingleProvider extends IQProvider<Jingle> {
|
|||
*/
|
||||
@Override
|
||||
public Jingle parse(XmlPullParser parser, int intialDepth)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
throws Exception {
|
||||
|
||||
Jingle jingle = new Jingle();
|
||||
String sid = "";
|
||||
|
|
|
@ -17,14 +17,10 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.ext.forms;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.SimpleIQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class WorkgroupForm extends SimpleIQ {
|
||||
|
||||
|
@ -51,8 +47,7 @@ public class WorkgroupForm extends SimpleIQ {
|
|||
|
||||
@Override
|
||||
public WorkgroupForm parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException,
|
||||
SmackException {
|
||||
throws Exception {
|
||||
WorkgroupForm answer = new WorkgroupForm();
|
||||
|
||||
boolean done = false;
|
||||
|
|
|
@ -23,16 +23,13 @@ import org.jivesoftware.smackx.workgroup.agent.OfferContent;
|
|||
import org.jivesoftware.smackx.workgroup.agent.TransferRequest;
|
||||
import org.jivesoftware.smackx.workgroup.agent.UserRequest;
|
||||
import org.jivesoftware.smackx.workgroup.util.MetaDataUtils;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -49,7 +46,7 @@ public class OfferRequestProvider extends IQProvider<IQ> {
|
|||
// happen anytime soon.
|
||||
|
||||
@Override
|
||||
public OfferRequestPacket parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
|
||||
public OfferRequestPacket parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||
int eventType = parser.getEventType();
|
||||
String sessionID = null;
|
||||
int timeout = -1;
|
||||
|
|
|
@ -17,14 +17,11 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -36,7 +33,7 @@ import java.util.List;
|
|||
public class TranscriptProvider extends IQProvider<Transcript> {
|
||||
|
||||
@Override
|
||||
public Transcript parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
|
||||
public Transcript parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||
String sessionID = parser.getAttributeValue("", "sessionID");
|
||||
List<Stanza> packets = new ArrayList<Stanza>();
|
||||
|
||||
|
|
|
@ -17,14 +17,10 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.SimpleIQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* IQ packet for retrieving the transcript search form, submiting the completed search form
|
||||
|
@ -56,7 +52,7 @@ public class TranscriptSearch extends SimpleIQ {
|
|||
public static class Provider extends IQProvider<TranscriptSearch> {
|
||||
|
||||
@Override
|
||||
public TranscriptSearch parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
|
||||
public TranscriptSearch parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||
TranscriptSearch answer = new TranscriptSearch();
|
||||
|
||||
boolean done = false;
|
||||
|
|
Loading…
Reference in a new issue