diff options
author | steckbrief <steckbrief@chefmail.de> | 2016-08-22 21:30:57 +0200 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2016-08-22 21:30:57 +0200 |
commit | e7089c55ac72f716e17203a9b8732b2b5c82c150 (patch) | |
tree | c6d47e95fe5cbceb7a556563709d04718f176825 /src/main | |
parent | 3ed7cb54e5858afaadc3f7ec5bc01edb61e1428e (diff) |
Improved error handling for httpupload
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/xmpp/httpupload/SlotPacketParser.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/httpupload/SlotPacketParser.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/httpupload/SlotPacketParser.java index 0630449a..655d8759 100644 --- a/src/main/java/de/thedevstack/conversationsplus/xmpp/httpupload/SlotPacketParser.java +++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/httpupload/SlotPacketParser.java @@ -1,27 +1,30 @@ package de.thedevstack.conversationsplus.xmpp.httpupload; import de.thedevstack.conversationsplus.xml.Element; -import de.thedevstack.conversationsplus.xmpp.AbstractIqPacketParser; +import de.thedevstack.conversationsplus.xmpp.IqPacketParser; import de.thedevstack.conversationsplus.xmpp.exceptions.UnexpectedIqPacketTypeException; import de.thedevstack.conversationsplus.xmpp.exceptions.XmppException; import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket; +import de.thedevstack.conversationsplus.xmpp.utils.ErrorIqPacketExceptionHelper; /** * */ -public final class SlotPacketParser extends AbstractIqPacketParser { +public final class SlotPacketParser extends IqPacketParser { public static HttpUploadSlot parseGetAndPutUrl(IqPacket packet) throws XmppException { + HttpUploadSlot httpUploadSlot = null; if (packet.getType() == IqPacket.TYPE.RESULT) { Element slot = findRequiredChild(packet, "slot", HttpUpload.NAMESPACE); String getUrl = findRequiredChildContent(slot, "get"); String putUrl = findRequiredChildContent(slot, "put"); - return new HttpUploadSlot(getUrl, putUrl); + httpUploadSlot = new HttpUploadSlot(getUrl, putUrl); } else if (packet.getType() == IqPacket.TYPE.ERROR) { - throw new XmppException(); // Do proper handling of error cases + ErrorIqPacketExceptionHelper.throwIqErrorException(packet); } else { throw new UnexpectedIqPacketTypeException(packet, packet.getType(), IqPacket.TYPE.RESULT, IqPacket.TYPE.ERROR); } + return httpUploadSlot; } } |