mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-12 22:11:07 +01:00
Rework exceptions in the parsing / provider subsystem
This commit is contained in:
parent
4c42d0cd32
commit
083dac8b83
130 changed files with 504 additions and 342 deletions
|
|
@ -16,7 +16,8 @@
|
|||
*/
|
||||
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.util.ParserUtils;
|
||||
|
||||
|
|
@ -35,8 +36,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
public class AffiliationProvider extends ExtensionElementProvider<Affiliation> {
|
||||
|
||||
@Override
|
||||
public Affiliation parse(XmlPullParser parser, int initialDepth)
|
||||
throws Exception {
|
||||
public Affiliation parse(XmlPullParser parser, int initialDepth) throws IOException {
|
||||
String node = parser.getAttributeValue(null, "node");
|
||||
BareJid jid = ParserUtils.getBareJidAttribute(parser);
|
||||
String namespaceString = parser.getNamespace();
|
||||
|
|
@ -56,7 +56,8 @@ public class AffiliationProvider extends ExtensionElementProvider<Affiliation> {
|
|||
affiliation = new Affiliation(jid, affiliationType, namespace);
|
||||
}
|
||||
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
|
||||
+ ". Jid: " + jid
|
||||
+ '.');
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
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.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* 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> {
|
||||
@Override
|
||||
public Item parse(XmlPullParser parser, int initialDepth)
|
||||
throws Exception {
|
||||
throws XmlPullParserException, IOException, ParseException {
|
||||
String id = parser.getAttributeValue(null, "id");
|
||||
String node = parser.getAttributeValue(null, "node");
|
||||
String xmlns = parser.getNamespace();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
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.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* 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> {
|
||||
@Override
|
||||
public PubSub parse(XmlPullParser parser, int initialDepth)
|
||||
throws Exception {
|
||||
public PubSub parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
|
||||
String namespace = parser.getNamespace();
|
||||
PubSubNamespace pubSubNamespace = PubSubNamespace.valueOfFromXmlns(namespace);
|
||||
PubSub pubsub = new PubSub(pubSubNamespace);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue