Skip to content

Commit 987ab04

Browse files
Merge pull request #1096 from nextcloud/feat/support-move-method
Implemented MOVE WebDAV method for SSO requests
2 parents fe2d220 + 4fd71b2 commit 987ab04

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public class MyActivity extends AppCompatActivity {
235235

236236
#### 5.3) **WebDAV**
237237

238-
Currently the following `WebDAV` Methods are supported: `PROPFIND` / `MKCOL`
238+
Currently the following `WebDAV` Methods are supported: `PROPFIND`, `MKCOL`, `MOVE`.
239239

240240
The following examples shows how to use the `PROPFIND` method with a depth of 0.
241241

@@ -251,6 +251,24 @@ final var nextcloudRequest = new NextcloudRequest.Builder()
251251
.build();
252252
```
253253

254+
For the `MOVE` method, the `Destination` and `Overwrite` params must be added:
255+
256+
```
257+
final var nextcloudRequest = new NextcloudRequest.Builder()
258+
.setMethod("MOVE")
259+
.setUrl(Uri.encode("/remote.php/webdav/" + remotePath, "/"))
260+
.setAdditionalParameter(
261+
NextcloudRequest.ADDITIONAL_PARAMETER_MOVE_DESTINATION,
262+
"/remote.php/webdav/" + destinationPath
263+
)
264+
.setAdditionalParameter(
265+
NextcloudRequest.ADDITIONAL_PARAMETER_MOVE_OVERWRITE,
266+
true
267+
)
268+
.build();
269+
```
270+
271+
254272
## Additional info
255273

256274
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:

‎lib/src/main/java/com/nextcloud/android/sso/aidl/NextcloudRequest.java‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.Serializable;
2222
import java.util.ArrayList;
2323
import java.util.Collection;
24+
import java.util.Collections;
2425
import java.util.HashMap;
2526
import java.util.LinkedList;
2627
import java.util.List;
@@ -34,9 +35,15 @@ public class NextcloudRequest implements Serializable {
3435

3536
private static final long serialVersionUID = 215521212534240L; //assign a long value
3637

38+
public static final String ADDITIONAL_PARAMETER_MOVE_DESTINATION = "Destination";
39+
public static final String ADDITIONAL_PARAMETER_MOVE_OVERWRITE = "Overwrite";
40+
41+
3742
private String method;
3843
private Map<String, List<String>> header = new HashMap<>();
3944
private Map<String, String> parameter = new HashMap<>();
45+
private Map<String, String> additionalParameter = new HashMap<>();
46+
4047
private String requestBody;
4148
private String url;
4249
private String token;
@@ -123,6 +130,16 @@ public Builder addParameter(QueryParam parameter) {
123130
return this;
124131
}
125132

133+
134+
public Builder setAdditionalParameters(Map<String, String> ap) {
135+
ncr.additionalParameter = ap;
136+
return this;
137+
}
138+
public Builder setAdditionalParameter(String key, String value) {
139+
ncr.additionalParameter.put(key, value);
140+
return this;
141+
}
142+
126143
private static void nullCheck(Object o) {
127144
if (o == null) {
128145
throw new IllegalArgumentException("null is not allowed here");
@@ -209,6 +226,13 @@ public Map<String, List<String>> getHeader() {
209226
return this.header;
210227
}
211228

229+
public Map<String, String> getAdditionalParameters() {
230+
return Collections.unmodifiableMap(this.additionalParameter);
231+
}
232+
public String getAdditionalParameter(String key) {
233+
return this.additionalParameter.get(key);
234+
}
235+
212236
public Collection<QueryParam> getParameterV2() {
213237
return this.parameterV2;
214238
}

0 commit comments

Comments
 (0)