changeset 598:031357c3e23e

Added stubs to set the name and ttl of a collection and to delete a collection. flys-client/trunk@2202 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 22 Jun 2011 11:47:07 +0000
parents 14e5e51a7de4
children 1dbffe4c6d12
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/services/DeleteCollectionService.java flys-client/src/main/java/de/intevation/flys/client/client/services/DeleteCollectionServiceAsync.java flys-client/src/main/java/de/intevation/flys/client/client/services/SetCollectionNameService.java flys-client/src/main/java/de/intevation/flys/client/client/services/SetCollectionNameServiceAsync.java flys-client/src/main/java/de/intevation/flys/client/client/services/SetCollectionTTLService.java flys-client/src/main/java/de/intevation/flys/client/client/services/SetCollectionTTLServiceAsync.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java flys-client/src/main/java/de/intevation/flys/client/server/DeleteCollectionServiceImpl.java flys-client/src/main/java/de/intevation/flys/client/server/SetCollectionNameServiceImpl.java flys-client/src/main/java/de/intevation/flys/client/server/SetCollectionTTLServiceImpl.java flys-client/src/main/webapp/WEB-INF/web.xml
diffstat 12 files changed, 381 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Wed Jun 22 10:14:57 2011 +0000
+++ b/flys-client/ChangeLog	Wed Jun 22 11:47:07 2011 +0000
@@ -1,3 +1,32 @@
+2011-06-22  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/services/SetCollectionNameServiceAsync.java,
+	  src/main/java/de/intevation/flys/client/client/services/SetCollectionNameService.java,
+	  src/main/java/de/intevation/flys/client/server/SetCollectionNameServiceImpl.java:
+	  New. This service is used to set the name of a collection. Note, that
+	  this is currently just a stub. The ServiceImpl currently throws a "NOT
+	  IMPLEMENTED" exception.
+
+	* src/main/java/de/intevation/flys/client/client/services/SetCollectionTTLServiceAsync.java,
+	  src/main/java/de/intevation/flys/client/client/services/SetCollectionTTLService.java,
+	  src/main/java/de/intevation/flys/client/server/SetCollectionTTLServiceImpl.java:
+	  New. This service is used to set the time-to-live of a collection. Note,
+	  that this is currently just a stub. The ServiceImpl currently throws a
+	  "NOT IMPLEMENTED" exception.
+
+	* src/main/java/de/intevation/flys/client/client/services/DeleteCollectionServiceAsync.java,
+	  src/main/java/de/intevation/flys/client/client/services/DeleteCollectionService.java,
+	  src/main/java/de/intevation/flys/client/server/DeleteCollectionServiceImpl.java:
+	  New. This service is used to delete a collection. Note, that this is
+	  currently just a stub. The ServiceImpl currently throws a "NOT
+	  IMPLEMENTED" exception.
+
+	* src/main/java/de/intevation/flys/client/client/ui/ProjectList.java:
+	  Calls the services SetCollectionTTLService, SetCollectionNameService and
+	  DeleteCollectionService and display a warning if an error occured.
+
+	* src/main/webapp/WEB-INF/web.xml: Registered the new services.
+
 2011-06-22  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/DeleteCollectionService.java	Wed Jun 22 11:47:07 2011 +0000
@@ -0,0 +1,28 @@
+package de.intevation.flys.client.client.services;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
+
+import de.intevation.flys.client.shared.exceptions.ServerException;
+import de.intevation.flys.client.shared.model.Collection;
+
+
+/**
+ * This interface describes the service to add an existing artifact to an
+ * existing collection.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+@RemoteServiceRelativePath("delete-collection")
+public interface DeleteCollectionService extends RemoteService {
+
+    /**
+     * Deletes a collection.
+     *
+     * @param collection The Collection that should be deleted.
+     * @param url        The url of the artifact server.
+     */
+    void delete(Collection collection, String url)
+    throws ServerException;
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/DeleteCollectionServiceAsync.java	Wed Jun 22 11:47:07 2011 +0000
@@ -0,0 +1,18 @@
+package de.intevation.flys.client.client.services;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+import de.intevation.flys.client.shared.model.Collection;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public interface DeleteCollectionServiceAsync {
+
+    public void delete(
+        Collection          collection,
+        String              url,
+        AsyncCallback<Void> callback);
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/SetCollectionNameService.java	Wed Jun 22 11:47:07 2011 +0000
@@ -0,0 +1,28 @@
+package de.intevation.flys.client.client.services;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
+
+import de.intevation.flys.client.shared.exceptions.ServerException;
+import de.intevation.flys.client.shared.model.Collection;
+
+
+/**
+ * This interface describes the service to add an existing artifact to an
+ * existing collection.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+@RemoteServiceRelativePath("set-collectionname")
+public interface SetCollectionNameService extends RemoteService {
+
+    /**
+     * Set the name of a collection.
+     *
+     * @param collection The Collection that should be extended.
+     * @param url        The url of the artifact server.
+     */
+    void setName(Collection collection, String url)
+    throws ServerException;
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/SetCollectionNameServiceAsync.java	Wed Jun 22 11:47:07 2011 +0000
@@ -0,0 +1,18 @@
+package de.intevation.flys.client.client.services;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+import de.intevation.flys.client.shared.model.Collection;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public interface SetCollectionNameServiceAsync {
+
+    public void setName(
+        Collection          collection,
+        String              url,
+        AsyncCallback<Void> callback);
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/SetCollectionTTLService.java	Wed Jun 22 11:47:07 2011 +0000
@@ -0,0 +1,19 @@
+package de.intevation.flys.client.client.services;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
+
+import de.intevation.flys.client.shared.exceptions.ServerException;
+import de.intevation.flys.client.shared.model.Collection;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+@RemoteServiceRelativePath("set-collectionttl")
+public interface SetCollectionTTLService extends RemoteService {
+
+    void setTTL(Collection c, String url)
+    throws ServerException;
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/SetCollectionTTLServiceAsync.java	Wed Jun 22 11:47:07 2011 +0000
@@ -0,0 +1,18 @@
+package de.intevation.flys.client.client.services;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+import de.intevation.flys.client.shared.model.Collection;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public interface SetCollectionTTLServiceAsync {
+
+    public void setTTL(
+        Collection          collection,
+        String              url,
+        AsyncCallback<Void> callback);
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java	Wed Jun 22 10:14:57 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java	Wed Jun 22 11:47:07 2011 +0000
@@ -2,6 +2,7 @@
 
 import java.util.Date;
 import java.util.Map;
+import java.util.MissingResourceException;
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.i18n.client.DateTimeFormat;
@@ -43,6 +44,12 @@
 import de.intevation.flys.client.client.FLYSConstants;
 import de.intevation.flys.client.client.event.CollectionChangeEvent;
 import de.intevation.flys.client.client.event.CollectionChangeHandler;
+import de.intevation.flys.client.client.services.DeleteCollectionService;
+import de.intevation.flys.client.client.services.DeleteCollectionServiceAsync;
+import de.intevation.flys.client.client.services.SetCollectionNameService;
+import de.intevation.flys.client.client.services.SetCollectionNameServiceAsync;
+import de.intevation.flys.client.client.services.SetCollectionTTLService;
+import de.intevation.flys.client.client.services.SetCollectionTTLServiceAsync;
 import de.intevation.flys.client.client.services.UserCollectionsService;
 import de.intevation.flys.client.client.services.UserCollectionsServiceAsync;
 
@@ -69,6 +76,18 @@
     protected UserCollectionsServiceAsync userCollectionsService =
         GWT.create(UserCollectionsService.class);
 
+    /** The service used to set the name of a project.*/
+    protected SetCollectionNameServiceAsync nameService =
+        GWT.create(SetCollectionNameService.class);
+
+    /** The service used to set the name of a project.*/
+    protected SetCollectionTTLServiceAsync ttlService =
+        GWT.create(SetCollectionTTLService.class);
+
+    /** The service used to set the name of a project.*/
+    protected DeleteCollectionServiceAsync deleteService =
+        GWT.create(DeleteCollectionService.class);
+
     /** A pointer to the FLYS instance.*/
     protected FLYS flys;
 
@@ -210,7 +229,7 @@
         MenuItem del = new MenuItem(messages.delete_project());
         del.addClickHandler(new ClickHandler() {
             public void onClick(MenuItemClickEvent evt) {
-                SC.warn("Removing projects is not implemented.");
+                deleteCollection(record.getCollection());
             }
         });
 
@@ -303,7 +322,23 @@
         GWT.log("Update Collection name: " + c.identifier());
         GWT.log("=> New name = " + c.getName());
 
-        // TODO IMPLEMENT ME
+        Config config = Config.getInstance();
+        nameService.setName(c, config.getServerUrl(), new AsyncCallback<Void>(){
+            public void onFailure(Throwable caught) {
+                String msg = caught.getMessage();
+
+                try {
+                    SC.warn(messages.getString(msg));
+                }
+                catch (MissingResourceException mre) {
+                    SC.warn(msg);
+                }
+            }
+
+            public void onSuccess(Void v) {
+                updateUserCollections();
+            }
+        });
     }
 
 
@@ -321,7 +356,55 @@
         GWT.log("Update Collection TTL: " + c.identifier());
         GWT.log("=> New ttl = " + c.getTTL());
 
-        // TODO IMPLEMENT ME
+        Config config = Config.getInstance();
+        ttlService.setTTL(c, config.getServerUrl(), new AsyncCallback<Void>() {
+            public void onFailure(Throwable caught) {
+                String msg = caught.getMessage();
+
+                try {
+                    SC.warn(messages.getString(msg));
+                }
+                catch (MissingResourceException mre) {
+                    SC.warn(msg);
+                }
+            }
+
+            public void onSuccess(Void v) {
+                updateUserCollections();
+            }
+        });
+    }
+
+
+    /**
+     * Delete the collection <i>c</i>.
+     *
+     * @param c The Collection that should be deleted.
+     */
+    protected void deleteCollection(Collection c) {
+        if (c == null) {
+            return;
+        }
+
+        GWT.log("Delete Collection: " + c.identifier());
+
+        Config config = Config.getInstance();
+        deleteService.delete(c, config.getServerUrl(), new AsyncCallback<Void>(){
+            public void onFailure(Throwable caught) {
+                String msg = caught.getMessage();
+
+                try {
+                    SC.warn(messages.getString(msg));
+                }
+                catch (MissingResourceException mre) {
+                    SC.warn(msg);
+                }
+            }
+
+            public void onSuccess(Void v) {
+                updateUserCollections();
+            }
+        });
     }
 
 
@@ -335,8 +418,14 @@
         userCollectionsService.getUserCollections(url, locale, user.identifier(),
             new AsyncCallback<Collection[]>() {
                 public void onFailure(Throwable caught) {
-                    GWT.log("Could not recieve a list of user collections.");
-                    GWT.log(caught.getMessage());
+                    String msg = caught.getMessage();
+
+                    try {
+                        SC.warn(messages.getString(msg));
+                    }
+                    catch (MissingResourceException mre) {
+                        SC.warn(msg);
+                    }
                 }
 
                 public void onSuccess(Collection[] collections) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/DeleteCollectionServiceImpl.java	Wed Jun 22 11:47:07 2011 +0000
@@ -0,0 +1,33 @@
+package de.intevation.flys.client.server;
+
+import org.w3c.dom.Document;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+import de.intevation.artifacts.common.utils.ClientProtocolUtils;
+
+import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
+import de.intevation.artifacts.httpclient.http.HttpClient;
+import de.intevation.artifacts.httpclient.http.HttpClientImpl;
+import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler;
+
+import de.intevation.flys.client.shared.exceptions.ServerException;
+import de.intevation.flys.client.shared.model.Collection;
+import de.intevation.flys.client.client.services.DeleteCollectionService;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class DeleteCollectionServiceImpl
+extends      RemoteServiceServlet
+implements   DeleteCollectionService
+{
+    public void delete(Collection c, String url)
+    throws ServerException
+    {
+        // TODO IMPLEMENT ME
+        throw new ServerException("Delete Service NOT IMPLEMENTED");
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/SetCollectionNameServiceImpl.java	Wed Jun 22 11:47:07 2011 +0000
@@ -0,0 +1,33 @@
+package de.intevation.flys.client.server;
+
+import org.w3c.dom.Document;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+import de.intevation.artifacts.common.utils.ClientProtocolUtils;
+
+import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
+import de.intevation.artifacts.httpclient.http.HttpClient;
+import de.intevation.artifacts.httpclient.http.HttpClientImpl;
+import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler;
+
+import de.intevation.flys.client.shared.exceptions.ServerException;
+import de.intevation.flys.client.shared.model.Collection;
+import de.intevation.flys.client.client.services.SetCollectionNameService;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class SetCollectionNameServiceImpl
+extends      RemoteServiceServlet
+implements   SetCollectionNameService
+{
+    public void setName(Collection c, String url)
+    throws ServerException
+    {
+        // TODO IMPLEMENT ME
+        throw new ServerException("Name Service NOT IMPLEMENTED");
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/SetCollectionTTLServiceImpl.java	Wed Jun 22 11:47:07 2011 +0000
@@ -0,0 +1,33 @@
+package de.intevation.flys.client.server;
+
+import org.w3c.dom.Document;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+import de.intevation.artifacts.common.utils.ClientProtocolUtils;
+
+import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
+import de.intevation.artifacts.httpclient.http.HttpClient;
+import de.intevation.artifacts.httpclient.http.HttpClientImpl;
+import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler;
+
+import de.intevation.flys.client.shared.exceptions.ServerException;
+import de.intevation.flys.client.shared.model.Collection;
+import de.intevation.flys.client.client.services.SetCollectionTTLService;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class SetCollectionTTLServiceImpl
+extends      RemoteServiceServlet
+implements   SetCollectionTTLService
+{
+    public void setTTL(Collection c, String url)
+    throws ServerException
+    {
+        // TODO IMPLEMENT ME
+        throw new ServerException("TTL Service NOT IMPLEMENTED");
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/webapp/WEB-INF/web.xml	Wed Jun 22 10:14:57 2011 +0000
+++ b/flys-client/src/main/webapp/WEB-INF/web.xml	Wed Jun 22 11:47:07 2011 +0000
@@ -187,6 +187,36 @@
     <url-pattern>/flys/chart-info</url-pattern>
   </servlet-mapping>
 
+  <servlet>
+    <servlet-name>SetCollectionNameService</servlet-name>
+    <servlet-class>de.intevation.flys.client.server.SetCollectionNameServiceImpl</servlet-class>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>SetCollectionNameService</servlet-name>
+    <url-pattern>/flys/set-collectionname</url-pattern>
+  </servlet-mapping>
+
+  <servlet>
+    <servlet-name>SetCollectionTTLService</servlet-name>
+    <servlet-class>de.intevation.flys.client.server.SetCollectionTTLServiceImpl</servlet-class>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>SetCollectionTTLService</servlet-name>
+    <url-pattern>/flys/set-collectionttl</url-pattern>
+  </servlet-mapping>
+
+  <servlet>
+    <servlet-name>DeleteCollectionService</servlet-name>
+    <servlet-class>de.intevation.flys.client.server.DeleteCollectionServiceImpl</servlet-class>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>DeleteCollectionService</servlet-name>
+    <url-pattern>/flys/delete-collection</url-pattern>
+  </servlet-mapping>
+
   <!-- Default page to serve -->
   <welcome-file-list>
     <welcome-file>FLYS.html</welcome-file>

http://dive4elements.wald.intevation.org