1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-10 18:59:41 +02: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

@ -16,6 +16,7 @@
*/
package org.jivesoftware.smackx.blocking.provider;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@ -26,6 +27,7 @@ import org.jivesoftware.smackx.blocking.element.BlockContactsIQ;
import org.jxmpp.jid.Jid;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/**
* Block contact IQ provider class.
@ -37,7 +39,7 @@ import org.xmlpull.v1.XmlPullParser;
public class BlockContactsIQProvider extends IQProvider<BlockContactsIQ> {
@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<>();
outerloop: while (true) {

View file

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

View file

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

View file

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

View file

@ -16,6 +16,8 @@
*/
package org.jivesoftware.smackx.bob.provider;
import java.io.IOException;
import org.jivesoftware.smack.provider.IQProvider;
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.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/**
* Bits of Binary IQ provider class.
@ -35,7 +38,7 @@ import org.xmlpull.v1.XmlPullParser;
public class BoBIQProvider extends IQProvider<BoBIQ> {
@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");
BoBHash bobHash = BoBHash.fromCid(cid);

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.bytestreams.ibb.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
@ -38,7 +39,7 @@ public class DataPacketProvider {
@Override
public Data parse(XmlPullParser parser, int initialDepth)
throws Exception {
throws IOException, XmlPullParserException, ParseException {
DataPacketExtension data = packetExtensionProvider.parse(parser);
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");
* 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 org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.caps.EntityCapsManager;
@ -30,8 +29,7 @@ import org.xmlpull.v1.XmlPullParserException;
public class CapsExtensionProvider extends ExtensionElementProvider<CapsExtension> {
@Override
public CapsExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
SmackException {
public CapsExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
String hash, version, node;
if (parser.getEventType() == XmlPullParser.START_TAG
&& parser.getName().equalsIgnoreCase(EntityCapsManager.ELEMENT)) {
@ -39,20 +37,23 @@ public class CapsExtensionProvider extends ExtensionElementProvider<CapsExtensio
version = parser.getAttributeValue(null, "ver");
node = parser.getAttributeValue(null, "node");
} else {
throw new SmackException("Malformed Caps element");
// TODO: Should be SmackParsingException.
throw new IOException("Malformed Caps element");
}
parser.next();
if (!(parser.getEventType() == XmlPullParser.END_TAG
&& 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) {
return new CapsExtension(node, version, hash);
} 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);
}
}

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");
* 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> {
@Override
public ChatStateExtension parse(XmlPullParser parser, int initialDepth) throws Exception {
public ChatStateExtension parse(XmlPullParser parser, int initialDepth) {
String chatStateString = parser.getName();
ChatState state = ChatState.valueOf(chatStateString);

View file

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

View file

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

View file

@ -17,12 +17,16 @@
package org.jivesoftware.smackx.disco.provider;
import java.io.IOException;
import java.text.ParseException;
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.
@ -32,8 +36,7 @@ import org.xmlpull.v1.XmlPullParser;
public class DiscoverInfoProvider extends IQProvider<DiscoverInfo> {
@Override
public DiscoverInfo parse(XmlPullParser parser, int initialDepth)
throws Exception {
public DiscoverInfo parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
DiscoverInfo discoverInfo = new DiscoverInfo();
boolean done = false;
DiscoverInfo.Identity identity;

View file

@ -16,9 +16,10 @@
*/
package org.jivesoftware.smackx.forward.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Stanza;
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.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/**
* 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());
@Override
public Forwarded parse(XmlPullParser parser, int initialDepth) throws Exception {
public Forwarded parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
DelayInformation di = null;
Stanza packet = null;
@ -77,8 +79,10 @@ public class ForwardedProvider extends ExtensionElementProvider<Forwarded> {
}
}
if (packet == null)
throw new SmackException("forwarded extension must contain a packet");
if (packet == null) {
// TODO: Should be SmackParseException.
throw new IOException("forwarded extension must contain a packet");
}
return new Forwarded(di, packet);
}
}

View file

@ -17,7 +17,6 @@
package org.jivesoftware.smackx.geoloc.provider;
import java.io.IOException;
import java.net.URISyntaxException;
import java.text.ParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
@ -32,7 +31,7 @@ public class GeoLocationProvider extends ExtensionElementProvider<GeoLocation> {
@Override
public GeoLocation parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
ParseException, URISyntaxException {
ParseException {
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");
* 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 org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider;
@ -103,21 +102,18 @@ public class LastActivity extends IQ {
public static class Provider extends IQProvider<LastActivity> {
@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();
String seconds = parser.getAttributeValue("", "seconds");
if (seconds != null) {
try {
lastActivity.setLastActivity(Long.parseLong(seconds));
} 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());
} catch (IOException e) {
throw new SmackException(e);
}
lastActivity.setMessage(parser.nextText());
return lastActivity;
}
}

View file

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

View file

@ -19,8 +19,6 @@ package org.jivesoftware.smackx.iqprivate.provider;
import java.io.IOException;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smackx.iqprivate.packet.PrivateData;
import org.xmlpull.v1.XmlPullParser;
@ -45,7 +43,6 @@ public interface PrivateDataProvider {
* @return a new PrivateData instance.
* @throws XmlPullParserException
* @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;
import java.io.IOException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@ -29,12 +31,12 @@ 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 Exception {
public Registration parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
String instruction = null;
Map<String, String> fields = new HashMap<>();
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");
* you may not use this file except in compliance with the License.
@ -16,16 +16,20 @@
*/
package org.jivesoftware.smackx.jingle.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public abstract class JingleContentDescriptionProvider<D extends JingleContentDescription>
extends ExtensionElementProvider<D> {
@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");
* you may not use this file except in compliance with the License.
@ -16,16 +16,19 @@
*/
package org.jivesoftware.smackx.jingle.provider;
import java.io.IOException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public abstract class JingleContentTransportProvider<T extends JingleContentTransport>
extends ExtensionElementProvider<T> {
@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");
* 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> {
@Override
public JingleError parse(XmlPullParser parser, int initialDepth) throws Exception {
public JingleError parse(XmlPullParser parser, int initialDepth) {
String errorName = parser.getName();
return JingleError.fromString(errorName);
}

View file

@ -16,6 +16,8 @@
*/
package org.jivesoftware.smackx.jingle.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.logging.Logger;
import org.jivesoftware.smack.packet.StandardExtensionElement;
@ -35,13 +37,14 @@ import org.jivesoftware.smackx.jingle.element.UnknownJingleContentTransport;
import org.jxmpp.jid.FullJid;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public class JingleProvider extends IQProvider<Jingle> {
private static final Logger LOGGER = Logger.getLogger(JingleProvider.class.getName());
@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();
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)
throws Exception {
throws XmlPullParserException, IOException, ParseException {
JingleContent.Builder builder = JingleContent.getBuilder();
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> {
@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 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.START_TAG;
import java.io.IOException;
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
import org.jivesoftware.smackx.jingle.provider.JingleContentTransportProvider;
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.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/**
* Provider for JingleSocks5BytestreamTransport elements.
@ -42,7 +45,7 @@ import org.xmlpull.v1.XmlPullParser;
public class JingleS5BTransportProvider extends JingleContentTransportProvider<JingleS5BTransport> {
@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();
String streamId = parser.getAttributeValue(null, JingleS5BTransport.ATTR_SID);

View file

@ -16,6 +16,7 @@
*/
package org.jivesoftware.smackx.last_interaction.provider;
import java.text.ParseException;
import java.util.Date;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
@ -28,11 +29,8 @@ public class IdleProvider extends ExtensionElementProvider<IdleElement> {
public static final IdleProvider TEST_INSTANCE = new IdleProvider();
/**
* {@inheritDoc}
*/
@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);
Date since = XmppDateTime.parseXEP0082Date(dateString);
return new IdleElement(since);

View file

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

View file

@ -16,13 +16,17 @@
*/
package org.jivesoftware.smackx.mood.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smackx.mood.element.MoodConcretisation;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public abstract class MoodConcretisationProvider<C extends MoodConcretisation> extends ExtensionElementProvider<C> {
@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.START_TAG;
import java.io.IOException;
import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -37,7 +39,8 @@ public class MoodProvider extends ExtensionElementProvider<MoodElement> {
public static final MoodProvider INSTANCE = new MoodProvider();
@Override
public MoodElement parse(XmlPullParser parser, int initialDepth) throws Exception {
public MoodElement parse(XmlPullParser parser, int initialDepth)
throws XmlPullParserException, IOException, ParseException {
String text = null;
Mood mood = null;
MoodConcretisation concretisation = null;

View file

@ -16,9 +16,13 @@
*/
package org.jivesoftware.smackx.mood.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smackx.mood.element.MoodConcretisation;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/**
* 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> {
@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.
return simpleExtension();
}

View file

@ -17,12 +17,16 @@
package org.jivesoftware.smackx.muc.provider;
import java.io.IOException;
import java.text.ParseException;
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)
@ -32,8 +36,7 @@ import org.xmlpull.v1.XmlPullParser;
public class MUCOwnerProvider extends IQProvider<MUCOwner> {
@Override
public MUCOwner parse(XmlPullParser parser, int initialDepth)
throws Exception {
public MUCOwner parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
MUCOwner mucOwner = new MUCOwner();
boolean done = false;
while (!done) {

View file

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

View file

@ -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
+ '.');

View file

@ -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();

View file

@ -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);

View file

@ -16,6 +16,9 @@
*/
package org.jivesoftware.smackx.search;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
@ -31,6 +34,7 @@ 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
@ -125,7 +129,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 Exception {
public IQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
UserSearch search = null;
SimpleUserSearch simpleUserSearch = new SimpleUserSearch();
@ -160,8 +164,7 @@ public class UserSearch extends SimpleIQ {
}
private static void buildDataForm(SimpleUserSearch search,
String instructions, XmlPullParser parser)
throws Exception {
String instructions, XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
DataForm dataForm = new DataForm(DataForm.Type.form);
boolean done = false;
dataForm.setTitle("User Search");

View file

@ -16,6 +16,7 @@
*/
package org.jivesoftware.smackx.si.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import java.util.logging.Level;
@ -30,6 +31,7 @@ import org.jivesoftware.smackx.xdata.provider.DataFormProvider;
import org.jxmpp.util.XmppDateTime;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/**
* The StreamInitiationProvider parses StreamInitiation packets.
@ -41,8 +43,7 @@ public class StreamInitiationProvider extends IQProvider<StreamInitiation> {
private static final Logger LOGGER = Logger.getLogger(StreamInitiationProvider.class.getName());
@Override
public StreamInitiation parse(XmlPullParser parser, int initialDepth)
throws Exception {
public StreamInitiation parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
boolean done = false;
// si

View file

@ -18,7 +18,6 @@ package org.jivesoftware.smackx.vcardtemp.provider;
import java.io.IOException;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.StringUtils;
@ -69,8 +68,7 @@ public class VCardProvider extends IQProvider<VCard> {
// @formatter:on
@Override
public VCard parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
SmackException {
public VCard parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
VCard vCard = new VCard();
String name = null;

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smackx.xdata.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
@ -45,8 +46,7 @@ public class DataFormProvider extends ExtensionElementProvider<DataForm> {
public static final DataFormProvider INSTANCE = new DataFormProvider();
@Override
public DataForm parse(XmlPullParser parser, int initialDepth) throws
Exception {
public DataForm parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
DataForm.Type dataFormType = DataForm.Type.fromString(parser.getAttributeValue("", "type"));
DataForm dataForm = new DataForm(dataFormType);
outerloop: while (true) {