changeset 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
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, 73 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Mar 08 18:23:45 2011 +0000
+++ b/ChangeLog	Wed Mar 23 16:27:56 2011 +0000
@@ -1,3 +1,9 @@
+2011-03-23  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:
+	  Added a method to trigger a collection specific action.
+
 2011-03-08  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java,
--- a/src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java	Tue Mar 08 18:23:45 2011 +0000
+++ b/src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java	Wed Mar 23 16:27:56 2011 +0000
@@ -69,6 +69,12 @@
         ResponseHandler handler)
     throws ConnectionException;
 
+    Object doCollectionAction(
+        Document        actionDocument,
+        String          uuid,
+        ResponseHandler handler)
+    throws ConnectionException;
+
 
     /*******************************
      * Users API
--- 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