diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index c43747ebc..d7aa31aa2 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -33,7 +33,6 @@ import java.security.SecureRandom; import java.security.Security; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; -import java.text.ParseException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -106,6 +105,7 @@ import org.jivesoftware.smack.packet.StreamError; import org.jivesoftware.smack.packet.StreamOpen; import org.jivesoftware.smack.packet.TopLevelStreamElement; import org.jivesoftware.smack.parsing.ParsingExceptionCallback; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.NonzaProvider; import org.jivesoftware.smack.provider.ProviderManager; @@ -1167,7 +1167,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { return successNonza; } - protected final void parseAndProcessNonza(XmlPullParser parser) throws IOException, XmlPullParserException, ParseException { + protected final void parseAndProcessNonza(XmlPullParser parser) throws IOException, XmlPullParserException, SmackParsingException { final String element = parser.getName(); final String namespace = parser.getNamespace(); final String key = XmppStringUtils.generateKey(element, namespace); @@ -1567,7 +1567,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { return this.fromMode; } - protected final void parseFeatures(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException { + protected final void parseFeatures(XmlPullParser parser) throws XmlPullParserException, IOException, SmackParsingException { streamFeatures.clear(); final int initialDepth = parser.getDepth(); while (true) { diff --git a/smack-core/src/main/java/org/jivesoftware/smack/compress/provider/FailureProvider.java b/smack-core/src/main/java/org/jivesoftware/smack/compress/provider/FailureProvider.java index 19bbc0877..34fcd22fa 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/compress/provider/FailureProvider.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/compress/provider/FailureProvider.java @@ -1,6 +1,6 @@ /** * - * Copyright 2018 Florian Schmaus + * Copyright 2018-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. @@ -17,12 +17,12 @@ package org.jivesoftware.smack.compress.provider; import java.io.IOException; -import java.text.ParseException; import java.util.logging.Logger; import org.jivesoftware.smack.compress.packet.Failure; import org.jivesoftware.smack.packet.StanzaError; import org.jivesoftware.smack.packet.StreamOpen; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.NonzaProvider; import org.jivesoftware.smack.util.PacketParserUtils; @@ -39,7 +39,7 @@ public final class FailureProvider extends NonzaProvider { } @Override - public Failure parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public Failure parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { Failure.CompressFailureError compressFailureError = null; StanzaError stanzaError = null; diff --git a/smack-core/src/main/java/org/jivesoftware/smack/fsm/AbstractXmppStateMachineConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/fsm/AbstractXmppStateMachineConnection.java index 2896f6f82..1b7407b9d 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/fsm/AbstractXmppStateMachineConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/fsm/AbstractXmppStateMachineConnection.java @@ -17,7 +17,6 @@ package org.jivesoftware.smack.fsm; import java.io.IOException; -import java.text.ParseException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -51,6 +50,7 @@ import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Presence; import org.jivesoftware.smack.packet.StreamError; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.sasl.SASLErrorException; import org.jivesoftware.smack.sasl.SASLMechanism; import org.jivesoftware.smack.sasl.packet.SaslStreamElements.Challenge; @@ -304,7 +304,7 @@ public abstract class AbstractXmppStateMachineConnection extends AbstractXMPPCon } protected final void parseAndProcessElement(String element) throws XmlPullParserException, IOException, - InterruptedException, StreamErrorException, SmackException, ParseException { + InterruptedException, StreamErrorException, SmackException, SmackParsingException { XmlPullParser parser = PacketParserUtils.getParserFor(element); // Skip the enclosing stream open what is guaranteed to be there. diff --git a/smack-core/src/main/java/org/jivesoftware/smack/parsing/SmackParsingException.java b/smack-core/src/main/java/org/jivesoftware/smack/parsing/SmackParsingException.java new file mode 100644 index 000000000..82502736f --- /dev/null +++ b/smack-core/src/main/java/org/jivesoftware/smack/parsing/SmackParsingException.java @@ -0,0 +1,54 @@ +/** + * + * Copyright 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jivesoftware.smack.parsing; + +import java.net.URISyntaxException; +import java.text.ParseException; + +public class SmackParsingException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + + protected SmackParsingException(Exception exception) { + super(exception); + } + + public static class SmackTextParseException extends SmackParsingException { + /** + * + */ + private static final long serialVersionUID = 1L; + + public SmackTextParseException(ParseException parsingException) { + super(parsingException); + } + } + + public static class SmackUriSyntaxParsingException extends SmackParsingException { + /** + * + */ + private static final long serialVersionUID = 1L; + + public SmackUriSyntaxParsingException(URISyntaxException uriSyntaxException) { + super(uriSyntaxException); + } + } +} diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/EmbeddedExtensionProvider.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/EmbeddedExtensionProvider.java index 16631219e..02e900269 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/EmbeddedExtensionProvider.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/EmbeddedExtensionProvider.java @@ -17,13 +17,13 @@ package org.jivesoftware.smack.provider; import java.io.IOException; -import java.text.ParseException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.jivesoftware.smack.packet.ExtensionElement; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.util.PacketParserUtils; import org.xmlpull.v1.XmlPullParser; @@ -85,7 +85,7 @@ import org.xmlpull.v1.XmlPullParserException; public abstract class EmbeddedExtensionProvider extends ExtensionElementProvider { @Override - public final PE parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public final PE parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { final String namespace = parser.getNamespace(); final String name = parser.getName(); final int attributeCount = parser.getAttributeCount(); diff --git a/smack-core/src/main/java/org/jivesoftware/smack/provider/Provider.java b/smack-core/src/main/java/org/jivesoftware/smack/provider/Provider.java index 7c8231447..a3cacec87 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/provider/Provider.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/provider/Provider.java @@ -1,6 +1,6 @@ /** * - * Copyright © 2014-2018 Florian Schmaus + * Copyright © 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. @@ -20,9 +20,9 @@ package org.jivesoftware.smack.provider; import java.io.IOException; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; -import java.text.ParseException; import org.jivesoftware.smack.packet.Element; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.util.ParserUtils; import org.xmlpull.v1.XmlPullParser; @@ -61,7 +61,7 @@ public abstract class Provider { return elementClass; } - public final E parse(XmlPullParser parser) throws IOException, XmlPullParserException, ParseException { + public final E parse(XmlPullParser parser) throws IOException, XmlPullParserException, SmackParsingException { // XPP3 calling convention assert: Parser should be at start tag ParserUtils.assertAtStartTag(parser); @@ -73,5 +73,5 @@ public abstract class Provider { return e; } - public abstract E parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException; + public abstract E parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException; } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java index 3580e1983..74d7eed6c 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java @@ -1,6 +1,6 @@ /** * - * Copyright 2003-2007 Jive Software. + * Copyright 2003-2007 Jive Software, 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.smack.util; import java.io.IOException; import java.io.Reader; import java.io.StringReader; -import java.text.ParseException; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -43,6 +42,7 @@ import org.jivesoftware.smack.packet.StanzaError; import org.jivesoftware.smack.packet.StartTls; import org.jivesoftware.smack.packet.StreamError; import org.jivesoftware.smack.packet.UnparsedIQ; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.parsing.StandardExtensionElementProvider; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.IQProvider; @@ -218,9 +218,9 @@ public class PacketParserUtils { * @return a Message packet. * @throws XmlPullParserException * @throws IOException - * @throws ParseException + * @throws SmackParsingException */ - public static Message parseMessage(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException { + public static Message parseMessage(XmlPullParser parser) throws XmlPullParserException, IOException, SmackParsingException { ParserUtils.assertAtStartTag(parser); assert (parser.getName().equals(Message.ELEMENT)); @@ -504,9 +504,9 @@ public class PacketParserUtils { * @return a Presence packet. * @throws IOException * @throws XmlPullParserException - * @throws ParseException + * @throws SmackParsingException */ - public static Presence parsePresence(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException { + public static Presence parsePresence(XmlPullParser parser) throws XmlPullParserException, IOException, SmackParsingException { ParserUtils.assertAtStartTag(parser); final int initialDepth = parser.getDepth(); @@ -791,9 +791,9 @@ public class PacketParserUtils { * @return an stream error packet. * @throws IOException * @throws XmlPullParserException - * @throws ParseException + * @throws SmackParsingException */ - public static StreamError parseStreamError(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException { + public static StreamError parseStreamError(XmlPullParser parser) throws XmlPullParserException, IOException, SmackParsingException { final int initialDepth = parser.getDepth(); List extensions = new ArrayList<>(); Map descriptiveTexts = null; @@ -843,9 +843,9 @@ public class PacketParserUtils { * @return an error sub-packet. * @throws IOException * @throws XmlPullParserException - * @throws ParseException + * @throws SmackParsingException */ - public static StanzaError.Builder parseError(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException { + public static StanzaError.Builder parseError(XmlPullParser parser) throws XmlPullParserException, IOException, SmackParsingException { final int initialDepth = parser.getDepth(); Map descriptiveTexts = null; List extensions = new ArrayList<>(); @@ -916,10 +916,10 @@ public class PacketParserUtils { * @return an extension element. * @throws XmlPullParserException * @throws IOException - * @throws ParseException + * @throws SmackParsingException */ public static ExtensionElement parseExtensionElement(String elementName, String namespace, - XmlPullParser parser) throws XmlPullParserException, IOException, ParseException { + XmlPullParser parser) throws XmlPullParserException, IOException, SmackParsingException { ParserUtils.assertAtStartTag(parser); // See if a provider is registered to handle the extension. ExtensionElementProvider provider = ProviderManager.getExtensionProvider(elementName, namespace); @@ -988,24 +988,24 @@ public class PacketParserUtils { } public static void addExtensionElement(Stanza packet, XmlPullParser parser) - throws XmlPullParserException, IOException, ParseException { + throws XmlPullParserException, IOException, SmackParsingException { 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, ParseException { + String namespace) throws XmlPullParserException, IOException, SmackParsingException { ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser); packet.addExtension(packetExtension); } public static void addExtensionElement(Collection collection, XmlPullParser parser) - throws XmlPullParserException, IOException, ParseException { + throws XmlPullParserException, IOException, SmackParsingException { addExtensionElement(collection, parser, parser.getName(), parser.getNamespace()); } public static void addExtensionElement(Collection collection, XmlPullParser parser, - String elementName, String namespace) throws XmlPullParserException, IOException, ParseException { + String elementName, String namespace) throws XmlPullParserException, IOException, SmackParsingException { ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser); collection.add(packetExtension); } diff --git a/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java b/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java index 6f6bd1d82..2a06c9c3c 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/util/ParserUtils.java @@ -1,6 +1,6 @@ /** * - * Copyright © 2014-2018 Florian Schmaus + * Copyright © 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. @@ -26,6 +26,10 @@ import java.util.Locale; import javax.xml.XMLConstants; import javax.xml.namespace.QName; +import org.jivesoftware.smack.parsing.SmackParsingException; +import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException; +import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException; + import org.jxmpp.jid.EntityBareJid; import org.jxmpp.jid.EntityFullJid; import org.jxmpp.jid.EntityJid; @@ -261,19 +265,41 @@ public class ParserUtils { return s; } - public static Date getDateFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException { - String dateString = parser.nextText(); - return XmppDateTime.parseDate(dateString); + public static Date getDateFromOptionalXep82String(String dateString) throws SmackTextParseException { + if (dateString == null) { + return null; + } + return getDateFromXep82String(dateString); } - public static URI getUriFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException { + public static Date getDateFromXep82String(String dateString) throws SmackTextParseException { + try { + return XmppDateTime.parseXEP0082Date(dateString); + } catch (ParseException e) { + throw new SmackParsingException.SmackTextParseException(e); + } + } + + public static Date getDateFromString(String dateString) throws SmackTextParseException { + try { + return XmppDateTime.parseDate(dateString); + } catch (ParseException e) { + throw new SmackParsingException.SmackTextParseException(e); + } + } + + public static Date getDateFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException, SmackTextParseException { + String dateString = parser.nextText(); + return getDateFromString(dateString); + } + + public static URI getUriFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException, SmackUriSyntaxParsingException { String uriString = parser.nextText(); try { return new URI(uriString); } catch (URISyntaxException e) { - // TODO: Should be SmackParseException (or subclass of). - throw new IOException(e); + throw new SmackParsingException.SmackUriSyntaxParsingException(e); } } diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java index 3cd6faa32..964efeb8f 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/provider/CarbonManagerProvider.java @@ -17,8 +17,8 @@ package org.jivesoftware.smackx.carbons.provider; import java.io.IOException; -import java.text.ParseException; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smackx.carbons.packet.CarbonExtension; @@ -41,7 +41,7 @@ public class CarbonManagerProvider extends ExtensionElementProvider without sequence number"); boolean done = ParserUtils.getBooleanAttribute(parser, "done", false); List nodes = new ArrayList<>(); @@ -68,7 +70,7 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider timestampElements = new ArrayList<>(); @@ -94,10 +96,15 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider fields = new ArrayList<>(); outerloop: while (true) { final int eventType = parser.next(); diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/ChecksumProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/ChecksumProvider.java index abb58f67e..4f7b762ed 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/ChecksumProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/ChecksumProvider.java @@ -20,8 +20,8 @@ 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 org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smackx.hashes.element.HashElement; import org.jivesoftware.smackx.hashes.provider.HashElementProvider; @@ -38,7 +38,7 @@ import org.xmlpull.v1.XmlPullParserException; */ public class ChecksumProvider extends ExtensionElementProvider { @Override - public Checksum parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public Checksum parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { JingleContent.Creator creator = null; String creatorString = parser.getAttributeValue(null, Checksum.ATTR_CREATOR); if (creatorString != null) { diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/JingleFileTransferProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/JingleFileTransferProvider.java index ccac77707..cbfb6d620 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/JingleFileTransferProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/jingle_filetransfer/provider/JingleFileTransferProvider.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.text.ParseException; import java.util.ArrayList; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smackx.hashes.element.HashElement; import org.jivesoftware.smackx.hashes.provider.HashElementProvider; import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement; @@ -42,7 +43,7 @@ public class JingleFileTransferProvider extends JingleContentDescriptionProvider { @Override - public JingleFileTransfer parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public JingleFileTransfer parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { ArrayList payloads = new ArrayList<>(); boolean inRange = false; JingleFileTransferChild.Builder builder = JingleFileTransferChild.getBuilder(); @@ -59,7 +60,11 @@ public class JingleFileTransferProvider if (tag == START_TAG) { switch (elem) { case JingleFileTransferChild.ELEM_DATE: + try { builder.setDate(XmppDateTime.parseXEP0082Date(parser.nextText())); + } catch (ParseException e) { + throw new SmackParsingException.SmackTextParseException(e); + } break; case JingleFileTransferChild.ELEM_DESC: diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/provider/MamFinIQProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/provider/MamFinIQProvider.java index cb5e8a2ce..4a399be9c 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/provider/MamFinIQProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/provider/MamFinIQProvider.java @@ -17,8 +17,8 @@ package org.jivesoftware.smackx.mam.provider; import java.io.IOException; -import java.text.ParseException; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.ParserUtils; @@ -40,7 +40,7 @@ import org.xmlpull.v1.XmlPullParserException; public class MamFinIQProvider extends IQProvider { @Override - public MamFinIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public MamFinIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { String queryId = parser.getAttributeValue("", "queryid"); boolean complete = ParserUtils.getBooleanAttribute(parser, "complete", false); boolean stable = ParserUtils.getBooleanAttribute(parser, "stable", true); diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/provider/MamQueryIQProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/provider/MamQueryIQProvider.java index 1ae617ea3..640da165d 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/provider/MamQueryIQProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/provider/MamQueryIQProvider.java @@ -17,8 +17,8 @@ package org.jivesoftware.smackx.mam.provider; import java.io.IOException; -import java.text.ParseException; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smackx.mam.element.MamQueryIQ; @@ -40,7 +40,7 @@ public class MamQueryIQProvider extends IQProvider { @Override public MamQueryIQ parse(XmlPullParser parser, int initialDepth) - throws XmlPullParserException, IOException, ParseException { + throws XmlPullParserException, IOException, SmackParsingException { DataForm dataForm = null; String queryId = parser.getAttributeValue("", "queryid"); String node = parser.getAttributeValue("", "node"); diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/provider/MamResultProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/provider/MamResultProvider.java index 3d37b1869..f6cdd4550 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/provider/MamResultProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/provider/MamResultProvider.java @@ -17,8 +17,8 @@ package org.jivesoftware.smackx.mam.provider; import java.io.IOException; -import java.text.ParseException; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smackx.forward.packet.Forwarded; @@ -39,7 +39,7 @@ import org.xmlpull.v1.XmlPullParserException; public class MamResultProvider extends ExtensionElementProvider { @Override - public MamResultExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public MamResultExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { Forwarded forwarded = null; String queryId = parser.getAttributeValue("", "queryid"); String id = parser.getAttributeValue("", "id"); diff --git a/smack-experimental/src/main/java/org/jivesoftware/smackx/reference/provider/ReferenceProvider.java b/smack-experimental/src/main/java/org/jivesoftware/smackx/reference/provider/ReferenceProvider.java index e46a99285..c74b884e5 100644 --- a/smack-experimental/src/main/java/org/jivesoftware/smackx/reference/provider/ReferenceProvider.java +++ b/smack-experimental/src/main/java/org/jivesoftware/smackx/reference/provider/ReferenceProvider.java @@ -19,9 +19,9 @@ package org.jivesoftware.smackx.reference.provider; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -import java.text.ParseException; import org.jivesoftware.smack.packet.ExtensionElement; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ProviderManager; import org.jivesoftware.smack.util.ParserUtils; @@ -35,7 +35,7 @@ public class ReferenceProvider extends ExtensionElementProvider { @Override - public AdHocCommandData parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public AdHocCommandData parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { boolean done = false; AdHocCommandData adHocCommandData = new AdHocCommandData(); DataFormProvider dataFormProvider = new DataFormProvider(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/AbstractDelayInformationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/AbstractDelayInformationProvider.java index 87e174d0c..e8c632644 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/AbstractDelayInformationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/AbstractDelayInformationProvider.java @@ -1,6 +1,6 @@ /** * - * Copyright © 2014 Florian Schmaus + * Copyright © 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. @@ -17,9 +17,9 @@ package org.jivesoftware.smackx.delay.provider; import java.io.IOException; -import java.text.ParseException; import java.util.Date; +import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smackx.delay.packet.DelayInformation; @@ -32,7 +32,7 @@ public abstract class AbstractDelayInformationProvider extends ExtensionElementP @Override public final DelayInformation parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, - IOException, ParseException { + IOException, SmackTextParseException { String stampString = (parser.getAttributeValue("", "stamp")); String from = parser.getAttributeValue("", "from"); String reason = null; @@ -58,5 +58,5 @@ public abstract class AbstractDelayInformationProvider extends ExtensionElementP return new DelayInformation(stamp, from, reason); } - protected abstract Date parseDate(String string) throws ParseException; + protected abstract Date parseDate(String string) throws SmackTextParseException; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/DelayInformationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/DelayInformationProvider.java index fc7378410..4e944894d 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/DelayInformationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/DelayInformationProvider.java @@ -1,6 +1,6 @@ /** * - * Copyright © 2014 Florian Schmaus + * Copyright © 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. @@ -16,10 +16,10 @@ */ package org.jivesoftware.smackx.delay.provider; -import java.text.ParseException; import java.util.Date; -import org.jxmpp.util.XmppDateTime; +import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException; +import org.jivesoftware.smack.util.ParserUtils; /** * The DelayInformationProvider parses DelayInformation packets. @@ -31,8 +31,8 @@ public class DelayInformationProvider extends AbstractDelayInformationProvider { public static final DelayInformationProvider INSTANCE = new DelayInformationProvider(); @Override - protected Date parseDate(String string) throws ParseException { - return XmppDateTime.parseXEP0082Date(string); + protected Date parseDate(String string) throws SmackTextParseException { + return ParserUtils.getDateFromXep82String(string); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/LegacyDelayInformationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/LegacyDelayInformationProvider.java index 8e469200d..1a2581fb8 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/LegacyDelayInformationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/provider/LegacyDelayInformationProvider.java @@ -1,6 +1,6 @@ /** * - * Copyright © 2014 Florian Schmaus + * Copyright © 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. @@ -16,10 +16,10 @@ */ package org.jivesoftware.smackx.delay.provider; -import java.text.ParseException; import java.util.Date; -import org.jxmpp.util.XmppDateTime; +import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException; +import org.jivesoftware.smack.util.ParserUtils; /** * The DelayInformationProvider parses DelayInformation packets. @@ -29,8 +29,8 @@ import org.jxmpp.util.XmppDateTime; public class LegacyDelayInformationProvider extends AbstractDelayInformationProvider { @Override - protected Date parseDate(String string) throws ParseException { - return XmppDateTime.parseDate(string); + protected Date parseDate(String string) throws SmackTextParseException { + return ParserUtils.getDateFromString(string); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverInfoProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverInfoProvider.java index 062b18986..6713c41dc 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverInfoProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/provider/DiscoverInfoProvider.java @@ -18,8 +18,8 @@ package org.jivesoftware.smackx.disco.provider; import java.io.IOException; -import java.text.ParseException; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; @@ -36,7 +36,7 @@ import org.xmlpull.v1.XmlPullParserException; public class DiscoverInfoProvider extends IQProvider { @Override - public DiscoverInfo parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public DiscoverInfo parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { DiscoverInfo discoverInfo = new DiscoverInfo(); boolean done = false; DiscoverInfo.Identity identity; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java index 0800a03f7..c3b65bfbb 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/forward/provider/ForwardedProvider.java @@ -17,11 +17,11 @@ package org.jivesoftware.smackx.forward.provider; import java.io.IOException; -import java.text.ParseException; import java.util.logging.Logger; import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Stanza; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.util.PacketParserUtils; @@ -45,7 +45,7 @@ public class ForwardedProvider extends ExtensionElementProvider { private static final Logger LOGGER = Logger.getLogger(ForwardedProvider.class.getName()); @Override - public Forwarded parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public Forwarded parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { DelayInformation di = null; Stanza packet = null; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/geoloc/provider/GeoLocationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/geoloc/provider/GeoLocationProvider.java index 57187c686..2dd64b557 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/geoloc/provider/GeoLocationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/geoloc/provider/GeoLocationProvider.java @@ -1,6 +1,6 @@ /** * - * Copyright 2015-2017 Ishan Khanna, Fernando Ramirez + * Copyright 2015-2017 Ishan Khanna, Fernando Ramirez, 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. @@ -17,8 +17,9 @@ package org.jivesoftware.smackx.geoloc.provider; import java.io.IOException; -import java.text.ParseException; +import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException; +import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.util.ParserUtils; @@ -31,7 +32,7 @@ public class GeoLocationProvider extends ExtensionElementProvider { @Override public GeoLocation parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, - ParseException { + SmackTextParseException, SmackUriSyntaxParsingException { GeoLocation.Builder builder = GeoLocation.builder(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationProvider.java index a91d49b4e..0d23970ea 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/provider/RegistrationProvider.java @@ -17,7 +17,6 @@ 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; @@ -25,6 +24,7 @@ import java.util.Map; import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.IQ; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; @@ -36,7 +36,7 @@ import org.xmlpull.v1.XmlPullParserException; public class RegistrationProvider extends IQProvider { @Override - public Registration parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public Registration parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { String instruction = null; Map fields = new HashMap<>(); List packetExtensions = new LinkedList<>(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/provider/JingleContentDescriptionProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/provider/JingleContentDescriptionProvider.java index 4f6166d68..ba1aed63a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/provider/JingleContentDescriptionProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/provider/JingleContentDescriptionProvider.java @@ -17,8 +17,8 @@ package org.jivesoftware.smackx.jingle.provider; import java.io.IOException; -import java.text.ParseException; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smackx.jingle.element.JingleContentDescription; @@ -30,6 +30,6 @@ public abstract class JingleContentDescriptionProvider { @Override - public abstract D parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException; + public abstract D parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/provider/JingleProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/provider/JingleProvider.java index c49fb80c5..b349e2042 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/provider/JingleProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/jingle/provider/JingleProvider.java @@ -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. @@ -17,10 +17,10 @@ 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; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.parsing.StandardExtensionElementProvider; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.ParserUtils; @@ -44,7 +44,7 @@ public class JingleProvider extends IQProvider { private static final Logger LOGGER = Logger.getLogger(JingleProvider.class.getName()); @Override - public Jingle parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public Jingle parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { Jingle.Builder builder = Jingle.getBuilder(); String actionString = parser.getAttributeValue("", Jingle.ACTION_ATTRIBUTE_NAME); @@ -102,7 +102,7 @@ public class JingleProvider extends IQProvider { } public static JingleContent parseJingleContent(XmlPullParser parser, final int initialDepth) - throws XmlPullParserException, IOException, ParseException { + throws XmlPullParserException, IOException, SmackParsingException { JingleContent.Builder builder = JingleContent.getBuilder(); String creatorString = parser.getAttributeValue("", JingleContent.CREATOR_ATTRIBUTE_NAME); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/last_interaction/provider/IdleProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/last_interaction/provider/IdleProvider.java index 8c0790f60..570fc352a 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/last_interaction/provider/IdleProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/last_interaction/provider/IdleProvider.java @@ -1,6 +1,6 @@ /** * - * Copyright © 2018 Paul Schaub + * Copyright © 2018 Paul Schaub, 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,6 +19,8 @@ package org.jivesoftware.smackx.last_interaction.provider; import java.text.ParseException; import java.util.Date; +import org.jivesoftware.smack.parsing.SmackParsingException; +import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smackx.last_interaction.element.IdleElement; @@ -30,9 +32,14 @@ public class IdleProvider extends ExtensionElementProvider { public static final IdleProvider TEST_INSTANCE = new IdleProvider(); @Override - public IdleElement parse(XmlPullParser parser, int initialDepth) throws ParseException { + public IdleElement parse(XmlPullParser parser, int initialDepth) throws SmackTextParseException { String dateString = parser.getAttributeValue(null, IdleElement.ATTR_SINCE); - Date since = XmppDateTime.parseXEP0082Date(dateString); + Date since; + try { + since = XmppDateTime.parseXEP0082Date(dateString); + } catch (ParseException e) { + throw new SmackParsingException.SmackTextParseException(e); + } return new IdleElement(since); } } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/mood/provider/MoodConcretisationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/mood/provider/MoodConcretisationProvider.java index 1ee3af639..c36c6a732 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/mood/provider/MoodConcretisationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/mood/provider/MoodConcretisationProvider.java @@ -17,7 +17,6 @@ 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; @@ -28,5 +27,5 @@ import org.xmlpull.v1.XmlPullParserException; public abstract class MoodConcretisationProvider extends ExtensionElementProvider { @Override - public abstract C parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException, ParseException; + public abstract C parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException; } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/mood/provider/MoodProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/mood/provider/MoodProvider.java index dcc515b29..dc30e70b5 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/mood/provider/MoodProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/mood/provider/MoodProvider.java @@ -20,10 +20,10 @@ 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; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ProviderManager; import org.jivesoftware.smackx.mood.Mood; @@ -40,7 +40,7 @@ public class MoodProvider extends ExtensionElementProvider { @Override public MoodElement parse(XmlPullParser parser, int initialDepth) - throws XmlPullParserException, IOException, ParseException { + throws XmlPullParserException, IOException, SmackParsingException { String text = null; Mood mood = null; MoodConcretisation concretisation = null; diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/mood/provider/SimpleMoodConcretisationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/mood/provider/SimpleMoodConcretisationProvider.java index 688488c7d..d57b163ac 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/mood/provider/SimpleMoodConcretisationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/mood/provider/SimpleMoodConcretisationProvider.java @@ -17,7 +17,6 @@ package org.jivesoftware.smackx.mood.provider; import java.io.IOException; -import java.text.ParseException; import org.jivesoftware.smackx.mood.element.MoodConcretisation; @@ -34,7 +33,7 @@ import org.xmlpull.v1.XmlPullParserException; public abstract class SimpleMoodConcretisationProvider extends MoodConcretisationProvider { @Override - public C parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException, ParseException { + public C parse(XmlPullParser parser, int initialDepth) throws IOException, XmlPullParserException { // Since the elements name and namespace is known, we can just return an instance of the MoodConcretisation. return simpleExtension(); } diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCOwnerProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCOwnerProvider.java index 7861a990c..7b56c83a4 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCOwnerProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/provider/MUCOwnerProvider.java @@ -18,8 +18,8 @@ package org.jivesoftware.smackx.muc.provider; import java.io.IOException; -import java.text.ParseException; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; @@ -36,7 +36,7 @@ import org.xmlpull.v1.XmlPullParserException; public class MUCOwnerProvider extends IQProvider { @Override - public MUCOwner parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public MUCOwner parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { MUCOwner mucOwner = new MUCOwner(); boolean done = false; while (!done) { diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java index 727ab0833..285f93a24 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java @@ -17,9 +17,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.parsing.SmackParsingException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.ProviderManager; import org.jivesoftware.smack.util.PacketParserUtils; @@ -44,7 +44,7 @@ import org.xmlpull.v1.XmlPullParserException; public class ItemProvider extends ExtensionElementProvider { @Override public Item parse(XmlPullParser parser, int initialDepth) - throws XmlPullParserException, IOException, ParseException { + throws XmlPullParserException, IOException, SmackParsingException { String id = parser.getAttributeValue(null, "id"); String node = parser.getAttributeValue(null, "node"); String xmlns = parser.getNamespace(); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java index 973cd8475..15211a0b6 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/PubSubProvider.java @@ -17,9 +17,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.parsing.SmackParsingException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; @@ -37,7 +37,7 @@ import org.xmlpull.v1.XmlPullParserException; */ public class PubSubProvider extends IQProvider { @Override - public PubSub parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public PubSub parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { String namespace = parser.getNamespace(); PubSubNamespace pubSubNamespace = PubSubNamespace.valueOfFromXmlns(namespace); PubSub pubsub = new PubSub(pubSubNamespace); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java index dbdf485ba..33d921a61 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearch.java @@ -17,7 +17,6 @@ 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; @@ -25,6 +24,7 @@ import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPException.XMPPErrorException; import org.jivesoftware.smack.packet.IQ; import org.jivesoftware.smack.packet.SimpleIQ; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; @@ -129,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 XmlPullParserException, IOException, ParseException { + public IQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { UserSearch search = null; SimpleUserSearch simpleUserSearch = new SimpleUserSearch(); @@ -164,7 +164,7 @@ public class UserSearch extends SimpleIQ { } private static void buildDataForm(SimpleUserSearch search, - String instructions, XmlPullParser parser) throws XmlPullParserException, IOException, ParseException { + String instructions, XmlPullParser parser) throws XmlPullParserException, IOException, SmackParsingException { DataForm dataForm = new DataForm(DataForm.Type.form); boolean done = false; dataForm.setTitle("User Search"); diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/si/provider/StreamInitiationProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/si/provider/StreamInitiationProvider.java index 20182e987..387f7eab0 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/si/provider/StreamInitiationProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/si/provider/StreamInitiationProvider.java @@ -22,6 +22,7 @@ import java.util.Date; import java.util.logging.Level; import java.util.logging.Logger; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smackx.si.packet.StreamInitiation; @@ -43,7 +44,7 @@ public class StreamInitiationProvider extends IQProvider { private static final Logger LOGGER = Logger.getLogger(StreamInitiationProvider.class.getName()); @Override - public StreamInitiation parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public StreamInitiation parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { boolean done = false; // si diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/provider/DataFormProvider.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/provider/DataFormProvider.java index 7000ff0b9..6fafc32d3 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/provider/DataFormProvider.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/provider/DataFormProvider.java @@ -18,10 +18,10 @@ package org.jivesoftware.smackx.xdata.provider; import java.io.IOException; -import java.text.ParseException; import java.util.ArrayList; import java.util.List; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.roster.packet.RosterPacket; import org.jivesoftware.smack.roster.provider.RosterPacketProvider; @@ -46,7 +46,7 @@ public class DataFormProvider extends ExtensionElementProvider { public static final DataFormProvider INSTANCE = new DataFormProvider(); @Override - public DataForm parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public DataForm parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { DataForm.Type dataFormType = DataForm.Type.fromString(parser.getAttributeValue("", "type")); DataForm dataForm = new DataForm(dataFormType); outerloop: while (true) { diff --git a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleProvider.java b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleProvider.java index 9ef138aff..3599f2ab2 100644 --- a/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleProvider.java +++ b/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleProvider.java @@ -18,8 +18,8 @@ package org.jivesoftware.smackx.jingleold.provider; import java.io.IOException; -import java.text.ParseException; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.ParserUtils; @@ -44,12 +44,12 @@ public class JingleProvider extends IQProvider { /** * Parse a iq/jingle element. - * @throws ParseException * @throws XmlPullParserException * @throws IOException + * @throws SmackParsingException */ @Override - public Jingle parse(XmlPullParser parser, int intialDepth) throws IOException, XmlPullParserException, ParseException { + public Jingle parse(XmlPullParser parser, int intialDepth) throws IOException, XmlPullParserException, SmackParsingException { Jingle jingle = new Jingle(); String sid = ""; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/forms/WorkgroupForm.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/forms/WorkgroupForm.java index 1f90472ec..edc07da9c 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/forms/WorkgroupForm.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/ext/forms/WorkgroupForm.java @@ -18,9 +18,9 @@ package org.jivesoftware.smackx.workgroup.ext.forms; import java.io.IOException; -import java.text.ParseException; import org.jivesoftware.smack.packet.SimpleIQ; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; @@ -51,7 +51,7 @@ public class WorkgroupForm extends SimpleIQ { public static class InternalProvider extends IQProvider { @Override - public WorkgroupForm parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public WorkgroupForm parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { WorkgroupForm answer = new WorkgroupForm(); boolean done = false; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OccupantsInfo.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OccupantsInfo.java index a667c2267..243d0d527 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OccupantsInfo.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OccupantsInfo.java @@ -27,6 +27,8 @@ import java.util.Set; import java.util.TimeZone; import org.jivesoftware.smack.packet.IQ; +import org.jivesoftware.smack.parsing.SmackParsingException; +import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException; import org.jivesoftware.smack.provider.IQProvider; import org.xmlpull.v1.XmlPullParser; @@ -135,7 +137,7 @@ public class OccupantsInfo extends IQ { public static class Provider extends IQProvider { @Override - public OccupantsInfo parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public OccupantsInfo parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackTextParseException { OccupantsInfo occupantsInfo = new OccupantsInfo(parser.getAttributeValue("", "roomID")); boolean done = false; @@ -152,7 +154,7 @@ public class OccupantsInfo extends IQ { return occupantsInfo; } - private OccupantInfo parseOccupantInfo(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException { + private OccupantInfo parseOccupantInfo(XmlPullParser parser) throws XmlPullParserException, IOException, SmackTextParseException { boolean done = false; String jid = null; @@ -168,7 +170,11 @@ public class OccupantsInfo extends IQ { } else if (eventType == XmlPullParser.START_TAG && "joined".equals(parser.getName())) { synchronized (UTC_FORMAT) { + try { joined = UTC_FORMAT.parse(parser.nextText()); + } catch (ParseException e) { + throw new SmackParsingException.SmackTextParseException(e); + } } } else if (eventType == XmlPullParser.END_TAG && "occupant".equals(parser.getName())) { diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java index c92296289..25c16d647 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java @@ -18,12 +18,12 @@ package org.jivesoftware.smackx.workgroup.packet; import java.io.IOException; -import java.text.ParseException; import java.util.HashMap; import java.util.List; import java.util.Map; import org.jivesoftware.smack.packet.IQ; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; import org.jivesoftware.smack.util.ParserUtils; @@ -51,7 +51,7 @@ public class OfferRequestProvider extends IQProvider { // happen anytime soon. @Override - public OfferRequestPacket parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public OfferRequestPacket parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { int eventType = parser.getEventType(); String sessionID = null; int timeout = -1; diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java index 0b39d1f13..a0d87ac23 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java @@ -27,6 +27,8 @@ import java.util.Set; import java.util.logging.Logger; import org.jivesoftware.smack.packet.ExtensionElement; +import org.jivesoftware.smack.parsing.SmackParsingException; +import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smackx.workgroup.QueueUser; @@ -145,7 +147,7 @@ public final class QueueDetails implements ExtensionElement { @Override public QueueDetails parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, - IOException, ParseException { + IOException, SmackTextParseException { SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); QueueDetails queueDetails = new QueueDetails(); @@ -176,10 +178,19 @@ public final class QueueDetails implements ExtensionElement { time = Integer.parseInt(parser.nextText()); } else if ("join-time".equals(parser.getName())) { - joinTime = dateFormat.parse(parser.nextText()); + try { + joinTime = dateFormat.parse(parser.nextText()); + } catch (ParseException e) { + throw new SmackParsingException.SmackTextParseException(e); + } } else if (parser.getName().equals("waitTime")) { - Date wait = dateFormat.parse(parser.nextText()); + Date wait; + try { + wait = dateFormat.parse(parser.nextText()); + } catch (ParseException e) { + throw new SmackParsingException.SmackTextParseException(e); + } LOGGER.fine(wait.toString()); } diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java index 2259f6332..3036f0444 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java @@ -24,6 +24,8 @@ import java.util.Date; import org.jivesoftware.smack.packet.ExtensionElement; import org.jivesoftware.smack.packet.XmlEnvironment; +import org.jivesoftware.smack.parsing.SmackParsingException; +import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException; import org.jivesoftware.smack.provider.ExtensionElementProvider; import org.jivesoftware.smackx.workgroup.agent.WorkgroupQueue; @@ -127,7 +129,7 @@ public class QueueOverview implements ExtensionElement { @Override public QueueOverview parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, - IOException, ParseException { + IOException, SmackTextParseException { int eventType = parser.getEventType(); QueueOverview queueOverview = new QueueOverview(); SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT); @@ -142,7 +144,11 @@ public class QueueOverview implements ExtensionElement { queueOverview.setAverageWaitTime(Integer.parseInt(parser.nextText())); } else if ("oldest".equals(parser.getName())) { - queueOverview.setOldestEntry(dateFormat.parse(parser.nextText())); + try { + queueOverview.setOldestEntry(dateFormat.parse(parser.nextText())); + } catch (ParseException e) { + throw new SmackParsingException.SmackTextParseException(e); + } } else if ("status".equals(parser.getName())) { queueOverview.setStatus(WorkgroupQueue.Status.fromString(parser.nextText())); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptProvider.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptProvider.java index 7443d1abd..390419dba 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptProvider.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptProvider.java @@ -18,11 +18,11 @@ package org.jivesoftware.smackx.workgroup.packet; import java.io.IOException; -import java.text.ParseException; import java.util.ArrayList; import java.util.List; import org.jivesoftware.smack.packet.Stanza; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; @@ -37,7 +37,7 @@ import org.xmlpull.v1.XmlPullParserException; public class TranscriptProvider extends IQProvider { @Override - public Transcript parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public Transcript parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { String sessionID = parser.getAttributeValue("", "sessionID"); List packets = new ArrayList<>(); diff --git a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptSearch.java b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptSearch.java index f9fc324d4..9244da7d7 100644 --- a/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptSearch.java +++ b/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/TranscriptSearch.java @@ -18,9 +18,9 @@ package org.jivesoftware.smackx.workgroup.packet; import java.io.IOException; -import java.text.ParseException; import org.jivesoftware.smack.packet.SimpleIQ; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smack.provider.IQProvider; import org.jivesoftware.smack.util.PacketParserUtils; @@ -57,7 +57,7 @@ public class TranscriptSearch extends SimpleIQ { public static class Provider extends IQProvider { @Override - public TranscriptSearch parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException { + public TranscriptSearch parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackParsingException { TranscriptSearch answer = new TranscriptSearch(); boolean done = false; diff --git a/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/provider/CryptElementProvider.java b/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/provider/CryptElementProvider.java index 830a76964..5c434b581 100644 --- a/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/provider/CryptElementProvider.java +++ b/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/provider/CryptElementProvider.java @@ -17,8 +17,8 @@ package org.jivesoftware.smackx.ox.provider; import java.io.IOException; -import java.text.ParseException; +import org.jivesoftware.smack.parsing.SmackParsingException; import org.jivesoftware.smackx.ox.element.CryptElement; import org.xmlpull.v1.XmlPullParser; @@ -32,7 +32,7 @@ public class CryptElementProvider extends OpenPgpContentElementProvider to = new HashSet<>(); Date timestamp = null; String rpad = null; @@ -97,7 +97,7 @@ public abstract class OpenPgpContentElementProvider