Revision 41285
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wms/WMSClient.java | ||
---|---|---|
31 | 31 |
import java.net.URL; |
32 | 32 |
import java.util.TreeMap; |
33 | 33 |
import java.util.Vector; |
34 |
import org.apache.commons.lang3.StringUtils; |
|
34 | 35 |
|
35 | 36 |
import org.gvsig.compat.net.ICancellable; |
36 | 37 |
import org.gvsig.remoteclient.exceptions.ServerErrorException; |
37 | 38 |
import org.gvsig.remoteclient.exceptions.WMSException; |
38 | 39 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
40 |
import org.slf4j.Logger; |
|
41 |
import org.slf4j.LoggerFactory; |
|
39 | 42 |
|
40 | 43 |
|
41 | 44 |
/** |
... | ... | |
44 | 47 |
*/ |
45 | 48 |
public class WMSClient extends org.gvsig.remoteclient.RasterClient { |
46 | 49 |
|
50 |
private static final Logger logger = LoggerFactory.getLogger(WMSClient.class); |
|
47 | 51 |
private org.gvsig.remoteclient.wms.WMSProtocolHandler handler; |
48 | 52 |
// private TreeMap layers = new TreeMap(); |
49 | 53 |
// private WMSLayer rootLayer; |
... | ... | |
66 | 70 |
handler = WMSProtocolHandlerFactory.negotiate(host); |
67 | 71 |
handler.setHost(host); |
68 | 72 |
} catch(ConnectException conE) { |
69 |
conE.printStackTrace();
|
|
73 |
logger.warn("Can't create WMS protocol handler for host '"+host+"'.",conE);
|
|
70 | 74 |
throw conE; |
71 | 75 |
} catch(IOException ioE) { |
72 |
ioE.printStackTrace();
|
|
76 |
logger.warn("Can't create WMS protocol handler for host '"+host+"'.",ioE);
|
|
73 | 77 |
throw ioE; |
74 | 78 |
} catch(Exception e) { |
75 |
e.printStackTrace();
|
|
79 |
logger.warn("Can't create WMS protocol handler for host '"+host+"'.",e);
|
|
76 | 80 |
} |
77 | 81 |
} |
78 | 82 |
|
... | ... | |
266 | 270 |
Rectangle2D extent = new Rectangle2D.Double(xmin, ymin, Math.abs(xmax-xmin), Math.abs(ymax-ymin)); |
267 | 271 |
return extent; |
268 | 272 |
} catch(Exception e) { |
269 |
e.printStackTrace(); |
|
273 |
String msg = null; |
|
274 |
try { |
|
275 |
msg = "Can't get layers extent, layers='"+StringUtils.join(layerNames, ",")+"', srs='"+srs+"'."; |
|
276 |
} catch(Exception ex) { |
|
277 |
msg = "Can't get layers extent."; |
|
278 |
} |
|
279 |
logger.warn(msg,e); |
|
270 | 280 |
return null; |
271 | 281 |
} |
272 | 282 |
} |
... | ... | |
287 | 297 |
*/ |
288 | 298 |
public boolean connect(boolean override, ICancellable cancel) |
289 | 299 |
{ |
300 |
String host = getHost(); |
|
290 | 301 |
try { |
291 | 302 |
if (handler == null) |
292 | 303 |
{ |
293 |
if (getHost().trim().length() > 0)
|
|
304 |
if (host.trim().length() > 0)
|
|
294 | 305 |
{ |
295 | 306 |
//TODO: Implement correctly the negotiate algorithm |
296 |
handler = WMSProtocolHandlerFactory.negotiate(getHost());
|
|
307 |
handler = WMSProtocolHandlerFactory.negotiate(host);
|
|
297 | 308 |
//handler = new WMSProtocolHandler1_1_1(); |
298 |
handler.setHost(getHost());
|
|
309 |
handler.setHost(host);
|
|
299 | 310 |
} |
300 | 311 |
else |
301 | 312 |
{ |
... | ... | |
307 | 318 |
return true; |
308 | 319 |
|
309 | 320 |
} catch (Exception e) { |
310 |
e.printStackTrace();
|
|
321 |
logger.warn("Can't connect to host '"+host+"'.",e);
|
|
311 | 322 |
return false; |
312 | 323 |
} |
313 | 324 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wms/wms_1_1_0/WMSProtocolHandler1_1_0.java | ||
---|---|---|
46 | 46 |
import org.gvsig.remoteclient.wms.wms_1_1_0.request.WMSGetFeatureInfoRequest1_1_0; |
47 | 47 |
import org.gvsig.remoteclient.wms.wms_1_1_0.request.WMSGetLegendGraphicRequest1_1_0; |
48 | 48 |
import org.gvsig.remoteclient.wms.wms_1_1_0.request.WMSGetMapRequest1_1_0; |
49 |
import org.gvsig.remoteclient.wms.wms_1_3_0.WMSProtocolHandler1_3_0; |
|
50 |
import org.slf4j.Logger; |
|
51 |
import org.slf4j.LoggerFactory; |
|
49 | 52 |
|
50 | 53 |
/** |
51 | 54 |
* <p> |
... | ... | |
54 | 57 |
*/ |
55 | 58 |
public class WMSProtocolHandler1_1_0 extends org.gvsig.remoteclient.wms.WMSProtocolHandler |
56 | 59 |
{ |
60 |
|
|
61 |
private static final Logger logger = LoggerFactory.getLogger(WMSProtocolHandler1_1_0.class); |
|
57 | 62 |
private WMSLayer1_1_0 fakeRootLayer; |
58 | 63 |
|
59 | 64 |
public WMSProtocolHandler1_1_0() |
... | ... | |
111 | 116 |
} |
112 | 117 |
} |
113 | 118 |
catch(XmlPullParserException parser_ex){ |
114 |
parser_ex.printStackTrace();
|
|
119 |
logger.warn("Error parsing capabilites.",parser_ex);
|
|
115 | 120 |
return false; |
116 | 121 |
} |
117 | 122 |
catch (IOException ioe) { |
118 |
ioe.printStackTrace();
|
|
123 |
logger.warn("Error parsing capabilites.",ioe);
|
|
119 | 124 |
return false; |
120 | 125 |
} finally { |
121 | 126 |
return true; |
... | ... | |
288 | 293 |
} |
289 | 294 |
} |
290 | 295 |
catch(XmlPullParserException parser_ex){ |
291 |
System.out.println(parser_ex.getMessage()); |
|
292 |
parser_ex.printStackTrace(); |
|
296 |
logger.warn("",parser_ex); |
|
293 | 297 |
} |
294 | 298 |
catch (IOException ioe) { |
295 |
ioe.printStackTrace();
|
|
299 |
logger.warn("",ioe);
|
|
296 | 300 |
} |
297 | 301 |
String message = errors.size()>0? "" : null; |
298 | 302 |
for (int i = 0; i < errors.size(); i++) { |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wms/WMSProtocolHandler.java | ||
---|---|---|
51 | 51 |
import org.gvsig.remoteclient.wms.request.WMSGetLegendGraphicRequest; |
52 | 52 |
import org.gvsig.remoteclient.wms.request.WMSGetMapRequest; |
53 | 53 |
import org.kxml2.io.KXmlParser; |
54 |
import org.slf4j.Logger; |
|
55 |
import org.slf4j.LoggerFactory; |
|
54 | 56 |
import org.xmlpull.v1.XmlPullParserException; |
55 | 57 |
|
56 | 58 |
/** |
... | ... | |
59 | 61 |
* |
60 | 62 |
*/ |
61 | 63 |
public abstract class WMSProtocolHandler extends OGCProtocolHandler { |
64 |
|
|
65 |
private static final Logger logger = LoggerFactory.getLogger(WMSProtocolHandler.class); |
|
62 | 66 |
/** |
63 | 67 |
* Encoding used to parse different xml documents. |
64 | 68 |
*/ |
... | ... | |
100 | 104 |
try { |
101 | 105 |
request = new URL(buildCapabilitiesRequest(status)); |
102 | 106 |
} catch(Exception e) { |
103 |
e.printStackTrace();
|
|
107 |
logger.warn("Can't get capabilities, error building url.",e);
|
|
104 | 108 |
} |
105 | 109 |
try { |
106 | 110 |
if (override) |
... | ... | |
113 | 117 |
clear(); |
114 | 118 |
parseCapabilities(f); |
115 | 119 |
} catch(Exception e) { |
116 |
e.printStackTrace();
|
|
120 |
logger.warn("Can't get capabilities.",e);
|
|
117 | 121 |
} |
118 | 122 |
} |
119 | 123 |
|
... | ... | |
196 | 200 |
} |
197 | 201 |
catch(Exception e) |
198 | 202 |
{ |
199 |
e.printStackTrace();
|
|
203 |
logger.warn("Can't get information by point.",e);
|
|
200 | 204 |
sb.append("<INFO>").append("Info format not supported").append("</INFO>"); |
201 | 205 |
return sb.toString(); |
202 | 206 |
|
... | ... | |
217 | 221 |
URL url = request.getURL(); |
218 | 222 |
|
219 | 223 |
URLConnection conn = url.openConnection(); |
220 |
System.out.println(request.toString());
|
|
224 |
logger.info(request.toString());
|
|
221 | 225 |
String type = conn.getContentType(); |
222 | 226 |
|
223 | 227 |
|
... | ... | |
269 | 273 |
} |
270 | 274 |
catch(IOException e) |
271 | 275 |
{ |
272 |
e.printStackTrace();
|
|
273 |
throw new ServerErrorException(); |
|
276 |
logger.warn("Can't build map request.",e);
|
|
277 |
throw new ServerErrorException();
|
|
274 | 278 |
} |
275 | 279 |
} |
276 | 280 |
|
... | ... | |
311 | 315 |
} |
312 | 316 |
catch(IOException e) |
313 | 317 |
{ |
314 |
e.printStackTrace();
|
|
315 |
throw new ServerErrorException(); |
|
318 |
logger.warn("Can't get legend graphics.",e);
|
|
319 |
throw new ServerErrorException();
|
|
316 | 320 |
} |
317 | 321 |
} |
318 | 322 |
|
... | ... | |
321 | 325 |
URL request = null; |
322 | 326 |
try { |
323 | 327 |
request = new URL(buildGetLegendGraphicRequest(status, layerName)); |
324 |
System.out.println(request);
|
|
328 |
logger.info(request.toString());
|
|
325 | 329 |
File f = Utilities.downloadFile(request, "wmsGetLegendGraphic", cancel); |
326 | 330 |
if (f== null) |
327 | 331 |
return null; |
... | ... | |
353 | 357 |
} |
354 | 358 |
return f; |
355 | 359 |
} catch(IOException e) { |
356 |
e.printStackTrace();
|
|
357 |
throw new ServerErrorException(); |
|
360 |
logger.warn("Can't get legend graphics",e);
|
|
361 |
throw new ServerErrorException();
|
|
358 | 362 |
} |
359 | 363 |
} |
360 | 364 |
|
... | ... | |
391 | 395 |
req.append(onlineResource + symbol + "REQUEST=GetLegendGraphic&SERVICE=WMS&VERSION=").append(getVersion()); |
392 | 396 |
req.append("&LAYER=" + layerName).append("&TRANSPARENT=TRUE").append("&FORMAT=image/png"); |
393 | 397 |
String aux = req.toString().replaceAll(" ", "%20"); |
394 |
System.out.println("GetLegendGraphic url:" + aux);
|
|
398 |
logger.info("GetLegendGraphic url:" + aux);
|
|
395 | 399 |
return aux; |
396 | 400 |
} |
397 | 401 |
|
... | ... | |
400 | 404 |
WMSGetMapRequest request = createGetMapRequest(status); |
401 | 405 |
return request.getURL(); |
402 | 406 |
} catch(IOException e) { |
403 |
e.printStackTrace();
|
|
404 |
throw new ServerErrorException(); |
|
407 |
logger.warn("Can't get map URL",e);
|
|
408 |
throw new ServerErrorException();
|
|
405 | 409 |
} |
406 | 410 |
} |
407 | 411 |
|
... | ... | |
511 | 515 |
} |
512 | 516 |
} |
513 | 517 |
catch(XmlPullParserException parser_ex){ |
514 |
parser_ex.printStackTrace();
|
|
518 |
logger.warn("",parser_ex);
|
|
515 | 519 |
} |
516 | 520 |
catch (IOException ioe) { |
517 |
ioe.printStackTrace();
|
|
521 |
logger.warn("",ioe);
|
|
518 | 522 |
} |
519 | 523 |
String message = errors.size()>0? "" : null; |
520 | 524 |
for (int i = 0; i < errors.size(); i++) { |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wms/wms_1_1_1/WMSProtocolHandler1_1_1.java | ||
---|---|---|
47 | 47 |
import org.gvsig.remoteclient.wms.wms_1_1_1.request.WMSGetFeatureInfoRequest1_1_1; |
48 | 48 |
import org.gvsig.remoteclient.wms.wms_1_1_1.request.WMSGetLegendGraphicRequest1_1_1; |
49 | 49 |
import org.gvsig.remoteclient.wms.wms_1_1_1.request.WMSGetMapRequest1_1_1; |
50 |
import org.slf4j.Logger; |
|
51 |
import org.slf4j.LoggerFactory; |
|
50 | 52 |
|
51 | 53 |
/** |
52 | 54 |
* <p> |
... | ... | |
54 | 56 |
* </p> |
55 | 57 |
*/ |
56 | 58 |
public class WMSProtocolHandler1_1_1 extends WMSProtocolHandler { |
59 |
|
|
60 |
private static final Logger logger = LoggerFactory.getLogger(WMSProtocolHandler1_1_1.class); |
|
61 |
|
|
57 | 62 |
private WMSLayer1_1_1 fakeRootLayer; |
58 | 63 |
|
59 | 64 |
public WMSProtocolHandler1_1_1() |
... | ... | |
124 | 129 |
} |
125 | 130 |
} |
126 | 131 |
catch(XmlPullParserException parser_ex){ |
127 |
parser_ex.printStackTrace();
|
|
132 |
logger.warn("Error parsing capabilites.",parser_ex);
|
|
128 | 133 |
return false; |
129 | 134 |
} |
130 | 135 |
catch (IOException ioe) { |
131 |
ioe.printStackTrace();
|
|
136 |
logger.warn("Error parsing capabilites.",ioe);
|
|
132 | 137 |
return false; |
133 | 138 |
} finally { |
134 | 139 |
return true; |
... | ... | |
321 | 326 |
} |
322 | 327 |
} |
323 | 328 |
catch(XmlPullParserException parser_ex){ |
324 |
System.out.println(parser_ex.getMessage()); |
|
325 |
parser_ex.printStackTrace(); |
|
329 |
logger.warn("",parser_ex); |
|
326 | 330 |
} |
327 | 331 |
catch (IOException ioe) { |
328 |
ioe.printStackTrace();
|
|
332 |
logger.warn("",ioe);
|
|
329 | 333 |
} |
330 | 334 |
String message = errors.size()>0? "" : null; |
331 | 335 |
for (int i = 0; i < errors.size(); i++) { |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wms/wms_1_3_0/WMSProtocolHandler1_3_0.java | ||
---|---|---|
42 | 42 |
import org.gvsig.remoteclient.wms.request.WMSGetFeatureInfoRequest; |
43 | 43 |
import org.gvsig.remoteclient.wms.request.WMSGetLegendGraphicRequest; |
44 | 44 |
import org.gvsig.remoteclient.wms.request.WMSGetMapRequest; |
45 |
import org.gvsig.remoteclient.wms.wms_1_1_1.WMSProtocolHandler1_1_1; |
|
45 | 46 |
import org.gvsig.remoteclient.wms.wms_1_3_0.request.WMSGetCapabilitiesRequest1_3_0; |
46 | 47 |
import org.gvsig.remoteclient.wms.wms_1_3_0.request.WMSGetFeatureInfoRequest1_1_3; |
47 | 48 |
import org.gvsig.remoteclient.wms.wms_1_3_0.request.WMSGetLegendGraphicRequest1_1_3; |
48 | 49 |
import org.gvsig.remoteclient.wms.wms_1_3_0.request.WMSGetMapRequest1_1_3; |
50 |
import org.slf4j.Logger; |
|
51 |
import org.slf4j.LoggerFactory; |
|
49 | 52 |
|
50 | 53 |
/** |
51 | 54 |
* <p> |
... | ... | |
53 | 56 |
* </p> |
54 | 57 |
*/ |
55 | 58 |
public class WMSProtocolHandler1_3_0 extends org.gvsig.remoteclient.wms.WMSProtocolHandler { |
59 |
|
|
60 |
private static final Logger logger = LoggerFactory.getLogger(WMSProtocolHandler1_3_0.class); |
|
56 | 61 |
private WMSLayer1_3_0 fakeRootLayer; |
57 | 62 |
|
58 | 63 |
public WMSProtocolHandler1_3_0() |
... | ... | |
107 | 112 |
} |
108 | 113 |
} |
109 | 114 |
catch(XmlPullParserException parser_ex){ |
110 |
parser_ex.printStackTrace();
|
|
115 |
logger.warn("Error parsing capabilites.",parser_ex);
|
|
111 | 116 |
return false; |
112 | 117 |
} |
113 | 118 |
catch (IOException ioe) { |
114 |
ioe.printStackTrace();
|
|
119 |
logger.warn("Error parsing capabilites.",ioe);
|
|
115 | 120 |
return false; |
116 | 121 |
} finally { |
117 | 122 |
return true; |
... | ... | |
284 | 289 |
} |
285 | 290 |
} |
286 | 291 |
catch(XmlPullParserException parser_ex){ |
287 |
System.out.println(parser_ex.getMessage()); |
|
288 |
parser_ex.printStackTrace(); |
|
292 |
logger.warn("",parser_ex); |
|
289 | 293 |
} |
290 | 294 |
catch (IOException ioe) { |
291 |
ioe.printStackTrace();
|
|
295 |
logger.warn("",ioe);
|
|
292 | 296 |
} |
293 | 297 |
String message = errors.size()>0? "" : null; |
294 | 298 |
for (int i = 0; i < errors.size(); i++) { |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wms/WMSProtocolHandlerFactory.java | ||
---|---|---|
36 | 36 |
import org.xmlpull.v1.XmlPullParserException; |
37 | 37 |
|
38 | 38 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
39 |
import org.slf4j.Logger; |
|
40 |
import org.slf4j.LoggerFactory; |
|
39 | 41 |
|
40 |
/** |
|
41 |
* <p></p> |
|
42 |
* |
|
43 |
*/ |
|
44 | 42 |
public class WMSProtocolHandlerFactory { |
45 |
/** |
|
46 |
* <p></p> |
|
47 |
* |
|
48 |
*/ |
|
43 |
|
|
44 |
private static final Logger logger = LoggerFactory.getLogger(WMSProtocolHandlerFactory.class); |
|
49 | 45 |
public org.gvsig.remoteclient.wms.WMSProtocolHandler wMSProtocolHandler; |
50 | 46 |
|
51 | 47 |
private static ArrayList supportedVersions = new ArrayList(); |
... | ... | |
163 | 159 |
} |
164 | 160 |
catch(Exception e) |
165 | 161 |
{ |
166 |
e.printStackTrace();
|
|
167 |
return null; |
|
162 |
logger.warn("Can't determine server version",e);
|
|
163 |
return null;
|
|
168 | 164 |
} |
169 | 165 |
} |
170 | 166 |
|
... | ... | |
232 | 228 |
} |
233 | 229 |
catch(XmlPullParserException xmlEx) |
234 | 230 |
{ |
235 |
xmlEx.printStackTrace();
|
|
231 |
logger.warn("Can't determine server version",xmlEx);
|
|
236 | 232 |
return ""; |
237 | 233 |
} |
238 | 234 |
finally{ |
... | ... | |
241 | 237 |
try{ |
242 | 238 |
reader.close(); |
243 | 239 |
}catch(Exception ex){ |
244 |
ex.printStackTrace();
|
|
240 |
logger.warn("Can't close reader",ex);
|
|
245 | 241 |
} |
246 | 242 |
} |
247 | 243 |
if (dis != null) |
... | ... | |
249 | 245 |
try { |
250 | 246 |
dis.close(); |
251 | 247 |
} catch(Exception ex) { |
252 |
ex.printStackTrace();
|
|
248 |
logger.warn("Can't close input stream",ex);
|
|
253 | 249 |
} |
254 | 250 |
} |
255 | 251 |
} |
... | ... | |
272 | 268 |
} |
273 | 269 |
catch (Exception e) |
274 | 270 |
{ |
275 |
e.printStackTrace();
|
|
271 |
logger.warn("Can't create WMS protocol handler for version '"+version+"'.",e);
|
|
276 | 272 |
//throw new Exception("WMSDriverFactory. Unknown driver version " + e); |
277 | 273 |
return null; |
278 | 274 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/pom.xml | ||
---|---|---|
38 | 38 |
<artifactId>xmlpull</artifactId> |
39 | 39 |
<scope>compile</scope> |
40 | 40 |
</dependency> |
41 |
<dependency> |
|
42 |
<groupId>org.apache.commons</groupId> |
|
43 |
<artifactId>commons-lang3</artifactId> |
|
44 |
<scope>compile</scope> |
|
45 |
</dependency> |
|
41 | 46 |
</dependencies> |
42 | 47 |
|
43 | 48 |
<build> |
Also available in: Unified diff