Skip to content

Commit f34c128

Browse files
committed
Return accidentally removed code
1 parent 948c524 commit f34c128

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
@@ -159,6 +159,18 @@ public interface Sardine
159159
*/
160160
List<DavResource> patch(String url, List<Element> addProps, List<QName> removeProps) throws IOException;
161161

162+
/**
163+
* Add or remove custom properties for a url using WebDAV <code>PROPPATCH</code>.
164+
*
165+
* @param url Path to the resource including protocol and hostname
166+
* @param addProps Properties to add to resource. If a property already exists then its value is replaced.
167+
* @param removeProps Properties to remove from resource. Specifying the removal of a property that does not exist is not an error.
168+
* @param headers Additional HTTP headers to add to the request
169+
* @return The patched resources from the response
170+
* @throws IOException I/O error or HTTP response validation failure
171+
*/
172+
List<DavResource> patch(String url, List<Element> addProps, List<QName> removeProps, Map<String, String> headers) throws IOException;
173+
162174
/**
163175
* Uses HTTP <code>GET</code> to download data from a server. The stream must be closed after reading.
164176
*
@@ -286,6 +298,15 @@ public interface Sardine
286298
*/
287299
void delete(String url) throws IOException;
288300

301+
/**
302+
* Delete a resource using HTTP <code>DELETE</code> at the specified url
303+
*
304+
* @param url Path to the resource including protocol and hostname
305+
* @param headers Additional HTTP headers to add to the request
306+
* @throws IOException I/O error or HTTP response validation failure
307+
*/
308+
void delete(String url, Map<String, String> headers) throws IOException;
309+
289310
/**
290311
* Uses WebDAV <code>MKCOL</code> to create a directory at the specified url
291312
*
@@ -343,6 +364,17 @@ public interface Sardine
343364
*/
344365
void copy(String sourceUrl, String destinationUrl, boolean overwrite) throws IOException;
345366

367+
/**
368+
* Copy a url from source to destination using WebDAV <code>COPY</code>.
369+
*
370+
* @param sourceUrl Path to the resource including protocol and hostname
371+
* @param destinationUrl Path to the resource including protocol and hostname
372+
* @param overwrite {@code true} to overwrite if the destination exists, {@code false} otherwise.
373+
* @param headers Additional HTTP headers to add to the request
374+
* @throws IOException I/O error or HTTP response validation failure
375+
*/
376+
void copy(String sourceUrl, String destinationUrl, boolean overwrite, Map<String, String> headers) throws IOException;
377+
346378
/**
347379
* Performs a HTTP <code>HEAD</code> request to see if a resource exists or not.
348380
*

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,17 @@ public List<DavResource> patch(String url, Map<QName, String> setProps, List<QNa
566566
@Override
567567
public List<DavResource> patch(String url, List<Element> setProps, List<QName> removeProps) throws IOException
568568
{
569+
return this.patch(url, setProps, removeProps, Collections.emptyMap());
570+
}
571+
572+
@Override
573+
public List<DavResource> patch(String url, List<Element> setProps, List<QName> removeProps, Map<String, String> headers) throws IOException
574+
{
575+
HttpPropPatch patch = new HttpPropPatch(url);
576+
for (Map.Entry<String, String> h : headers.entrySet())
577+
{
578+
patch.addHeader(new BasicHeader(h.getKey(), h.getValue()));
579+
}
569580
HttpPropPatch entity = new HttpPropPatch(url);
570581
// Build WebDAV <code>PROPPATCH</code> entity.
571582
Propertyupdate body = new Propertyupdate();
@@ -987,6 +998,12 @@ public void put(String url, File localFile, String contentType, boolean expectCo
987998

988999
@Override
9891000
public void delete(String url) throws IOException
1001+
{
1002+
this.delete(url, Collections.emptyMap());
1003+
}
1004+
1005+
@Override
1006+
public void delete(String url, Map<String, String> headers) throws IOException
9901007
{
9911008
HttpDelete delete = new HttpDelete(url);
9921009
this.execute(delete, new VoidResponseHandler());
@@ -1023,8 +1040,18 @@ public void copy(String sourceUrl, String destinationUrl) throws IOException
10231040

10241041
@Override
10251042
public void copy(String sourceUrl, String destinationUrl, boolean overwrite) throws IOException
1043+
{
1044+
this.copy(sourceUrl, destinationUrl, overwrite, Collections.emptyMap());
1045+
}
1046+
1047+
@Override
1048+
public void copy(String sourceUrl, String destinationUrl, boolean overwrite, Map<String, String> headers) throws IOException
10261049
{
10271050
HttpCopy copy = new HttpCopy(sourceUrl, destinationUrl, overwrite);
1051+
for (Map.Entry<String, String> h : headers.entrySet())
1052+
{
1053+
copy.addHeader(new BasicHeader(h.getKey(), h.getValue()));
1054+
}
10281055
this.execute(copy, new VoidResponseHandler());
10291056
}
10301057

0 commit comments

Comments
 (0)