Skip to content

Commit

Permalink
Return accidentally removed code
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrusHahol committed Aug 20, 2024
1 parent 948c524 commit f34c128
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/main/java/com/github/sardine/Sardine.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ public interface Sardine
*/
List<DavResource> patch(String url, List<Element> addProps, List<QName> removeProps) throws IOException;

/**
* Add or remove custom properties for a url using WebDAV <code>PROPPATCH</code>.
*
* @param url Path to the resource including protocol and hostname
* @param addProps Properties to add to resource. If a property already exists then its value is replaced.
* @param removeProps Properties to remove from resource. Specifying the removal of a property that does not exist is not an error.
* @param headers Additional HTTP headers to add to the request
* @return The patched resources from the response
* @throws IOException I/O error or HTTP response validation failure
*/
List<DavResource> patch(String url, List<Element> addProps, List<QName> removeProps, Map<String, String> headers) throws IOException;

/**
* Uses HTTP <code>GET</code> to download data from a server. The stream must be closed after reading.
*
Expand Down Expand Up @@ -286,6 +298,15 @@ public interface Sardine
*/
void delete(String url) throws IOException;

/**
* Delete a resource using HTTP <code>DELETE</code> at the specified url
*
* @param url Path to the resource including protocol and hostname
* @param headers Additional HTTP headers to add to the request
* @throws IOException I/O error or HTTP response validation failure
*/
void delete(String url, Map<String, String> headers) throws IOException;

/**
* Uses WebDAV <code>MKCOL</code> to create a directory at the specified url
*
Expand Down Expand Up @@ -343,6 +364,17 @@ public interface Sardine
*/
void copy(String sourceUrl, String destinationUrl, boolean overwrite) throws IOException;

/**
* Copy a url from source to destination using WebDAV <code>COPY</code>.
*
* @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.
* @param headers Additional HTTP headers to add to the request
* @throws IOException I/O error or HTTP response validation failure
*/
void copy(String sourceUrl, String destinationUrl, boolean overwrite, Map<String, String> headers) throws IOException;

/**
* Performs a HTTP <code>HEAD</code> request to see if a resource exists or not.
*
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/com/github/sardine/impl/SardineImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,17 @@ public List<DavResource> patch(String url, Map<QName, String> setProps, List<QNa
@Override
public List<DavResource> patch(String url, List<Element> setProps, List<QName> removeProps) throws IOException
{
return this.patch(url, setProps, removeProps, Collections.emptyMap());
}

@Override
public List<DavResource> patch(String url, List<Element> setProps, List<QName> removeProps, Map<String, String> headers) throws IOException
{
HttpPropPatch patch = new HttpPropPatch(url);
for (Map.Entry<String, String> h : headers.entrySet())
{
patch.addHeader(new BasicHeader(h.getKey(), h.getValue()));
}
HttpPropPatch entity = new HttpPropPatch(url);
// Build WebDAV <code>PROPPATCH</code> entity.
Propertyupdate body = new Propertyupdate();
Expand Down Expand Up @@ -987,6 +998,12 @@ public void put(String url, File localFile, String contentType, boolean expectCo

@Override
public void delete(String url) throws IOException
{
this.delete(url, Collections.emptyMap());
}

@Override
public void delete(String url, Map<String, String> headers) throws IOException
{
HttpDelete delete = new HttpDelete(url);
this.execute(delete, new VoidResponseHandler());
Expand Down Expand Up @@ -1023,8 +1040,18 @@ public void copy(String sourceUrl, String destinationUrl) throws IOException

@Override
public void copy(String sourceUrl, String destinationUrl, boolean overwrite) throws IOException
{
this.copy(sourceUrl, destinationUrl, overwrite, Collections.emptyMap());
}

@Override
public void copy(String sourceUrl, String destinationUrl, boolean overwrite, Map<String, String> headers) throws IOException
{
HttpCopy copy = new HttpCopy(sourceUrl, destinationUrl, overwrite);
for (Map.Entry<String, String> h : headers.entrySet())
{
copy.addHeader(new BasicHeader(h.getKey(), h.getValue()));
}
this.execute(copy, new VoidResponseHandler());
}

Expand Down

0 comments on commit f34c128

Please sign in to comment.