diff src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java @ 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
line wrap: on
line diff
--- 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