blob: 0630449a0fec75f3a4c34648af7d7d38cb0127db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
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);
}
}
}
|