Skip to content

Commit 5b1b208

Browse files
PetrusHaholdkocher
authored andcommitted
Return accidentally removed code
1 parent 1da0330 commit 5b1b208

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

src/main/java/com/github/sardine/Sardine.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,18 @@ public interface Sardine
190190
*/
191191
List<DavResource> patch(String url, List<Element> addProps, List<QName> removeProps) throws IOException;
192192

193+
/**
194+
* Add or remove custom properties for a url using WebDAV <code>PROPPATCH</code>.
195+
*
196+
* @param url Path to the resource including protocol and hostname
197+
* @param addProps Properties to add to resource. If a property already exists then its value is replaced.
198+
* @param removeProps Properties to remove from resource. Specifying the removal of a property that does not exist is not an error.
199+
* @param headers Additional HTTP headers to add to the request
200+
* @return The patched resources from the response
201+
* @throws IOException I/O error or HTTP response validation failure
202+
*/
203+
List<DavResource> patch(String url, List<Element> addProps, List<QName> removeProps, Map<String, String> headers) throws IOException;
204+
193205
/**
194206
* Uses HTTP <code>GET</code> to download data from a server. The stream must be closed after reading.
195207
*
@@ -328,6 +340,15 @@ public interface Sardine
328340
*/
329341
void delete(String url) throws IOException;
330342

343+
/**
344+
* Delete a resource using HTTP <code>DELETE</code> at the specified url
345+
*
346+
* @param url Path to the resource including protocol and hostname
347+
* @param headers Additional HTTP headers to add to the request
348+
* @throws IOException I/O error or HTTP response validation failure
349+
*/
350+
void delete(String url, Map<String, String> headers) throws IOException;
351+
331352
/**
332353
* Uses WebDAV <code>MKCOL</code> to create a directory at the specified url
333354
*
@@ -385,6 +406,17 @@ public interface Sardine
385406
*/
386407
void copy(String sourceUrl, String destinationUrl, boolean overwrite) throws IOException;
387408

409+
/**
410+
* Copy a url from source to destination using WebDAV <code>COPY</code>.
411+
*
412+
* @param sourceUrl Path to the resource including protocol and hostname
413+
* @param destinationUrl Path to the resource including protocol and hostname
414+
* @param overwrite {@code true} to overwrite if the destination exists, {@code false} otherwise.
415+
* @param headers Additional HTTP headers to add to the request
416+
* @throws IOException I/O error or HTTP response validation failure
417+
*/
418+
void copy(String sourceUrl, String destinationUrl, boolean overwrite, Map<String, String> headers) throws IOException;
419+
388420
/**
389421
* Performs a HTTP <code>HEAD</code> request to see if a resource exists or not.
390422
*

src/main/java/com/github/sardine/impl/SardineImpl.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,17 @@ public List<DavResource> patch(String url, Map<QName, String> setProps, List<QNa
527527
@Override
528528
public List<DavResource> patch(String url, List<Element> setProps, List<QName> removeProps) throws IOException
529529
{
530+
return this.patch(url, setProps, removeProps, Collections.emptyMap());
531+
}
532+
533+
@Override
534+
public List<DavResource> patch(String url, List<Element> setProps, List<QName> removeProps, Map<String, String> headers) throws IOException
535+
{
536+
HttpPropPatch patch = new HttpPropPatch(url);
537+
for (Map.Entry<String, String> h : headers.entrySet())
538+
{
539+
patch.addHeader(new BasicHeader(h.getKey(), h.getValue()));
540+
}
530541
HttpPropPatch entity = new HttpPropPatch(url);
531542
// Build WebDAV <code>PROPPATCH</code> entity.
532543
Propertyupdate body = new Propertyupdate();
@@ -970,6 +981,12 @@ public void put(String url, File localFile, String contentType, boolean expectCo
970981

971982
@Override
972983
public void delete(String url) throws IOException
984+
{
985+
this.delete(url, Collections.emptyMap());
986+
}
987+
988+
@Override
989+
public void delete(String url, Map<String, String> headers) throws IOException
973990
{
974991
HttpDelete delete = new HttpDelete(url);
975992
this.execute(delete, new VoidResponseHandler());
@@ -1006,8 +1023,18 @@ public void copy(String sourceUrl, String destinationUrl) throws IOException
10061023

10071024
@Override
10081025
public void copy(String sourceUrl, String destinationUrl, boolean overwrite) throws IOException
1026+
{
1027+
this.copy(sourceUrl, destinationUrl, overwrite, Collections.emptyMap());
1028+
}
1029+
1030+
@Override
1031+
public void copy(String sourceUrl, String destinationUrl, boolean overwrite, Map<String, String> headers) throws IOException
10091032
{
10101033
HttpCopy copy = new HttpCopy(sourceUrl, destinationUrl, overwrite);
1034+
for (Map.Entry<String, String> h : headers.entrySet())
1035+
{
1036+
copy.addHeader(new BasicHeader(h.getKey(), h.getValue()));
1037+
}
10111038
this.execute(copy, new VoidResponseHandler());
10121039
}
10131040

0 commit comments

Comments
 (0)