Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/server/GFIServiceImpl.java @ 8203:238fc722f87a
sed 's/logger/log/g' src/**/*.java
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 05 Sep 2014 13:19:22 +0200 |
parents | ea9eef426962 |
children | 5e38e2924c07 |
comparison
equal
deleted
inserted
replaced
8202:e4606eae8ea5 | 8203:238fc722f87a |
---|---|
53 | 53 |
54 public static final String ERR_PARSING_RESPONSE_FAILED = | 54 public static final String ERR_PARSING_RESPONSE_FAILED = |
55 "error_gfi_parsing_failed"; | 55 "error_gfi_parsing_failed"; |
56 | 56 |
57 | 57 |
58 private static final Logger logger = | 58 private static final Logger log = |
59 Logger.getLogger(GFIServiceImpl.class); | 59 Logger.getLogger(GFIServiceImpl.class); |
60 | 60 |
61 | 61 |
62 /** | 62 /** |
63 * @param theme | 63 * @param theme |
79 int width, | 79 int width, |
80 int x, | 80 int x, |
81 int y | 81 int y |
82 ) throws ServerException | 82 ) throws ServerException |
83 { | 83 { |
84 logger.info("GFIServiceImpl.query"); | 84 log.info("GFIServiceImpl.query"); |
85 | 85 |
86 String path = createGetFeautureInfoURL( | 86 String path = createGetFeautureInfoURL( |
87 theme, format, bbox, projection, height, width, x, y); | 87 theme, format, bbox, projection, height, width, x, y); |
88 | 88 |
89 logger.debug("URL=" + path); | 89 log.debug("URL=" + path); |
90 | 90 |
91 try { | 91 try { |
92 URL url = new URL(path); | 92 URL url = new URL(path); |
93 | 93 |
94 URLConnection conn = url.openConnection(); | 94 URLConnection conn = url.openConnection(); |
98 | 98 |
99 return parseResponse(is); | 99 return parseResponse(is); |
100 | 100 |
101 } | 101 } |
102 catch (IOException ioe) { | 102 catch (IOException ioe) { |
103 logger.warn(ioe, ioe); | 103 log.warn(ioe, ioe); |
104 } | 104 } |
105 | 105 |
106 throw new ServerException(ERR_GFI_REQUEST_FAILED); | 106 throw new ServerException(ERR_GFI_REQUEST_FAILED); |
107 } | 107 } |
108 | 108 |
167 return attr.getAttr("url"); | 167 return attr.getAttr("url"); |
168 } | 168 } |
169 | 169 |
170 | 170 |
171 protected FeatureInfoResponse parseResponse(InputStream is) { | 171 protected FeatureInfoResponse parseResponse(InputStream is) { |
172 logger.debug("GFIServiceImpl.parseResponse"); | 172 log.debug("GFIServiceImpl.parseResponse"); |
173 | 173 |
174 ByteArrayOutputStream baos = new ByteArrayOutputStream(); | 174 ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
175 byte [] buf = new byte[1024]; | 175 byte [] buf = new byte[1024]; |
176 | 176 |
177 int r = -1; | 177 int r = -1; |
178 try { | 178 try { |
179 while ((r = is.read(buf)) >= 0) { | 179 while ((r = is.read(buf)) >= 0) { |
180 baos.write(buf, 0, r); | 180 baos.write(buf, 0, r); |
181 } | 181 } |
182 } catch (IOException ex) { | 182 } catch (IOException ex) { |
183 logger.warn("GetFeatureInfo response could not be read: ", ex); | 183 log.warn("GetFeatureInfo response could not be read: ", ex); |
184 return new FeatureInfoResponse(); | 184 return new FeatureInfoResponse(); |
185 } | 185 } |
186 | 186 |
187 String content; | 187 String content; |
188 try { | 188 try { |
202 return new FeatureInfoResponse(new ArrayList<FeatureInfo>(), content); | 202 return new FeatureInfoResponse(new ArrayList<FeatureInfo>(), content); |
203 } | 203 } |
204 | 204 |
205 | 205 |
206 protected void parseFeatureInfos(Node node, List<FeatureInfo> features) { | 206 protected void parseFeatureInfos(Node node, List<FeatureInfo> features) { |
207 logger.debug("GFIServiceImpl.parseFeatureInfos"); | 207 log.debug("GFIServiceImpl.parseFeatureInfos"); |
208 | 208 |
209 String name = node.getNodeName(); | 209 String name = node.getNodeName(); |
210 | 210 |
211 if (name.endsWith("_layer")) { | 211 if (name.endsWith("_layer")) { |
212 features.add(parseFeature(node)); | 212 features.add(parseFeature(node)); |
223 } | 223 } |
224 } | 224 } |
225 | 225 |
226 | 226 |
227 protected FeatureInfo parseFeature(Node node) { | 227 protected FeatureInfo parseFeature(Node node) { |
228 logger.debug("GFIServiceImpl.parseFeature"); | 228 log.debug("GFIServiceImpl.parseFeature"); |
229 | 229 |
230 String layername = node.getNodeName(); | 230 String layername = node.getNodeName(); |
231 | 231 |
232 FeatureInfo f = new FeatureInfo(layername); | 232 FeatureInfo f = new FeatureInfo(layername); |
233 | 233 |
234 NodeList children = node.getChildNodes(); | 234 NodeList children = node.getChildNodes(); |
235 int numChildren = children != null ? children.getLength() : 0; | 235 int numChildren = children != null ? children.getLength() : 0; |
236 | 236 |
237 logger.debug("Feature '" + layername + "' has " + numChildren + " nodes."); | 237 log.debug("Feature '" + layername + "' has " + numChildren + " nodes."); |
238 | 238 |
239 for (int i = 0; i < numChildren; i++) { | 239 for (int i = 0; i < numChildren; i++) { |
240 Node tmp = children.item(i); | 240 Node tmp = children.item(i); |
241 String nodeName = tmp.getNodeName(); | 241 String nodeName = tmp.getNodeName(); |
242 | 242 |
243 logger.debug(" node name: '" + nodeName + "'"); | 243 log.debug(" node name: '" + nodeName + "'"); |
244 | 244 |
245 if (nodeName.equals("gml:name")) { | 245 if (nodeName.equals("gml:name")) { |
246 logger.debug("NAME node has child: " + tmp.getFirstChild().getNodeValue()); | 246 log.debug("NAME node has child: " + tmp.getFirstChild().getNodeValue()); |
247 f.setLayername(tmp.getFirstChild().getNodeValue()); | 247 f.setLayername(tmp.getFirstChild().getNodeValue()); |
248 } | 248 } |
249 else if (nodeName.endsWith("_feature")) { | 249 else if (nodeName.endsWith("_feature")) { |
250 parseFeatureAttributes(tmp, f); | 250 parseFeatureAttributes(tmp, f); |
251 } | 251 } |
254 return f; | 254 return f; |
255 } | 255 } |
256 | 256 |
257 | 257 |
258 protected void parseFeatureAttributes(Node node, FeatureInfo f) { | 258 protected void parseFeatureAttributes(Node node, FeatureInfo f) { |
259 logger.debug("GFIServiceImpl.parseFeatureAttributes"); | 259 log.debug("GFIServiceImpl.parseFeatureAttributes"); |
260 | 260 |
261 NodeList children = node.getChildNodes(); | 261 NodeList children = node.getChildNodes(); |
262 int numChildren = children != null ? children.getLength() : 0; | 262 int numChildren = children != null ? children.getLength() : 0; |
263 | 263 |
264 logger.debug("Has " + numChildren + " attributes."); | 264 log.debug("Has " + numChildren + " attributes."); |
265 | 265 |
266 for (int i = 0; i < numChildren; i++) { | 266 for (int i = 0; i < numChildren; i++) { |
267 Node tmp = children.item(i); | 267 Node tmp = children.item(i); |
268 String name = tmp.getNodeName(); | 268 String name = tmp.getNodeName(); |
269 | 269 |
270 logger.debug(" tmp attribute name: '" + name + "'"); | 270 log.debug(" tmp attribute name: '" + name + "'"); |
271 | 271 |
272 if (name.equals("gml:boundedBy")) { | 272 if (name.equals("gml:boundedBy")) { |
273 // TODO | 273 // TODO |
274 } | 274 } |
275 else { | 275 else { |