svn-gvsig-desktop / 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 @ 40559
History | View | Annotate | Download (19 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.remoteclient.wfs.wfs_1_0_0; |
25 |
|
26 |
import java.io.File; |
27 |
import java.io.FileNotFoundException; |
28 |
import java.io.IOException; |
29 |
|
30 |
import org.kxml2.io.KXmlParser; |
31 |
import org.xmlpull.v1.XmlPullParserException; |
32 |
|
33 |
import org.gvsig.compat.CompatLocator; |
34 |
import org.gvsig.compat.lang.StringUtils; |
35 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
36 |
import org.gvsig.remoteclient.wfs.WFSProtocolHandler; |
37 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
38 |
import org.gvsig.remoteclient.wfs.edition.WFSTTags; |
39 |
import org.gvsig.remoteclient.wfs.edition.WFSTTransaction; |
40 |
import org.gvsig.remoteclient.wfs.exceptions.ExceptionsFactory; |
41 |
import org.gvsig.remoteclient.wfs.exceptions.WFSException; |
42 |
import org.gvsig.remoteclient.wfs.exceptions.WFSGetFeatureException; |
43 |
import org.gvsig.remoteclient.wfs.request.WFSDescribeFeatureTypeRequest; |
44 |
import org.gvsig.remoteclient.wfs.request.WFSGetFeatureRequest; |
45 |
import org.gvsig.remoteclient.wfs.request.WFSTLockFeatureRequest; |
46 |
import org.gvsig.remoteclient.wfs.request.WFSTransactionRequest; |
47 |
import org.gvsig.remoteclient.wfs.request.WFSTransactionRequestInformation; |
48 |
import org.gvsig.remoteclient.wfs.schema.XMLSchemaParser; |
49 |
import org.gvsig.remoteclient.wfs.wfs_1_0_0.request.WFSDescribeFeatureTypeRequest1_0_0; |
50 |
import org.gvsig.remoteclient.wfs.wfs_1_0_0.request.WFSGetFeatureRequest1_0_0; |
51 |
import org.gvsig.remoteclient.wfs.wfs_1_0_0.request.WFSTLockFeatureRequest1_0_0; |
52 |
import org.gvsig.remoteclient.wfs.wfs_1_0_0.request.WFSTransactionRequest1_0_0; |
53 |
|
54 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
55 |
*
|
56 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
57 |
*
|
58 |
* This program is free software; you can redistribute it and/or
|
59 |
* modify it under the terms of the GNU General Public License
|
60 |
* as published by the Free Software Foundation; either version 2
|
61 |
* of the License, or (at your option) any later version.
|
62 |
*
|
63 |
* This program is distributed in the hope that it will be useful,
|
64 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
65 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
66 |
* GNU General Public License for more details.
|
67 |
*
|
68 |
* You should have received a copy of the GNU General Public License
|
69 |
* along with this program; if not, write to the Free Software
|
70 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
71 |
*
|
72 |
* For more information, contact:
|
73 |
*
|
74 |
* Generalitat Valenciana
|
75 |
* Conselleria d'Infraestructures i Transport
|
76 |
* Av. Blasco Ib??ez, 50
|
77 |
* 46010 VALENCIA
|
78 |
* SPAIN
|
79 |
*
|
80 |
* +34 963862235
|
81 |
* gvsig@gva.es
|
82 |
* www.gvsig.gva.es
|
83 |
*
|
84 |
* or
|
85 |
*
|
86 |
* IVER T.I. S.A
|
87 |
* Salamanca 50
|
88 |
* 46005 Valencia
|
89 |
* Spain
|
90 |
*
|
91 |
* +34 963163400
|
92 |
* dac@iver.es
|
93 |
*/
|
94 |
/* CVS MESSAGES:
|
95 |
*
|
96 |
* $Id: WFSProtocolHandler1_0_0.java 34133 2010-11-15 11:32:55Z jpiera $
|
97 |
* $Log$
|
98 |
* Revision 1.12 2007-02-19 11:43:10 jorpiell
|
99 |
* A?adidos los filtros por ?rea
|
100 |
*
|
101 |
* Revision 1.11 2007/02/09 14:11:01 jorpiell
|
102 |
* Primer piloto del soporte para WFS 1.1 y para WFS-T
|
103 |
*
|
104 |
* Revision 1.10 2007/01/16 08:30:22 csanchez
|
105 |
* Sistema de Warnings y Excepciones adaptado a BasicException
|
106 |
*
|
107 |
* Revision 1.9 2006/12/22 11:31:01 jorpiell
|
108 |
* Cambio del parser 2.x
|
109 |
*
|
110 |
* Revision 1.8 2006/10/31 09:36:51 jorpiell
|
111 |
* Se devuelve el tipo de la entidad completo, y no sus hijos
|
112 |
*
|
113 |
* Revision 1.7 2006/10/10 12:52:28 jorpiell
|
114 |
* Soporte para features complejas.
|
115 |
*
|
116 |
* Revision 1.6 2006/06/14 07:54:18 jorpiell
|
117 |
* Se parsea el online resource que antes se ignoraba
|
118 |
*
|
119 |
* Revision 1.5 2006/05/25 10:20:57 jorpiell
|
120 |
* Se ha cambiado el nombre de la clase WFSField por la clase WFSAttribute, porque resultaba confuso
|
121 |
*
|
122 |
* Revision 1.4 2006/05/23 13:23:22 jorpiell
|
123 |
* Se ha cambiado el final del bucle de parseado y se tiene en cuenta el online resource
|
124 |
*
|
125 |
* Revision 1.2 2006/04/20 16:39:16 jorpiell
|
126 |
* A?adida la operacion de describeFeatureType y el parser correspondiente.
|
127 |
*
|
128 |
* Revision 1.1 2006/04/19 12:51:35 jorpiell
|
129 |
* A?adidas algunas de las clases del servicio WFS
|
130 |
*
|
131 |
*
|
132 |
*/
|
133 |
/**
|
134 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
135 |
*/
|
136 |
public class WFSProtocolHandler1_0_0 extends WFSProtocolHandler{ |
137 |
|
138 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
139 |
|
140 |
public WFSProtocolHandler1_0_0(){
|
141 |
this.version = "1.0.0"; |
142 |
this.name = "WFS1.0.0"; |
143 |
} |
144 |
|
145 |
/*
|
146 |
* (non-Javadoc)
|
147 |
* @see org.gvsig.remoteClient.OGCProtocolHandler#parseCapabilities(java.io.File)
|
148 |
*/
|
149 |
public boolean parseCapabilities(File f) { |
150 |
int tag;
|
151 |
XMLSchemaParser parser = null;
|
152 |
parser = new XMLSchemaParser();
|
153 |
try
|
154 |
{ |
155 |
parser.setInput(f); |
156 |
parser.nextTag(); |
157 |
|
158 |
if ( parser.getEventType() != KXmlParser.END_DOCUMENT )
|
159 |
{ |
160 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_CAPABILITIES_ROOT1_0_0);
|
161 |
//Parses the Namespaces...
|
162 |
parseNamespaces(parser); |
163 |
//Parse the capabilities document
|
164 |
tag = parser.nextTag(); |
165 |
while(tag != KXmlParser.END_DOCUMENT)
|
166 |
{ |
167 |
switch(tag)
|
168 |
{ |
169 |
case KXmlParser.START_TAG:
|
170 |
if (parser.getName().compareTo(CapabilitiesTags.SERVICE)==0) |
171 |
{ |
172 |
parseServiceTag(parser); |
173 |
} |
174 |
else if (parser.getName().compareTo(CapabilitiesTags.CAPABILITY)==0) |
175 |
{ |
176 |
parseCapabilityTag(parser); |
177 |
} |
178 |
else if (parser.getName().compareTo(CapabilitiesTags.WFS_FEATURETYPELIST)==0) |
179 |
{ |
180 |
parseFeatureTypeListTag(parser); |
181 |
} |
182 |
break;
|
183 |
case KXmlParser.END_TAG:
|
184 |
break;
|
185 |
case KXmlParser.TEXT:
|
186 |
break;
|
187 |
} |
188 |
tag = parser.next(); |
189 |
} |
190 |
parser.require(KXmlParser.END_DOCUMENT, null, null); |
191 |
} |
192 |
} |
193 |
catch(XmlPullParserException parser_ex){
|
194 |
parser_ex.printStackTrace(); |
195 |
return false; |
196 |
} |
197 |
catch (IOException ioe) { |
198 |
ioe.printStackTrace(); |
199 |
return false; |
200 |
} |
201 |
return true; |
202 |
} |
203 |
|
204 |
/**
|
205 |
* <p>Parses the Service Information </p>
|
206 |
*/
|
207 |
private void parseServiceTag(KXmlParser parser) throws IOException, XmlPullParserException |
208 |
{ |
209 |
int currentTag;
|
210 |
boolean end = false; |
211 |
|
212 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.SERVICE);
|
213 |
currentTag = parser.next(); |
214 |
|
215 |
while (!end)
|
216 |
{ |
217 |
switch(currentTag)
|
218 |
{ |
219 |
case KXmlParser.START_TAG:
|
220 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.NAME)==0) |
221 |
{ |
222 |
serviceInfo.name = parser.nextText(); |
223 |
} |
224 |
else if (parser.getName().compareTo(CapabilitiesTags.WFS_TITLE)==0) |
225 |
{ |
226 |
serviceInfo.title = parser.nextText(); |
227 |
} |
228 |
else if (parser.getName().compareTo(CapabilitiesTags.WFS_ABSTRACT)==0) |
229 |
{ |
230 |
serviceInfo.abstr = parser.nextText(); |
231 |
} |
232 |
else if (parser.getName().compareTo(CapabilitiesTags.ONLINERESOURCE)==0) |
233 |
{ |
234 |
serviceInfo.online_resource = parser.nextText(); |
235 |
|
236 |
} |
237 |
break;
|
238 |
case KXmlParser.END_TAG:
|
239 |
if (parser.getName().compareTo(CapabilitiesTags.SERVICE) == 0) |
240 |
end = true;
|
241 |
break;
|
242 |
case KXmlParser.TEXT:
|
243 |
break;
|
244 |
} |
245 |
if (!end){
|
246 |
currentTag = parser.next(); |
247 |
} |
248 |
} |
249 |
} |
250 |
|
251 |
private void parseCapabilityTag(KXmlParser parser) throws IOException, XmlPullParserException |
252 |
{ |
253 |
int currentTag;
|
254 |
boolean end = false; |
255 |
|
256 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.CAPABILITY);
|
257 |
currentTag = parser.next(); |
258 |
|
259 |
while (!end)
|
260 |
{ |
261 |
switch(currentTag)
|
262 |
{ |
263 |
case KXmlParser.START_TAG:
|
264 |
if (parser.getName().compareTo(CapabilitiesTags.REQUEST)==0) |
265 |
{ |
266 |
parseRequestTag(parser); |
267 |
} |
268 |
else if (parser.getName().compareTo(CapabilitiesTags.EXCEPTION)==0) |
269 |
{ |
270 |
//TODO Parse exception tags...
|
271 |
parser.skipSubTree(); |
272 |
} |
273 |
else if ((parser.getName().compareTo(CapabilitiesTags.VENDORSPECIFICCAPABILITIES)==0) || |
274 |
(parser.getName().compareTo(CapabilitiesTags.USERDEFINEDSYMBOLIZATION )==0))
|
275 |
{ |
276 |
parser.skipSubTree(); |
277 |
} |
278 |
break;
|
279 |
case KXmlParser.END_TAG:
|
280 |
if (parser.getName().compareTo(CapabilitiesTags.CAPABILITY) == 0) |
281 |
end = true;
|
282 |
break;
|
283 |
case KXmlParser.TEXT:
|
284 |
break;
|
285 |
} |
286 |
if (!end){
|
287 |
currentTag = parser.next(); |
288 |
} |
289 |
} |
290 |
} |
291 |
|
292 |
/**
|
293 |
* <p>Parses the Request tag </p>
|
294 |
*/
|
295 |
private void parseRequestTag(KXmlParser parser) throws IOException, XmlPullParserException |
296 |
{ |
297 |
int currentTag;
|
298 |
boolean end = false; |
299 |
|
300 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.REQUEST);
|
301 |
currentTag = parser.next(); |
302 |
|
303 |
while (!end)
|
304 |
{ |
305 |
switch(currentTag)
|
306 |
{ |
307 |
case KXmlParser.START_TAG:
|
308 |
if (parser.getName().compareTo(CapabilitiesTags.GETCAPABILITIES)==0){ |
309 |
parserDcpType(parser, CapabilitiesTags.GETCAPABILITIES); |
310 |
} else if (parser.getName().compareTo(CapabilitiesTags.WFS_DESCRIBEFEATURETYPE)==0) { |
311 |
parserDcpType(parser, CapabilitiesTags.WFS_DESCRIBEFEATURETYPE); |
312 |
}else if (parser.getName().compareTo(CapabilitiesTags.WFS_GETFEATURE)==0){ |
313 |
parserDcpType(parser, CapabilitiesTags.WFS_GETFEATURE); |
314 |
}else if (parser.getName().compareTo(CapabilitiesTags.WFS_LOCKFEATURE)==0){ |
315 |
parserDcpType(parser, CapabilitiesTags.WFS_LOCKFEATURE); |
316 |
}else if (parser.getName().compareTo(CapabilitiesTags.WFS_TRANSACTION)==0){ |
317 |
parserDcpType(parser, CapabilitiesTags.WFS_TRANSACTION); |
318 |
} |
319 |
break;
|
320 |
case KXmlParser.END_TAG:
|
321 |
if (parser.getName().compareTo(CapabilitiesTags.REQUEST) == 0) |
322 |
end = true;
|
323 |
break;
|
324 |
case KXmlParser.TEXT:
|
325 |
break;
|
326 |
} |
327 |
if (!end){
|
328 |
currentTag = parser.next(); |
329 |
} |
330 |
} |
331 |
} |
332 |
|
333 |
/**
|
334 |
* It parses the feature typelist tag
|
335 |
* @param parser
|
336 |
* @throws IOException
|
337 |
* @throws XmlPullParserException
|
338 |
*/
|
339 |
private void parseFeatureTypeListTag(KXmlParser parser) throws IOException, XmlPullParserException{ |
340 |
int currentTag;
|
341 |
boolean end = false; |
342 |
|
343 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_FEATURETYPELIST);
|
344 |
currentTag = parser.next(); |
345 |
|
346 |
while (!end)
|
347 |
{ |
348 |
switch(currentTag)
|
349 |
{ |
350 |
case KXmlParser.START_TAG:
|
351 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.WFS_FEATURETYPE)==0){ |
352 |
//Parse the namespaces...
|
353 |
parseNamespaces(parser); |
354 |
WFSFeature1_0_0 feature = new WFSFeature1_0_0(serviceInfo);
|
355 |
feature.parse(parser); |
356 |
features.put(feature.getName(),feature); |
357 |
} |
358 |
break;
|
359 |
case KXmlParser.END_TAG:
|
360 |
if (parser.getName().compareTo(CapabilitiesTags.WFS_FEATURETYPELIST) == 0) |
361 |
end = true;
|
362 |
break;
|
363 |
case KXmlParser.TEXT:
|
364 |
break;
|
365 |
} |
366 |
if (!end){
|
367 |
currentTag = parser.next(); |
368 |
} |
369 |
} |
370 |
} |
371 |
|
372 |
/*
|
373 |
* (non-Javadoc)
|
374 |
* @see org.gvsig.remoteClient.wfs.WFSProtocolHandler#parseGetFeature(java.io.File, java.lang.String)
|
375 |
*/
|
376 |
protected boolean parseGetFeature(File f, String nameSpace) throws WFSException { |
377 |
XMLSchemaParser parser = null;
|
378 |
parser = new XMLSchemaParser();
|
379 |
try
|
380 |
{ |
381 |
parser.setInput(f); |
382 |
parser.nextTag(); |
383 |
if (parser.getName().compareTo(CapabilitiesTags.SERVICE_EXCEPTION_REPORT)==0){ |
384 |
throw ExceptionsFactory.parseServiceExceptionReport(parser);
|
385 |
} |
386 |
} catch (FileNotFoundException e) { |
387 |
e.printStackTrace(); |
388 |
throw new WFSGetFeatureException(e); |
389 |
} catch (XmlPullParserException e) {
|
390 |
e.printStackTrace(); |
391 |
throw new WFSGetFeatureException(e); |
392 |
} catch (IOException e) { |
393 |
e.printStackTrace(); |
394 |
throw new WFSGetFeatureException(e); |
395 |
} |
396 |
|
397 |
return true; |
398 |
} |
399 |
|
400 |
/*
|
401 |
* (non-Javadoc)
|
402 |
* @see org.gvsig.remoteClient.wfs.WFSProtocolHandler#parseTransaction(java.io.File, java.lang.String)
|
403 |
*/
|
404 |
protected boolean parseTransaction(File f, WFSStatus status) throws WFSException { |
405 |
int tag;
|
406 |
XMLSchemaParser parser = null;
|
407 |
parser = new XMLSchemaParser();
|
408 |
|
409 |
WFSTransactionRequestInformation transactionRequestInformation = |
410 |
(WFSTransactionRequestInformation)this.getLastWfsRequestInformation();
|
411 |
|
412 |
try
|
413 |
{ |
414 |
parser.setInput(f); |
415 |
parser.nextTag(); |
416 |
if (CapabilitiesTags.SERVICE_EXCEPTION_REPORT.equals(parser.getName())) {
|
417 |
throw ExceptionsFactory.parseServiceExceptionReport(parser);
|
418 |
}else if (parser.getName().equals(CapabilitiesTags.EXCEPTION_REPORT)){ |
419 |
throw ExceptionsFactory.parseExceptionReport(parser);
|
420 |
} |
421 |
|
422 |
if ( parser.getEventType() != KXmlParser.END_DOCUMENT )
|
423 |
{ |
424 |
tag = parser.nextTag(); |
425 |
while(tag != KXmlParser.END_DOCUMENT)
|
426 |
{ |
427 |
switch(tag)
|
428 |
{ |
429 |
case KXmlParser.START_TAG:
|
430 |
if (parser.getName().compareTo(WFSTTags.WFST_TRANSACTIONRESULT)==0){ |
431 |
parseTransactionResult(parser, transactionRequestInformation); |
432 |
}else if (parser.getName().compareTo(WFSTTags.WFST_TRANSACTIONRESPONSE)==0){ |
433 |
parseFeaturesLocked(parser); |
434 |
} |
435 |
break;
|
436 |
case KXmlParser.END_TAG:
|
437 |
break;
|
438 |
case KXmlParser.TEXT:
|
439 |
break;
|
440 |
} |
441 |
tag = parser.next(); |
442 |
} |
443 |
parser.require(KXmlParser.END_DOCUMENT, null, null); |
444 |
} |
445 |
} |
446 |
catch(XmlPullParserException parser_ex){
|
447 |
parser_ex.printStackTrace(); |
448 |
return false; |
449 |
} |
450 |
catch (IOException ioe) { |
451 |
ioe.printStackTrace(); |
452 |
return false; |
453 |
} |
454 |
return true; |
455 |
} |
456 |
|
457 |
/**
|
458 |
* Parse the transaction result XML sub tree
|
459 |
* @param parser
|
460 |
* @param transaction
|
461 |
* @throws IOException
|
462 |
* @throws XmlPullParserException
|
463 |
*/
|
464 |
private void parseTransactionResult(XMLSchemaParser parser, |
465 |
WFSTransactionRequestInformation transactionRequestInformation) throws XmlPullParserException, IOException { |
466 |
int currentTag;
|
467 |
boolean end = false; |
468 |
|
469 |
currentTag = parser.next(); |
470 |
|
471 |
while (!end)
|
472 |
{ |
473 |
switch(currentTag)
|
474 |
{ |
475 |
case KXmlParser.START_TAG:
|
476 |
if (parser.getName().compareTo(WFSTTags.WFST_STATUS)==0){ |
477 |
parseStatus(parser, transactionRequestInformation); |
478 |
}else if (parser.getName().compareTo(WFSTTags.WFST_TRANSACTIONMESSAGE)==0){ |
479 |
parser.next(); |
480 |
transactionRequestInformation.setMessage(parser.getText()); |
481 |
} |
482 |
break;
|
483 |
case KXmlParser.END_TAG:
|
484 |
if (parser.getName().compareTo(WFSTTags.WFST_TRANSACTIONRESULT)==0) |
485 |
end = true;
|
486 |
break;
|
487 |
case KXmlParser.TEXT:
|
488 |
break;
|
489 |
} |
490 |
if (!end){
|
491 |
currentTag = parser.next(); |
492 |
} |
493 |
} |
494 |
} |
495 |
|
496 |
/**
|
497 |
* Parser WFST Status subtree
|
498 |
* @param parser
|
499 |
* Teh xML parser
|
500 |
* @param transaction
|
501 |
* The current transaction
|
502 |
* @throws IOException
|
503 |
* @throws XmlPullParserException
|
504 |
*/
|
505 |
private void parseStatus(XMLSchemaParser parser, WFSTransactionRequestInformation transactionRequestInformation) throws XmlPullParserException, IOException { |
506 |
int currentTag;
|
507 |
boolean end = false; |
508 |
|
509 |
currentTag = parser.next(); |
510 |
|
511 |
while (!end)
|
512 |
{ |
513 |
switch(currentTag)
|
514 |
{ |
515 |
case KXmlParser.START_TAG:
|
516 |
if (parser.getName().compareTo(WFSTTags.WFST_SUCCESS)==0){ |
517 |
transactionRequestInformation.setStatus(WFSTransactionRequestInformation.STATUS_SUCCESS); |
518 |
}else if (parser.getName().compareTo(WFSTTags.WFST_FAILED)==0){ |
519 |
transactionRequestInformation.setStatus(WFSTransactionRequestInformation.STATUS_FAILED); |
520 |
} |
521 |
break;
|
522 |
case KXmlParser.END_TAG:
|
523 |
if (parser.getName().compareTo(WFSTTags.WFST_STATUS)==0) |
524 |
end = true;
|
525 |
break;
|
526 |
case KXmlParser.TEXT:
|
527 |
break;
|
528 |
} |
529 |
if (!end){
|
530 |
currentTag = parser.next(); |
531 |
} |
532 |
} |
533 |
} |
534 |
|
535 |
/*
|
536 |
* (non-Javadoc)
|
537 |
* @see org.gvsig.remoteClient.wfs.WFSProtocolHandler#parseLockFeature(java.io.File, java.lang.String)
|
538 |
*/
|
539 |
protected boolean parseLockFeature(File f, String nameSpace, WFSStatus status) throws WFSException { |
540 |
int tag;
|
541 |
XMLSchemaParser parser = null;
|
542 |
parser = new XMLSchemaParser();
|
543 |
try
|
544 |
{ |
545 |
parser.setInput(f); |
546 |
parser.nextTag(); |
547 |
if (parser.getName().compareTo(CapabilitiesTags.SERVICE_EXCEPTION_REPORT)==0){ |
548 |
throw ExceptionsFactory.parseServiceExceptionReport(parser);
|
549 |
} |
550 |
|
551 |
|
552 |
if ( parser.getEventType() != KXmlParser.END_DOCUMENT )
|
553 |
{ |
554 |
tag = parser.nextTag(); |
555 |
while(tag != KXmlParser.END_DOCUMENT)
|
556 |
{ |
557 |
switch(tag)
|
558 |
{ |
559 |
case KXmlParser.START_TAG:
|
560 |
if (parser.getName().compareTo(WFSTTags.WFST_LOCKID)==0){ |
561 |
parser.next(); |
562 |
status.addFeatureLocked(parser.getText()); |
563 |
}else if (parser.getName().compareTo(WFSTTags.WFST_FEATURESLOCKED)==0){ |
564 |
parseFeaturesLocked(parser); |
565 |
} |
566 |
break;
|
567 |
case KXmlParser.END_TAG:
|
568 |
break;
|
569 |
case KXmlParser.TEXT:
|
570 |
break;
|
571 |
} |
572 |
tag = parser.next(); |
573 |
} |
574 |
parser.require(KXmlParser.END_DOCUMENT, null, null); |
575 |
} |
576 |
} |
577 |
catch(XmlPullParserException parser_ex){
|
578 |
parser_ex.printStackTrace(); |
579 |
return false; |
580 |
} |
581 |
catch (IOException ioe) { |
582 |
ioe.printStackTrace(); |
583 |
return false; |
584 |
} |
585 |
return true; |
586 |
} |
587 |
|
588 |
/**
|
589 |
* It parses the featuresLocked tag
|
590 |
* @param parser
|
591 |
* @throws IOException
|
592 |
* @throws XmlPullParserException
|
593 |
*/
|
594 |
private void parseFeaturesLocked(XMLSchemaParser parser) throws XmlPullParserException, IOException { |
595 |
int currentTag;
|
596 |
boolean end = false; |
597 |
|
598 |
currentTag = parser.next(); |
599 |
|
600 |
while (!end)
|
601 |
{ |
602 |
switch(currentTag)
|
603 |
{ |
604 |
case KXmlParser.START_TAG:
|
605 |
if (parser.getName().compareTo(WFSTTags.WFST_FEATURESID)==0){ |
606 |
|
607 |
} |
608 |
break;
|
609 |
case KXmlParser.END_TAG:
|
610 |
if (parser.getName().compareTo(WFSTTags.WFST_FEATURESLOCKED)==0) |
611 |
end = true;
|
612 |
break;
|
613 |
case KXmlParser.TEXT:
|
614 |
break;
|
615 |
} |
616 |
if (!end){
|
617 |
currentTag = parser.next(); |
618 |
} |
619 |
} |
620 |
} |
621 |
|
622 |
/*
|
623 |
* (non-Javadoc)
|
624 |
* @see org.gvsig.remoteClient.wfs.WFSProtocolHandler#createDescribeFeatureTypeRequest(org.gvsig.remoteClient.wfs.WFSStatus)
|
625 |
*/
|
626 |
protected WFSDescribeFeatureTypeRequest createDescribeFeatureTypeRequest(
|
627 |
WFSStatus status) { |
628 |
return new WFSDescribeFeatureTypeRequest1_0_0(status, this); |
629 |
} |
630 |
|
631 |
/*
|
632 |
* (non-Javadoc)
|
633 |
* @see org.gvsig.remoteClient.wfs.WFSProtocolHandler#createGetFeatureRequest(org.gvsig.remoteClient.wfs.WFSStatus)
|
634 |
*/
|
635 |
protected WFSGetFeatureRequest createGetFeatureRequest(WFSStatus status) {
|
636 |
return new WFSGetFeatureRequest1_0_0(status, this); |
637 |
} |
638 |
|
639 |
/*
|
640 |
* (non-Javadoc)
|
641 |
* @see org.gvsig.remoteClient.wfs.WFSProtocolHandler#createLockFeatureRequest(org.gvsig.remoteClient.wfs.WFSStatus)
|
642 |
*/
|
643 |
protected WFSTLockFeatureRequest createLockFeatureRequest(WFSStatus status) {
|
644 |
return new WFSTLockFeatureRequest1_0_0(status, this); |
645 |
} |
646 |
|
647 |
protected WFSTransactionRequest createTransactionRequest(WFSStatus status) {
|
648 |
return new WFSTransactionRequest1_0_0(status, this); |
649 |
} |
650 |
} |