Mercurial > dive4elements > http-client
diff src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java @ 5:7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
http-client/trunk@1430 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 08 Mar 2011 18:23:45 +0000 |
parents | 19b3ba7f2568 |
children | 09a84c6e263a |
line wrap: on
line diff
--- a/src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java Mon Mar 07 13:42:33 2011 +0000 +++ b/src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java Tue Mar 08 18:23:45 2011 +0000 @@ -45,6 +45,9 @@ /** The URL part of the resource to list the existing users of the server.*/ public static final String PATH_LIST_USERS = "/list-users"; + /** The URL part of the resource to call a specific service.*/ + public static final String PATH_SERVICE = "/service"; + /** The URL path of the resource to create new artifact collections.*/ public static final String PATH_CREATE_COLLECTION = "/create-collection"; @@ -260,8 +263,31 @@ /******************************* + * Service API + *******************************/ + + public Document callService(String url, String service, Document input) + throws ConnectionException + { + logger.info("Start service call to '" + service + "'"); + + DocumentResponseHandler handler = new DocumentResponseHandler(); + + try { + String serverUrl = url + PATH_SERVICE + "/" + service; + return (Document) handler.handle(doPost(serverUrl, input)); + } + catch (IOException ioe) { + throw new ConnectionException( + "Connection to server failed: " + ioe.getMessage()); + } + } + + + /******************************* * Users API *******************************/ + public Document listUsers() throws ConnectionException {