Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/server/MapInfoServiceImpl.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 |
---|---|
34 */ | 34 */ |
35 public class MapInfoServiceImpl | 35 public class MapInfoServiceImpl |
36 extends RemoteServiceServlet | 36 extends RemoteServiceServlet |
37 implements MapInfoService | 37 implements MapInfoService |
38 { | 38 { |
39 private static final Logger logger = | 39 private static final Logger log = |
40 Logger.getLogger(MapInfoServiceImpl.class); | 40 Logger.getLogger(MapInfoServiceImpl.class); |
41 | 41 |
42 | 42 |
43 public static final String XPATH_RIVER = | 43 public static final String XPATH_RIVER = |
44 "/mapinfo/river/@name"; | 44 "/mapinfo/river/@name"; |
67 | 67 |
68 @Override | 68 @Override |
69 public MapInfo getMapInfo(String locale, String river) | 69 public MapInfo getMapInfo(String locale, String river) |
70 throws ServerException | 70 throws ServerException |
71 { | 71 { |
72 logger.info("MapInfoServiceImpl.getMapInfo"); | 72 log.info("MapInfoServiceImpl.getMapInfo"); |
73 | 73 |
74 String url = getServletContext().getInitParameter("server-url"); | 74 String url = getServletContext().getInitParameter("server-url"); |
75 | 75 |
76 Document request = getRequestDocument(river, "rivermap"); | 76 Document request = getRequestDocument(river, "rivermap"); |
77 | 77 |
78 HttpClient client = new HttpClientImpl(url, locale); | 78 HttpClient client = new HttpClientImpl(url, locale); |
79 | 79 |
80 try { | 80 try { |
81 logger.debug("MapInfoServiceImpl.callService"); | 81 log.debug("MapInfoServiceImpl.callService"); |
82 Document result = client.callService(url, "mapinfo", request); | 82 Document result = client.callService(url, "mapinfo", request); |
83 | 83 |
84 if (result == null) { | 84 if (result == null) { |
85 logger.warn("MapInfo service returned no result."); | 85 log.warn("MapInfo service returned no result."); |
86 throw new ServerException(ERROR_NO_MAPINFO_FOUND); | 86 throw new ServerException(ERROR_NO_MAPINFO_FOUND); |
87 } | 87 } |
88 | 88 |
89 return getMapInfo(result); | 89 return getMapInfo(result); |
90 } | 90 } |
91 catch (ConnectionException ce) { | 91 catch (ConnectionException ce) { |
92 logger.error(ce, ce); | 92 log.error(ce, ce); |
93 } | 93 } |
94 | 94 |
95 throw new ServerException(ERROR_NO_MAPINFO_FOUND); | 95 throw new ServerException(ERROR_NO_MAPINFO_FOUND); |
96 } | 96 } |
97 | 97 |
98 | 98 |
99 public static Document getRequestDocument(String rivername, String maptypeStr) { | 99 public static Document getRequestDocument(String rivername, String maptypeStr) { |
100 logger.debug("MapInfoServiceImpl.getRequestDocument"); | 100 log.debug("MapInfoServiceImpl.getRequestDocument"); |
101 | 101 |
102 Document request = XMLUtils.newDocument(); | 102 Document request = XMLUtils.newDocument(); |
103 ElementCreator cr = new ElementCreator(request, null, null); | 103 ElementCreator cr = new ElementCreator(request, null, null); |
104 | 104 |
105 Element root = cr.create("mapinfo"); | 105 Element root = cr.create("mapinfo"); |
116 return request; | 116 return request; |
117 } | 117 } |
118 | 118 |
119 | 119 |
120 public static MapInfo getMapInfo(Document result) { | 120 public static MapInfo getMapInfo(Document result) { |
121 logger.debug("MapInfoServiceImpl.getMapInfo"); | 121 log.debug("MapInfoServiceImpl.getMapInfo"); |
122 | 122 |
123 String river = XMLUtils.xpathString(result, XPATH_RIVER, null); | 123 String river = XMLUtils.xpathString(result, XPATH_RIVER, null); |
124 String sridStr = XMLUtils.xpathString(result, XPATH_SRID, null); | 124 String sridStr = XMLUtils.xpathString(result, XPATH_SRID, null); |
125 String bboxS = XMLUtils.xpathString(result, XPATH_BBOX, null); | 125 String bboxS = XMLUtils.xpathString(result, XPATH_BBOX, null); |
126 BBox bbox = BBox.getBBoxFromString(bboxS); | 126 BBox bbox = BBox.getBBoxFromString(bboxS); |