Revision 41301
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wfs/WFSProtocolHandlerFactory.java | ||
---|---|---|
41 | 41 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
42 | 42 |
import org.gvsig.remoteclient.utils.EncodingXMLParser; |
43 | 43 |
import org.gvsig.remoteclient.utils.Utilities; |
44 |
import org.slf4j.Logger; |
|
45 |
import org.slf4j.LoggerFactory; |
|
44 | 46 |
|
45 | 47 |
/** |
46 | 48 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
47 | 49 |
*/ |
48 | 50 |
public class WFSProtocolHandlerFactory { |
49 |
public WFSProtocolHandler wFSProtocolHandler; |
|
51 |
private static Logger logger = LoggerFactory.getLogger(WFSProtocolHandlerFactory.class); |
|
52 |
|
|
53 |
public WFSProtocolHandler wFSProtocolHandler; |
|
50 | 54 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
51 | 55 |
private static ArrayList supportedVersions = new ArrayList(); |
52 | 56 |
|
... | ... | |
152 | 156 |
} |
153 | 157 |
catch(Exception e) |
154 | 158 |
{ |
155 |
e.printStackTrace();
|
|
159 |
logger.warn("Can't negotiate version for host '"+host+"'.",e);
|
|
156 | 160 |
return null; |
157 | 161 |
} |
158 | 162 |
} |
... | ... | |
169 | 173 |
String request = WFSProtocolHandler.buildCapabilitiesSuitableVersionRequest(host, _version); |
170 | 174 |
String version = new String(); |
171 | 175 |
Reader reader = null; |
176 |
File file = null; |
|
172 | 177 |
try { |
173 |
File file = Utilities.downloadFile(new URL(request), "wfs-suitable-version", null);
|
|
178 |
file = Utilities.downloadFile(new URL(request), "wfs-suitable-version", null); |
|
174 | 179 |
|
175 | 180 |
reader = new FileReader(file); |
176 | 181 |
EncodingXMLParser kxmlParser = new EncodingXMLParser(); |
... | ... | |
193 | 198 |
} catch(IOException ioEx) { |
194 | 199 |
throw new IOException(ioEx.getMessage()); |
195 | 200 |
} catch(XmlPullParserException xmlEx) { |
196 |
xmlEx.printStackTrace(); |
|
201 |
String fname = ""; |
|
202 |
if( file != null ) { |
|
203 |
fname = file.getAbsolutePath(); |
|
204 |
} |
|
205 |
logger.warn("Can't get suitable WFS version for host '"+host+"' from file '"+fname+"'.",xmlEx); |
|
197 | 206 |
return ""; |
198 | 207 |
} finally { |
199 | 208 |
if (reader != null) { |
200 | 209 |
try { |
201 | 210 |
reader.close(); |
202 | 211 |
} catch(Exception ex) { |
203 |
ex.printStackTrace();
|
|
212 |
logger.warn("Can't close reader.",ex);
|
|
204 | 213 |
} |
205 | 214 |
} |
206 | 215 |
} |
... | ... | |
244 | 253 |
driver = Class.forName("org.gvsig.remoteclient.wfs.wfs_"+version+".WFSProtocolHandler" + version); |
245 | 254 |
return (WFSProtocolHandler)driver.newInstance(); |
246 | 255 |
} catch (Exception e) { |
247 |
e.printStackTrace(); |
|
248 |
//throw new Exception("WFSDriverFactory. Unknown driver version " + e); |
|
256 |
logger.warn("Can't create driver for WFS version '"+version+"'.",e); |
|
249 | 257 |
return null; |
250 | 258 |
} |
251 | 259 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wfs/wfs_1_0_0/WFSProtocolHandler1_0_0.java | ||
---|---|---|
33 | 33 |
import org.gvsig.compat.CompatLocator; |
34 | 34 |
import org.gvsig.compat.lang.StringUtils; |
35 | 35 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
36 |
import org.gvsig.remoteclient.utils.Utilities; |
|
36 | 37 |
import org.gvsig.remoteclient.wfs.WFSProtocolHandler; |
37 | 38 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
38 | 39 |
import org.gvsig.remoteclient.wfs.edition.WFSTTags; |
39 |
import org.gvsig.remoteclient.wfs.edition.WFSTTransaction; |
|
40 | 40 |
import org.gvsig.remoteclient.wfs.exceptions.ExceptionsFactory; |
41 | 41 |
import org.gvsig.remoteclient.wfs.exceptions.WFSException; |
42 | 42 |
import org.gvsig.remoteclient.wfs.exceptions.WFSGetFeatureException; |
... | ... | |
50 | 50 |
import org.gvsig.remoteclient.wfs.wfs_1_0_0.request.WFSGetFeatureRequest1_0_0; |
51 | 51 |
import org.gvsig.remoteclient.wfs.wfs_1_0_0.request.WFSTLockFeatureRequest1_0_0; |
52 | 52 |
import org.gvsig.remoteclient.wfs.wfs_1_0_0.request.WFSTransactionRequest1_0_0; |
53 |
import org.slf4j.Logger; |
|
54 |
import org.slf4j.LoggerFactory; |
|
53 | 55 |
|
54 | 56 |
/** |
55 | 57 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
56 | 58 |
*/ |
57 | 59 |
public class WFSProtocolHandler1_0_0 extends WFSProtocolHandler{ |
58 | 60 |
|
61 |
private static Logger logger = LoggerFactory.getLogger(WFSProtocolHandler1_0_0.class); |
|
59 | 62 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
60 | 63 |
|
61 | 64 |
public WFSProtocolHandler1_0_0(){ |
... | ... | |
112 | 115 |
} |
113 | 116 |
} |
114 | 117 |
catch(XmlPullParserException parser_ex){ |
115 |
parser_ex.printStackTrace();
|
|
116 |
return false;
|
|
118 |
logger.warn("Can't parse capabilities '"+Utilities.getAbsolutePathOrEmpty(f)+"'.",parser_ex);
|
|
119 |
return false;
|
|
117 | 120 |
} |
118 | 121 |
catch (IOException ioe) { |
119 |
ioe.printStackTrace();
|
|
120 |
return false;
|
|
122 |
logger.warn("Can't parse capabilities '"+Utilities.getAbsolutePathOrEmpty(f)+"'.",ioe);
|
|
123 |
return false;
|
|
121 | 124 |
} |
122 | 125 |
return true; |
123 | 126 |
} |
... | ... | |
305 | 308 |
throw ExceptionsFactory.parseServiceExceptionReport(parser); |
306 | 309 |
} |
307 | 310 |
} catch (FileNotFoundException e) { |
308 |
e.printStackTrace();
|
|
311 |
logger.warn("Can't get feature from file '"+Utilities.getAbsolutePathOrEmpty(f)+"' with namaspace '"+nameSpace+"'.",e);
|
|
309 | 312 |
throw new WFSGetFeatureException(e); |
310 | 313 |
} catch (XmlPullParserException e) { |
311 |
e.printStackTrace();
|
|
314 |
logger.warn("Can't get feature from file '"+Utilities.getAbsolutePathOrEmpty(f)+"' with namaspace '"+nameSpace+"'.",e);
|
|
312 | 315 |
throw new WFSGetFeatureException(e); |
313 | 316 |
} catch (IOException e) { |
314 |
e.printStackTrace();
|
|
317 |
logger.warn("Can't get feature from file '"+Utilities.getAbsolutePathOrEmpty(f)+"' with namaspace '"+nameSpace+"'.",e);
|
|
315 | 318 |
throw new WFSGetFeatureException(e); |
316 | 319 |
} |
317 | 320 |
|
... | ... | |
365 | 368 |
} |
366 | 369 |
} |
367 | 370 |
catch(XmlPullParserException parser_ex){ |
368 |
parser_ex.printStackTrace();
|
|
371 |
logger.warn("Can't parse transaction from file '"+Utilities.getAbsolutePathOrEmpty(f)+"'.",parser_ex);
|
|
369 | 372 |
return false; |
370 | 373 |
} |
371 | 374 |
catch (IOException ioe) { |
372 |
ioe.printStackTrace();
|
|
375 |
logger.warn("Can't parse transaction from file '"+Utilities.getAbsolutePathOrEmpty(f)+"'.",ioe);
|
|
373 | 376 |
return false; |
374 | 377 |
} |
375 | 378 |
return true; |
... | ... | |
496 | 499 |
} |
497 | 500 |
} |
498 | 501 |
catch(XmlPullParserException parser_ex){ |
499 |
parser_ex.printStackTrace();
|
|
502 |
logger.warn("Can't parse lock-feature from file '"+Utilities.getAbsolutePathOrEmpty(f)+"'.",parser_ex);
|
|
500 | 503 |
return false; |
501 | 504 |
} |
502 | 505 |
catch (IOException ioe) { |
503 |
ioe.printStackTrace();
|
|
506 |
logger.warn("Can't parse lock-feature from file '"+Utilities.getAbsolutePathOrEmpty(f)+"'.",ioe);
|
|
504 | 507 |
return false; |
505 | 508 |
} |
506 | 509 |
return true; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wfs/wfs_1_1_0/WFSProtocolHandler1_1_0.java | ||
---|---|---|
33 | 33 |
import org.gvsig.compat.CompatLocator; |
34 | 34 |
import org.gvsig.compat.lang.StringUtils; |
35 | 35 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
36 |
import org.gvsig.remoteclient.utils.Utilities; |
|
36 | 37 |
import org.gvsig.remoteclient.wfs.WFSOperation; |
37 | 38 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
38 | 39 |
import org.gvsig.remoteclient.wfs.edition.WFSTTags; |
... | ... | |
50 | 51 |
import org.gvsig.remoteclient.wfs.wfs_1_1_0.request.WFSGetFeatureRequest1_1_0; |
51 | 52 |
import org.gvsig.remoteclient.wfs.wfs_1_1_0.request.WFSTLockFeatureRequest1_1_0; |
52 | 53 |
import org.gvsig.remoteclient.wfs.wfs_1_1_0.request.WFSTransactionRequest1_1_0; |
54 |
import org.slf4j.Logger; |
|
55 |
import org.slf4j.LoggerFactory; |
|
53 | 56 |
|
54 | 57 |
/** |
55 | 58 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
56 | 59 |
*/ |
57 | 60 |
public class WFSProtocolHandler1_1_0 extends WFSProtocolHandler1_0_0{ |
58 | 61 |
|
62 |
private static Logger logger = LoggerFactory.getLogger(WFSProtocolHandler1_1_0.class); |
|
63 |
|
|
59 | 64 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
60 | 65 |
|
61 | 66 |
public WFSProtocolHandler1_1_0(){ |
... | ... | |
121 | 126 |
} |
122 | 127 |
} |
123 | 128 |
catch(XmlPullParserException parser_ex){ |
124 |
parser_ex.printStackTrace();
|
|
129 |
logger.warn("Can't parse capabilities from file '"+Utilities.getAbsolutePathOrEmpty(f)+"'.",parser_ex);
|
|
125 | 130 |
return false; |
126 | 131 |
} |
127 | 132 |
catch (IOException ioe) { |
128 |
ioe.printStackTrace();
|
|
133 |
logger.warn("Can't parse capabilities from file '"+Utilities.getAbsolutePathOrEmpty(f)+"'.",ioe);
|
|
129 | 134 |
return false; |
130 | 135 |
} |
131 | 136 |
return true; |
... | ... | |
392 | 397 |
} |
393 | 398 |
} |
394 | 399 |
} catch (FileNotFoundException e) { |
395 |
e.printStackTrace();
|
|
400 |
logger.warn("Can't get feature from file '"+Utilities.getAbsolutePathOrEmpty(f)+"' with namaspace '"+nameSpace+"'.",e);
|
|
396 | 401 |
throw new WFSGetFeatureException(e); |
397 | 402 |
} catch (XmlPullParserException e) { |
398 |
e.printStackTrace();
|
|
403 |
logger.warn("Can't get feature from file '"+Utilities.getAbsolutePathOrEmpty(f)+"' with namaspace '"+nameSpace+"'.",e);
|
|
399 | 404 |
throw new WFSGetFeatureException(e); |
400 | 405 |
} catch (IOException e) { |
401 |
e.printStackTrace();
|
|
406 |
logger.warn("Can't get feature from file '"+Utilities.getAbsolutePathOrEmpty(f)+"' with namaspace '"+nameSpace+"'.",e);
|
|
402 | 407 |
throw new WFSGetFeatureException(e); |
403 | 408 |
} |
404 | 409 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wfs/WFSClient.java | ||
---|---|---|
33 | 33 |
import org.gvsig.compat.net.ICancellable; |
34 | 34 |
import org.gvsig.remoteclient.RemoteClient; |
35 | 35 |
import org.gvsig.remoteclient.wfs.exceptions.WFSException; |
36 |
import org.slf4j.Logger; |
|
37 |
import org.slf4j.LoggerFactory; |
|
36 | 38 |
|
37 | 39 |
/** |
38 | 40 |
* Represents the class the with the necessary logic to connect to a |
... | ... | |
41 | 43 |
*/ |
42 | 44 |
public class WFSClient extends RemoteClient{ |
43 | 45 |
|
46 |
private static Logger logger = LoggerFactory.getLogger(WFSClient.class); |
|
47 |
|
|
44 | 48 |
private WFSProtocolHandler handler; |
45 | 49 |
|
46 | 50 |
//private Logger LOG = LoggerFactory.getLogger(WFSClient.class); |
... | ... | |
66 | 70 |
try { |
67 | 71 |
handler = WFSProtocolHandlerFactory.negotiate(host); |
68 | 72 |
} catch(ConnectException conE) { |
69 |
conE.printStackTrace();
|
|
73 |
logger.warn("Can'r negotiate version for the host '"+host+"'.",conE);
|
|
70 | 74 |
throw conE; |
71 | 75 |
} catch(IOException ioE) { |
72 |
ioE.printStackTrace();
|
|
76 |
logger.warn("Can'r negotiate version for the host '"+host+"'.",ioE);
|
|
73 | 77 |
throw ioE; |
74 | 78 |
} catch(Exception e) { |
75 |
e.printStackTrace();
|
|
79 |
logger.warn("Can'r negotiate version for the host '"+host+"'.",e);
|
|
76 | 80 |
} |
77 | 81 |
}else{ |
78 | 82 |
handler = WFSProtocolHandlerFactory.createVersionDriver(version); |
79 | 83 |
} |
80 | 84 |
|
81 | 85 |
if (handler == null){ |
86 |
logger.warn("Unsupported version '"+version+"' for host '"+host+"'."); |
|
82 | 87 |
throw new UnsupportedOperationException("Unsupported version"); |
83 | 88 |
} |
84 | 89 |
handler.setHost(host); |
... | ... | |
204 | 209 |
return true; |
205 | 210 |
|
206 | 211 |
} catch (Exception e) { |
207 |
e.printStackTrace();
|
|
212 |
logger.warn("Can't connect to host '"+this.hostName+"'.",e);
|
|
208 | 213 |
return false; |
209 | 214 |
} |
210 | 215 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/utils/Utilities.java | ||
---|---|---|
468 | 468 |
downloader.removeURL(url); |
469 | 469 |
} |
470 | 470 |
|
471 |
/** |
|
471 |
|
|
472 |
public static String getAbsolutePathOrEmpty(File f) { |
|
473 |
if( f==null ) { |
|
474 |
return ""; |
|
475 |
} |
|
476 |
return f.getAbsolutePath(); |
|
477 |
} |
|
478 |
|
|
479 |
/** |
|
472 | 480 |
* This class has to be deleted when all the classes uses the ICancellable |
473 | 481 |
* method from libCompat |
474 | 482 |
* @author gvSIG Team |
... | ... | |
492 | 500 |
return cancellable.isCanceled(); |
493 | 501 |
} |
494 | 502 |
}*/ |
503 |
|
|
495 | 504 |
} |
Also available in: Unified diff