comparison gwt-client/src/main/java/org/dive4elements/river/client/server/RiverInfoServiceImpl.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 350a7cf09fbc
children 17db08570637
comparison
equal deleted inserted replaced
8202:e4606eae8ea5 8203:238fc722f87a
45 */ 45 */
46 public class RiverInfoServiceImpl 46 public class RiverInfoServiceImpl
47 extends RemoteServiceServlet 47 extends RemoteServiceServlet
48 implements RiverInfoService 48 implements RiverInfoService
49 { 49 {
50 private static final Logger logger = 50 private static final Logger log =
51 Logger.getLogger(RiverInfoServiceImpl.class); 51 Logger.getLogger(RiverInfoServiceImpl.class);
52 52
53 public static final String ERROR_NO_RIVER_INFO_FOUND = 53 public static final String ERROR_NO_RIVER_INFO_FOUND =
54 "error_no_riverinfo_found"; 54 "error_no_riverinfo_found";
55 55
63 63
64 public static final DateFormat DATE_FORMAT = DateFormat.getDateInstance( 64 public static final DateFormat DATE_FORMAT = DateFormat.getDateInstance(
65 DateFormat.SHORT, Locale.GERMANY); 65 DateFormat.SHORT, Locale.GERMANY);
66 66
67 public RiverInfo getGauges(String river) throws ServerException { 67 public RiverInfo getGauges(String river) throws ServerException {
68 logger.info("RiverInfoServiceImpl.getRiverInfo"); 68 log.info("RiverInfoServiceImpl.getRiverInfo");
69 69
70 String url = getServletContext().getInitParameter("server-url"); 70 String url = getServletContext().getInitParameter("server-url");
71 71
72 Document doc = XMLUtils.newDocument(); 72 Document doc = XMLUtils.newDocument();
73 73
91 riverinfo.isKmUp(), riverinfo.getWstUnit()); 91 riverinfo.isKmUp(), riverinfo.getWstUnit());
92 92
93 93
94 riverinfo.setGauges(gauges); 94 riverinfo.setGauges(gauges);
95 95
96 logger.debug("Finished RiverInfoService.getGauges."); 96 log.debug("Finished RiverInfoService.getGauges.");
97 97
98 return riverinfo; 98 return riverinfo;
99 } 99 }
100 catch (ConnectionException ce) { 100 catch (ConnectionException ce) {
101 logger.error(ce, ce); 101 log.error(ce, ce);
102 } 102 }
103 103
104 logger.warn("No gauge found"); 104 log.warn("No gauge found");
105 throw new ServerException(ERROR_NO_RIVER_INFO_FOUND); 105 throw new ServerException(ERROR_NO_RIVER_INFO_FOUND);
106 } 106 }
107 107
108 public RiverInfo getMeasurementStations(String river) throws ServerException { 108 public RiverInfo getMeasurementStations(String river) throws ServerException {
109 logger.info("RiverInfoServiceImpl.getMeasurementStations"); 109 log.info("RiverInfoServiceImpl.getMeasurementStations");
110 110
111 String url = getServletContext().getInitParameter("server-url"); 111 String url = getServletContext().getInitParameter("server-url");
112 112
113 Document doc = XMLUtils.newDocument(); 113 Document doc = XMLUtils.newDocument();
114 114
131 List<MeasurementStation> mstations = createMeasurementStations( 131 List<MeasurementStation> mstations = createMeasurementStations(
132 result, riverinfo.getName(), riverinfo.isKmUp()); 132 result, riverinfo.getName(), riverinfo.isKmUp());
133 133
134 riverinfo.setMeasurementStations(mstations); 134 riverinfo.setMeasurementStations(mstations);
135 135
136 logger.debug("Finished MeasurementStationInfoService."); 136 log.debug("Finished MeasurementStationInfoService.");
137 137
138 return riverinfo; 138 return riverinfo;
139 } 139 }
140 catch (ConnectionException ce) { 140 catch (ConnectionException ce) {
141 logger.error(ce, ce); 141 log.error(ce, ce);
142 } 142 }
143 143
144 logger.warn("No measurement station found"); 144 log.warn("No measurement station found");
145 throw new ServerException(ERROR_NO_RIVER_INFO_FOUND); 145 throw new ServerException(ERROR_NO_RIVER_INFO_FOUND);
146 } 146 }
147 147
148 /** 148 /**
149 * Avoids NullPointerException when parsing double value 149 * Avoids NullPointerException when parsing double value
154 } 154 }
155 try { 155 try {
156 return Double.valueOf(value); 156 return Double.valueOf(value);
157 } 157 }
158 catch(NumberFormatException e) { 158 catch(NumberFormatException e) {
159 logger.error(e, e); 159 log.error(e, e);
160 return null; 160 return null;
161 } 161 }
162 } 162 }
163 163
164 private Long parseLong(String value) { 164 private Long parseLong(String value) {
167 } 167 }
168 try { 168 try {
169 return Long.valueOf(value); 169 return Long.valueOf(value);
170 } 170 }
171 catch(NumberFormatException e) { 171 catch(NumberFormatException e) {
172 logger.error(e, e); 172 log.error(e, e);
173 return null; 173 return null;
174 } 174 }
175 } 175 }
176 176
177 private Integer parseInteger(String value) { 177 private Integer parseInteger(String value) {
180 } 180 }
181 try { 181 try {
182 return Integer.valueOf(value); 182 return Integer.valueOf(value);
183 } 183 }
184 catch(NumberFormatException e) { 184 catch(NumberFormatException e) {
185 logger.error(e, e); 185 log.error(e, e);
186 return null; 186 return null;
187 } 187 }
188 } 188 }
189 189
190 private Date parseDate(String value) { 190 private Date parseDate(String value) {
193 } 193 }
194 try { 194 try {
195 return DATE_FORMAT.parse(value); 195 return DATE_FORMAT.parse(value);
196 } 196 }
197 catch(ParseException e) { 197 catch(ParseException e) {
198 logger.error(e, e); 198 log.error(e, e);
199 return null; 199 return null;
200 } 200 }
201 } 201 }
202 202
203 private List<MeasurementStation> createMeasurementStations( 203 private List<MeasurementStation> createMeasurementStations(
212 int num = stationnodes == null ? 0 : stationnodes.getLength(); 212 int num = stationnodes == null ? 0 : stationnodes.getLength();
213 213
214 ArrayList<MeasurementStation> mstations = new ArrayList<MeasurementStation>(num); 214 ArrayList<MeasurementStation> mstations = new ArrayList<MeasurementStation>(num);
215 215
216 if (num == 0) { 216 if (num == 0) {
217 logger.warn("No measurement station found."); 217 log.warn("No measurement station found.");
218 } 218 }
219 else { 219 else {
220 logger.debug("Found " + num + " measurement stations."); 220 log.debug("Found " + num + " measurement stations.");
221 221
222 for (int i = 0; i < num; i++) { 222 for (int i = 0; i < num; i++) {
223 Element stationele = (Element)stationnodes.item(i); 223 Element stationele = (Element)stationnodes.item(i);
224 224
225 String mname = stationele.getAttributeNS( 225 String mname = stationele.getAttributeNS(
250 gaugename = gaugeele.getAttributeNS( 250 gaugename = gaugeele.getAttributeNS(
251 ArtifactNamespaceContext.NAMESPACE_URI, "name"); 251 ArtifactNamespaceContext.NAMESPACE_URI, "name");
252 } 252 }
253 253
254 254
255 logger.debug("Found measurement station with name " + mname); 255 log.debug("Found measurement station with name " + mname);
256 256
257 MeasurementStation station = new DefaultMeasurementStation( 257 MeasurementStation station = new DefaultMeasurementStation(
258 rivername, 258 rivername,
259 mname, 259 mname,
260 parseInteger(mid), 260 parseInteger(mid),
287 int num = gaugenodes == null ? 0 : gaugenodes.getLength(); 287 int num = gaugenodes == null ? 0 : gaugenodes.getLength();
288 288
289 ArrayList<GaugeInfo> gauges = new ArrayList<GaugeInfo>(num); 289 ArrayList<GaugeInfo> gauges = new ArrayList<GaugeInfo>(num);
290 290
291 if (num == 0) { 291 if (num == 0) {
292 logger.warn("No gauge info found."); 292 log.warn("No gauge info found.");
293 } 293 }
294 else { 294 else {
295 logger.debug("Found " + num + " gauges."); 295 log.debug("Found " + num + " gauges.");
296 296
297 for (int i = 0; i < num; i++) { 297 for (int i = 0; i < num; i++) {
298 Element gaugeele = (Element)gaugenodes.item(i); 298 Element gaugeele = (Element)gaugenodes.item(i);
299 299
300 String gname = gaugeele.getAttributeNS( 300 String gname = gaugeele.getAttributeNS(
318 String gstation = gaugeele.getAttributeNS( 318 String gstation = gaugeele.getAttributeNS(
319 ArtifactNamespaceContext.NAMESPACE_URI, "station"); 319 ArtifactNamespaceContext.NAMESPACE_URI, "station");
320 String gofficial = gaugeele.getAttributeNS( 320 String gofficial = gaugeele.getAttributeNS(
321 ArtifactNamespaceContext.NAMESPACE_URI, "official"); 321 ArtifactNamespaceContext.NAMESPACE_URI, "official");
322 322
323 logger.debug("Found gauge with name " + gname); 323 log.debug("Found gauge with name " + gname);
324 324
325 GaugeInfo gaugeinfo = new DefaultGaugeInfo( 325 GaugeInfo gaugeinfo = new DefaultGaugeInfo(
326 rivername, 326 rivername,
327 gname, 327 gname,
328 kmup, 328 kmup,
369 String rofficial = riverresp.getAttributeNS( 369 String rofficial = riverresp.getAttributeNS(
370 ArtifactNamespaceContext.NAMESPACE_URI, "official"); 370 ArtifactNamespaceContext.NAMESPACE_URI, "official");
371 String rmuuid = riverresp.getAttributeNS( 371 String rmuuid = riverresp.getAttributeNS(
372 ArtifactNamespaceContext.NAMESPACE_URI, "model-uuid"); 372 ArtifactNamespaceContext.NAMESPACE_URI, "model-uuid");
373 373
374 logger.debug("River is " + rname); 374 log.debug("River is " + rname);
375 375
376 boolean kmup = rkmup.equalsIgnoreCase("true"); 376 boolean kmup = rkmup.equalsIgnoreCase("true");
377 DefaultRiverInfo riverinfo = new DefaultRiverInfo( 377 DefaultRiverInfo riverinfo = new DefaultRiverInfo(
378 rname, 378 rname,
379 kmup, 379 kmup,

http://dive4elements.wald.intevation.org