diff --git a/README.md b/README.md index ef477196b..889888431 100644 --- a/README.md +++ b/README.md @@ -235,7 +235,7 @@ public class MyActivity extends AppCompatActivity { #### 5.3) **WebDAV** -Currently the following `WebDAV` Methods are supported: `PROPFIND` / `MKCOL` +Currently the following `WebDAV` Methods are supported: `PROPFIND`, `MKCOL`, `MOVE`. The following examples shows how to use the `PROPFIND` method with a depth of 0. @@ -251,6 +251,24 @@ final var nextcloudRequest = new NextcloudRequest.Builder() .build(); ``` +For the `MOVE` method, the `Destination` and `Overwrite` params must be added: + +``` +final var nextcloudRequest = new NextcloudRequest.Builder() + .setMethod("MOVE") + .setUrl(Uri.encode("/remote.php/webdav/" + remotePath, "/")) + .setAdditionalParameter( + NextcloudRequest.ADDITIONAL_PARAMETER_MOVE_DESTINATION, + "/remote.php/webdav/" + destinationPath + ) + .setAdditionalParameter( + NextcloudRequest.ADDITIONAL_PARAMETER_MOVE_OVERWRITE, + true + ) + .build(); +``` + + ## Additional info In case that you require some SSO features that were introduced in a specific Nextcloud Files app version, you can run a simple version check using the following helper method: diff --git a/lib/src/main/java/com/nextcloud/android/sso/aidl/NextcloudRequest.java b/lib/src/main/java/com/nextcloud/android/sso/aidl/NextcloudRequest.java index 3aea3889c..ef57d6dfc 100644 --- a/lib/src/main/java/com/nextcloud/android/sso/aidl/NextcloudRequest.java +++ b/lib/src/main/java/com/nextcloud/android/sso/aidl/NextcloudRequest.java @@ -34,9 +34,15 @@ public class NextcloudRequest implements Serializable { private static final long serialVersionUID = 215521212534240L; //assign a long value + public static final String ADDITIONAL_PARAMETER_MOVE_DESTINATION = "Destination"; + public static final String ADDITIONAL_PARAMETER_MOVE_OVERWRITE = "Overwrite"; + + private String method; private Map> header = new HashMap<>(); private Map parameter = new HashMap<>(); + private Map additionalParameter = new HashMap<>(); + private String requestBody; private String url; private String token; @@ -123,6 +129,16 @@ public Builder addParameter(QueryParam parameter) { return this; } + + public Builder setAdditionalParameters(Map ap) { + ncr.additionalParameter = ap; + return this; + } + public Builder setAdditionalParameter(String key, String value) { + ncr.additionalParameter.put(key, value); + return this; + } + private static void nullCheck(Object o) { if (o == null) { throw new IllegalArgumentException("null is not allowed here"); @@ -209,6 +225,13 @@ public Map> getHeader() { return this.header; } + public Map getAdditionalParameters() { + return this.additionalParameter; + } + public String getAdditionalParameter(String key) { + return this.additionalParameter.get(key); + } + public Collection getParameterV2() { return this.parameterV2; }