diff --git a/src/main/java/com/thegrizzlylabs/sardineandroid/Sardine.java b/src/main/java/com/thegrizzlylabs/sardineandroid/Sardine.java index 1a6fc5d..97ea98e 100755 --- a/src/main/java/com/thegrizzlylabs/sardineandroid/Sardine.java +++ b/src/main/java/com/thegrizzlylabs/sardineandroid/Sardine.java @@ -315,6 +315,16 @@ public interface Sardine */ void move(String sourceUrl, String destinationUrl, boolean overwrite) throws IOException; + /** + * Move a url to from source to destination using WebDAV MOVE. + * + * @param sourceUrl Path to the resource including protocol and hostname + * @param destinationUrl Path to the resource including protocol and hostname + * @param overwrite {@code true} to overwrite if the destination exists, {@code false} otherwise. + * @throws IOException I/O error or HTTP response validation failure + */ + void move(String sourceUrl, String destinationUrl, boolean overwrite, String lockTocken) throws IOException; + /** * Copy a url from source to destination using WebDAV COPY. Assumes overwrite. * diff --git a/src/main/java/com/thegrizzlylabs/sardineandroid/impl/OkHttpSardine.java b/src/main/java/com/thegrizzlylabs/sardineandroid/impl/OkHttpSardine.java index dac1a4e..d95c32b 100644 --- a/src/main/java/com/thegrizzlylabs/sardineandroid/impl/OkHttpSardine.java +++ b/src/main/java/com/thegrizzlylabs/sardineandroid/impl/OkHttpSardine.java @@ -349,12 +349,20 @@ public void move(String sourceUrl, String destinationUrl) throws IOException { @Override public void move(String sourceUrl, String destinationUrl, boolean overwrite) throws IOException { - Request request = new Request.Builder() + move(sourceUrl, destinationUrl, overwrite, null); + } + + @Override + public void move(String sourceUrl, String destinationUrl, boolean overwrite, String lockToken) throws IOException { + Request.Builder buildsr = new Request.Builder() .url(sourceUrl) .method("MOVE", null) .header("DESTINATION", URI.create(destinationUrl).toASCIIString()) - .header("OVERWRITE", overwrite ? "T" : "F") - .build(); + .header("OVERWRITE", overwrite ? "T" : "F"); + if (lockToken != null) { + buildsr.header("If", "<" + destinationUrl + "> (<" + lockToken + ">)"); + } + Request request = buildsr.build(); execute(request); }