# HG changeset patch # User Bjoern Ricks # Date 1342186294 0 # Node ID 875a5c4095605a5d39e01aa20b7f736a1084f495 # Parent 0d5ec0f2e6b540b4036a00043b05b16313126c45 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 diff -r 0d5ec0f2e6b5 -r 875a5c409560 ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/artifacts/httpclient/http/response/StringResponseHandler.java, diff -r 0d5ec0f2e6b5 -r 875a5c409560 src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.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: diff -r 0d5ec0f2e6b5 -r 875a5c409560 src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java --- 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: