Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/MapInfoServiceImpl.java @ 1367:ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
flys-client/trunk@3069 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 25 Oct 2011 12:31:15 +0000 |
parents | 910b03de6857 |
children | bc06a671ef60 |
comparison
equal
deleted
inserted
replaced
1366:d0eb2202ffbe | 1367:ab8eb2f544f2 |
---|---|
1 package de.intevation.flys.client.server; | 1 package de.intevation.flys.client.server; |
2 | 2 |
3 import org.w3c.dom.Document; | 3 import org.w3c.dom.Document; |
4 import org.w3c.dom.Element; | 4 import org.w3c.dom.Element; |
5 | |
6 import org.apache.log4j.Logger; | |
5 | 7 |
6 import com.google.gwt.user.server.rpc.RemoteServiceServlet; | 8 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
7 | 9 |
8 import de.intevation.artifacts.common.utils.XMLUtils; | 10 import de.intevation.artifacts.common.utils.XMLUtils; |
9 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; | 11 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
27 */ | 29 */ |
28 public class MapInfoServiceImpl | 30 public class MapInfoServiceImpl |
29 extends RemoteServiceServlet | 31 extends RemoteServiceServlet |
30 implements MapInfoService | 32 implements MapInfoService |
31 { | 33 { |
34 private static final Logger logger = | |
35 Logger.getLogger(MapInfoServiceImpl.class); | |
36 | |
37 | |
32 public static final String XPATH_RIVER = | 38 public static final String XPATH_RIVER = |
33 "/mapinfo/river/@name"; | 39 "/mapinfo/river/@name"; |
34 | 40 |
35 public static final String XPATH_SRID = | 41 public static final String XPATH_SRID = |
36 "/mapinfo/river/srid/@value"; | 42 "/mapinfo/river/srid/@value"; |
52 | 58 |
53 | 59 |
54 public MapInfo getMapInfo(String url, String locale, String river) | 60 public MapInfo getMapInfo(String url, String locale, String river) |
55 throws ServerException | 61 throws ServerException |
56 { | 62 { |
57 System.out.println("MapInfoServiceImpl.getMapInfo"); | 63 logger.info("MapInfoServiceImpl.getMapInfo"); |
58 | 64 |
59 Document request = getRequestDocument(river);; | 65 Document request = getRequestDocument(river);; |
60 | 66 |
61 HttpClient client = new HttpClientImpl(url, locale); | 67 HttpClient client = new HttpClientImpl(url, locale); |
62 | 68 |
63 try { | 69 try { |
64 System.out.println("MapInfoServiceImpl.callService"); | 70 logger.debug("MapInfoServiceImpl.callService"); |
65 Document result = client.callService(url, "mapinfo", request); | 71 Document result = client.callService(url, "mapinfo", request); |
66 | 72 |
67 if (result == null) { | 73 if (result == null) { |
68 System.err.println("MapInfo service returned no result."); | 74 logger.warn("MapInfo service returned no result."); |
69 throw new ServerException(ERROR_NO_MAPINFO_FOUND); | 75 throw new ServerException(ERROR_NO_MAPINFO_FOUND); |
70 } | 76 } |
71 | 77 |
72 return getMapInfo(result); | 78 return getMapInfo(result); |
73 } | 79 } |
74 catch (ConnectionException ce) { | 80 catch (ConnectionException ce) { |
75 System.err.println(ce.getLocalizedMessage()); | 81 logger.error(ce, ce); |
76 } | 82 } |
77 | 83 |
78 throw new ServerException(ERROR_NO_MAPINFO_FOUND); | 84 throw new ServerException(ERROR_NO_MAPINFO_FOUND); |
79 } | 85 } |
80 | 86 |
81 | 87 |
82 public static Document getRequestDocument(String rivername) { | 88 public static Document getRequestDocument(String rivername) { |
83 System.out.println("MapInfoServiceImpl.getRequestDocument"); | 89 logger.debug("MapInfoServiceImpl.getRequestDocument"); |
84 | 90 |
85 Document request = XMLUtils.newDocument(); | 91 Document request = XMLUtils.newDocument(); |
86 ElementCreator cr = new ElementCreator(request, null, null); | 92 ElementCreator cr = new ElementCreator(request, null, null); |
87 | 93 |
88 Element root = cr.create("mapinfo"); | 94 Element root = cr.create("mapinfo"); |
96 return request; | 102 return request; |
97 } | 103 } |
98 | 104 |
99 | 105 |
100 public static MapInfo getMapInfo(Document result) { | 106 public static MapInfo getMapInfo(Document result) { |
101 System.out.println("MapInfoServiceImpl.getMapInfo"); | 107 logger.debug("MapInfoServiceImpl.getMapInfo"); |
102 | 108 |
103 String river = XMLUtils.xpathString(result, XPATH_RIVER, null); | 109 String river = XMLUtils.xpathString(result, XPATH_RIVER, null); |
104 String sridStr = XMLUtils.xpathString(result, XPATH_SRID, null); | 110 String sridStr = XMLUtils.xpathString(result, XPATH_SRID, null); |
105 String bboxS = XMLUtils.xpathString(result, XPATH_BBOX, null); | 111 String bboxS = XMLUtils.xpathString(result, XPATH_BBOX, null); |
106 BBox bbox = BBox.getBBoxFromString(bboxS); | 112 BBox bbox = BBox.getBBoxFromString(bboxS); |