blob: df17a997485a924a2d9683872a62ec1f2f2cc1bb (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
package de.thedevstack.conversationsplus.xmpp.filetransfer.http.delete;
import de.thedevstack.conversationsplus.xml.Element;
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.filetransfer.http.FileTransferHttp;
import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket;
import de.thedevstack.conversationsplus.xmpp.utils.ErrorIqPacketExceptionHelper;
/**
* IqPacketParser to parse the response of a remote file delete request.
* This parser parses a IqPacket according to the specification 'filetransfer for XMPP over http".
*/
public class DeletedPacketParser extends IqPacketParser {
/**
* Parses an IqPacket.
* <pre>
* <iq from='montague.tld'
* id='delete-file_002'
* to='romeo@montague.tld/garden'
* type='result'>
* <deleted xmlns='urn:xmpp:filetransfer:http'/>
* </iq>
* </pre>
* @param packet the packet to parse
* @return <code>true</code> if the result packet contains a deleted element of namespace <code>urn:xmpp:filetransfer:http</code>
* @throws XmppException in case of IqPacket type error or {@link UnexpectedIqPacketTypeException} in case of an unexpected IqPacket type.
*/
public static boolean parseDeleteToken(IqPacket packet) throws XmppException {
boolean successfullyDeleted = false;
if (packet.getType() == IqPacket.TYPE.RESULT) {
Element deletedElement = findRequiredChild(packet, "deleted", FileTransferHttp.NAMESPACE);
successfullyDeleted = null != deletedElement;
} else if (packet.getType() == IqPacket.TYPE.ERROR) {
ErrorIqPacketExceptionHelper.throwIqErrorException(packet);
} else {
throw new UnexpectedIqPacketTypeException(packet, packet.getType(), IqPacket.TYPE.RESULT, IqPacket.TYPE.ERROR);
}
return successfullyDeleted;
}
}
|