package de.thedevstack.conversationsplus.xmpp.httpupload; import de.thedevstack.conversationsplus.xml.Element; import de.thedevstack.conversationsplus.xmpp.AbstractIqPacketParser; import de.thedevstack.conversationsplus.xmpp.exceptions.UnexpectedIqPacketTypeException; import de.thedevstack.conversationsplus.xmpp.exceptions.XmppException; import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket; /** * */ public final class SlotPacketParser extends AbstractIqPacketParser { public static HttpUploadSlot parseGetAndPutUrl(IqPacket packet) throws XmppException { 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); } else if (packet.getType() == IqPacket.TYPE.ERROR) { throw new XmppException(); // Do proper handling of error cases } else { throw new UnexpectedIqPacketTypeException(packet, packet.getType(), IqPacket.TYPE.RESULT, IqPacket.TYPE.ERROR); } } }