comparison gwt-client/src/main/java/org/dive4elements/river/client/server/DistanceInfoServiceImpl.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 0a5239a1e46e
comparison
equal deleted inserted replaced
8202:e4606eae8ea5 8203:238fc722f87a
37 */ 37 */
38 public class DistanceInfoServiceImpl 38 public class DistanceInfoServiceImpl
39 extends RemoteServiceServlet 39 extends RemoteServiceServlet
40 implements DistanceInfoService 40 implements DistanceInfoService
41 { 41 {
42 private static final Logger logger = 42 private static final Logger log =
43 Logger.getLogger(DistanceInfoServiceImpl.class); 43 Logger.getLogger(DistanceInfoServiceImpl.class);
44 44
45 public static final String ERROR_NO_DISTANCEINFO_FOUND = 45 public static final String ERROR_NO_DISTANCEINFO_FOUND =
46 "error_no_distanceinfo_found"; 46 "error_no_distanceinfo_found";
47 47
51 public DistanceInfoObject[] getDistanceInfo( 51 public DistanceInfoObject[] getDistanceInfo(
52 String locale, 52 String locale,
53 String river) 53 String river)
54 throws ServerException 54 throws ServerException
55 { 55 {
56 logger.info("DistanceInfoServiceImpl.getDistanceInfo"); 56 log.info("DistanceInfoServiceImpl.getDistanceInfo");
57 57
58 String url = getServletContext().getInitParameter("server-url"); 58 String url = getServletContext().getInitParameter("server-url");
59 59
60 Document doc = XMLUtils.newDocument(); 60 Document doc = XMLUtils.newDocument();
61 61
73 HttpClient client = new HttpClientImpl(url, locale); 73 HttpClient client = new HttpClientImpl(url, locale);
74 74
75 try { 75 try {
76 Document result = client.callService(url, "distanceinfo", doc); 76 Document result = client.callService(url, "distanceinfo", doc);
77 77
78 logger.debug("Extract distance info objects now."); 78 log.debug("Extract distance info objects now.");
79 DistanceInfoObject[] objects = extractDistanceInfoObjects(result); 79 DistanceInfoObject[] objects = extractDistanceInfoObjects(result);
80 80
81 if (objects != null && objects.length > 0) { 81 if (objects != null && objects.length > 0) {
82 return objects; 82 return objects;
83 } 83 }
84 } 84 }
85 catch (ConnectionException ce) { 85 catch (ConnectionException ce) {
86 logger.error(ce, ce); 86 log.error(ce, ce);
87 } 87 }
88 88
89 throw new ServerException(ERROR_NO_DISTANCEINFO_FOUND); 89 throw new ServerException(ERROR_NO_DISTANCEINFO_FOUND);
90 } 90 }
91 91
101 throws ServerException 101 throws ServerException
102 { 102 {
103 NodeList list = result.getElementsByTagName("distance"); 103 NodeList list = result.getElementsByTagName("distance");
104 104
105 if (list == null || list.getLength() == 0) { 105 if (list == null || list.getLength() == 0) {
106 logger.warn("No distance info found."); 106 log.warn("No distance info found.");
107 throw new ServerException(ERROR_NO_DISTANCEINFO_FOUND); 107 throw new ServerException(ERROR_NO_DISTANCEINFO_FOUND);
108 } 108 }
109 109
110 int num = list.getLength(); 110 int num = list.getLength();
111 logger.debug("Response contains " + num + " objects."); 111 log.debug("Response contains " + num + " objects.");
112 112
113 List<DistanceInfoObject> objects = 113 List<DistanceInfoObject> objects =
114 new ArrayList<DistanceInfoObject>(num); 114 new ArrayList<DistanceInfoObject>(num);
115 115
116 for (int i = 0; i < num; i++) { 116 for (int i = 0; i < num; i++) {
120 if (obj != null) { 120 if (obj != null) {
121 objects.add(obj); 121 objects.add(obj);
122 } 122 }
123 } 123 }
124 124
125 logger.debug("Retrieved " + objects.size() + " distances."); 125 log.debug("Retrieved " + objects.size() + " distances.");
126 126
127 return (DistanceInfoObject[]) 127 return (DistanceInfoObject[])
128 objects.toArray(new DistanceInfoObject[num]); 128 objects.toArray(new DistanceInfoObject[num]);
129 } 129 }
130 130
154 Double tp = top .length() > 0 ? new Double(top) : null; 154 Double tp = top .length() > 0 ? new Double(top) : null;
155 155
156 return new DistanceInfoObjectImpl(desc, f, t, riverside, b, tp); 156 return new DistanceInfoObjectImpl(desc, f, t, riverside, b, tp);
157 } 157 }
158 catch (NumberFormatException nfe) { 158 catch (NumberFormatException nfe) {
159 logger.warn(nfe.getLocalizedMessage()); 159 log.warn(nfe.getLocalizedMessage());
160 } 160 }
161 } 161 }
162 162
163 logger.warn("Invalid distance info object found."); 163 log.warn("Invalid distance info object found.");
164 164
165 return null; 165 return null;
166 } 166 }
167 } 167 }
168 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 168 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org