mirror of
https://github.com/owncloud/android-library.git
synced 2026-08-18 11:52:56 +00:00
Create RemoveRemoteFileOperation and use it
This commit is contained in:
@@ -52,8 +52,8 @@ public abstract class RemoteOperation<I extends Object> {
|
||||
}
|
||||
|
||||
|
||||
protected RemoteOperation(OCContext context) {
|
||||
mContext = context;
|
||||
protected RemoteOperation(OCContext ocContext) {
|
||||
mContext = ocContext;
|
||||
if(mClient == null) {
|
||||
mClient = new OkHttpClient.Builder()
|
||||
.followRedirects(false)
|
||||
|
||||
+5
-1
@@ -29,6 +29,10 @@ import at.bitfire.dav4android.DavOCResource;
|
||||
import static com.owncloud.android.lib.refactor.operations.RemoteOperationResult.ResultCode.OK;
|
||||
|
||||
/**
|
||||
* Remote operation performing the download of a remote file in the ownCloud server.
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* @author masensio
|
||||
* @author David González Verdugo
|
||||
*/
|
||||
public class DownloadRemoteFileOperation extends RemoteOperation<Void> {
|
||||
@@ -52,7 +56,7 @@ public class DownloadRemoteFileOperation extends RemoteOperation<Void> {
|
||||
);
|
||||
davOCResource.get("*/*");
|
||||
|
||||
//TODO Create local file from the downloaded one
|
||||
//TODO Create local file from the downloaded one and implement progress listener
|
||||
|
||||
return new Result(OK);
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/* ownCloud Android Library is available under MIT license
|
||||
* Copyright (C) 2018 ownCloud GmbH.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.lib.refactor.resources.files;
|
||||
|
||||
import com.owncloud.android.lib.refactor.OCContext;
|
||||
import com.owncloud.android.lib.refactor.operations.RemoteOperation;
|
||||
import at.bitfire.dav4android.DavOCResource;
|
||||
|
||||
import static com.owncloud.android.lib.refactor.operations.RemoteOperationResult.ResultCode.OK;
|
||||
|
||||
/**
|
||||
* Remote operation performing the removal of a remote file or folder in the ownCloud server.
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* @author masensio
|
||||
* @author David González Verdugo
|
||||
*/
|
||||
public class RemoveRemoteFileOperation extends RemoteOperation<Void> {
|
||||
|
||||
private String mRemotePath;
|
||||
|
||||
public RemoveRemoteFileOperation(OCContext ocContext, String remotePath) {
|
||||
super(ocContext);
|
||||
|
||||
mRemotePath = remotePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result exec() {
|
||||
try {
|
||||
DavOCResource davOCResource = new DavOCResource(
|
||||
getClient(),
|
||||
getWebDavHttpUrl(mRemotePath)
|
||||
);
|
||||
davOCResource.delete(null);
|
||||
|
||||
return new Result(OK);
|
||||
|
||||
} catch (Exception e) {
|
||||
return new Result(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
*
|
||||
* @author David A. Velasco
|
||||
* @author masensio
|
||||
* @author David González Verdugo
|
||||
*/
|
||||
public class RemoveRemoteFileOperation extends RemoteOperation {
|
||||
private static final String TAG = RemoveRemoteFileOperation.class.getSimpleName();
|
||||
@@ -88,5 +89,4 @@ public class RemoveRemoteFileOperation extends RemoteOperation {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user