1 package com
.owncloud
.android
.oc_framework
.operations
.remote
;
3 import org
.apache
.commons
.httpclient
.HttpStatus
;
4 import org
.apache
.jackrabbit
.webdav
.client
.methods
.DeleteMethod
;
6 import android
.util
.Log
;
8 import com
.owncloud
.android
.oc_framework
.network
.webdav
.WebdavClient
;
9 import com
.owncloud
.android
.oc_framework
.network
.webdav
.WebdavUtils
;
10 import com
.owncloud
.android
.oc_framework
.operations
.RemoteOperation
;
11 import com
.owncloud
.android
.oc_framework
.operations
.RemoteOperationResult
;
14 * Remote operation performing the removal of a remote file or folder in the ownCloud server.
16 * @author David A. Velasco
19 public class RemoveRemoteFileOperation
extends RemoteOperation
{
20 private static final String TAG
= RemoveRemoteFileOperation
.class.getSimpleName();
22 private static final int REMOVE_READ_TIMEOUT
= 10000;
23 private static final int REMOVE_CONNECTION_TIMEOUT
= 5000;
25 private String mRemotePath
;
30 * @param remotePath RemotePath of the remote file or folder to remove from the server
32 public RemoveRemoteFileOperation(String remotePath
) {
33 mRemotePath
= remotePath
;
37 * Performs the rename operation.
39 * @param client Client object to communicate with the remote ownCloud server.
42 protected RemoteOperationResult
run(WebdavClient client
) {
43 RemoteOperationResult result
= null
;
44 DeleteMethod delete
= null
;
47 delete
= new DeleteMethod(client
.getBaseUri() + WebdavUtils
.encodePath(mRemotePath
));
48 int status
= client
.executeMethod(delete
, REMOVE_READ_TIMEOUT
, REMOVE_CONNECTION_TIMEOUT
);
50 delete
.getResponseBodyAsString(); // exhaust the response, although not interesting
51 result
= new RemoteOperationResult((delete
.succeeded() || status
== HttpStatus
.SC_NOT_FOUND
), status
, delete
.getResponseHeaders());
52 Log
.i(TAG
, "Remove " + mRemotePath
+ ": " + result
.getLogMessage());
54 } catch (Exception e
) {
55 result
= new RemoteOperationResult(e
);
56 Log
.e(TAG
, "Remove " + mRemotePath
+ ": " + result
.getLogMessage(), e
);
60 delete
.releaseConnection();