changeset 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 0d5ec0f2e6b5
children c8420b732201
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, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Apr 19 08:59:02 2012 +0000
+++ b/ChangeLog	Fri Jul 13 13:31:34 2012 +0000
@@ -1,3 +1,10 @@
+2012-07-13	Björn Ricks	<bjoern.ricks@intevation.de>
+
+	* src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java
+	  src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java:
+	  Implemented a createUser method for HttpClient.
+	  With the new method its possible to create new users via the HttpClient.
+
 2012-04-16	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/artifacts/httpclient/http/response/StringResponseHandler.java,
--- a/src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java	Thu Apr 19 08:59:02 2012 +0000
+++ b/src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java	Fri Jul 13 13:31:34 2012 +0000
@@ -106,5 +106,8 @@
 
     Document listUserCollections(String userid)
     throws ConnectionException;
+
+    Document createUser(Document doc)
+    throws ConnectionException;
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
--- 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