changeset 3:19a617578b88

Added a new method to the HttpClient that triggers the creation of a new artifact collection. http-client/trunk@1398 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 04 Mar 2011 11:49:49 +0000
parents 2fdfa20cfa63
children 19b3ba7f2568
files ChangeLog src/main/java/de/intevation/artifacts/httpclient/exceptions/ConnectionException.java src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java
diffstat 4 files changed, 49 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Feb 17 11:19:02 2011 +0000
+++ b/ChangeLog	Fri Mar 04 11:49:49 2011 +0000
@@ -1,3 +1,12 @@
+2011-03-04  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:
+	  New method that creates a new artifact collection.
+
+	* src/main/java/de/intevation/artifacts/httpclient/exceptions/ConnectionException.java:
+	  New constructor added.
+
 2011-02-17  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/artifacts/httpclient/utils/ArtifactCreator.java:
--- a/src/main/java/de/intevation/artifacts/httpclient/exceptions/ConnectionException.java	Thu Feb 17 11:19:02 2011 +0000
+++ b/src/main/java/de/intevation/artifacts/httpclient/exceptions/ConnectionException.java	Fri Mar 04 11:49:49 2011 +0000
@@ -17,5 +17,9 @@
     public ConnectionException(String msg) {
         super(msg);
     }
+
+    public ConnectionException(String msg, Throwable throwable) {
+        super(msg, throwable);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
--- a/src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java	Thu Feb 17 11:19:02 2011 +0000
+++ b/src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java	Fri Mar 04 11:49:49 2011 +0000
@@ -28,6 +28,12 @@
     Object create(Document createDocument, ArtifactCreator creator)
     throws ConnectionException;
 
+    Object createCollection(
+        Document        createDocument,
+        String          ownerId,
+        ResponseHandler handler)
+    throws ConnectionException;
+
     Object describe(
         Artifact        artifact,
         Document        describeDocument,
--- a/src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java	Thu Feb 17 11:19:02 2011 +0000
+++ b/src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java	Fri Mar 04 11:49:49 2011 +0000
@@ -42,6 +42,9 @@
 
     private static final Logger logger = Logger.getLogger(HttpClient.class);
 
+    /** The URL path of the resource to create new artifact collections.*/
+    public static final String PATH_CREATE_COLLECTION = "/create-collection";
+
     private String serverUrl;
 
 
@@ -101,6 +104,33 @@
     }
 
 
+    /**
+     * This method triggers the artifact servers resource to create a new
+     * artifact collection.
+     *
+     * @param create The CREATE document for the collection.
+     * @param ownerId The uuid of the creator.
+     * @param handler The handler that is used to create the result object.
+     *
+     * @return a result object created by <i>handler</i>.
+     */
+    public Object createCollection(
+        Document        create,
+        String          ownerId,
+        ResponseHandler handler)
+    throws ConnectionException
+    {
+        String url = serverUrl + PATH_CREATE_COLLECTION + "/" + ownerId;
+
+        try {
+            return handler.handle(doPost(url, create));
+        }
+        catch (IOException ioe) {
+            throw new ConnectionException(ioe.getMessage(), ioe);
+        }
+    }
+
+
     @Override
     public Object describe(
         Artifact        artifact,

http://dive4elements.wald.intevation.org