comparison flys-client/src/main/java/de/intevation/flys/client/server/ChartInfoServiceImpl.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 460b8e0f0563
children bc06a671ef60
comparison
equal deleted inserted replaced
1366:d0eb2202ffbe 1367:ab8eb2f544f2
9 import javax.xml.xpath.XPathConstants; 9 import javax.xml.xpath.XPathConstants;
10 10
11 import org.w3c.dom.Document; 11 import org.w3c.dom.Document;
12 import org.w3c.dom.Node; 12 import org.w3c.dom.Node;
13 import org.w3c.dom.NodeList; 13 import org.w3c.dom.NodeList;
14
15 import org.apache.log4j.Logger;
14 16
15 import com.google.gwt.user.server.rpc.RemoteServiceServlet; 17 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
16 18
17 import de.intevation.artifacts.common.ArtifactNamespaceContext; 19 import de.intevation.artifacts.common.ArtifactNamespaceContext;
18 import de.intevation.artifacts.common.utils.ClientProtocolUtils; 20 import de.intevation.artifacts.common.utils.ClientProtocolUtils;
38 */ 40 */
39 public class ChartInfoServiceImpl 41 public class ChartInfoServiceImpl
40 extends RemoteServiceServlet 42 extends RemoteServiceServlet
41 implements ChartInfoService 43 implements ChartInfoService
42 { 44 {
45 private static final Logger logger =
46 Logger.getLogger(ChartInfoServiceImpl.class);
47
48
43 public static final String XPATH_TRANSFORM_MATRIX = 49 public static final String XPATH_TRANSFORM_MATRIX =
44 "/art:chartinfo/art:transformation-matrix/art:matrix"; 50 "/art:chartinfo/art:transformation-matrix/art:matrix";
45 51
46 public static final String XPATH_X_AXES = 52 public static final String XPATH_X_AXES =
47 "/art:chartinfo/art:axes/art:domain"; 53 "/art:chartinfo/art:axes/art:domain";
58 String locale, 64 String locale,
59 String type, 65 String type,
60 Map<String, String> attr) 66 Map<String, String> attr)
61 throws ServerException 67 throws ServerException
62 { 68 {
63 System.out.println("ChartInfoServiceImpl.getChartInfo"); 69 logger.info("ChartInfoServiceImpl.getChartInfo");
64 70
65 Document request = ClientProtocolUtils.newOutCollectionDocument( 71 Document request = ClientProtocolUtils.newOutCollectionDocument(
66 collection.identifier(), 72 collection.identifier(),
67 type, 73 type,
68 type, 74 type,
84 } 90 }
85 catch (Exception e) { 91 catch (Exception e) {
86 e.printStackTrace(); 92 e.printStackTrace();
87 } 93 }
88 94
89 System.err.println("Error while fetching chart info."); 95 logger.debug("Error while fetching chart info.");
90 96
91 throw new ServerException(EXCEPTION_STRING); 97 throw new ServerException(EXCEPTION_STRING);
92 } 98 }
93 99
94 100
100 return new ChartInfo(xAxes, yAxes, transformer); 106 return new ChartInfo(xAxes, yAxes, transformer);
101 } 107 }
102 108
103 109
104 protected Axis[] parseXAxes(Document doc) { 110 protected Axis[] parseXAxes(Document doc) {
105 System.out.println("ChartInfoServiceImpl.parseXAxes"); 111 logger.debug("ChartInfoServiceImpl.parseXAxes");
106 112
107 NodeList axes = (NodeList) XMLUtils.xpath( 113 NodeList axes = (NodeList) XMLUtils.xpath(
108 doc, 114 doc,
109 XPATH_X_AXES, 115 XPATH_X_AXES,
110 XPathConstants.NODESET, 116 XPathConstants.NODESET,
113 return parseAxes(axes); 119 return parseAxes(axes);
114 } 120 }
115 121
116 122
117 protected Axis[] parseYAxes(Document doc) { 123 protected Axis[] parseYAxes(Document doc) {
118 System.out.println("ChartInfoServiceImpl.parseYAxes"); 124 logger.debug("ChartInfoServiceImpl.parseYAxes");
119 125
120 NodeList axes = (NodeList) XMLUtils.xpath( 126 NodeList axes = (NodeList) XMLUtils.xpath(
121 doc, 127 doc,
122 XPATH_Y_AXES, 128 XPATH_Y_AXES,
123 XPathConstants.NODESET, 129 XPathConstants.NODESET,
126 return parseAxes(axes); 132 return parseAxes(axes);
127 } 133 }
128 134
129 135
130 protected Axis[] parseAxes(NodeList axes) { 136 protected Axis[] parseAxes(NodeList axes) {
131 System.out.println("ChartInfoServiceImpl.parseAxes"); 137 logger.debug("ChartInfoServiceImpl.parseAxes");
132 138
133 int count = axes != null ? axes.getLength() : 0; 139 int count = axes != null ? axes.getLength() : 0;
134 140
135 System.out.println("Chart has " + count + " axes."); 141 logger.debug("Chart has " + count + " axes.");
136 142
137 if (count == 0) { 143 if (count == 0) {
138 return null; 144 return null;
139 } 145 }
140 146
165 double min = Double.parseDouble(minStr); 171 double min = Double.parseDouble(minStr);
166 double max = Double.parseDouble(maxStr); 172 double max = Double.parseDouble(maxStr);
167 173
168 if (pos >= result.length) { 174 if (pos >= result.length) {
169 // this should never happen 175 // this should never happen
170 System.err.println("The axis is out of valid range: " + pos); 176 logger.debug("The axis is out of valid range: " + pos);
171 continue; 177 continue;
172 } 178 }
173 179
174 result[pos] = new Axis(pos, from, to, min, max); 180 result[pos] = new Axis(pos, from, to, min, max);
175 } 181 }
176 catch (NumberFormatException nfe) { 182 catch (NumberFormatException nfe) {
177 nfe.printStackTrace(); 183 nfe.printStackTrace();
178 } 184 }
179 } 185 }
180 186
181 System.out.println("Parsed " + result.length + " axes"); 187 logger.debug("Parsed " + result.length + " axes");
182 188
183 return result; 189 return result;
184 } 190 }
185 191
186 192
191 * 197 *
192 * @return a Transform2D object to transfrom pixel coordinates into chart 198 * @return a Transform2D object to transfrom pixel coordinates into chart
193 * coordinates. 199 * coordinates.
194 */ 200 */
195 protected Transform2D[] parseTransformationMatrix(Document doc) { 201 protected Transform2D[] parseTransformationMatrix(Document doc) {
196 System.out.println("ChartInfoServiceImpl.parseTransformationMatrix"); 202 logger.debug("ChartInfoServiceImpl.parseTransformationMatrix");
197 203
198 NodeList matrix = (NodeList) XMLUtils.xpath( 204 NodeList matrix = (NodeList) XMLUtils.xpath(
199 doc, 205 doc,
200 XPATH_TRANSFORM_MATRIX, 206 XPATH_TRANSFORM_MATRIX,
201 XPathConstants.NODESET, 207 XPathConstants.NODESET,
207 213
208 for (int i = 0; i < num; i++) { 214 for (int i = 0; i < num; i++) {
209 Transform2D t = createTransformer(matrix.item(i)); 215 Transform2D t = createTransformer(matrix.item(i));
210 216
211 if (t == null) { 217 if (t == null) {
212 System.err.println("Broken transformation matrix at pos: " + i); 218 logger.warn("Broken transformation matrix at pos: " + i);
213 continue; 219 continue;
214 } 220 }
215 221
216 transformer.add(t); 222 transformer.add(t);
217 } 223 }
240 Double.parseDouble(sy), 246 Double.parseDouble(sy),
241 Double.parseDouble(tx), 247 Double.parseDouble(tx),
242 Double.parseDouble(ty)); 248 Double.parseDouble(ty));
243 } 249 }
244 catch (NumberFormatException nfe) { 250 catch (NumberFormatException nfe) {
245 System.err.println("Error while parsing matrix values."); 251 logger.warn("Error while parsing matrix values.");
246 } 252 }
247 } 253 }
248 254
249 System.err.println("No matrix values found."); 255 logger.warn("No matrix values found.");
250 256
251 return new Transform2D(1d, 1d, 0d, 0d); 257 return new Transform2D(1d, 1d, 0d, 0d);
252 } 258 }
253 } 259 }
254 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 260 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org