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. *
** @param packet the packet to parse * @return* **
true
if the result packet contains a deleted element of namespace urn:xmpp:filetransfer:http
* @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;
}
}