Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/ModuleServiceImpl.java @ 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 |
parents | |
children | 40ddd713d9fd |
comparison
equal
deleted
inserted
replaced
3514:1f293ada93d0 | 3515:70c0942156ad |
---|---|
1 package de.intevation.flys.client.server; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import org.apache.log4j.Logger; | |
7 | |
8 import de.intevation.flys.client.client.FLYSConstants; | |
9 import de.intevation.flys.client.client.services.ModuleService; | |
10 import de.intevation.flys.client.server.auth.User; | |
11 import de.intevation.flys.client.shared.model.DefaultModule; | |
12 import de.intevation.flys.client.shared.model.Module; | |
13 | |
14 public class ModuleServiceImpl | |
15 extends RemoteServiceServlet | |
16 implements ModuleService | |
17 { | |
18 private static final Logger logger = | |
19 Logger.getLogger(ModuleServiceImpl.class); | |
20 | |
21 /** Constant value for the WINFO plugin.*/ | |
22 public static final String FIELD_PLUGIN_WINFO = "winfo"; | |
23 | |
24 /** Constant value for the MINFO plugin.*/ | |
25 public static final String FIELD_PLUGIN_MINFO = "minfo"; | |
26 | |
27 /** Constant value for the MAP plugin.*/ | |
28 public static final String FIELD_PLUGIN_MAP = "new_map"; | |
29 | |
30 /** Constant value for the CHART plugin.*/ | |
31 public static final String FIELD_PLUGIN_CHART = "new_chart"; | |
32 | |
33 /** Constant value for the FIX plugin.*/ | |
34 public static final String FIELD_PLUGIN_FIX = "fixanalysis"; | |
35 | |
36 @Override | |
37 public Module[] list(String locale) { | |
38 User user = this.getUser(); | |
39 | |
40 //TODO load modules from artifactserver | |
41 Module[] available = { | |
42 new DefaultModule(FIELD_PLUGIN_WINFO, "WINFO"), | |
43 new DefaultModule(FIELD_PLUGIN_MINFO, "MINFO"), | |
44 new DefaultModule(FIELD_PLUGIN_MAP, "MAP"), | |
45 new DefaultModule(FIELD_PLUGIN_CHART, "CHART"), | |
46 new DefaultModule(FIELD_PLUGIN_FIX, "FIX") | |
47 }; | |
48 | |
49 List<Module> modules = new ArrayList<Module>(available.length); | |
50 for(Module module : available) { | |
51 if (user == null || user.canUseFeature("module:" + module.getName())) { | |
52 modules.add(module); | |
53 } | |
54 } | |
55 return modules.toArray(new Module[modules.size()]); | |
56 } | |
57 } | |
58 | |
59 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 tw=80 : |