comparison 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
comparison
equal deleted inserted replaced
3491:1c9bfdbfb265 3492:d45fcf70b994
9 import org.w3c.dom.NodeList; 9 import org.w3c.dom.NodeList;
10 import org.w3c.dom.Node; 10 import org.w3c.dom.Node;
11 11
12 import org.apache.log4j.Logger; 12 import org.apache.log4j.Logger;
13 13
14 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
15 14
16 import de.intevation.artifacts.common.ArtifactNamespaceContext; 15 import de.intevation.artifacts.common.ArtifactNamespaceContext;
17 import de.intevation.artifacts.common.utils.XMLUtils; 16 import de.intevation.artifacts.common.utils.XMLUtils;
18 17
19 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; 18 import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
22 21
23 import de.intevation.flys.client.shared.exceptions.ServerException; 22 import de.intevation.flys.client.shared.exceptions.ServerException;
24 import de.intevation.flys.client.shared.model.DefaultRiver; 23 import de.intevation.flys.client.shared.model.DefaultRiver;
25 import de.intevation.flys.client.shared.model.River; 24 import de.intevation.flys.client.shared.model.River;
26 import de.intevation.flys.client.client.services.RiverService; 25 import de.intevation.flys.client.client.services.RiverService;
26
27 import de.intevation.flys.client.server.auth.User;
27 28
28 29
29 /** 30 /**
30 * This interface provides a method to list the supported rivers of the artifact 31 * This interface provides a method to list the supported rivers of the artifact
31 * server. 32 * server.
77 if (rivers == null || rivers.getLength() == 0) { 78 if (rivers == null || rivers.getLength() == 0) {
78 throw new ServerException(ERROR_NO_RIVERS_FOUND); 79 throw new ServerException(ERROR_NO_RIVERS_FOUND);
79 } 80 }
80 81
81 int count = rivers.getLength(); 82 int count = rivers.getLength();
83 int rcount = 0;
82 84
83 List<River> theRivers = new ArrayList<River>(count); 85 List<River> theRivers = new ArrayList<River>(count);
86 User user = this.getUser();
84 87
85 for (int i = 0; i < count; i++) { 88 for (int i = 0; i < count; i++) {
86 Node tmp = rivers.item(i); 89 Node tmp = rivers.item(i);
87 90
88 String name = XMLUtils.xpathString( 91 String name = XMLUtils.xpathString(
89 tmp, "@art:name", ArtifactNamespaceContext.INSTANCE); 92 tmp, "@art:name", ArtifactNamespaceContext.INSTANCE);
90 93
91 theRivers.add(new DefaultRiver(name)); 94 if (user.canUseFeature("river:" + name)) {
95 theRivers.add(new DefaultRiver(name));
96 rcount++;
97 }
92 } 98 }
93 99
94 return theRivers.toArray(new River[count]); 100 return theRivers.toArray(new River[rcount]);
95 } 101 }
96 catch (ConnectionException ce) { 102 catch (ConnectionException ce) {
97 logger.error(ce, ce); 103 logger.error(ce, ce);
98 } 104 }
99 105

http://dive4elements.wald.intevation.org