changeset 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
files ChangeLog src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java
diffstat 3 files changed, 43 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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 <ingo@intevation.de>
+
+	* 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 <ingo@intevation.de>
 
 	* src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.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;
 }
--- 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
     {

http://dive4elements.wald.intevation.org