1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 00:59:39 +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

@ -17,11 +17,15 @@
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.provider.IQProvider;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
public class WorkgroupForm extends SimpleIQ {
@ -47,8 +51,7 @@ public class WorkgroupForm extends SimpleIQ {
public static class InternalProvider extends IQProvider<WorkgroupForm> {
@Override
public WorkgroupForm parse(XmlPullParser parser, int initialDepth)
throws Exception {
public WorkgroupForm parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
WorkgroupForm answer = new WorkgroupForm();
boolean done = false;

View file

@ -26,7 +26,6 @@ import java.util.HashSet;
import java.util.Set;
import java.util.TimeZone;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider;
@ -136,7 +135,7 @@ public class OccupantsInfo extends IQ {
public static class Provider extends IQProvider<OccupantsInfo> {
@Override
public OccupantsInfo parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
public OccupantsInfo parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
OccupantsInfo occupantsInfo = new OccupantsInfo(parser.getAttributeValue("", "roomID"));
boolean done = false;
@ -153,7 +152,7 @@ public class OccupantsInfo extends IQ {
return occupantsInfo;
}
private OccupantInfo parseOccupantInfo(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException {
private OccupantInfo parseOccupantInfo(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
boolean done = false;
String jid = null;
@ -168,13 +167,9 @@ public class OccupantsInfo extends IQ {
nickname = parser.nextText();
} else if (eventType == XmlPullParser.START_TAG &&
"joined".equals(parser.getName())) {
try {
synchronized (UTC_FORMAT) {
joined = UTC_FORMAT.parse(parser.nextText());
}
} catch (ParseException e) {
throw new SmackException(e);
}
} else if (eventType == XmlPullParser.END_TAG &&
"occupant".equals(parser.getName())) {
done = true;

View file

@ -17,6 +17,8 @@
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;
@ -35,6 +37,7 @@ import org.jivesoftware.smackx.workgroup.util.MetaDataUtils;
import org.jxmpp.jid.Jid;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/**
* An IQProvider for agent offer requests.
@ -48,7 +51,7 @@ public class OfferRequestProvider extends IQProvider<IQ> {
// happen anytime soon.
@Override
public OfferRequestPacket parse(XmlPullParser parser, int initialDepth) throws Exception {
public OfferRequestPacket parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
int eventType = parser.getEventType();
String sessionID = null;
int timeout = -1;

View file

@ -26,7 +26,6 @@ import java.util.Iterator;
import java.util.Set;
import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
@ -146,7 +145,7 @@ public final class QueueDetails implements ExtensionElement {
@Override
public QueueDetails parse(XmlPullParser parser,
int initialDepth) throws XmlPullParserException,
IOException, SmackException {
IOException, ParseException {
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
QueueDetails queueDetails = new QueueDetails();
@ -177,19 +176,10 @@ public final class QueueDetails implements ExtensionElement {
time = Integer.parseInt(parser.nextText());
}
else if ("join-time".equals(parser.getName())) {
try {
joinTime = dateFormat.parse(parser.nextText());
} catch (ParseException e) {
throw new SmackException(e);
}
}
else if (parser.getName().equals("waitTime")) {
Date wait;
try {
wait = dateFormat.parse(parser.nextText());
} catch (ParseException e) {
throw new SmackException(e);
}
Date wait = dateFormat.parse(parser.nextText());
LOGGER.fine(wait.toString());
}

View file

@ -22,7 +22,6 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
@ -128,7 +127,7 @@ public class QueueOverview implements ExtensionElement {
@Override
public QueueOverview parse(XmlPullParser parser,
int initialDepth) throws XmlPullParserException,
IOException, SmackException {
IOException, ParseException {
int eventType = parser.getEventType();
QueueOverview queueOverview = new QueueOverview();
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
@ -143,11 +142,7 @@ public class QueueOverview implements ExtensionElement {
queueOverview.setAverageWaitTime(Integer.parseInt(parser.nextText()));
}
else if ("oldest".equals(parser.getName())) {
try {
queueOverview.setOldestEntry(dateFormat.parse(parser.nextText()));
} catch (ParseException e) {
throw new SmackException(e);
}
queueOverview.setOldestEntry(dateFormat.parse(parser.nextText()));
}
else if ("status".equals(parser.getName())) {
queueOverview.setStatus(WorkgroupQueue.Status.fromString(parser.nextText()));

View file

@ -17,6 +17,8 @@
package org.jivesoftware.smackx.workgroup.packet;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
@ -25,6 +27,7 @@ import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/**
* An IQProvider for transcripts.
@ -34,7 +37,7 @@ import org.xmlpull.v1.XmlPullParser;
public class TranscriptProvider extends IQProvider<Transcript> {
@Override
public Transcript parse(XmlPullParser parser, int initialDepth) throws Exception {
public Transcript parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
String sessionID = parser.getAttributeValue("", "sessionID");
List<Stanza> packets = new ArrayList<>();

View file

@ -17,11 +17,15 @@
package org.jivesoftware.smackx.workgroup.packet;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.SimpleIQ;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/**
* IQ stanza for retrieving the transcript search form, submitting the completed search form
@ -53,7 +57,7 @@ public class TranscriptSearch extends SimpleIQ {
public static class Provider extends IQProvider<TranscriptSearch> {
@Override
public TranscriptSearch parse(XmlPullParser parser, int initialDepth) throws Exception {
public TranscriptSearch parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, ParseException {
TranscriptSearch answer = new TranscriptSearch();
boolean done = false;