diff src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java @ 34:875a5c409560 2.8

Implemented a createUser method for HttpClient. With the new method its possible to create new users via the HttpClient. http-client/trunk@4993 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Fri, 13 Jul 2012 13:31:34 +0000
parents c4431f39926a
children 874c25363dc9
line wrap: on
line diff
--- a/src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java	Thu Apr 19 08:59:02 2012 +0000
+++ b/src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java	Fri Jul 13 13:31:34 2012 +0000
@@ -54,6 +54,9 @@
      * user.*/
     public static final String PATH_USER_COLLECTIONS = "/list-collections";
 
+    /** The URL part og the resource to create a new user on the server.*/
+    public static final String PATH_CREATE_USER = "/create-user";
+
     /** The URL part of the resource to call a specific service.*/
     public static final String PATH_SERVICE = "/service";
 
@@ -535,5 +538,21 @@
             throw new ConnectionException(ioe.getMessage(), ioe);
         }
     }
+
+    @Override
+    public Document createUser(Document doc)
+    throws ConnectionException {
+        ResponseHandler handler = new DocumentResponseHandler();
+
+        String url = this.serverUrl + PATH_CREATE_USER;
+
+        try {
+            return (Document) handler.handle(doPost(url, doc));
+        }
+        catch (IOException ioe) {
+            throw new ConnectionException(
+                "Connection to server failed: " + ioe.getMessage());
+        }
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org