Mercurial > dive4elements > http-client
comparison src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java @ 12:5b62267a1c3c
The HttpClient got a new method that returns the InputStream of a Collection's OUT operation.
http-client/trunk@1857 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 09 May 2011 09:28:11 +0000 |
parents | ea8b7e244e61 |
children | 5cb8513b9e78 |
comparison
equal
deleted
inserted
replaced
11:ea8b7e244e61 | 12:5b62267a1c3c |
---|---|
393 String uuid, | 393 String uuid, |
394 String type, | 394 String type, |
395 OutputStream out) | 395 OutputStream out) |
396 throws ConnectionException | 396 throws ConnectionException |
397 { | 397 { |
398 String url = serverUrl + PATH_OUT_COLLECTION + "/" + uuid + "/" + type; | 398 try { |
399 | 399 InputStream stream = collectionOut(doc, uuid, type); |
400 ResponseHandler handler = new StreamResponseHandler(); | |
401 | |
402 try { | |
403 InputStream stream = (InputStream) handler.handle(doPost(url, doc)); | |
404 | 400 |
405 byte[] b = new byte[4096]; | 401 byte[] b = new byte[4096]; |
406 int i = -1; | 402 int i = -1; |
407 while ((i = stream.read(b)) > 0) { | 403 while ((i = stream.read(b)) > 0) { |
408 out.write(b, 0, i); | 404 out.write(b, 0, i); |
412 throw new ConnectionException(ioe.getMessage(), ioe); | 408 throw new ConnectionException(ioe.getMessage(), ioe); |
413 } | 409 } |
414 } | 410 } |
415 | 411 |
416 | 412 |
413 /** | |
414 * This method triggers the out() operation of a Collection. The result of | |
415 * this operation is returned as an InputStream. | |
416 * | |
417 * @param doc The request document for the out() operation. | |
418 * @param uuid The identifier of the Collection. | |
419 * @param type The name of the output type. | |
420 * | |
421 * @return an InputStream. | |
422 */ | |
423 public InputStream collectionOut( | |
424 Document doc, | |
425 String uuid, | |
426 String type) | |
427 throws ConnectionException | |
428 { | |
429 String url = serverUrl + PATH_OUT_COLLECTION + "/" + uuid + "/" + type; | |
430 | |
431 ResponseHandler handler = new StreamResponseHandler(); | |
432 | |
433 try { | |
434 return (InputStream) handler.handle(doPost(url, doc)); | |
435 } | |
436 catch (IOException ioe) { | |
437 throw new ConnectionException(ioe.getMessage(), ioe); | |
438 } | |
439 } | |
440 | |
441 | |
417 /******************************* | 442 /******************************* |
418 * Service API | 443 * Service API |
419 *******************************/ | 444 *******************************/ |
420 | 445 |
421 public Document callService(String url, String service, Document input) | 446 public Document callService(String url, String service, Document input) |