Revision 119
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.8/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<artifactId>org.gvsig.wfs.app</artifactId> |
|
4 |
<packaging>pom</packaging> |
|
5 |
|
|
6 |
<name>Formats: WFS support</name> |
|
7 |
<description>Web Feature Service support</description> |
|
8 |
<version>2.0.8</version> |
|
9 |
|
|
10 |
<parent> |
|
11 |
<groupId>org.gvsig</groupId> |
|
12 |
<artifactId>org.gvsig.desktop</artifactId> |
|
13 |
<version>2.0.58</version> |
|
14 |
</parent> |
|
15 |
|
|
16 |
<url>https://devel.gvsig.org/redmine/projects/gvsig-wfs</url> |
|
17 |
|
|
18 |
<repositories> |
|
19 |
<repository> |
|
20 |
<id>gvsig-public-http-repository</id> |
|
21 |
<name>gvSIG maven public HTTP repository</name> |
|
22 |
<url>http://devel.gvsig.org/m2repo/j2se</url> |
|
23 |
<releases> |
|
24 |
<enabled>true</enabled> |
|
25 |
<updatePolicy>daily</updatePolicy> |
|
26 |
<checksumPolicy>warn</checksumPolicy> |
|
27 |
</releases> |
|
28 |
<snapshots> |
|
29 |
<enabled>true</enabled> |
|
30 |
<updatePolicy>daily</updatePolicy> |
|
31 |
<checksumPolicy>warn</checksumPolicy> |
|
32 |
</snapshots> |
|
33 |
</repository> |
|
34 |
</repositories> |
|
35 |
|
|
36 |
<scm> |
|
37 |
<connection>scm:svn:https://devel.gvsig.org/svn/gvsig-wfs/org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.8</connection> |
|
38 |
<developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-wfs/org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.8</developerConnection> |
|
39 |
<url>scm:svn:https://devel.gvsig.org/svn/gvsig-wfs/org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.8</url> |
|
40 |
</scm> |
|
41 |
|
|
42 |
<build> |
|
43 |
<plugins> |
|
44 |
<plugin> |
|
45 |
<groupId>org.apache.maven.plugins</groupId> |
|
46 |
<artifactId>maven-release-plugin</artifactId> |
|
47 |
<configuration> |
|
48 |
<tagBase>https://devel.gvsig.org/svn/gvsig-wfs/org.gvsig.wfs.app/tags</tagBase> |
|
49 |
</configuration> |
|
50 |
</plugin> |
|
51 |
</plugins> |
|
52 |
</build> |
|
53 |
|
|
54 |
<dependencyManagement> |
|
55 |
<dependencies> |
|
56 |
|
|
57 |
<dependency> |
|
58 |
<groupId>org.gvsig</groupId> |
|
59 |
<artifactId>org.gvsig.gpe.lib.api</artifactId> |
|
60 |
<version>2.1.1</version> |
|
61 |
</dependency> |
|
62 |
<dependency> |
|
63 |
<groupId>org.gvsig</groupId> |
|
64 |
<artifactId>org.gvsig.xmlschema.lib.api</artifactId> |
|
65 |
<version>2.0.1</version> |
|
66 |
</dependency> |
|
67 |
<dependency> |
|
68 |
<groupId>org.gvsig</groupId> |
|
69 |
<artifactId>org.gvsig.xmlpull.lib.impl</artifactId> |
|
70 |
<version>2.0.1</version> |
|
71 |
</dependency> |
|
72 |
<dependency> |
|
73 |
<groupId>org.gvsig</groupId> |
|
74 |
<artifactId>org.gvsig.xmlpull.prov.kxml</artifactId> |
|
75 |
<version>2.0.1</version> |
|
76 |
</dependency> |
|
77 |
<dependency> |
|
78 |
<groupId>org.gvsig</groupId> |
|
79 |
<artifactId>org.gvsig.xmlschema.lib.impl</artifactId> |
|
80 |
<version>2.0.1</version> |
|
81 |
</dependency> |
|
82 |
<dependency> |
|
83 |
<groupId>org.gvsig</groupId> |
|
84 |
<artifactId>org.gvsig.xmlschema.prov.kxml</artifactId> |
|
85 |
<version>2.0.1</version> |
|
86 |
</dependency> |
|
87 |
|
|
88 |
</dependencies> |
|
89 |
</dependencyManagement> |
|
90 |
|
|
91 |
<modules> |
|
92 |
<module>org.gvsig.wfs.app.mainplugin</module> |
|
93 |
</modules> |
|
94 |
|
|
95 |
</project> |
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.8/org.gvsig.wfs.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
</fileSets> |
|
24 |
|
|
25 |
<!-- |
|
26 |
<dependencySets> |
|
27 |
<dependencySet> |
|
28 |
<useProjectArtifact>false</useProjectArtifact> |
|
29 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
30 |
<outputDirectory>lib</outputDirectory> |
|
31 |
<includes> |
|
32 |
<include>org.gvsig:org.gvsig.wfs.app.mainplugin</include> |
|
33 |
</includes> |
|
34 |
</dependencySet> |
|
35 |
</dependencySets> |
|
36 |
--> |
|
37 |
|
|
38 |
</assembly> |
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.8/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/WFSSchemaParser.java | ||
---|---|---|
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; |
|
25 |
|
|
26 |
import java.io.IOException; |
|
27 |
|
|
28 |
import org.kxml2.io.KXmlParser; |
|
29 |
import org.xmlpull.v1.XmlPullParserException; |
|
30 |
|
|
31 |
/** |
|
32 |
* |
|
33 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
34 |
*/ |
|
35 |
public class WFSSchemaParser extends KXmlParser { |
|
36 |
private String schema = ""; |
|
37 |
|
|
38 |
public WFSSchemaParser(){ |
|
39 |
super(); |
|
40 |
} |
|
41 |
|
|
42 |
public WFSSchemaParser(String schema){ |
|
43 |
this.schema = schema; |
|
44 |
} |
|
45 |
|
|
46 |
/** |
|
47 |
* It gets the schema from a tag. The schema is separated |
|
48 |
* of the tag name by ":". |
|
49 |
* @param tag |
|
50 |
*/ |
|
51 |
public void setSchemaFromMainTag(String tag){ |
|
52 |
int pos = tag.indexOf(":"); |
|
53 |
if (pos > 0){ |
|
54 |
this.schema = tag.substring(0,pos); |
|
55 |
}else{ |
|
56 |
this.schema = ""; |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* @return Returns the schema. |
|
62 |
*/ |
|
63 |
public String getSchema() { |
|
64 |
return schema; |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* @param schema The schema to set. |
|
69 |
*/ |
|
70 |
public void setSchema(String schema) { |
|
71 |
this.schema = schema; |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Returns a SCHEMA:TAG |
|
76 |
* @param tag |
|
77 |
* @return SCHEMA:TAG |
|
78 |
*/ |
|
79 |
private String getTag(String tag){ |
|
80 |
if (tag == null){ |
|
81 |
return null; |
|
82 |
} |
|
83 |
if ((schema == null) || (schema.equals(""))){ |
|
84 |
return tag; |
|
85 |
} |
|
86 |
return schema + ":" + tag; |
|
87 |
} |
|
88 |
|
|
89 |
/* |
|
90 |
* (non-Javadoc) |
|
91 |
* @see org.xmlpull.v1.XmlPullParser#require(int, java.lang.String, java.lang.String) |
|
92 |
*/ |
|
93 |
public void require(int type, String namespace, String name) |
|
94 |
throws XmlPullParserException, IOException{ |
|
95 |
super.require(type,namespace,getTag(name)); |
|
96 |
} |
|
97 |
|
|
98 |
/* |
|
99 |
* (non-Javadoc) |
|
100 |
* @see org.xmlpull.v1.XmlPullParser#getName() |
|
101 |
*/ |
|
102 |
public String getName(){ |
|
103 |
try{ |
|
104 |
String name = super.getName(); |
|
105 |
if ((schema != null) || (!(schema.equals("")))){ |
|
106 |
return name.substring(name.indexOf(":") + 1,name.length()); |
|
107 |
} |
|
108 |
return name; |
|
109 |
}catch (NullPointerException e){ |
|
110 |
return ""; |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
} |
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.8/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/wfs_1_0_0/request/WFSTLockFeatureRequest1_0_0.java | ||
---|---|---|
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.request; |
|
25 |
|
|
26 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
27 |
import org.gvsig.remoteclient.wfs.WFSProtocolHandler; |
|
28 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
|
29 |
import org.gvsig.remoteclient.wfs.edition.WFSTTags; |
|
30 |
import org.gvsig.remoteclient.wfs.request.WFSTLockFeatureRequest; |
|
31 |
|
|
32 |
/** |
|
33 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
34 |
*/ |
|
35 |
public class WFSTLockFeatureRequest1_0_0 extends WFSTLockFeatureRequest{ |
|
36 |
|
|
37 |
public WFSTLockFeatureRequest1_0_0(WFSStatus status, |
|
38 |
WFSProtocolHandler protocolHandler) { |
|
39 |
super(status, protocolHandler); |
|
40 |
} |
|
41 |
|
|
42 |
/* |
|
43 |
* (non-Javadoc) |
|
44 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getHttpGetRequest(java.lang.String) |
|
45 |
*/ |
|
46 |
protected String getHttpGetRequest(String onlineResource) { |
|
47 |
StringBuffer req = new StringBuffer(); |
|
48 |
req.append(onlineResource); |
|
49 |
req.append("REQUEST=LockFeature&SERVICE=WFS&"); |
|
50 |
req.append("TYPENAME=").append(status.getFeatureName()).append("&"); |
|
51 |
req.append("LOCKACTION=" + status.getLockAction() + "&"); |
|
52 |
if (status.getFilterQueryLocked() != null){ |
|
53 |
req.append("FILTER="); |
|
54 |
req.append(status.getFilterQueryLocked() + "&"); |
|
55 |
} |
|
56 |
if (status.getExpiry() > 0){ |
|
57 |
req.append("EXPIRY=" + status.getExpiry() + "&"); |
|
58 |
} |
|
59 |
req.append("VERSION=").append(protocolHandler.getVersion()).append("&EXCEPTIONS=XML"); |
|
60 |
req.append("&MAXFEATURES=").append(status.getMaxFeatures()); |
|
61 |
return req.toString(); |
|
62 |
} |
|
63 |
|
|
64 |
/* |
|
65 |
* (non-Javadoc) |
|
66 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getHttpPostRequest(java.lang.String) |
|
67 |
*/ |
|
68 |
protected String getHttpPostRequest(String onlineResource) { |
|
69 |
StringBuffer request = new StringBuffer(); |
|
70 |
request.append(WFSTTags.XML_ROOT); |
|
71 |
request.append("<" + WFSTTags.WFS_NAMESPACE_PREFIX + ":"); |
|
72 |
request.append(CapabilitiesTags.WFS_LOCKFEATURE + " "); |
|
73 |
request.append(CapabilitiesTags.VERSION + "=\"" + protocolHandler.getVersion() + "\" "); |
|
74 |
request.append(WFSTTags.WFST_SERVICE + "=\"WFS\" "); |
|
75 |
if (status.getExpiry() > 0){ |
|
76 |
request.append(WFSTTags.WFST_EXPIRYTIME + "=\"" + status.getExpiry() + "\" "); |
|
77 |
} |
|
78 |
request.append(WFSTTags.XMLNS + ":" + WFSTTags.OGC_NAMESPACE_PREFIX); |
|
79 |
request.append("=\"" + WFSTTags.OGC_NAMESPACE + "\" "); |
|
80 |
request.append(WFSTTags.XMLNS + ":" + WFSTTags.WFS_NAMESPACE_PREFIX); |
|
81 |
request.append("=\"" + WFSTTags.WFS_NAMESPACE + "\" "); |
|
82 |
request.append(WFSTTags.XMLNS + ":" + WFSTTags.XML_NAMESPACE_PREFIX); |
|
83 |
request.append("=\"" + WFSTTags.XML_NAMESPACE + "\" "); |
|
84 |
request.append(WFSTTags.XMLNS + ":" + WFSTTags.GML_NAMESPACE_PREFIX); |
|
85 |
request.append("=\"" + WFSTTags.GML_NAMESPACE + "\" "); |
|
86 |
request.append(WFSTTags.XMLNS + ":" + status.getNamespacePrefix()); |
|
87 |
request.append("=\"" + status.getNamespaceLocation() + "\" "); |
|
88 |
request.append(WFSTTags.XML_NAMESPACE_PREFIX + ":" + WFSTTags.XML_SCHEMALOCATION); |
|
89 |
request.append("=\"" + WFSTTags.WFS_NAMESPACE + " "); |
|
90 |
request.append(getSchemaLocation()); |
|
91 |
request.append("\">"); |
|
92 |
request.append(getLockPostRequest()); |
|
93 |
request.append("</" + WFSTTags.WFS_NAMESPACE_PREFIX + ":"); |
|
94 |
request.append(CapabilitiesTags.WFS_LOCKFEATURE + ">"); |
|
95 |
return request.toString(); |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* Creates a Lock query for a HTTP Post request |
|
100 |
* @return |
|
101 |
*/ |
|
102 |
private String getLockPostRequest(){ |
|
103 |
StringBuffer request = new StringBuffer(); |
|
104 |
request.append("<" + WFSTTags.WFS_NAMESPACE_PREFIX + ":"); |
|
105 |
request.append(WFSTTags.WFST_LOCK); |
|
106 |
request.append(" typeName=\"" + status.getFeatureName() + "\""); |
|
107 |
request.append(">"); |
|
108 |
String filter = status.getFilterQueryLocked(); |
|
109 |
if (filter != null){ |
|
110 |
request.append(status.getFilterQueryLockedPost()); |
|
111 |
} |
|
112 |
request.append("</" + WFSTTags.WFS_NAMESPACE_PREFIX + ":"); |
|
113 |
request.append(WFSTTags.WFST_LOCK + ">"); |
|
114 |
return request.toString(); |
|
115 |
} |
|
116 |
|
|
117 |
/* |
|
118 |
* (non-Javadoc) |
|
119 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getSchemaLocation() |
|
120 |
*/ |
|
121 |
protected String getSchemaLocation() { |
|
122 |
return "../wfs/1.0.0/WFS-transaction.xsd"; |
|
123 |
} |
|
124 |
|
|
125 |
} |
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.8/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/wfs_1_0_0/request/WFSGetFeatureRequest1_0_0.java | ||
---|---|---|
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.request; |
|
25 |
|
|
26 |
import org.gvsig.remoteclient.wfs.WFSProtocolHandler; |
|
27 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
|
28 |
import org.gvsig.remoteclient.wfs.filters.filterencoding.FilterEncoding; |
|
29 |
import org.gvsig.remoteclient.wfs.request.WFSGetFeatureRequest; |
|
30 |
|
|
31 |
/** |
|
32 |
* @author Jorge Piera Llodr? (jorge.piera@iver.es) |
|
33 |
*/ |
|
34 |
public class WFSGetFeatureRequest1_0_0 extends WFSGetFeatureRequest{ |
|
35 |
|
|
36 |
public WFSGetFeatureRequest1_0_0(WFSStatus status, |
|
37 |
WFSProtocolHandler protocolHandler) { |
|
38 |
super(status, protocolHandler); |
|
39 |
} |
|
40 |
|
|
41 |
|
|
42 |
/* |
|
43 |
* (non-Javadoc) |
|
44 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getHttpGetRequest(java.lang.String) |
|
45 |
*/ |
|
46 |
protected String getHttpGetRequest(String onlineResource) { |
|
47 |
StringBuffer req = new StringBuffer(); |
|
48 |
req.append(onlineResource); |
|
49 |
req.append("REQUEST=GetFeature&SERVICE=WFS&"); |
|
50 |
req.append("TYPENAME=").append(status.getFeatureFullName()).append("&"); |
|
51 |
String[] fields = status.getFields(); |
|
52 |
addPropertyName(req); |
|
53 |
if ((status.getFilterByAttribute() != null) || (status.getFilterByArea() != null)){ |
|
54 |
FilterEncoding filterEncoding = new FilterEncoding(status); |
|
55 |
req.append("FILTER=" + filterEncoding.toString(protocolHandler.getVersion()) + "&"); |
|
56 |
} |
|
57 |
req.append("VERSION=").append(protocolHandler.getVersion()).append("&EXCEPTIONS=XML"); |
|
58 |
req.append("&MAXFEATURES=").append(status.getMaxFeatures()); |
|
59 |
req.append("&SRSNAME=").append(status.getSrs()); |
|
60 |
|
|
61 |
return req.toString(); |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* Adds the "PROPERTYNAME" attribute |
|
66 |
* @param req |
|
67 |
* The current request |
|
68 |
*/ |
|
69 |
protected void addPropertyName(StringBuffer req){ |
|
70 |
String[] fields = status.getFields(); |
|
71 |
if (fields.length > 0){ |
|
72 |
req.append("PROPERTYNAME="); |
|
73 |
|
|
74 |
// opening parenthesis (march 2013) |
|
75 |
req.append("("); |
|
76 |
|
|
77 |
req.append(fields[0]); |
|
78 |
for (int i=1 ; i<fields.length ; i++){ |
|
79 |
req.append("," + fields[i]); |
|
80 |
} |
|
81 |
|
|
82 |
// closing parenthesis (march 2013) |
|
83 |
req.append(")"); |
|
84 |
|
|
85 |
req.append("&"); |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
protected String getSchemaLocation() { |
|
90 |
return "../wfs/1.0.0/WFS-basic.xsd"; |
|
91 |
} |
|
92 |
} |
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.8/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/wfs_1_0_0/request/WFSDescribeFeatureTypeRequest1_0_0.java | ||
---|---|---|
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.request; |
|
25 |
|
|
26 |
import org.gvsig.compat.CompatLocator; |
|
27 |
import org.gvsig.compat.lang.StringUtils; |
|
28 |
import org.gvsig.remoteclient.wfs.WFSProtocolHandler; |
|
29 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
|
30 |
import org.gvsig.remoteclient.wfs.request.WFSDescribeFeatureTypeRequest; |
|
31 |
|
|
32 |
/** |
|
33 |
* @author Jorge Piera Llodr? (jorge.piera@iver.es) |
|
34 |
*/ |
|
35 |
public class WFSDescribeFeatureTypeRequest1_0_0 extends WFSDescribeFeatureTypeRequest { |
|
36 |
|
|
37 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
38 |
|
|
39 |
public WFSDescribeFeatureTypeRequest1_0_0(WFSStatus status, |
|
40 |
WFSProtocolHandler protocolHandler) { |
|
41 |
super(status, protocolHandler); |
|
42 |
} |
|
43 |
|
|
44 |
/* |
|
45 |
* (non-Javadoc) |
|
46 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getHttpGetRequest(java.lang.String) |
|
47 |
*/ |
|
48 |
protected String getHttpGetRequest(String onlineResource) { |
|
49 |
StringBuffer req = new StringBuffer(); |
|
50 |
req.append(onlineResource); |
|
51 |
req.append("REQUEST=DescribeFeatureType&SERVICE=WFS&"); |
|
52 |
//Typename |
|
53 |
String typeName = status.getFeatureFullName(); |
|
54 |
if ((status.getNamespaceLocation() != null) && |
|
55 |
(status.getNamespacePrefix() != null)){ |
|
56 |
req.append("NAMESPACE="); |
|
57 |
req.append("xmlns(" + status.getNamespacePrefix() + "="); |
|
58 |
req.append(status.getNamespaceLocation() + ")"); |
|
59 |
req.append("&"); |
|
60 |
} |
|
61 |
req.append("TYPENAME=").append(typeName).append("&"); |
|
62 |
req.append("VERSION=").append(protocolHandler.getVersion()).append("&EXCEPTIONS=XML"); |
|
63 |
String request = stringUtils.replaceAll(req.toString(), "UEeRtKxB+ROJTlqYiWB3XQ==", "UEeRtKxB%2bROJTlqYiWB3XQ%3d%3d"); |
|
64 |
return request; |
|
65 |
} |
|
66 |
|
|
67 |
} |
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.8/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/wfs_1_0_0/request/WFSTransactionRequest1_0_0.java | ||
---|---|---|
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.request; |
|
25 |
|
|
26 |
import java.util.Iterator; |
|
27 |
|
|
28 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
29 |
import org.gvsig.remoteclient.wfs.WFSProtocolHandler; |
|
30 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
|
31 |
import org.gvsig.remoteclient.wfs.edition.IWFSTOperation; |
|
32 |
import org.gvsig.remoteclient.wfs.edition.WFSTInsertOperation; |
|
33 |
import org.gvsig.remoteclient.wfs.edition.WFSTTags; |
|
34 |
import org.gvsig.remoteclient.wfs.edition.WFSTTransaction; |
|
35 |
import org.gvsig.remoteclient.wfs.edition.WFSTUpdateOperation; |
|
36 |
import org.gvsig.remoteclient.wfs.filters.filterencoding.FilterEncoding; |
|
37 |
import org.gvsig.remoteclient.wfs.request.WFSTransactionRequest; |
|
38 |
|
|
39 |
|
|
40 |
/** |
|
41 |
* @author gvSIG Team |
|
42 |
* @version $Id$ |
|
43 |
* |
|
44 |
*/ |
|
45 |
public class WFSTransactionRequest1_0_0 extends WFSTransactionRequest{ |
|
46 |
|
|
47 |
/** |
|
48 |
* @param status |
|
49 |
* @param protocolHandler |
|
50 |
*/ |
|
51 |
public WFSTransactionRequest1_0_0(WFSStatus status, |
|
52 |
WFSProtocolHandler protocolHandler) { |
|
53 |
super(status, protocolHandler); |
|
54 |
} |
|
55 |
|
|
56 |
protected String getHttpGetRequest(String onlineResource) { |
|
57 |
// TODO Auto-generated method stub |
|
58 |
return null; |
|
59 |
} |
|
60 |
|
|
61 |
protected String getHttpPostRequest(String onlineResource) { |
|
62 |
StringBuffer request = new StringBuffer(); |
|
63 |
addHttpPostHeaderRequest(request); |
|
64 |
//Add the operations |
|
65 |
WFSTTransaction transaction = status.getTransaction(); |
|
66 |
|
|
67 |
//Insert operations |
|
68 |
for (int i=0 ; i<transaction.getInsertOperationSize() ; i++){ |
|
69 |
addInsertOperation(transaction.getInseOperationAt(i), request); |
|
70 |
} |
|
71 |
|
|
72 |
//Update operations |
|
73 |
for (int i=0 ; i<transaction.getUpdateOperationSize() ; i++){ |
|
74 |
addUpdateOperation(transaction.getUpdateOperationAt(i), request); |
|
75 |
} |
|
76 |
|
|
77 |
//Delete operations. All of them in just one operation |
|
78 |
if (transaction.getDeleteOperationSize() > 0){ |
|
79 |
IWFSTOperation firstOperation = transaction.getDeleteOperationAt(0); |
|
80 |
addOperationHeader(firstOperation, request); |
|
81 |
|
|
82 |
FilterEncoding filterEncoding = new FilterEncoding(status); |
|
83 |
filterEncoding.setQualified(true); |
|
84 |
for (int i=0 ; i<transaction.getDeleteOperationSize() ; i++){ |
|
85 |
filterEncoding.addFeatureById(transaction.getDeleteOperationAt(i).getId()); |
|
86 |
} |
|
87 |
request.append(filterEncoding.toString(protocolHandler.getVersion())); |
|
88 |
addOperationEnd(firstOperation, request); |
|
89 |
} |
|
90 |
addHttpPostEndRequest(request); |
|
91 |
return request.toString(); |
|
92 |
} |
|
93 |
|
|
94 |
private void addOperationHeader(IWFSTOperation operation, StringBuffer request){ |
|
95 |
request.append("<" + CapabilitiesTags.WFS_NAMESPACE_PREFIX + ":"); |
|
96 |
request.append(operation.getOperationName()); |
|
97 |
if (operation.hasTypeName()){ |
|
98 |
request.append(" typeName=\"" + status.getFeatureFullName() + "\""); |
|
99 |
} |
|
100 |
request.append(">"); |
|
101 |
} |
|
102 |
|
|
103 |
private void addOperationEnd(IWFSTOperation operation, StringBuffer request){ |
|
104 |
request.append("</" + CapabilitiesTags.WFS_NAMESPACE_PREFIX + ":"); |
|
105 |
request.append(operation.getOperationName() + ">"); |
|
106 |
} |
|
107 |
|
|
108 |
private void addInsertOperation(WFSTInsertOperation insertOperation, StringBuffer request){ |
|
109 |
addOperationHeader(insertOperation, request); |
|
110 |
request.append(createXMLStartTag(status.getFeatureFullName())); |
|
111 |
Iterator it = insertOperation.getKeysIterator(); |
|
112 |
while (it.hasNext()){ |
|
113 |
String attName = (String)it.next(); |
|
114 |
request.append(createXMLStartTag(status.getNamespacePrefix() + ":" + attName)); |
|
115 |
request.append(insertOperation.getValue(attName)); |
|
116 |
request.append(createXMLEndtTag(status.getNamespacePrefix() + ":" + attName)); |
|
117 |
} |
|
118 |
request.append(createXMLEndtTag(status.getFeatureFullName())); |
|
119 |
addOperationEnd(insertOperation, request); |
|
120 |
} |
|
121 |
|
|
122 |
private void addUpdateOperation(WFSTUpdateOperation updateOperation, StringBuffer request){ |
|
123 |
addOperationHeader(updateOperation, request); |
|
124 |
Iterator it = updateOperation.getKeysIterator(); |
|
125 |
while (it.hasNext()){ |
|
126 |
String attName = (String)it.next(); |
|
127 |
request.append(createXMLStartTag(UPDATE_PROPERTY_TAG)); |
|
128 |
request.append(createXMLStartTag(UPDATE_NAME_TAG)); |
|
129 |
request.append(status.getNamespacePrefix() + ":" + attName); |
|
130 |
request.append(createXMLEndtTag(UPDATE_NAME_TAG)); |
|
131 |
request.append(createXMLStartTag(UPDATE_VALUE_TAG)); |
|
132 |
request.append(updateOperation.getValue(attName)); |
|
133 |
request.append(createXMLEndtTag(UPDATE_VALUE_TAG)); |
|
134 |
request.append(createXMLEndtTag(UPDATE_PROPERTY_TAG)); |
|
135 |
} |
|
136 |
//Add the filter encoding |
|
137 |
FilterEncoding filterEncoding = new FilterEncoding(status); |
|
138 |
filterEncoding.setQualified(true); |
|
139 |
filterEncoding.addFeatureById(updateOperation.getId()); |
|
140 |
request.append(filterEncoding.toString(protocolHandler.getVersion())); |
|
141 |
addOperationEnd(updateOperation, request); |
|
142 |
} |
|
143 |
|
|
144 |
private void addHttpPostHeaderRequest(StringBuffer request){ |
|
145 |
request.append(WFSTTags.XML_ROOT); |
|
146 |
request.append("<" + WFSTTags.WFS_NAMESPACE_PREFIX + ":"); |
|
147 |
request.append(CapabilitiesTags.WFS_TRANSACTION + " "); |
|
148 |
request.append(CapabilitiesTags.VERSION + "=\"" + protocolHandler.getVersion() + "\" "); |
|
149 |
request.append(WFSTTags.WFST_RELEASEACTION + "=\"ALL\" "); |
|
150 |
request.append(WFSTTags.WFST_SERVICE + "=\"WFS\" "); |
|
151 |
request.append(WFSTTags.XMLNS + ":" + WFSTTags.OGC_NAMESPACE_PREFIX); |
|
152 |
request.append("=\"" + WFSTTags.OGC_NAMESPACE + "\" "); |
|
153 |
request.append(WFSTTags.XMLNS + ":" + WFSTTags.WFS_NAMESPACE_PREFIX); |
|
154 |
request.append("=\"" + WFSTTags.WFS_NAMESPACE + "\" "); |
|
155 |
request.append(WFSTTags.XMLNS + ":" + WFSTTags.XML_NAMESPACE_PREFIX); |
|
156 |
request.append("=\"" + WFSTTags.XML_NAMESPACE + "\" "); |
|
157 |
request.append(WFSTTags.XMLNS + ":" + WFSTTags.GML_NAMESPACE_PREFIX); |
|
158 |
request.append("=\"" + WFSTTags.GML_NAMESPACE + "\" "); |
|
159 |
request.append(WFSTTags.XMLNS + ":" + status.getNamespacePrefix()); |
|
160 |
request.append("=\"" + status.getNamespaceLocation() + "\" "); |
|
161 |
request.append(WFSTTags.XML_NAMESPACE_PREFIX + ":" + WFSTTags.XML_SCHEMALOCATION); |
|
162 |
request.append("=\"" + WFSTTags.WFS_NAMESPACE + " "); |
|
163 |
request.append(getSchemaLocation()); |
|
164 |
request.append("\">"); |
|
165 |
} |
|
166 |
|
|
167 |
private void addHttpPostEndRequest(StringBuffer request){ |
|
168 |
request.append("</" + WFSTTags.WFS_NAMESPACE_PREFIX + ":"); |
|
169 |
request.append(CapabilitiesTags.WFS_TRANSACTION + ">"); |
|
170 |
} |
|
171 |
|
|
172 |
protected String getSchemaLocation() { |
|
173 |
return "../wfs/1.0.0/WFS-transaction.xsd"; |
|
174 |
} |
|
175 |
} |
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.8/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/wfs_1_0_0/WFSFeature1_0_0.java | ||
---|---|---|
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.IOException; |
|
27 |
|
|
28 |
import org.kxml2.io.KXmlParser; |
|
29 |
import org.xmlpull.v1.XmlPullParserException; |
|
30 |
import org.gvsig.compat.CompatLocator; |
|
31 |
import org.gvsig.compat.lang.StringUtils; |
|
32 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
|
33 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
34 |
import org.gvsig.remoteclient.utils.Utilities; |
|
35 |
import org.gvsig.remoteclient.wfs.WFSFeature; |
|
36 |
import org.gvsig.remoteclient.wfs.WFSServiceInformation; |
|
37 |
import org.gvsig.remoteclient.wfs.schema.GMLTags; |
|
38 |
import org.gvsig.remoteclient.wfs.schema.XMLNameSpace; |
|
39 |
|
|
40 |
/** |
|
41 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
42 |
*/ |
|
43 |
public class WFSFeature1_0_0 extends WFSFeature{ |
|
44 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
45 |
|
|
46 |
WFSFeature1_0_0(WFSServiceInformation serviceInformation) { |
|
47 |
super(serviceInformation); |
|
48 |
} |
|
49 |
|
|
50 |
WFSFeature1_0_0(WFSServiceInformation serviceInformation, String name) { |
|
51 |
super(serviceInformation, name); |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* <p>Parses the contents of the parser(WMSCapabilities) |
|
56 |
* to extract the information about an WMSLayer</p> |
|
57 |
* @throws IOException |
|
58 |
* @throws XmlPullParserException |
|
59 |
* |
|
60 |
*/ |
|
61 |
public void parse(KXmlParser parser) throws XmlPullParserException, IOException{ |
|
62 |
int currentTag; |
|
63 |
boolean end = false; |
|
64 |
|
|
65 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_FEATURETYPE); |
|
66 |
|
|
67 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
68 |
String[] attName = stringUtils.split(parser.getAttributeName(i), ":"); |
|
69 |
if (attName.length == 2){ |
|
70 |
if (attName[0].compareTo(GMLTags.XML_NAMESPACE)==0){ |
|
71 |
XMLNameSpace nameSpace = new XMLNameSpace(attName[1],parser.getAttributeValue(i)); |
|
72 |
this.setNamespace(nameSpace); |
|
73 |
} |
|
74 |
} |
|
75 |
} |
|
76 |
|
|
77 |
currentTag = parser.next(); |
|
78 |
while (!end) |
|
79 |
{ |
|
80 |
switch(currentTag) |
|
81 |
{ |
|
82 |
case KXmlParser.START_TAG: |
|
83 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.NAME)==0) |
|
84 |
{ |
|
85 |
this.setName(parser.nextText()); |
|
86 |
} |
|
87 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.TITLE)==0) |
|
88 |
{ |
|
89 |
this.setTitle(parser.nextText()); |
|
90 |
} |
|
91 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.WFS_KEYWORDS)==0) |
|
92 |
{ |
|
93 |
String keyword = parser.nextText(); |
|
94 |
if ((keyword != null) || (!(keyword.equals("")))){ |
|
95 |
this.addKeyword(keyword); |
|
96 |
} |
|
97 |
} |
|
98 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.KEYWORD)==0) |
|
99 |
{ |
|
100 |
this.addKeyword(parser.nextText()); |
|
101 |
} |
|
102 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.SRS)==0) |
|
103 |
{ |
|
104 |
String value = parser.nextText(); |
|
105 |
if (value != null){ |
|
106 |
String[] mySRSs = stringUtils.split(value, " "); |
|
107 |
for (int i = 0; i < mySRSs.length; i++) { |
|
108 |
this.addSRS(mySRSs[i]); |
|
109 |
} |
|
110 |
|
|
111 |
} |
|
112 |
} |
|
113 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.LATLONGBOUNDINGBOX)==0) |
|
114 |
{ |
|
115 |
BoundaryBox bbox = new BoundaryBox(); |
|
116 |
// En las pruebas realizadas, mapserver ofrece en este tag el boundingbox |
|
117 |
// tanto si est? en coordenadas geogr?ficas como en cartesianas |
|
118 |
// y no incluye (en ninguno de los dos casos) el atributo SRS |
|
119 |
// as? que, para crear el bbox, lo tomamos del tag SRS si lo hubiera. |
|
120 |
if(this.getDefaultSRS()!=null){ |
|
121 |
bbox.setSrs(this.getDefaultSRS()); |
|
122 |
} else { |
|
123 |
bbox.setSrs(CapabilitiesTags.EPSG_4326); |
|
124 |
} |
|
125 |
String value = parser.getAttributeValue("",CapabilitiesTags.MINX); |
|
126 |
if ((value != null) && (Utilities.isNumber(value))) |
|
127 |
bbox.setXmin(Double.parseDouble(value)); |
|
128 |
value = parser.getAttributeValue("",CapabilitiesTags.MINY); |
|
129 |
if ((value != null) && (Utilities.isNumber(value))) |
|
130 |
bbox.setYmin(Double.parseDouble(value)); |
|
131 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXX); |
|
132 |
if ((value != null) && (Utilities.isNumber(value))) |
|
133 |
bbox.setXmax(Double.parseDouble(value)); |
|
134 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXY); |
|
135 |
if ((value != null) && (Utilities.isNumber(value))) |
|
136 |
bbox.setYmax(Double.parseDouble(value)); |
|
137 |
this.addBBox(bbox); |
|
138 |
this.setLatLonBbox(bbox); |
|
139 |
} |
|
140 |
if (parser.getName().compareTo(CapabilitiesTags.BOUNDINGBOX)==0) |
|
141 |
{ |
|
142 |
BoundaryBox bbox = new BoundaryBox(); |
|
143 |
String value = parser.getAttributeValue("",CapabilitiesTags.SRS); |
|
144 |
if (value != null) |
|
145 |
bbox.setSrs(value); |
|
146 |
value = parser.getAttributeValue("",CapabilitiesTags.MINX); |
|
147 |
if ((value != null) && (Utilities.isNumber(value))) |
|
148 |
bbox.setXmin(Double.parseDouble(value)); |
|
149 |
value = parser.getAttributeValue("",CapabilitiesTags.MINY); |
|
150 |
if ((value != null) && (Utilities.isNumber(value))) |
|
151 |
bbox.setYmin(Double.parseDouble(value)); |
|
152 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXX); |
|
153 |
if ((value != null) && (Utilities.isNumber(value))) |
|
154 |
bbox.setXmax(Double.parseDouble(value)); |
|
155 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXY); |
|
156 |
if ((value != null) && (Utilities.isNumber(value))) |
|
157 |
bbox.setYmax(Double.parseDouble(value)); |
|
158 |
if (bbox.getSrs() != null){ |
|
159 |
this.addBBox(bbox); |
|
160 |
this.addSRS(bbox.getSrs()); |
|
161 |
} |
|
162 |
} |
|
163 |
if (CapabilitiesTags.WGS84BOUNDINGBOX.equals(parser.getName())){ |
|
164 |
String lowerCorner = null; |
|
165 |
String upperCorner = null; |
|
166 |
parser.next(); |
|
167 |
String tagName = parser.getName(); |
|
168 |
while(!CapabilitiesTags.WGS84BOUNDINGBOX.equals(tagName)){ |
|
169 |
if ((CapabilitiesTags.LOWERCORNER.equals(tagName)) && (KXmlParser.START_TAG == currentTag)){ |
|
170 |
parser.next(); |
|
171 |
lowerCorner = parser.getText(); |
|
172 |
}else if ((CapabilitiesTags.UPPERCORNER.equals(tagName)) && (KXmlParser.START_TAG == currentTag)){ |
|
173 |
parser.next(); |
|
174 |
upperCorner = parser.getText(); |
|
175 |
} |
|
176 |
currentTag = parser.next(); |
|
177 |
tagName = parser.getName(); |
|
178 |
} |
|
179 |
if ((lowerCorner != null) && (upperCorner != null)){ |
|
180 |
BoundaryBox bbox = new BoundaryBox(); |
|
181 |
bbox.setSrs("EPSG:4326"); |
|
182 |
String[] lowerCoordinates = stringUtils.split(lowerCorner, "[! \t\r\n]"); |
|
183 |
if (lowerCoordinates.length >= 2){ |
|
184 |
try{ |
|
185 |
bbox.setXmin(Double.valueOf(lowerCoordinates[0]).doubleValue()); |
|
186 |
bbox.setYmin(Double.valueOf(lowerCoordinates[1]).doubleValue()); |
|
187 |
}catch(NumberFormatException e){ |
|
188 |
//Is not a number |
|
189 |
} |
|
190 |
} |
|
191 |
String[] upperCoordinates = stringUtils.split(upperCorner, "[! \t\r\n]"); |
|
192 |
if (upperCoordinates.length >= 2){ |
|
193 |
try{ |
|
194 |
bbox.setXmax(Double.valueOf(upperCoordinates[0]).doubleValue()); |
|
195 |
bbox.setYmax(Double.valueOf(upperCoordinates[1]).doubleValue()); |
|
196 |
}catch(NumberFormatException e){ |
|
197 |
//Is not a number |
|
198 |
} |
|
199 |
} |
|
200 |
bbox = BoundaryBox.clipGeodeticBBox(bbox); |
|
201 |
this.addBBox(bbox); |
|
202 |
this.setLatLonBbox(bbox); |
|
203 |
} |
|
204 |
} |
|
205 |
|
|
206 |
break; |
|
207 |
case KXmlParser.END_TAG: |
|
208 |
if (parser.getName().compareTo(CapabilitiesTags.WFS_FEATURETYPE) == 0) |
|
209 |
end = true; |
|
210 |
break; |
|
211 |
case KXmlParser.TEXT: |
|
212 |
break; |
|
213 |
} |
|
214 |
if (!end){ |
|
215 |
currentTag = parser.next(); |
|
216 |
} |
|
217 |
} |
|
218 |
} |
|
219 |
} |
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.8/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/remoteclient/wfs/wfs_1_0_0/WFSProtocolHandler1_0_0.java | ||
---|---|---|
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.utils.Utilities; |
|
37 |
import org.gvsig.remoteclient.wfs.WFSProtocolHandler; |
|
38 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
|
39 |
import org.gvsig.remoteclient.wfs.edition.WFSTTags; |
|
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 |
import org.slf4j.Logger; |
|
54 |
import org.slf4j.LoggerFactory; |
|
55 |
|
|
56 |
/** |
|
57 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
58 |
*/ |
|
59 |
public class WFSProtocolHandler1_0_0 extends WFSProtocolHandler{ |
|
60 |
|
|
61 |
private static Logger logger = LoggerFactory.getLogger(WFSProtocolHandler1_0_0.class); |
|
62 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
63 |
|
|
64 |
public WFSProtocolHandler1_0_0(){ |
|
65 |
this.version = "1.0.0"; |
|
66 |
this.name = "WFS1.0.0"; |
|
67 |
} |
|
68 |
|
|
69 |
/* |
|
70 |
* (non-Javadoc) |
|
71 |
* @see org.gvsig.remoteClient.OGCProtocolHandler#parseCapabilities(java.io.File) |
|
72 |
*/ |
|
73 |
public boolean parseCapabilities(File f) { |
|
74 |
int tag; |
|
75 |
XMLSchemaParser parser = null; |
|
76 |
parser = new XMLSchemaParser(); |
|
77 |
try |
|
78 |
{ |
|
79 |
parser.setInput(f); |
|
80 |
parser.nextTag(); |
|
81 |
|
|
82 |
if ( parser.getEventType() != KXmlParser.END_DOCUMENT ) |
|
83 |
{ |
|
84 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_CAPABILITIES_ROOT1_0_0); |
|
85 |
//Parses the Namespaces... |
|
86 |
parseNamespaces(parser); |
|
87 |
//Parse the capabilities document |
|
88 |
tag = parser.nextTag(); |
|
89 |
while(tag != KXmlParser.END_DOCUMENT) |
|
90 |
{ |
|
91 |
switch(tag) |
|
92 |
{ |
|
93 |
case KXmlParser.START_TAG: |
|
94 |
if (parser.getName().compareTo(CapabilitiesTags.SERVICE)==0) |
|
95 |
{ |
|
96 |
parseServiceTag(parser); |
|
97 |
} |
|
98 |
else if (parser.getName().compareTo(CapabilitiesTags.CAPABILITY)==0) |
|
99 |
{ |
|
100 |
parseCapabilityTag(parser); |
|
101 |
} |
|
102 |
else if (parser.getName().compareTo(CapabilitiesTags.WFS_FEATURETYPELIST)==0) |
|
103 |
{ |
|
104 |
parseFeatureTypeListTag(parser); |
|
105 |
} |
|
106 |
break; |
|
107 |
case KXmlParser.END_TAG: |
|
108 |
break; |
|
109 |
case KXmlParser.TEXT: |
|
110 |
break; |
|
111 |
} |
|
112 |
tag = parser.next(); |
|
113 |
} |
|
114 |
parser.require(KXmlParser.END_DOCUMENT, null, null); |
|
115 |
} |
|
116 |
} |
|
117 |
catch(XmlPullParserException parser_ex){ |
|
118 |
logger.warn("Can't parse capabilities '"+Utilities.getAbsolutePathOrEmpty(f)+"'.",parser_ex); |
|
119 |
return false; |
|
120 |
} |
|
121 |
catch (IOException ioe) { |
|
122 |
logger.warn("Can't parse capabilities '"+Utilities.getAbsolutePathOrEmpty(f)+"'.",ioe); |
|
123 |
return false; |
|
124 |
} |
|
125 |
return true; |
|
126 |
} |
|
127 |
|
|
128 |
/** |
|
129 |
* <p>Parses the Service Information </p> |
|
130 |
*/ |
|
131 |
private void parseServiceTag(KXmlParser parser) throws IOException, XmlPullParserException |
|
132 |
{ |
|
133 |
int currentTag; |
|
134 |
boolean end = false; |
|
135 |
|
|
136 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.SERVICE); |
|
137 |
currentTag = parser.next(); |
|
138 |
|
|
139 |
while (!end) |
|
140 |
{ |
|
141 |
switch(currentTag) |
|
142 |
{ |
|
143 |
case KXmlParser.START_TAG: |
|
144 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.NAME)==0) |
|
145 |
{ |
|
146 |
serviceInfo.name = parser.nextText(); |
|
147 |
} |
|
148 |
else if (parser.getName().compareTo(CapabilitiesTags.WFS_TITLE)==0) |
|
149 |
{ |
|
150 |
serviceInfo.title = parser.nextText(); |
|
151 |
} |
|
152 |
else if (parser.getName().compareTo(CapabilitiesTags.WFS_ABSTRACT)==0) |
|
153 |
{ |
|
154 |
serviceInfo.abstr = parser.nextText(); |
|
155 |
} |
|
156 |
else if (parser.getName().compareTo(CapabilitiesTags.ONLINERESOURCE)==0) |
|
157 |
{ |
|
158 |
serviceInfo.online_resource = parser.nextText(); |
|
159 |
|
|
160 |
} |
|
161 |
break; |
|
162 |
case KXmlParser.END_TAG: |
|
163 |
if (parser.getName().compareTo(CapabilitiesTags.SERVICE) == 0) |
|
164 |
end = true; |
|
165 |
break; |
|
166 |
case KXmlParser.TEXT: |
|
167 |
break; |
|
168 |
} |
|
169 |
if (!end){ |
|
170 |
currentTag = parser.next(); |
|
171 |
} |
|
172 |
} |
|
173 |
} |
|
174 |
|
|
175 |
private void parseCapabilityTag(KXmlParser parser) throws IOException, XmlPullParserException |
|
176 |
{ |
|
177 |
int currentTag; |
|
178 |
boolean end = false; |
|
179 |
|
|
180 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.CAPABILITY); |
|
181 |
currentTag = parser.next(); |
|
182 |
|
|
183 |
while (!end) |
|
184 |
{ |
|
185 |
switch(currentTag) |
|
186 |
{ |
|
187 |
case KXmlParser.START_TAG: |
|
188 |
if (parser.getName().compareTo(CapabilitiesTags.REQUEST)==0) |
|
189 |
{ |
|
190 |
parseRequestTag(parser); |
|
191 |
} |
|
192 |
else if (parser.getName().compareTo(CapabilitiesTags.EXCEPTION)==0) |
|
193 |
{ |
|
194 |
//TODO Parse exception tags... |
|
195 |
parser.skipSubTree(); |
|
196 |
} |
|
197 |
else if ((parser.getName().compareTo(CapabilitiesTags.VENDORSPECIFICCAPABILITIES)==0) || |
|
198 |
(parser.getName().compareTo(CapabilitiesTags.USERDEFINEDSYMBOLIZATION )==0)) |
|
199 |
{ |
|
200 |
parser.skipSubTree(); |
|
201 |
} |
|
202 |
break; |
|
203 |
case KXmlParser.END_TAG: |
|
204 |
if (parser.getName().compareTo(CapabilitiesTags.CAPABILITY) == 0) |
|
205 |
end = true; |
|
206 |
break; |
|
207 |
case KXmlParser.TEXT: |
|
208 |
break; |
|
209 |
} |
|
210 |
if (!end){ |
|
211 |
currentTag = parser.next(); |
|
212 |
} |
|
213 |
} |
|
214 |
} |
|
215 |
|
|
216 |
/** |
|
217 |
* <p>Parses the Request tag </p> |
|
218 |
*/ |
|
219 |
private void parseRequestTag(KXmlParser parser) throws IOException, XmlPullParserException |
|
220 |
{ |
|
221 |
int currentTag; |
|
222 |
boolean end = false; |
|
223 |
|
|
224 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.REQUEST); |
|
225 |
currentTag = parser.next(); |
|
226 |
|
|
227 |
while (!end) |
|
228 |
{ |
|
229 |
switch(currentTag) |
|
230 |
{ |
|
231 |
case KXmlParser.START_TAG: |
|
232 |
if (parser.getName().compareTo(CapabilitiesTags.GETCAPABILITIES)==0){ |
|
233 |
parserDcpType(parser, CapabilitiesTags.GETCAPABILITIES); |
|
234 |
} else if (parser.getName().compareTo(CapabilitiesTags.WFS_DESCRIBEFEATURETYPE)==0) { |
|
235 |
parserDcpType(parser, CapabilitiesTags.WFS_DESCRIBEFEATURETYPE); |
|
236 |
}else if (parser.getName().compareTo(CapabilitiesTags.WFS_GETFEATURE)==0){ |
|
237 |
parserDcpType(parser, CapabilitiesTags.WFS_GETFEATURE); |
|
238 |
}else if (parser.getName().compareTo(CapabilitiesTags.WFS_LOCKFEATURE)==0){ |
|
239 |
parserDcpType(parser, CapabilitiesTags.WFS_LOCKFEATURE); |
|
240 |
}else if (parser.getName().compareTo(CapabilitiesTags.WFS_TRANSACTION)==0){ |
|
241 |
parserDcpType(parser, CapabilitiesTags.WFS_TRANSACTION); |
|
242 |
} |
|
243 |
break; |
|
244 |
case KXmlParser.END_TAG: |
|
245 |
if (parser.getName().compareTo(CapabilitiesTags.REQUEST) == 0) |
|
246 |
end = true; |
|
247 |
break; |
|
248 |
case KXmlParser.TEXT: |
|
249 |
break; |
|
250 |
} |
|
251 |
if (!end){ |
|
252 |
currentTag = parser.next(); |
|
253 |
} |
|
254 |
} |
|
255 |
} |
|
256 |
|
|
257 |
/** |
|
258 |
* It parses the feature typelist tag |
|
259 |
* @param parser |
|
260 |
* @throws IOException |
|
261 |
* @throws XmlPullParserException |
|
262 |
*/ |
|
263 |
private void parseFeatureTypeListTag(KXmlParser parser) throws IOException, XmlPullParserException{ |
|
264 |
int currentTag; |
|
265 |
boolean end = false; |
|
266 |
|
|
267 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_FEATURETYPELIST); |
|
268 |
currentTag = parser.next(); |
|
269 |
|
|
270 |
while (!end) |
|
271 |
{ |
|
272 |
switch(currentTag) |
|
273 |
{ |
|
274 |
case KXmlParser.START_TAG: |
|
275 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.WFS_FEATURETYPE)==0){ |
|
276 |
//Parse the namespaces... |
|
277 |
parseNamespaces(parser); |
|
278 |
WFSFeature1_0_0 feature = new WFSFeature1_0_0(serviceInfo); |
|
279 |
feature.parse(parser); |
|
280 |
features.put(feature.getName(),feature); |
|
281 |
} |
|
282 |
break; |
|
283 |
case KXmlParser.END_TAG: |
|
284 |
if (parser.getName().compareTo(CapabilitiesTags.WFS_FEATURETYPELIST) == 0) |
|
285 |
end = true; |
|
286 |
break; |
|
287 |
case KXmlParser.TEXT: |
|
288 |
break; |
|
289 |
} |
|
290 |
if (!end){ |
|
291 |
currentTag = parser.next(); |
|
292 |
} |
|
293 |
} |
|
294 |
} |
|
295 |
|
|
296 |
/* |
|
297 |
* (non-Javadoc) |
|
298 |
* @see org.gvsig.remoteClient.wfs.WFSProtocolHandler#parseGetFeature(java.io.File, java.lang.String) |
|
299 |
*/ |
|
300 |
protected boolean parseGetFeature(File f, String nameSpace) throws WFSException { |
|
301 |
XMLSchemaParser parser = null; |
|
302 |
parser = new XMLSchemaParser(); |
|
303 |
try |
|
304 |
{ |
|
305 |
parser.setInput(f); |
|
306 |
parser.nextTag(); |
|
307 |
if (parser.getName().compareTo(CapabilitiesTags.SERVICE_EXCEPTION_REPORT)==0){ |
|
308 |
throw ExceptionsFactory.parseServiceExceptionReport(parser); |
|
309 |
} |
|
310 |
} catch (FileNotFoundException e) { |
|
311 |
logger.warn("Can't get feature from file '"+Utilities.getAbsolutePathOrEmpty(f)+"' with namaspace '"+nameSpace+"'.",e); |
|
312 |
throw new WFSGetFeatureException(e); |
|
313 |
} catch (XmlPullParserException e) { |
|
314 |
logger.warn("Can't get feature from file '"+Utilities.getAbsolutePathOrEmpty(f)+"' with namaspace '"+nameSpace+"'.",e); |
|
315 |
throw new WFSGetFeatureException(e); |
|
316 |
} catch (IOException e) { |
|
317 |
logger.warn("Can't get feature from file '"+Utilities.getAbsolutePathOrEmpty(f)+"' with namaspace '"+nameSpace+"'.",e); |
|
318 |
throw new WFSGetFeatureException(e); |
|
319 |
} |
|
320 |
|
|
321 |
return true; |
|
322 |
} |
|
323 |
|
|
324 |
/* |
|
325 |
* (non-Javadoc) |
|
326 |
* @see org.gvsig.remoteClient.wfs.WFSProtocolHandler#parseTransaction(java.io.File, java.lang.String) |
|
327 |
*/ |
|
328 |
protected boolean parseTransaction(File f, WFSStatus status) throws WFSException { |
|
329 |
int tag; |
|
330 |
XMLSchemaParser parser = null; |
|
331 |
parser = new XMLSchemaParser(); |
|
332 |
|
|
333 |
WFSTransactionRequestInformation transactionRequestInformation = |
|
334 |
(WFSTransactionRequestInformation)this.getLastWfsRequestInformation(); |
|
335 |
|
|
336 |
try |
|
337 |
{ |
|
338 |
parser.setInput(f); |
|
339 |
parser.nextTag(); |
|
340 |
if (CapabilitiesTags.SERVICE_EXCEPTION_REPORT.equals(parser.getName())) { |
|
341 |
throw ExceptionsFactory.parseServiceExceptionReport(parser); |
|
342 |
}else if (parser.getName().equals(CapabilitiesTags.EXCEPTION_REPORT)){ |
|
343 |
throw ExceptionsFactory.parseExceptionReport(parser); |
|
344 |
} |
|
345 |
|
|
346 |
if ( parser.getEventType() != KXmlParser.END_DOCUMENT ) |
|
347 |
{ |
|
348 |
tag = parser.nextTag(); |
|
349 |
while(tag != KXmlParser.END_DOCUMENT) |
|
350 |
{ |
|
351 |
switch(tag) |
|
352 |
{ |
|
353 |
case KXmlParser.START_TAG: |
|
354 |
if (parser.getName().compareTo(WFSTTags.WFST_TRANSACTIONRESULT)==0){ |
|
355 |
parseTransactionResult(parser, transactionRequestInformation); |
|
356 |
}else if (parser.getName().compareTo(WFSTTags.WFST_TRANSACTIONRESPONSE)==0){ |
|
357 |
parseFeaturesLocked(parser); |
|
358 |
} |
|
359 |
break; |
|
360 |
case KXmlParser.END_TAG: |
|
361 |
break; |
|
362 |
case KXmlParser.TEXT: |
|
363 |
break; |
|
364 |
} |
|
365 |
tag = parser.next(); |
|
366 |
} |
|
367 |
parser.require(KXmlParser.END_DOCUMENT, null, null); |
|
368 |
} |
|
369 |
} |
|
370 |
catch(XmlPullParserException parser_ex){ |
|
371 |
logger.warn("Can't parse transaction from file '"+Utilities.getAbsolutePathOrEmpty(f)+"'.",parser_ex); |
|
372 |
return false; |
|
373 |
} |
|
374 |
catch (IOException ioe) { |
|
375 |
logger.warn("Can't parse transaction from file '"+Utilities.getAbsolutePathOrEmpty(f)+"'.",ioe); |
|
376 |
return false; |
|
377 |
} |
|
378 |
return true; |
|
379 |
} |
|
380 |
|
|
381 |
/** |
|
382 |
* Parse the transaction result XML sub tree |
|
383 |
* @param parser |
|
384 |
* @param transaction |
|
385 |
* @throws IOException |
|
386 |
* @throws XmlPullParserException |
|
387 |
*/ |
|
388 |
private void parseTransactionResult(XMLSchemaParser parser, |
|
389 |
WFSTransactionRequestInformation transactionRequestInformation) throws XmlPullParserException, IOException { |
|
390 |
int currentTag; |
|
391 |
boolean end = false; |
|
392 |
|
|
393 |
currentTag = parser.next(); |
|
394 |
|
|
395 |
while (!end) |
|
396 |
{ |
|
397 |
switch(currentTag) |
|
398 |
{ |
|
399 |
case KXmlParser.START_TAG: |
|
400 |
if (parser.getName().compareTo(WFSTTags.WFST_STATUS)==0){ |
|
401 |
parseStatus(parser, transactionRequestInformation); |
|
402 |
}else if (parser.getName().compareTo(WFSTTags.WFST_TRANSACTIONMESSAGE)==0){ |
|
403 |
parser.next(); |
|
404 |
transactionRequestInformation.setMessage(parser.getText()); |
|
405 |
} |
|
406 |
break; |
|
407 |
case KXmlParser.END_TAG: |
|
408 |
if (parser.getName().compareTo(WFSTTags.WFST_TRANSACTIONRESULT)==0) |
|
409 |
end = true; |
|
410 |
break; |
|
411 |
case KXmlParser.TEXT: |
|
412 |
break; |
|
413 |
} |
|
414 |
if (!end){ |
|
415 |
currentTag = parser.next(); |
|
416 |
} |
|
417 |
} |
|
418 |
} |
|
419 |
|
|
420 |
/** |
|
421 |
* Parser WFST Status subtree |
|
422 |
* @param parser |
|
423 |
* Teh xML parser |
|
424 |
* @param transaction |
|
425 |
* The current transaction |
|
426 |
* @throws IOException |
|
427 |
* @throws XmlPullParserException |
|
428 |
*/ |
|
429 |
private void parseStatus(XMLSchemaParser parser, WFSTransactionRequestInformation transactionRequestInformation) throws XmlPullParserException, IOException { |
|
430 |
int currentTag; |
|
431 |
boolean end = false; |
|
432 |
|
|
433 |
currentTag = parser.next(); |
|
434 |
|
|
435 |
while (!end) |
|
436 |
{ |
|
437 |
switch(currentTag) |
|
438 |
{ |
|
439 |
case KXmlParser.START_TAG: |
|
440 |
if (parser.getName().compareTo(WFSTTags.WFST_SUCCESS)==0){ |
|
441 |
transactionRequestInformation.setStatus(WFSTransactionRequestInformation.STATUS_SUCCESS); |
|
442 |
}else if (parser.getName().compareTo(WFSTTags.WFST_FAILED)==0){ |
|
443 |
transactionRequestInformation.setStatus(WFSTransactionRequestInformation.STATUS_FAILED); |
|
444 |
} |
|
445 |
break; |
|
446 |
case KXmlParser.END_TAG: |
|
447 |
if (parser.getName().compareTo(WFSTTags.WFST_STATUS)==0) |
|
448 |
end = true; |
|
449 |
break; |
|
450 |
case KXmlParser.TEXT: |
|
451 |
break; |
|
452 |
} |
|
453 |
if (!end){ |
|
454 |
currentTag = parser.next(); |
|
455 |
} |
|
456 |
} |
|
457 |
} |
|
458 |
|
|
459 |
/* |
|
460 |
* (non-Javadoc) |
|
461 |
* @see org.gvsig.remoteClient.wfs.WFSProtocolHandler#parseLockFeature(java.io.File, java.lang.String) |
|
462 |
*/ |
|
463 |
protected boolean parseLockFeature(File f, String nameSpace, WFSStatus status) throws WFSException { |
|
464 |
int tag; |
|
465 |
XMLSchemaParser parser = null; |
|
466 |
parser = new XMLSchemaParser(); |
|
467 |
try |
|
468 |
{ |
|
469 |
parser.setInput(f); |
|
470 |
parser.nextTag(); |
|
471 |
if (parser.getName().compareTo(CapabilitiesTags.SERVICE_EXCEPTION_REPORT)==0){ |
|
472 |
throw ExceptionsFactory.parseServiceExceptionReport(parser); |
|
473 |
} |
|
474 |
|
|
475 |
|
|
476 |
if ( parser.getEventType() != KXmlParser.END_DOCUMENT ) |
|
477 |
{ |
|
478 |
tag = parser.nextTag(); |
|
479 |
while(tag != KXmlParser.END_DOCUMENT) |
|
480 |
{ |
|
481 |
switch(tag) |
|
482 |
{ |
|
483 |
case KXmlParser.START_TAG: |
|
484 |
if (parser.getName().compareTo(WFSTTags.WFST_LOCKID)==0){ |
|
485 |
parser.next(); |
|
486 |
status.addFeatureLocked(parser.getText()); |
|
487 |
}else if (parser.getName().compareTo(WFSTTags.WFST_FEATURESLOCKED)==0){ |
|
488 |
parseFeaturesLocked(parser); |
|
489 |
} |
|
490 |
break; |
|
491 |
case KXmlParser.END_TAG: |
|
492 |
break; |
|
493 |
case KXmlParser.TEXT: |
|
494 |
break; |
|
495 |
} |
|
496 |
tag = parser.next(); |
|
497 |
} |
|
498 |
parser.require(KXmlParser.END_DOCUMENT, null, null); |
|
499 |
} |
|
500 |
} |
|
501 |
catch(XmlPullParserException parser_ex){ |
|
502 |
logger.warn("Can't parse lock-feature from file '"+Utilities.getAbsolutePathOrEmpty(f)+"'.",parser_ex); |
|
503 |
return false; |
|
504 |
} |
|
505 |
catch (IOException ioe) { |
|
506 |
logger.warn("Can't parse lock-feature from file '"+Utilities.getAbsolutePathOrEmpty(f)+"'.",ioe); |
|
507 |
return false; |
|
508 |
} |
|
509 |
return true; |
|
510 |
} |
|
511 |
|
|
512 |
/** |
|
513 |
* It parses the featuresLocked tag |
|
514 |
* @param parser |
|
515 |
* @throws IOException |
|
516 |
* @throws XmlPullParserException |
|
517 |
*/ |
|
518 |
private void parseFeaturesLocked(XMLSchemaParser parser) throws XmlPullParserException, IOException { |
|
519 |
int currentTag; |
|
520 |
boolean end = false; |
|
521 |
|
|
522 |
currentTag = parser.next(); |
|
523 |
|
|
524 |
while (!end) |
|
525 |
{ |
|
526 |
switch(currentTag) |
|
527 |
{ |
|
528 |
case KXmlParser.START_TAG: |
|
529 |
if (parser.getName().compareTo(WFSTTags.WFST_FEATURESID)==0){ |
|
530 |
|
Also available in: Unified diff