# HG changeset patch # User Bjoern Ricks # Date 1346237016 0 # Node ID 70c0942156addee88c0046144b52f39c876522b1 # Parent 1f293ada93d0ebfd1c1e6691d7fc263a183176c4 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 diff -r 1f293ada93d0 -r 70c0942156ad flys-client/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/client/shared/model/DefaultModule.java, diff -r 1f293ada93d0 -r 70c0942156ad flys-client/src/main/java/de/intevation/flys/client/client/services/ModuleService.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 : diff -r 1f293ada93d0 -r 70c0942156ad flys-client/src/main/java/de/intevation/flys/client/client/services/ModuleServiceAsync.java --- /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 callback); +} + +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 tw=80 : diff -r 1f293ada93d0 -r 70c0942156ad flys-client/src/main/java/de/intevation/flys/client/server/ModuleServiceImpl.java --- /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 modules = new ArrayList(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 :