comparison flys-client/src/main/java/de/intevation/flys/client/server/RiverServiceImpl.java @ 3496:f1814efec714

Replaced another attribute fetching XPath with a simple DOM getAttributeNS() call. flys-client/trunk@5215 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 16 Aug 2012 08:14:09 +0000
parents 4825950acf1e
children 98fac4872ae6
comparison
equal deleted inserted replaced
3495:e1ac8f5a2139 3496:f1814efec714
5 5
6 import javax.xml.xpath.XPathConstants; 6 import javax.xml.xpath.XPathConstants;
7 7
8 import org.w3c.dom.Document; 8 import org.w3c.dom.Document;
9 import org.w3c.dom.NodeList; 9 import org.w3c.dom.NodeList;
10 import org.w3c.dom.Node; 10 import org.w3c.dom.Element;
11 11
12 import org.apache.log4j.Logger; 12 import org.apache.log4j.Logger;
13 13
14 14
15 import de.intevation.artifacts.common.ArtifactNamespaceContext; 15 import de.intevation.artifacts.common.ArtifactNamespaceContext;
48 * the supported rivers from server.*/ 48 * the supported rivers from server.*/
49 public static final String ERROR_NO_RIVERS_FOUND = "error_no_rivers_found"; 49 public static final String ERROR_NO_RIVERS_FOUND = "error_no_rivers_found";
50 50
51 51
52 /** Get river list. */ 52 /** Get river list. */
53 @Override
53 public River[] list(String locale) 54 public River[] list(String locale)
54 throws ServerException 55 throws ServerException
55 { 56 {
56 String url = getServletContext().getInitParameter("server-url"); 57 String url = getServletContext().getInitParameter("server-url");
57 58
78 if (rivers == null || rivers.getLength() == 0) { 79 if (rivers == null || rivers.getLength() == 0) {
79 throw new ServerException(ERROR_NO_RIVERS_FOUND); 80 throw new ServerException(ERROR_NO_RIVERS_FOUND);
80 } 81 }
81 82
82 int count = rivers.getLength(); 83 int count = rivers.getLength();
83 int rcount = 0;
84 84
85 List<River> theRivers = new ArrayList<River>(count); 85 List<River> theRivers = new ArrayList<River>(count);
86 User user = this.getUser(); 86 User user = this.getUser();
87 87
88 for (int i = 0; i < count; i++) { 88 for (int i = 0; i < count; i++) {
89 Node tmp = rivers.item(i); 89 Element tmp = (Element)rivers.item(i);
90 90
91 String name = XMLUtils.xpathString( 91 String name = tmp.getAttributeNS(
92 tmp, "@art:name", ArtifactNamespaceContext.INSTANCE); 92 ArtifactNamespaceContext.NAMESPACE_URI, "name");
93 93
94 if (user == null || user.canUseFeature("river:" + name)) { 94 if (name.length() > 0
95 && (user == null || user.canUseFeature("river:" + name))) {
95 theRivers.add(new DefaultRiver(name)); 96 theRivers.add(new DefaultRiver(name));
96 rcount++;
97 } 97 }
98 } 98 }
99 99
100 return theRivers.toArray(new River[rcount]); 100 return theRivers.toArray(new River[theRivers.size()]);
101 } 101 }
102 catch (ConnectionException ce) { 102 catch (ConnectionException ce) {
103 logger.error(ce, ce); 103 logger.error(ce, ce);
104 } 104 }
105 105

http://dive4elements.wald.intevation.org