Code pour la copie d'un document

6 views
Skip to first unread message

Olivier Duchâteau

unread,
Jun 11, 2017, 11:55:16 AM6/11/17
to LightCouch


Dans la classe CouchDbclientBase, j'ai ajouté :
       /**
* Copie le document
* @param id
* @param destinationId
* @return
*/
public Response copy(String id, String destinationId) {
return copy(getDBUri(), id, destinationId);
}
/**
* Performs a HTTP COPY request, duplique the document
* @return {@link Response}
*/
Response copy(URI uri, String id, String destinationId) {
assertNotEmpty(destinationId, "destinationID");
HttpResponse response = null;
try {  
final HttpCopy copy = new HttpCopy(buildUri(uri).path(id, true).build());
copy.addHeader("Destination", destinationId);
response = executeRequest(copy); 
return getResponse(response);
} finally {
close(response);
}
}


La méthode HttpCopy n'étant pas standard

package org.lightcouch;

import java.net.URI;

import org.apache.http.client.methods.HttpPut;

public class HttpCopy extends HttpPut {

public HttpCopy(final URI uri) {
        super(uri);
    }
@Override
public String getMethod() {
return "COPY";
}

}

Reply all
Reply to author
Forward
0 new messages