comparison flys-client/src/main/java/de/intevation/flys/client/server/WQInfoServiceImpl.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 1e73d5a4859c
children bc06a671ef60
comparison
equal deleted inserted replaced
1366:d0eb2202ffbe 1367:ab8eb2f544f2
7 7
8 import org.w3c.dom.Document; 8 import org.w3c.dom.Document;
9 import org.w3c.dom.Element; 9 import org.w3c.dom.Element;
10 import org.w3c.dom.Node; 10 import org.w3c.dom.Node;
11 import org.w3c.dom.NodeList; 11 import org.w3c.dom.NodeList;
12
13 import org.apache.log4j.Logger;
12 14
13 import com.google.gwt.user.server.rpc.RemoteServiceServlet; 15 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
14 16
15 import de.intevation.artifacts.common.ArtifactNamespaceContext; 17 import de.intevation.artifacts.common.ArtifactNamespaceContext;
16 import de.intevation.artifacts.common.utils.XMLUtils; 18 import de.intevation.artifacts.common.utils.XMLUtils;
30 */ 32 */
31 public class WQInfoServiceImpl 33 public class WQInfoServiceImpl
32 extends RemoteServiceServlet 34 extends RemoteServiceServlet
33 implements WQInfoService 35 implements WQInfoService
34 { 36 {
37 private static final Logger logger =
38 Logger.getLogger(WQInfoServiceImpl.class);
39
40
35 public static final String ERROR_NO_WQINFO_FOUND = 41 public static final String ERROR_NO_WQINFO_FOUND =
36 "error_no_wqinfo_found"; 42 "error_no_wqinfo_found";
37 43
38 public static final String XPATH_WQS = "art:service/art:mainvalues/art:mainvalue"; 44 public static final String XPATH_WQS = "art:service/art:mainvalues/art:mainvalue";
39 45
44 String river, 50 String river,
45 double from, 51 double from,
46 double to) 52 double to)
47 throws ServerException 53 throws ServerException
48 { 54 {
49 System.out.println("WQInfoServiceImpl.getWQInfo"); 55 logger.info("WQInfoServiceImpl.getWQInfo");
50 56
51 Document doc = XMLUtils.newDocument(); 57 Document doc = XMLUtils.newDocument();
52 58
53 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( 59 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
54 doc, 60 doc,
73 HttpClient client = new HttpClientImpl(url, locale); 79 HttpClient client = new HttpClientImpl(url, locale);
74 80
75 try { 81 try {
76 Document result = client.callService(url, "mainvalues", doc); 82 Document result = client.callService(url, "mainvalues", doc);
77 83
78 System.out.println("Extract wq info objects now."); 84 logger.debug("Extract wq info objects now.");
79 WQInfoObject[] objects = extractWQInfoObjects(result); 85 WQInfoObject[] objects = extractWQInfoObjects(result);
80 86
81 if (objects != null && objects.length > 0) { 87 if (objects != null && objects.length > 0) {
82 return objects; 88 return objects;
83 } 89 }
84 } 90 }
85 catch (ConnectionException ce) { 91 catch (ConnectionException ce) {
86 System.err.println(ce.getLocalizedMessage()); 92 logger.error(ce, ce);
87 } 93 }
88 94
89 throw new ServerException(ERROR_NO_WQINFO_FOUND); 95 throw new ServerException(ERROR_NO_WQINFO_FOUND);
90 } 96 }
91 97
105 XPATH_WQS, 111 XPATH_WQS,
106 XPathConstants.NODESET, 112 XPathConstants.NODESET,
107 ArtifactNamespaceContext.INSTANCE); 113 ArtifactNamespaceContext.INSTANCE);
108 114
109 if (list == null || list.getLength() == 0) { 115 if (list == null || list.getLength() == 0) {
110 System.err.println("No wq info found."); 116 logger.warn("No wq info found.");
111 117
112 throw new ServerException(ERROR_NO_WQINFO_FOUND); 118 throw new ServerException(ERROR_NO_WQINFO_FOUND);
113 } 119 }
114 120
115 int num = list.getLength(); 121 int num = list.getLength();
116 System.out.println("Response contains " + num + " objects."); 122 logger.debug("Response contains " + num + " objects.");
117 123
118 List<WQInfoObject> objects = 124 List<WQInfoObject> objects =
119 new ArrayList<WQInfoObject>(num); 125 new ArrayList<WQInfoObject>(num);
120 126
121 for (int i = 0; i < num; i++) { 127 for (int i = 0; i < num; i++) {
124 if (obj != null) { 130 if (obj != null) {
125 objects.add(obj); 131 objects.add(obj);
126 } 132 }
127 } 133 }
128 134
129 System.out.println("Retrieved " + objects.size() + " wq values"); 135 logger.debug("Retrieved " + objects.size() + " wq values");
130 136
131 return (WQInfoObject[]) 137 return (WQInfoObject[])
132 objects.toArray(new WQInfoObject[num]); 138 objects.toArray(new WQInfoObject[num]);
133 } 139 }
134 140
158 name, 164 name,
159 type, 165 type,
160 new Double(value)); 166 new Double(value));
161 } 167 }
162 catch (NumberFormatException nfe) { 168 catch (NumberFormatException nfe) {
163 System.err.println(nfe.getLocalizedMessage()); 169 logger.warn(nfe.getLocalizedMessage());
164 } 170 }
165 } 171 }
166 172
167 System.err.println("Invalid wq info object found."); 173 logger.warn("Invalid wq info object found.");
168 174
169 return null; 175 return null;
170 } 176 }
171 } 177 }
172 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 178 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org