changeset 3515:70c0942156ad

Add service to list available modules for a user The new service returns a list of modules that a user is allowed to access. flys-client/trunk@5289 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Wed, 29 Aug 2012 10:43:36 +0000 (2012-08-29)
parents 1f293ada93d0
children f7b13fd59f05
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/services/ModuleService.java flys-client/src/main/java/de/intevation/flys/client/client/services/ModuleServiceAsync.java flys-client/src/main/java/de/intevation/flys/client/server/ModuleServiceImpl.java
diffstat 4 files changed, 100 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Wed Aug 29 10:39:16 2012 +0000
+++ b/flys-client/ChangeLog	Wed Aug 29 10:43:36 2012 +0000
@@ -1,3 +1,10 @@
+2012-08-30	Bj�rn Ricks	<bjoern.ricks@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/services/ModuleServiceAsync.java,
+	  src/main/java/de/intevation/flys/client/client/services/ModuleService.java,
+	  src/main/java/de/intevation/flys/client/server/ModuleServiceImpl.java:
+	  Added service to list available modules for a user.
+
 2012-08-30	Bj�rn Ricks	<bjoern.ricks@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/shared/model/DefaultModule.java,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/ModuleService.java	Wed Aug 29 10:43:36 2012 +0000
@@ -0,0 +1,21 @@
+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.model.Module;
+
+@RemoteServiceRelativePath("modules")
+public interface ModuleService extends RemoteService {
+
+    /**
+     * Returns the list of available modules of a user
+     *
+     * @param locale The locale used for the request
+     * @return a String array of all available modules
+     *
+     */
+    public Module[] list(String locale);
+}
+
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 tw=80 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/ModuleServiceAsync.java	Wed Aug 29 10:43:36 2012 +0000
@@ -0,0 +1,13 @@
+package de.intevation.flys.client.client.services;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+import de.intevation.flys.client.shared.model.Module;
+
+public interface ModuleServiceAsync {
+
+    public void list(String locale,
+        AsyncCallback<Module[]> callback);
+}
+
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 tw=80 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/ModuleServiceImpl.java	Wed Aug 29 10:43:36 2012 +0000
@@ -0,0 +1,59 @@
+package de.intevation.flys.client.server;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.flys.client.client.FLYSConstants;
+import de.intevation.flys.client.client.services.ModuleService;
+import de.intevation.flys.client.server.auth.User;
+import de.intevation.flys.client.shared.model.DefaultModule;
+import de.intevation.flys.client.shared.model.Module;
+
+public class ModuleServiceImpl
+extends      RemoteServiceServlet
+implements   ModuleService
+{
+    private static final Logger logger =
+        Logger.getLogger(ModuleServiceImpl.class);
+
+    /** Constant value for the WINFO plugin.*/
+    public static final String FIELD_PLUGIN_WINFO = "winfo";
+
+    /** Constant value for the MINFO plugin.*/
+    public static final String FIELD_PLUGIN_MINFO = "minfo";
+
+    /** Constant value for the MAP plugin.*/
+    public static final String FIELD_PLUGIN_MAP   = "new_map";
+
+    /** Constant value for the CHART plugin.*/
+    public static final String FIELD_PLUGIN_CHART = "new_chart";
+
+    /** Constant value for the FIX plugin.*/
+    public static final String FIELD_PLUGIN_FIX   = "fixanalysis";
+
+    @Override
+    public Module[] list(String locale) {
+        User user = this.getUser();
+
+        //TODO load modules from artifactserver
+        Module[] available = {
+            new DefaultModule(FIELD_PLUGIN_WINFO, "WINFO"),
+            new DefaultModule(FIELD_PLUGIN_MINFO, "MINFO"),
+            new DefaultModule(FIELD_PLUGIN_MAP,   "MAP"),
+            new DefaultModule(FIELD_PLUGIN_CHART, "CHART"),
+            new DefaultModule(FIELD_PLUGIN_FIX,   "FIX")
+        };
+
+        List<Module> modules = new ArrayList<Module>(available.length);
+        for(Module module : available) {
+            if (user == null || user.canUseFeature("module:" + module.getName())) {
+                modules.add(module);
+            }
+        }
+        return modules.toArray(new Module[modules.size()]);
+    }
+}
+
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 tw=80 :

http://dive4elements.wald.intevation.org