# HG changeset patch # User Ingo Weinzierl # Date 1299608625 0 # Node ID 7917c21fad01d8252d8d9457ba9c887fab671895 # Parent 19b3ba7f2568375a930e56fa3c7dd68e91311bd3 Enabled the HttpClient to call services that are registered at the artifact server. http-client/trunk@1430 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 19b3ba7f2568 -r 7917c21fad01 ChangeLog --- a/ChangeLog Mon Mar 07 13:42:33 2011 +0000 +++ b/ChangeLog Tue Mar 08 18:23:45 2011 +0000 @@ -1,3 +1,10 @@ +2011-03-08 Ingo Weinzierl + + * src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java, + src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java: + Enabled the HttpClient to call services registered at the artifact server + by calling callService(). + 2011-03-07 Ingo Weinzierl * src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java, diff -r 19b3ba7f2568 -r 7917c21fad01 src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java --- a/src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java Mon Mar 07 13:42:33 2011 +0000 +++ b/src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java Tue Mar 08 18:23:45 2011 +0000 @@ -52,8 +52,17 @@ /******************************* + * Service API + *******************************/ + + Document callService(String url, String service, Document input) + throws ConnectionException; + + + /******************************* * Collections API *******************************/ + Object createCollection( Document createDocument, String ownerId, @@ -64,6 +73,7 @@ /******************************* * Users API *******************************/ + Document listUsers() throws ConnectionException; } diff -r 19b3ba7f2568 -r 7917c21fad01 src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java --- 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 {