# HG changeset patch # User Ingo Weinzierl # Date 1302175695 0 # Node ID 072e8d488f831c30c1017e0d5ff4eb5509e51e72 # Parent 77c09d0e2c2ed84eeec76d85cf37a078193cbe73 Enhanced the HttpClient with a method to trigger the out() operation of Collections. http-client/trunk@1654 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 77c09d0e2c2e -r 072e8d488f83 ChangeLog --- a/ChangeLog Wed Mar 30 13:46:07 2011 +0000 +++ b/ChangeLog Thu Apr 07 11:28:15 2011 +0000 @@ -1,3 +1,10 @@ +2011-04-07 Ingo Weinzierl + + * src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java, + src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java: + Added a method that triggers the out() operation of a Collection and + writes the result to an OutputStream. + 2011-03-30 Ingo Weinzierl Tagged RELEASE 0.1 diff -r 77c09d0e2c2e -r 072e8d488f83 src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java --- a/src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java Wed Mar 30 13:46:07 2011 +0000 +++ b/src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java Thu Apr 07 11:28:15 2011 +0000 @@ -75,6 +75,13 @@ ResponseHandler handler) throws ConnectionException; + void collectionOut( + Document outDocument, + String uuid, + String type, + OutputStream out) + throws ConnectionException; + /******************************* * Users API diff -r 77c09d0e2c2e -r 072e8d488f83 src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java --- a/src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java Wed Mar 30 13:46:07 2011 +0000 +++ b/src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java Thu Apr 07 11:28:15 2011 +0000 @@ -58,6 +58,9 @@ /** The URL path of the resource to work with an artifact collections.*/ public static final String PATH_ACTION_COLLECTION = "/collection"; + /** The URL path of the resource to work with an artifact collections.*/ + public static final String PATH_OUT_COLLECTION = "/collection"; + private String serverUrl; @@ -300,6 +303,42 @@ } + /** + * This method triggers the out() operation of a Collection. The result of + * this operation is written to out directly - there is no return + * value. + * + * @param doc The request document for the out() operation. + * @param uuid The identifier of the Collection. + * @param type The name of the output type. + * @param out The OutputStream. + */ + public void collectionOut( + Document doc, + String uuid, + String type, + OutputStream out) + throws ConnectionException + { + String url = serverUrl + PATH_OUT_COLLECTION + "/" + uuid + "/" + type; + + ResponseHandler handler = new StreamResponseHandler(); + + try { + InputStream stream = (InputStream) handler.handle(doPost(url, doc)); + + byte[] b = new byte[4096]; + int i = -1; + while ((i = stream.read(b)) > 0) { + out.write(b, 0, i); + } + } + catch (IOException ioe) { + throw new ConnectionException(ioe.getMessage(), ioe); + } + } + + /******************************* * Service API *******************************/