diff src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java @ 6:09a84c6e263a

Enhanced the HttpClient with a method sto trigger a collection specific action. http-client/trunk@1552 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 23 Mar 2011 16:27:56 +0000
parents 7917c21fad01
children 06e9e25632cd
line wrap: on
line diff
--- a/src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java	Tue Mar 08 18:23:45 2011 +0000
+++ b/src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java	Wed Mar 23 16:27:56 2011 +0000
@@ -51,6 +51,9 @@
     /** The URL path of the resource to create new artifact collections.*/
     public static final String PATH_CREATE_COLLECTION = "/create-collection";
 
+    /** The URL path of the resource to work with an artifact collections.*/
+    public static final String PATH_ACTION_COLLECTION = "/collection";
+
     private String serverUrl;
 
 
@@ -110,33 +113,6 @@
     }
 
 
-    /**
-     * 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,
@@ -262,6 +238,64 @@
     }
 
 
+    //==============================
+    // Collection API
+    //==============================
+
+    /**
+     * 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);
+        }
+    }
+
+
+    /**
+     * This method might be used to trigger a collection specific action. The
+     * action that is executed depends on the document <i>actionDoc</i>.
+     *
+     * @param actionDoc The document that describes the action to be executed.
+     * @param uuid      The uuid of the collection.
+     * @param handler   The handler that is used to create the result object.
+     *
+     * @return a result object created by <i>handler</i>.
+     */
+    public Object doCollectionAction(
+        Document        actionDoc,
+        String          uuid,
+        ResponseHandler handler)
+    throws ConnectionException
+    {
+        String url = serverUrl + PATH_ACTION_COLLECTION + "/" + uuid;
+
+        try {
+            return handler.handle(doPost(url, actionDoc));
+        }
+        catch (IOException ioe) {
+            throw new ConnectionException(ioe.getMessage(), ioe);
+        }
+    }
+
+
     /*******************************
      * Service API
      *******************************/

http://dive4elements.wald.intevation.org