diff flys-client/src/main/java/de/intevation/flys/client/server/RiverServiceImpl.java @ 3492:d45fcf70b994

Don't display not allowed rivers to the user Only return rivers that the user is allowed to see. Evaluate the allowed features of the current logged in user and hide rivers which aren't mentioned in the features list. flys-client/trunk@5208 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Wed, 15 Aug 2012 12:11:41 +0000
parents 0de61fc9d281
children 4825950acf1e
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/RiverServiceImpl.java	Wed Aug 15 12:08:20 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/RiverServiceImpl.java	Wed Aug 15 12:11:41 2012 +0000
@@ -11,7 +11,6 @@
 
 import org.apache.log4j.Logger;
 
-import com.google.gwt.user.server.rpc.RemoteServiceServlet;
 
 import de.intevation.artifacts.common.ArtifactNamespaceContext;
 import de.intevation.artifacts.common.utils.XMLUtils;
@@ -25,6 +24,8 @@
 import de.intevation.flys.client.shared.model.River;
 import de.intevation.flys.client.client.services.RiverService;
 
+import de.intevation.flys.client.server.auth.User;
+
 
 /**
  * This interface provides a method to list the supported rivers of the artifact
@@ -79,8 +80,10 @@
             }
 
             int count = rivers.getLength();
+            int rcount = 0;
 
             List<River> theRivers = new ArrayList<River>(count);
+            User user = this.getUser();
 
             for (int i = 0; i < count; i++) {
                 Node tmp = rivers.item(i);
@@ -88,10 +91,13 @@
                 String name = XMLUtils.xpathString(
                     tmp, "@art:name", ArtifactNamespaceContext.INSTANCE);
 
-                theRivers.add(new DefaultRiver(name));
+                if (user.canUseFeature("river:" + name)) {
+                    theRivers.add(new DefaultRiver(name));
+                    rcount++;
+                }
             }
 
-            return theRivers.toArray(new River[count]);
+            return theRivers.toArray(new River[rcount]);
         }
         catch (ConnectionException ce) {
             logger.error(ce, ce);

http://dive4elements.wald.intevation.org