Revision 40511
tags/org.gvsig.desktop-2.0.10/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/RemoteClientStatus.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.remoteclient; |
|
3 |
|
|
4 |
import org.gvsig.remoteclient.ogc.OGCClientOperation; |
|
5 |
|
|
6 |
/** |
|
7 |
* This class represents the client status at a certain moment |
|
8 |
* it describes the "graphic" situation or the requirements of the data |
|
9 |
* to be retrieved. |
|
10 |
* |
|
11 |
*/ |
|
12 |
public abstract class RemoteClientStatus { |
|
13 |
|
|
14 |
// width and heigh of the map |
|
15 |
private int width; |
|
16 |
private int height; |
|
17 |
|
|
18 |
//format of the image to be retrieved |
|
19 |
private String format; |
|
20 |
private String infoFormat; |
|
21 |
// spatial reference system of the image to be retrieved |
|
22 |
private String srs; |
|
23 |
// exception format, to be retrieved in case of error |
|
24 |
private String exceptionFormat; |
|
25 |
|
|
26 |
//To set if the client has to use GET or POST |
|
27 |
private int protocol = OGCClientOperation.PROTOCOL_UNDEFINED; |
|
28 |
|
|
29 |
public int getWidth() { |
|
30 |
return width; |
|
31 |
} |
|
32 |
|
|
33 |
public void setWidth(int _width) { |
|
34 |
width = _width; |
|
35 |
} |
|
36 |
|
|
37 |
public int getHeight() { |
|
38 |
return height; |
|
39 |
} |
|
40 |
public void setHeight(int _height) { |
|
41 |
height = _height; |
|
42 |
} |
|
43 |
|
|
44 |
public String getFormat() { |
|
45 |
return format; |
|
46 |
} |
|
47 |
|
|
48 |
public void setFormat(String _format) { |
|
49 |
format = _format; |
|
50 |
} |
|
51 |
|
|
52 |
public String getInfoFormat() { |
|
53 |
return infoFormat; |
|
54 |
} |
|
55 |
|
|
56 |
public void setInfoFormat(String _format) { |
|
57 |
infoFormat = _format; |
|
58 |
} |
|
59 |
|
|
60 |
public String getSrs() { |
|
61 |
return srs; |
|
62 |
} |
|
63 |
|
|
64 |
public void setSrs(String _srs) { |
|
65 |
srs = _srs; |
|
66 |
} |
|
67 |
|
|
68 |
public void setExceptionFormat(String _format) { |
|
69 |
exceptionFormat = _format; |
|
70 |
} |
|
71 |
|
|
72 |
public String getExceptionFormat() { |
|
73 |
return exceptionFormat; |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* @return the protocol |
|
78 |
*/ |
|
79 |
public int getProtocol() { |
|
80 |
return protocol; |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* @param protocol the protocol to set |
|
85 |
*/ |
|
86 |
public void setProtocol(int protocol) { |
|
87 |
this.protocol = protocol; |
|
88 |
} |
|
89 |
|
|
90 |
} |
|
0 | 91 |
tags/org.gvsig.desktop-2.0.10/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/RasterClient.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.remoteclient; |
|
3 |
|
|
4 |
/** |
|
5 |
* <p></p> |
|
6 |
* |
|
7 |
*/ |
|
8 |
public abstract class RasterClient extends org.gvsig.remoteclient.RemoteClient implements org.gvsig.remoteclient.IRasterClient { |
|
9 |
} |
|
0 | 10 |
tags/org.gvsig.desktop-2.0.10/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wfs/WFSRequestInformation.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {Iver T.I.} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.remoteclient.wfs; |
|
29 |
/** |
|
30 |
* This class is used like a container of all the properties |
|
31 |
* that the library is able to retrieve in the XML header of |
|
32 |
* every WFS reply. |
|
33 |
* |
|
34 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
35 |
*/ |
|
36 |
public class WFSRequestInformation { |
|
37 |
/** |
|
38 |
* The attribute may be used by a web |
|
39 |
* feature service to indicate the time and |
|
40 |
* date when a response was generated. |
|
41 |
*/ |
|
42 |
private String timeStamp = null; |
|
43 |
|
|
44 |
public WFSRequestInformation() { |
|
45 |
super(); |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* @return the timeStamp |
|
50 |
*/ |
|
51 |
public String getTimeStamp() { |
|
52 |
return timeStamp; |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* @param timeStamp the timeStamp to set |
|
57 |
*/ |
|
58 |
public void setTimeStamp(String timeStamp) { |
|
59 |
this.timeStamp = timeStamp; |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
0 | 63 |
tags/org.gvsig.desktop-2.0.10/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wfs/WFSFeatureField.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 2 |
|
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 |
*/ |
|
22 |
package org.gvsig.remoteclient.wfs; |
|
23 |
|
|
24 |
import java.util.Vector; |
|
25 |
|
|
26 |
import org.gvsig.tools.ToolsLocator; |
|
27 |
import org.gvsig.tools.dataTypes.DataType; |
|
28 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
29 |
import org.gvsig.tools.dataTypes.DataTypesManager; |
|
30 |
|
|
31 |
|
|
32 |
/** |
|
33 |
* @author gvSIG Team |
|
34 |
* @version $Id$ |
|
35 |
* |
|
36 |
*/ |
|
37 |
public class WFSFeatureField { |
|
38 |
protected String name; |
|
39 |
private String type; |
|
40 |
private DataType dataType = null; |
|
41 |
private boolean isGeometry = false; |
|
42 |
private boolean isComplex = false; |
|
43 |
private int geometryType = -1; |
|
44 |
private static final DataTypesManager dataTypesManager = ToolsLocator.getDataTypesManager(); |
|
45 |
private Vector fields = new Vector(); |
|
46 |
|
|
47 |
public WFSFeatureField() { |
|
48 |
dataType = dataTypesManager.get(DataTypes.OBJECT); |
|
49 |
} |
|
50 |
|
|
51 |
public WFSFeatureField(String name, String type, DataType dataType) { |
|
52 |
super(); |
|
53 |
this.name = name; |
|
54 |
this.type = type; |
|
55 |
if (dataType == null){ |
|
56 |
dataType = dataTypesManager.get(DataTypes.OBJECT); |
|
57 |
}else{ |
|
58 |
this.dataType = dataType; |
|
59 |
if (dataType.getType() == dataTypesManager.getType("Geometry")){ |
|
60 |
isGeometry = true; |
|
61 |
} |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
public WFSFeatureField(String name, String type, int geometryType) { |
|
66 |
super(); |
|
67 |
this.name = name; |
|
68 |
this.type = type; |
|
69 |
this.dataType = dataTypesManager.get(dataTypesManager.getType("Geometry")); |
|
70 |
this.geometryType = geometryType; |
|
71 |
isGeometry = true; |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* @return the name |
|
76 |
*/ |
|
77 |
public String getName() { |
|
78 |
return name; |
|
79 |
} |
|
80 |
|
|
81 |
|
|
82 |
/** |
|
83 |
* @return the type |
|
84 |
*/ |
|
85 |
public String getType() { |
|
86 |
return type; |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* @return the dataType |
|
91 |
*/ |
|
92 |
public DataType getDataType() { |
|
93 |
return dataType; |
|
94 |
} |
|
95 |
|
|
96 |
|
|
97 |
/** |
|
98 |
* @return the isGeometry |
|
99 |
*/ |
|
100 |
public boolean isGeometry() { |
|
101 |
return isGeometry; |
|
102 |
} |
|
103 |
|
|
104 |
public boolean isComplex(){ |
|
105 |
return isComplex; |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* @return the geometryType |
|
110 |
*/ |
|
111 |
public int getGeometryType() { |
|
112 |
return geometryType; |
|
113 |
} |
|
114 |
|
|
115 |
/** |
|
116 |
* @return Returns the fields. |
|
117 |
*/ |
|
118 |
public WFSFeatureField getFieldAt(int index) { |
|
119 |
if (index >= fields.size()){ |
|
120 |
return null; |
|
121 |
} |
|
122 |
return (WFSFeatureField)fields.get(index); |
|
123 |
} |
|
124 |
|
|
125 |
public int getFieldSize(){ |
|
126 |
return fields.size(); |
|
127 |
} |
|
128 |
|
|
129 |
public void addField(String fieldName, String fieldType, DataType dataType){ |
|
130 |
isComplex = true; |
|
131 |
fields.add(new WFSFeatureField(fieldName, fieldType, dataType)); |
|
132 |
} |
|
133 |
|
|
134 |
public String toString() { |
|
135 |
return getName(); |
|
136 |
} |
|
137 |
|
|
138 |
|
|
139 |
} |
|
0 | 140 |
tags/org.gvsig.desktop-2.0.10/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wfs/WFSProtocolHandler.java | ||
---|---|---|
1 |
package org.gvsig.remoteclient.wfs; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.net.URL; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.Hashtable; |
|
7 |
import java.util.StringTokenizer; |
|
8 |
|
|
9 |
import org.gvsig.compat.net.ICancellable; |
|
10 |
import org.gvsig.remoteclient.ogc.OGCProtocolHandler; |
|
11 |
import org.gvsig.remoteclient.ogc.OGCServiceInformation; |
|
12 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
13 |
import org.gvsig.remoteclient.wfs.exceptions.WFSException; |
|
14 |
import org.gvsig.remoteclient.wfs.request.WFSDescribeFeatureTypeRequest; |
|
15 |
import org.gvsig.remoteclient.wfs.request.WFSGetFeatureRequest; |
|
16 |
import org.gvsig.remoteclient.wfs.request.WFSTLockFeatureRequest; |
|
17 |
import org.gvsig.remoteclient.wfs.request.WFSTransactionRequest; |
|
18 |
import org.gvsig.remoteclient.wfs.schema.GMLTags; |
|
19 |
import org.kxml2.io.KXmlParser; |
|
20 |
|
|
21 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
22 |
* |
|
23 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
24 |
* |
|
25 |
* This program is free software; you can redistribute it and/or |
|
26 |
* modify it under the terms of the GNU General Public License |
|
27 |
* as published by the Free Software Foundation; either version 2 |
|
28 |
* of the License, or (at your option) any later version. |
|
29 |
* |
|
30 |
* This program is distributed in the hope that it will be useful, |
|
31 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
32 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
33 |
* GNU General Public License for more details. |
|
34 |
* |
|
35 |
* You should have received a copy of the GNU General Public License |
|
36 |
* along with this program; if not, write to the Free Software |
|
37 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
38 |
* |
|
39 |
* For more information, contact: |
|
40 |
* |
|
41 |
* Generalitat Valenciana |
|
42 |
* Conselleria d'Infraestructures i Transport |
|
43 |
* Av. Blasco Ib??ez, 50 |
|
44 |
* 46010 VALENCIA |
|
45 |
* SPAIN |
|
46 |
* |
|
47 |
* +34 963862235 |
|
48 |
* gvsig@gva.es |
|
49 |
* www.gvsig.gva.es |
|
50 |
* |
|
51 |
* or |
|
52 |
* |
|
53 |
* IVER T.I. S.A |
|
54 |
* Salamanca 50 |
|
55 |
* 46005 Valencia |
|
56 |
* Spain |
|
57 |
* |
|
58 |
* +34 963163400 |
|
59 |
* dac@iver.es |
|
60 |
*/ |
|
61 |
/* CVS MESSAGES: |
|
62 |
* |
|
63 |
* $Id: WFSProtocolHandler.java 34402 2011-01-13 16:47:02Z nbrodin $ |
|
64 |
* $Log$ |
|
65 |
* Revision 1.11 2007-09-20 09:30:12 jaume |
|
66 |
* removed unnecessary imports |
|
67 |
* |
|
68 |
* Revision 1.10 2007/02/09 14:11:01 jorpiell |
|
69 |
* Primer piloto del soporte para WFS 1.1 y para WFS-T |
|
70 |
* |
|
71 |
* Revision 1.9 2007/01/12 13:09:42 jorpiell |
|
72 |
* added searches by area |
|
73 |
* |
|
74 |
* Revision 1.8 2006/10/10 12:52:28 jorpiell |
|
75 |
* Soporte para features complejas. |
|
76 |
* |
|
77 |
* Revision 1.7 2006/06/21 12:53:03 jorpiell |
|
78 |
* Se tienen en cuanta el n?mero de features |
|
79 |
* |
|
80 |
* Revision 1.6 2006/06/14 08:46:07 jorpiell |
|
81 |
* Se tiene en cuanta la opcion para refrescar las capabilities |
|
82 |
* |
|
83 |
* Revision 1.5 2006/06/14 07:54:18 jorpiell |
|
84 |
* Se parsea el online resource que antes se ignoraba |
|
85 |
* |
|
86 |
* Revision 1.4 2006/05/30 13:58:03 jaume |
|
87 |
* cancelable downloads |
|
88 |
* |
|
89 |
* Revision 1.3 2006/05/23 13:23:13 jorpiell |
|
90 |
* Se ha cambiado el final del bucle de parseado y se tiene en cuenta el online resource |
|
91 |
* |
|
92 |
* Revision 1.2 2006/04/20 16:39:16 jorpiell |
|
93 |
* A?adida la operacion de describeFeatureType y el parser correspondiente. |
|
94 |
* |
|
95 |
* Revision 1.1 2006/04/19 12:51:35 jorpiell |
|
96 |
* A?adidas algunas de las clases del servicio WFS |
|
97 |
* |
|
98 |
* |
|
99 |
*/ |
|
100 |
/** |
|
101 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
102 |
*/ |
|
103 |
public abstract class WFSProtocolHandler extends OGCProtocolHandler { |
|
104 |
//protected static Logger LOG = LoggerFactory.getLogger(WFSProtocolHandler.class); |
|
105 |
|
|
106 |
/** |
|
107 |
* WFS metadata |
|
108 |
*/ |
|
109 |
protected WFSServiceInformation serviceInfo = new WFSServiceInformation(); |
|
110 |
protected Hashtable features = new Hashtable(); |
|
111 |
protected String currentFeature = null; |
|
112 |
private int numberOfErrors = 0; |
|
113 |
|
|
114 |
/** |
|
115 |
* This class contains all the data that the library is able |
|
116 |
* to retrieve of the server for all the requests. |
|
117 |
*/ |
|
118 |
protected ArrayList wfsRequestInformations = new ArrayList(); |
|
119 |
|
|
120 |
/** |
|
121 |
* Clear the connection |
|
122 |
*/ |
|
123 |
private void clear() { |
|
124 |
features.clear(); |
|
125 |
serviceInfo.clear(); |
|
126 |
} |
|
127 |
|
|
128 |
/** |
|
129 |
* <p>Builds a GetCapabilities request that is sent to the WFS |
|
130 |
* the response will be parse to extract the data needed by the |
|
131 |
* WFS client</p> |
|
132 |
*/ |
|
133 |
public void getCapabilities(WFSStatus status,boolean override, ICancellable cancel) throws WFSException { |
|
134 |
URL request = null; |
|
135 |
try { |
|
136 |
request = new URL(buildCapabilitiesRequest(status)); |
|
137 |
if (override){ |
|
138 |
downloader.removeURL(request); |
|
139 |
} |
|
140 |
File f = downloader.downloadFile(request,"wfs_capabilities.xml", cancel); |
|
141 |
if (f == null) |
|
142 |
return; |
|
143 |
clear(); |
|
144 |
parseCapabilities(f); |
|
145 |
} catch (Exception e){ |
|
146 |
throw new WFSException(e); |
|
147 |
} |
|
148 |
} |
|
149 |
|
|
150 |
/** |
|
151 |
* @return |
|
152 |
*/ |
|
153 |
private String buildCapabilitiesRequest(WFSStatus status) { |
|
154 |
StringBuffer req = new StringBuffer(); |
|
155 |
String symbol = null; |
|
156 |
|
|
157 |
String onlineResource; |
|
158 |
if (status == null || status.getOnlineResource() == null) |
|
159 |
onlineResource = getHost(); |
|
160 |
else |
|
161 |
onlineResource = status.getOnlineResource(); |
|
162 |
symbol = getSymbol(onlineResource); |
|
163 |
|
|
164 |
req.append(onlineResource).append(symbol).append("REQUEST=GetCapabilities&SERVICE=WFS&"); |
|
165 |
req.append("VERSION=").append(getVersion()).append("&EXCEPTIONS=XML"); |
|
166 |
return req.toString(); |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* Builds the GetCapabilitiesRequest according to the OGC WFS Specifications |
|
171 |
* without a VERSION, to get the highest version than a WFS supports. |
|
172 |
*/ |
|
173 |
public static String buildCapabilitiesSuitableVersionRequest(String _host, String _version) |
|
174 |
{ |
|
175 |
int index = _host.indexOf('?'); |
|
176 |
|
|
177 |
if (index > -1) { |
|
178 |
String host = _host.substring(0, index + 1); |
|
179 |
String query = _host.substring(index + 1, _host.length()); |
|
180 |
|
|
181 |
StringTokenizer tokens = new StringTokenizer(query, "&"); |
|
182 |
String newQuery = "", token; |
|
183 |
|
|
184 |
// If there is a field or a value with spaces, (and then it's on different tokens) -> unify them |
|
185 |
while (tokens.hasMoreTokens()) { |
|
186 |
token = tokens.nextToken().trim(); |
|
187 |
|
|
188 |
if (token.toUpperCase().compareTo("REQUEST=GETCAPABILITIES") == 0) |
|
189 |
continue; |
|
190 |
|
|
191 |
if (token.toUpperCase().compareTo("SERVICE=WFS") == 0) |
|
192 |
continue; |
|
193 |
|
|
194 |
if ((_version != null) && (_version.length() > 0)) { |
|
195 |
if (token.toUpperCase().compareTo("VERSION=" + _version) == 0) |
|
196 |
continue; |
|
197 |
} |
|
198 |
|
|
199 |
if (token.toUpperCase().compareTo("EXCEPTIONS=XML") == 0) |
|
200 |
continue; |
|
201 |
|
|
202 |
newQuery += token + "&"; |
|
203 |
} |
|
204 |
|
|
205 |
_host = host + newQuery; |
|
206 |
} |
|
207 |
else { |
|
208 |
_host += "?"; |
|
209 |
} |
|
210 |
|
|
211 |
if ((_version != null) && (_version.compareTo("") != 0)) |
|
212 |
_host += "REQUEST=GetCapabilities&SERVICE=WFS&VERSION=" + _version + "&EXCEPTIONS=XML"; |
|
213 |
else |
|
214 |
_host += "REQUEST=GetCapabilities&SERVICE=WFS&EXCEPTIONS=XML"; |
|
215 |
|
|
216 |
return _host; |
|
217 |
} |
|
218 |
|
|
219 |
/** |
|
220 |
* <p>Builds a describeFeatureType request that is sent to the WFS |
|
221 |
* the response will be parse to extract the data needed by the |
|
222 |
* WFS client</p> |
|
223 |
* @param status |
|
224 |
* WFS client status. Contains all the information to create |
|
225 |
* the query. In this case, the only the feature name is needed. |
|
226 |
*/ |
|
227 |
public File describeFeatureType(WFSStatus status,boolean override, ICancellable cancel)throws WFSException { |
|
228 |
this.currentFeature = status.getFeatureFullName(); |
|
229 |
//sets the namespace URI |
|
230 |
if ((status.getNamespacePrefix() != null) && (status.getNamespaceLocation() == null)){ |
|
231 |
String namespaceURI = serviceInfo.getNamespace(status.getNamespacePrefix()); |
|
232 |
if (namespaceURI != null){ |
|
233 |
status.setNamespaceLocation(namespaceURI); |
|
234 |
} |
|
235 |
} |
|
236 |
try { |
|
237 |
WFSDescribeFeatureTypeRequest request = createDescribeFeatureTypeRequest(status); |
|
238 |
File f = request.sendRequest(cancel); |
|
239 |
return f; |
|
240 |
} catch (Exception e){ |
|
241 |
throw new WFSException(e); |
|
242 |
} |
|
243 |
} |
|
244 |
|
|
245 |
/** |
|
246 |
* <p>Builds a getFeature request that is sent to the WFS |
|
247 |
* the response will be parse to extract the data needed by the |
|
248 |
* WFS client</p> |
|
249 |
* @param status |
|
250 |
* WFS client status. Contains all the information to create |
|
251 |
* the query. |
|
252 |
* @return File |
|
253 |
* GML file |
|
254 |
*/ |
|
255 |
public File getFeature(WFSStatus status,boolean override, ICancellable cancel) throws WFSException{ |
|
256 |
try{ |
|
257 |
WFSGetFeatureRequest request = createGetFeatureRequest(status); |
|
258 |
File f = request.sendRequest(cancel); |
|
259 |
parseGetFeature(f, status.getNamespacePrefix()); |
|
260 |
return f; |
|
261 |
} catch (Exception e){ |
|
262 |
throw new WFSException(e); |
|
263 |
} |
|
264 |
} |
|
265 |
|
|
266 |
/** |
|
267 |
* parses the data retrieved by the GetFeature XML document. It is |
|
268 |
* used just to find errors |
|
269 |
*/ |
|
270 |
protected abstract boolean parseGetFeature(File f,String nameSpace) throws WFSException; |
|
271 |
|
|
272 |
|
|
273 |
/** |
|
274 |
* <p>Builds a transaction request that is sent to the WFS |
|
275 |
* the response will be parse to extract the data needed by the |
|
276 |
* WFS client</p> |
|
277 |
* @param status |
|
278 |
* WFS client status. Contains all the information to create |
|
279 |
* the query. |
|
280 |
*/ |
|
281 |
public void transaction(WFSStatus status,boolean override, ICancellable cancel) throws WFSException { |
|
282 |
try { |
|
283 |
WFSTransactionRequest request = createTransactionRequest(status); |
|
284 |
File f = request.sendRequest(cancel); |
|
285 |
parseTransaction(f, status); |
|
286 |
} catch (Exception e){ |
|
287 |
throw new WFSException(e); |
|
288 |
} |
|
289 |
} |
|
290 |
|
|
291 |
/** |
|
292 |
* <p>Builds a transaction request that is sent to the WFS |
|
293 |
* the response will be parse to extract the data needed by the |
|
294 |
* WFS client</p> |
|
295 |
* @param status |
|
296 |
* WFS client status. Contains all the information to create |
|
297 |
* the query. |
|
298 |
*/ |
|
299 |
private String buildTransactionRequest(WFSStatus status){ |
|
300 |
StringBuffer req = new StringBuffer(); |
|
301 |
String symbol = null; |
|
302 |
|
|
303 |
String onlineResource; |
|
304 |
if(serviceInfo.getOnlineResource(CapabilitiesTags.WFS_TRANSACTION) != null){ |
|
305 |
onlineResource = serviceInfo.getOnlineResource(CapabilitiesTags.WFS_TRANSACTION); |
|
306 |
}else { |
|
307 |
onlineResource = getHost(); |
|
308 |
} |
|
309 |
symbol = getSymbol(onlineResource); |
|
310 |
|
|
311 |
req.append(onlineResource); |
|
312 |
return req.toString(); |
|
313 |
} |
|
314 |
|
|
315 |
/** |
|
316 |
* parses the data retrieved by the transaction operation |
|
317 |
* @param f |
|
318 |
* The retrieved file |
|
319 |
* @param nameSpace |
|
320 |
* The namespace |
|
321 |
*/ |
|
322 |
protected abstract boolean parseTransaction(File f, WFSStatus status) throws WFSException; |
|
323 |
|
|
324 |
/** |
|
325 |
* <p>Builds a lockFeature request that is sent to the WFS |
|
326 |
* the response will be parse to extract the data needed by the |
|
327 |
* WFS client</p> |
|
328 |
* @param status |
|
329 |
* WFS client status. Contains all the information to create |
|
330 |
* the query. |
|
331 |
*/ |
|
332 |
public void lockFeature(WFSStatus status,boolean override, ICancellable cancel) throws WFSException { |
|
333 |
try { |
|
334 |
WFSTLockFeatureRequest request = createLockFeatureRequest(status); |
|
335 |
File f = request.sendRequest(cancel); |
|
336 |
parseLockFeature(f,status.getNamespacePrefix(),status); |
|
337 |
} catch(WFSException e) { |
|
338 |
throw e; |
|
339 |
} catch (Exception e){ |
|
340 |
throw new WFSException(e); |
|
341 |
} |
|
342 |
} |
|
343 |
|
|
344 |
/** |
|
345 |
* parses the data retrieved by the LockFeature operation |
|
346 |
*/ |
|
347 |
protected abstract boolean parseLockFeature(File f,String nameSpace, WFSStatus status) throws WFSException; |
|
348 |
|
|
349 |
/** |
|
350 |
* @return Returns the features. |
|
351 |
*/ |
|
352 |
public Hashtable getFeatures() { |
|
353 |
return features; |
|
354 |
} |
|
355 |
|
|
356 |
/** |
|
357 |
* @return Returns the currentFeature. |
|
358 |
*/ |
|
359 |
public String getCurrentFeature() { |
|
360 |
return currentFeature; |
|
361 |
} |
|
362 |
|
|
363 |
/** |
|
364 |
* @param currentFeature The currentFeature to set. |
|
365 |
*/ |
|
366 |
public void setCurrentFeature(String currentFeature) { |
|
367 |
this.currentFeature = currentFeature; |
|
368 |
} |
|
369 |
|
|
370 |
/** |
|
371 |
* It parses the attributes of the current KXMLParser |
|
372 |
* and add the new namespaces to the service information |
|
373 |
* @param parser |
|
374 |
* The KXML parser |
|
375 |
*/ |
|
376 |
protected void parseNamespaces(KXmlParser parser){ |
|
377 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
378 |
String attName = parser.getAttributeName(i); |
|
379 |
if (attName.startsWith(GMLTags.XML_NAMESPACE)){ |
|
380 |
int index = attName.indexOf(":"); |
|
381 |
if (index > 0){ |
|
382 |
serviceInfo.addNamespace(attName.substring(index+1, attName.length()), |
|
383 |
parser.getAttributeValue(i)); |
|
384 |
} |
|
385 |
} |
|
386 |
} |
|
387 |
} |
|
388 |
|
|
389 |
/* (non-Javadoc) |
|
390 |
* @see org.gvsig.remoteClient.ogc.OGCProtocolHandler#getServiceInformation() |
|
391 |
*/ |
|
392 |
public OGCServiceInformation getServiceInformation() { |
|
393 |
return serviceInfo; |
|
394 |
} |
|
395 |
|
|
396 |
/** |
|
397 |
* @param status |
|
398 |
* The WFS status |
|
399 |
* @param protocolHandler |
|
400 |
* The handler to parse the requests |
|
401 |
* @return an object to send the DescribeFeatureType requests |
|
402 |
*/ |
|
403 |
protected abstract WFSDescribeFeatureTypeRequest createDescribeFeatureTypeRequest(WFSStatus status); |
|
404 |
|
|
405 |
/** |
|
406 |
* @param status |
|
407 |
* The WFS status |
|
408 |
* @param protocolHandler |
|
409 |
* The handler to parse the requests |
|
410 |
* @return an object to send the GetFeature requests |
|
411 |
*/ |
|
412 |
protected abstract WFSGetFeatureRequest createGetFeatureRequest(WFSStatus status); |
|
413 |
|
|
414 |
/** |
|
415 |
* @param status |
|
416 |
* The WFS status |
|
417 |
* @param protocolHandler |
|
418 |
* The handler to parse the requests |
|
419 |
* @return an object to send the LockFeature requests |
|
420 |
*/ |
|
421 |
protected abstract WFSTLockFeatureRequest createLockFeatureRequest(WFSStatus status); |
|
422 |
|
|
423 |
/** |
|
424 |
* @param status |
|
425 |
* The WFS status |
|
426 |
* @param protocolHandler |
|
427 |
* The handler to parse the requests |
|
428 |
* @return an object to send the Transaction request |
|
429 |
*/ |
|
430 |
protected abstract WFSTransactionRequest createTransactionRequest(WFSStatus status); |
|
431 |
|
|
432 |
/** |
|
433 |
* @return the wfsRequestInformations |
|
434 |
*/ |
|
435 |
ArrayList getWfsRequestInformations() { |
|
436 |
return wfsRequestInformations; |
|
437 |
} |
|
438 |
|
|
439 |
/** |
|
440 |
* Adds a new WFSRequestInformation |
|
441 |
* @param wfsRequestInformation |
|
442 |
*/ |
|
443 |
public void addLastWfsRequestInformation( |
|
444 |
WFSRequestInformation wfsRequestInformation) { |
|
445 |
wfsRequestInformations.add(wfsRequestInformation); |
|
446 |
} |
|
447 |
|
|
448 |
/** |
|
449 |
* @return the lastWfsRequestInformation |
|
450 |
*/ |
|
451 |
public WFSRequestInformation getLastWfsRequestInformation() { |
|
452 |
if (wfsRequestInformations.size() > 0){ |
|
453 |
return (WFSRequestInformation)wfsRequestInformations.get(wfsRequestInformations.size() - 1); |
|
454 |
} |
|
455 |
return null; |
|
456 |
} |
|
457 |
} |
|
0 | 458 |
tags/org.gvsig.desktop-2.0.10/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wfs/WFSOperation.java | ||
---|---|---|
1 |
package org.gvsig.remoteclient.wfs; |
|
2 |
|
|
3 |
import java.util.Hashtable; |
|
4 |
|
|
5 |
import org.gvsig.remoteclient.ogc.OGCClientOperation; |
|
6 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
7 |
|
|
8 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
9 |
* |
|
10 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
11 |
* |
|
12 |
* This program is free software; you can redistribute it and/or |
|
13 |
* modify it under the terms of the GNU General Public License |
|
14 |
* as published by the Free Software Foundation; either version 2 |
|
15 |
* of the License, or (at your option) any later version. |
|
16 |
* |
|
17 |
* This program is distributed in the hope that it will be useful, |
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 |
* GNU General Public License for more details. |
|
21 |
* |
|
22 |
* You should have received a copy of the GNU General Public License |
|
23 |
* along with this program; if not, write to the Free Software |
|
24 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
25 |
* |
|
26 |
* For more information, contact: |
|
27 |
* |
|
28 |
* Generalitat Valenciana |
|
29 |
* Conselleria d'Infraestructures i Transport |
|
30 |
* Av. Blasco Ib??ez, 50 |
|
31 |
* 46010 VALENCIA |
|
32 |
* SPAIN |
|
33 |
* |
|
34 |
* +34 963862235 |
|
35 |
* gvsig@gva.es |
|
36 |
* www.gvsig.gva.es |
|
37 |
* |
|
38 |
* or |
|
39 |
* |
|
40 |
* IVER T.I. S.A |
|
41 |
* Salamanca 50 |
|
42 |
* 46005 Valencia |
|
43 |
* Spain |
|
44 |
* |
|
45 |
* +34 963163400 |
|
46 |
* dac@iver.es |
|
47 |
*/ |
|
48 |
/* CVS MESSAGES: |
|
49 |
* |
|
50 |
* $Id: WFSOperation.java 29650 2009-06-29 17:07:18Z jpiera $ |
|
51 |
* $Log$ |
|
52 |
* Revision 1.1 2007-02-09 14:11:01 jorpiell |
|
53 |
* Primer piloto del soporte para WFS 1.1 y para WFS-T |
|
54 |
* |
|
55 |
* |
|
56 |
*/ |
|
57 |
/** |
|
58 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
59 |
*/ |
|
60 |
public class WFSOperation extends OGCClientOperation{ |
|
61 |
protected static Hashtable operations = new Hashtable(); |
|
62 |
|
|
63 |
static{ |
|
64 |
operations.put(CapabilitiesTags.GETCAPABILITIES, new WFSOperation(CapabilitiesTags.GETCAPABILITIES)); |
|
65 |
operations.put(CapabilitiesTags.WFS_DESCRIBEFEATURETYPE, new WFSOperation(CapabilitiesTags.WFS_DESCRIBEFEATURETYPE)); |
|
66 |
operations.put(CapabilitiesTags.WFS_GETFEATURE, new WFSOperation(CapabilitiesTags.WFS_GETFEATURE)); |
|
67 |
operations.put(CapabilitiesTags.WFS_TRANSACTION, new WFSOperation(CapabilitiesTags.WFS_TRANSACTION)); |
|
68 |
operations.put(CapabilitiesTags.WFS_LOCKFEATURE, new WFSOperation(CapabilitiesTags.WFS_LOCKFEATURE)); |
|
69 |
} |
|
70 |
|
|
71 |
public WFSOperation(String operationName) { |
|
72 |
super(operationName); |
|
73 |
} |
|
74 |
|
|
75 |
public WFSOperation(String operationName, String onlineResource) { |
|
76 |
super(operationName, onlineResource); |
|
77 |
} |
|
78 |
|
|
79 |
|
|
80 |
/* |
|
81 |
* (non-Javadoc) |
|
82 |
* @see org.gvsig.remoteClient.OGCClientOperation#getOperations() |
|
83 |
*/ |
|
84 |
public Hashtable getOperations() { |
|
85 |
return operations; |
|
86 |
} |
|
87 |
|
|
88 |
|
|
89 |
} |
|
90 |
|
|
0 | 91 |
tags/org.gvsig.desktop-2.0.10/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wfs/schema/XMLNameSpace.java | ||
---|---|---|
1 |
package org.gvsig.remoteclient.wfs.schema; |
|
2 |
|
|
3 |
|
|
4 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
5 |
* |
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
21 |
* |
|
22 |
* For more information, contact: |
|
23 |
* |
|
24 |
* Generalitat Valenciana |
|
25 |
* Conselleria d'Infraestructures i Transport |
|
26 |
* Av. Blasco Ib??ez, 50 |
|
27 |
* 46010 VALENCIA |
|
28 |
* SPAIN |
|
29 |
* |
|
30 |
* +34 963862235 |
|
31 |
* gvsig@gva.es |
|
32 |
* www.gvsig.gva.es |
|
33 |
* |
|
34 |
* or |
|
35 |
* |
|
36 |
* IVER T.I. S.A |
|
37 |
* Salamanca 50 |
|
38 |
* 46005 Valencia |
|
39 |
* Spain |
|
40 |
* |
|
41 |
* +34 963163400 |
|
42 |
* dac@iver.es |
|
43 |
*/ |
|
44 |
/* CVS MESSAGES: |
|
45 |
* |
|
46 |
* $Id: XMLNameSpace.java 9729 2007-01-15 13:11:17Z csanchez $ |
|
47 |
* $Log$ |
|
48 |
* Revision 1.2 2007-01-15 13:11:00 csanchez |
|
49 |
* Sistema de Warnings y Excepciones adaptado a BasicException |
|
50 |
* |
|
51 |
* Revision 1.1 2006/12/22 11:25:04 csanchez |
|
52 |
* Nuevo parser GML 2.x para gml's sin esquema |
|
53 |
* |
|
54 |
* Revision 1.1 2006/08/10 12:00:49 jorpiell |
|
55 |
* Primer commit del driver de Gml |
|
56 |
* |
|
57 |
* |
|
58 |
*/ |
|
59 |
/** |
|
60 |
* This class represent a XSD schema file |
|
61 |
* |
|
62 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
63 |
* @author Carlos S?nchez Peri??n (sanchez_carper@gva.es) |
|
64 |
* |
|
65 |
*/ |
|
66 |
public class XMLNameSpace { |
|
67 |
private String prefix = null; |
|
68 |
private String location = null; |
|
69 |
|
|
70 |
public XMLNameSpace(String prefix,String location) { |
|
71 |
super(); |
|
72 |
this.prefix = prefix; |
|
73 |
this.location = location; |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* @return Returns the location. |
|
78 |
*/ |
|
79 |
public String getLocation() { |
|
80 |
return location; |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* @return Returns the name. |
|
85 |
*/ |
|
86 |
public String getPrefix() { |
|
87 |
return prefix; |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* @param location The location to set. |
|
92 |
*/ |
|
93 |
public void setLocation(String location) { |
|
94 |
this.location = location; |
|
95 |
} |
|
96 |
} |
|
0 | 97 |
tags/org.gvsig.desktop-2.0.10/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wfs/schema/GMLTags.java | ||
---|---|---|
1 |
package org.gvsig.remoteclient.wfs.schema; |
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
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 2 |
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id: GMLTags.java 9723 2007-01-14 13:12:11Z jaume $ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.4 2007-01-14 13:12:11 jaume |
|
47 |
* objects to strings |
|
48 |
* |
|
49 |
* Revision 1.3 2006/12/22 11:25:44 csanchez |
|
50 |
* Nuevo parser GML 2.x para gml's sin esquema |
|
51 |
* |
|
52 |
* Revision 1.2 2006/08/10 12:37:05 jorpiell |
|
53 |
* A?adido el tag description al GML parser |
|
54 |
* |
|
55 |
* Revision 1.1 2006/08/10 12:00:49 jorpiell |
|
56 |
* Primer commit del driver de Gml |
|
57 |
* |
|
58 |
* |
|
59 |
*/ |
|
60 |
/** |
|
61 |
* Class containing a description for all the TAGS defined in |
|
62 |
* the GML File |
|
63 |
* |
|
64 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
65 |
* @author Carlos S?nchez Peri??n (sanchez_carper@gva.es) |
|
66 |
* |
|
67 |
*/ |
|
68 |
public class GMLTags { |
|
69 |
public static final String VERSION = "version"; |
|
70 |
public static final String XML_TARGET_NAMESPACE = "targetNamespace"; |
|
71 |
public static final String XML_ELEMENT_FORM_DEFAULT = "elementFormDefault"; |
|
72 |
public static final String XML_ATTRIBUTE_FORM_DEFAULT = "attributeFormDefault"; |
|
73 |
public static final String XML_NAMESPACE = "xmlns"; |
|
74 |
public static final String XML_SCHEMA_LOCATION = "schemaLocation"; |
|
75 |
public static final String GML_NAME = "name"; |
|
76 |
public static final String GML_DESCRIPTION = "description"; |
|
77 |
public static final String GML_BOUNDEDBY = "boundedBy"; |
|
78 |
public static final String GML_BOX = "Box"; |
|
79 |
public static final String GML_COORDINATES = "coordinates"; |
|
80 |
public static final String GML_COORD = "coord"; |
|
81 |
public static final String GML_X = "X"; |
|
82 |
public static final String GML_Y = "Y"; |
|
83 |
public static final String GML_COORDINATES_DECIMAL = "decimal"; |
|
84 |
public static final String GML_COORDINATES_CS = "cs"; |
|
85 |
public static final String GML_COORDINATES_TS = "ts"; |
|
86 |
public static final String GML_SRS_NAME = "srsName"; |
|
87 |
|
|
88 |
//GML types |
|
89 |
public static final String GML_POINT = "Point"; |
|
90 |
public static final String GML_MUNTILINE = "MultiLineString"; |
|
91 |
} |
|
0 | 92 |
tags/org.gvsig.desktop-2.0.10/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wfs/schema/XMLSchemaParser.java | ||
---|---|---|
1 |
package org.gvsig.remoteclient.wfs.schema; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import org.gvsig.compat.CompatLocator; |
|
6 |
import org.gvsig.remoteclient.utils.EncodingXMLParser; |
|
7 |
import org.xmlpull.v1.XmlPullParserException; |
|
8 |
|
|
9 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
10 |
* |
|
11 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
12 |
* |
|
13 |
* This program is free software; you can redistribute it and/or |
|
14 |
* modify it under the terms of the GNU General Public License |
|
15 |
* as published by the Free Software Foundation; either version 2 |
|
16 |
* of the License, or (at your option) any later version. |
|
17 |
* |
|
18 |
* This program is distributed in the hope that it will be useful, |
|
19 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 |
* GNU General Public License for more details. |
|
22 |
* |
|
23 |
* You should have received a copy of the GNU General Public License |
|
24 |
* along with this program; if not, write to the Free Software |
|
25 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
26 |
* |
|
27 |
* For more information, contact: |
|
28 |
* |
|
29 |
* Generalitat Valenciana |
|
30 |
* Conselleria d'Infraestructures i Transport |
|
31 |
* Av. Blasco Ib??ez, 50 |
|
32 |
* 46010 VALENCIA |
|
33 |
* SPAIN |
|
34 |
* |
|
35 |
* +34 963862235 |
|
36 |
* gvsig@gva.es |
|
37 |
* www.gvsig.gva.es |
|
38 |
* |
|
39 |
* or |
|
40 |
* |
|
41 |
* IVER T.I. S.A |
|
42 |
* Salamanca 50 |
|
43 |
* 46005 Valencia |
|
44 |
* Spain |
|
45 |
* |
|
46 |
* +34 963163400 |
|
47 |
* dac@iver.es |
|
48 |
*/ |
|
49 |
/* CVS MESSAGES: |
|
50 |
* |
|
51 |
* $Id: XMLSchemaParser.java 18271 2008-01-24 09:06:43Z jpiera $ |
|
52 |
* $Log$ |
|
53 |
* Revision 1.7 2007-01-15 13:11:00 csanchez |
|
54 |
* Sistema de Warnings y Excepciones adaptado a BasicException |
|
55 |
* |
|
56 |
* Revision 1.6 2006/12/29 17:15:48 jorpiell |
|
57 |
* Se tienen en cuenta los simpleTypes y los choices, adem?s de los atributos multiples |
|
58 |
* |
|
59 |
* Revision 1.5 2006/12/22 11:25:44 csanchez |
|
60 |
* Nuevo parser GML 2.x para gml's sin esquema |
|
61 |
* |
|
62 |
* Revision 1.4 2006/10/10 12:52:28 jorpiell |
|
63 |
* Soporte para features complejas. |
|
64 |
* |
|
65 |
* Revision 1.3 2006/10/02 08:33:49 jorpiell |
|
66 |
* Cambios del 10 copiados al head |
|
67 |
* |
|
68 |
* Revision 1.1.2.1 2006/09/19 12:23:15 jorpiell |
|
69 |
* Ya no se depende de geotools |
|
70 |
* |
|
71 |
* Revision 1.2 2006/09/18 12:08:55 jorpiell |
|
72 |
* Se han hecho algunas modificaciones que necesitaba el WFS |
|
73 |
* |
|
74 |
* Revision 1.1 2006/08/10 12:00:49 jorpiell |
|
75 |
* Primer commit del driver de Gml |
|
76 |
* |
|
77 |
* Revision 1.1 2006/05/16 14:12:56 jorpiell |
|
78 |
* A?adido el parseador de Esquemas |
|
79 |
* |
|
80 |
* |
|
81 |
*/ |
|
82 |
/** |
|
83 |
* Thas class is used to parse a schema XSD |
|
84 |
* |
|
85 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
86 |
* @author Carlos S?nchez Peri??n (sanchez_carper@gva.es) |
|
87 |
* |
|
88 |
*/ |
|
89 |
public class XMLSchemaParser extends EncodingXMLParser { |
|
90 |
private String targetNameSpace = null; |
|
91 |
private String schema = ""; |
|
92 |
private String encoding = "UTF-8"; |
|
93 |
private String nameSpace = ""; |
|
94 |
private String version = null; |
|
95 |
|
|
96 |
|
|
97 |
public XMLSchemaParser(){ |
|
98 |
super(); |
|
99 |
} |
|
100 |
|
|
101 |
public XMLSchemaParser(String schema){ |
|
102 |
super(); |
|
103 |
//schema instace is named with the string in "schema" |
|
104 |
this.schema = schema; |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* It gets the schema from a tag. The schema is separated |
|
109 |
* of the tag name by ":". |
|
110 |
* @param tag |
|
111 |
*/ |
|
112 |
public void setSchemaFromMainTag(String tag){ |
|
113 |
//set the name string of the namespace. |
|
114 |
int pos = tag.indexOf(":"); |
|
115 |
if (pos > 0){ |
|
116 |
this.schema = tag.substring(0,pos); |
|
117 |
}else{ |
|
118 |
this.schema = ""; |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* @return Returns the schema. |
|
124 |
*/ |
|
125 |
public String getSchema() { |
|
126 |
return schema; |
|
127 |
} |
|
128 |
|
|
129 |
/** |
|
130 |
* @param schema The schema to set. |
|
131 |
*/ |
|
132 |
public void setSchema(String schema) { |
|
133 |
this.schema = schema; |
|
134 |
} |
|
135 |
|
|
136 |
/** |
|
137 |
* Returns a SCHEMA:TAG |
|
138 |
* @param tag |
|
139 |
* @return SCHEMA:TAG |
|
140 |
*/ |
|
141 |
private String getTag(String tag){ |
|
142 |
//get the tag without the namespace |
|
143 |
if (tag == null){ |
|
144 |
return null; |
|
145 |
} |
|
146 |
if ((schema == null) || (schema.equals(""))){ |
|
147 |
return tag; |
|
148 |
} |
|
149 |
return schema + ":" + tag; |
|
150 |
} |
|
151 |
|
|
152 |
/* |
|
153 |
* (non-Javadoc) |
|
154 |
* @see org.xmlpull.v1.XmlPullParser#require(int, java.lang.String, java.lang.String) |
|
155 |
*/ |
|
156 |
public void require(int type, String namespace, String name) |
|
157 |
throws XmlPullParserException, IOException{ |
|
158 |
super.require(type,namespace,getTag(name)); |
|
159 |
} |
|
160 |
|
|
161 |
/* |
|
162 |
* (non-Javadoc) |
|
163 |
* @see org.xmlpull.v1.XmlPullParser#getName() |
|
164 |
*/ |
|
165 |
public String getName(){ |
|
166 |
try{ |
|
167 |
String name = super.getName(); |
|
168 |
if ((schema != null) || (!(schema.equals("")))){ |
|
169 |
return name.substring(name.indexOf(":") + 1,name.length()); |
|
170 |
} |
|
171 |
return name; |
|
172 |
}catch (NullPointerException e){ |
|
173 |
return ""; |
|
174 |
} |
|
175 |
} |
|
176 |
|
|
177 |
/* |
|
178 |
* (non-Javadoc) |
|
179 |
* @see org.xmlpull.v1.XmlPullParser#getName() |
|
180 |
*/ |
|
181 |
public String getNameSpace(){ |
|
182 |
try{ |
|
183 |
String name = super.getName(); |
|
184 |
if ((name!=null)&&(CompatLocator.getStringUtils().split(name,":").length > 1)){ |
|
185 |
return CompatLocator.getStringUtils().split(name, ":")[0]; |
|
186 |
} |
|
187 |
return ""; |
|
188 |
}catch (NullPointerException e){ |
|
189 |
return ""; |
|
190 |
} |
|
191 |
} |
|
192 |
|
|
193 |
|
|
194 |
public String getversion() { |
|
195 |
if (version == null){ |
|
196 |
//return the default GML version |
|
197 |
return "99.99.99"; |
|
198 |
} |
|
199 |
return version; |
|
200 |
} |
|
201 |
public String getTargetNamespace() { |
|
202 |
return targetNameSpace; |
|
203 |
} |
|
204 |
} |
|
0 | 205 |
tags/org.gvsig.desktop-2.0.10/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wfs/schema/type/GMLException.java | ||
---|---|---|
1 |
package org.gvsig.remoteclient.wfs.schema.type; |
|
2 |
|
|
3 |
import java.util.Hashtable; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
7 |
* |
|
8 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
9 |
* |
|
10 |
* This program is free software; you can redistribute it and/or |
|
11 |
* modify it under the terms of the GNU General Public License |
|
12 |
* as published by the Free Software Foundation; either version 2 |
|
13 |
* of the License, or (at your option) any later version. |
|
14 |
* |
|
15 |
* This program is distributed in the hope that it will be useful, |
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
* GNU General Public License for more details. |
|
19 |
* |
|
20 |
* You should have received a copy of the GNU General Public License |
|
21 |
* along with this program; if not, write to the Free Software |
|
22 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
23 |
* |
|
24 |
* For more information, contact: |
|
25 |
* |
|
26 |
* Generalitat Valenciana |
|
27 |
* Conselleria d'Infraestructures i Transport |
|
28 |
* Av. Blasco Ib??ez, 50 |
|
29 |
* 46010 VALENCIA |
|
30 |
* SPAIN |
|
31 |
* |
|
32 |
* +34 963862235 |
|
33 |
* gvsig@gva.es |
|
34 |
* www.gvsig.gva.es |
|
35 |
* |
|
36 |
* or |
|
37 |
* |
|
38 |
* IVER T.I. S.A |
|
39 |
* Salamanca 50 |
|
40 |
* 46005 Valencia |
|
41 |
* Spain |
|
42 |
* |
|
43 |
* +34 963163400 |
|
44 |
* dac@iver.es |
|
45 |
*/ |
|
46 |
/* CVS MESSAGES: |
|
47 |
* |
|
48 |
* $Id: GMLException.java 18271 2008-01-24 09:06:43Z jpiera $ |
|
49 |
* $Log$ |
|
50 |
* Revision 1.1 2007-01-15 13:11:00 csanchez |
|
51 |
* Sistema de Warnings y Excepciones adaptado a BasicException |
|
52 |
* |
|
53 |
* Revision 1.2 2006/12/22 11:25:44 csanchez |
|
54 |
* Nuevo parser GML 2.x para gml's sin esquema |
|
55 |
* |
|
56 |
* Revision 1.1 2006/08/10 12:00:49 jorpiell |
|
57 |
* Primer commit del driver de Gml |
|
58 |
* |
|
59 |
* |
|
60 |
*/ |
|
61 |
/** |
|
62 |
* GML Exception. |
|
63 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
64 |
* @author Carlos S?nchez Peri??n (sanchez_carper@gva.es) |
|
65 |
* |
|
66 |
*/ |
|
67 |
public class GMLException extends Exception { |
|
68 |
private static final long serialVersionUID = -5486463227342843579L; |
|
69 |
private String filename=""; |
|
70 |
protected String formatString; |
|
71 |
protected String messageKey; |
|
72 |
protected long code; |
|
73 |
|
|
74 |
public GMLException() { |
|
75 |
|
|
76 |
} |
|
77 |
|
|
78 |
public GMLException(String file) { |
|
79 |
init(); |
|
80 |
this.filename=file; |
|
81 |
} |
|
82 |
public GMLException(Throwable exception) { |
|
83 |
init(); |
|
84 |
initCause(exception); |
|
85 |
} |
|
86 |
public GMLException(String file, Throwable exception) { |
|
87 |
init(); |
|
88 |
this.filename=file; |
|
89 |
initCause(exception); |
|
90 |
} |
|
91 |
|
|
92 |
public String getFilename() { |
|
93 |
return filename; |
|
94 |
} |
|
95 |
|
|
96 |
public void setFilename(String filename) { |
|
97 |
this.filename = filename; |
|
98 |
} |
|
99 |
|
|
100 |
protected Map values() { |
|
101 |
//Key -> value... filename -> name of the file |
|
102 |
Hashtable params; |
|
103 |
params = new Hashtable(); |
|
104 |
params.put("file",filename); |
|
105 |
|
|
106 |
return params; |
|
107 |
} |
|
108 |
|
|
109 |
public void init() { |
|
110 |
messageKey="Gml_Error"; |
|
111 |
formatString="Error opening GML shape %(file)"; |
|
112 |
code = serialVersionUID; |
|
113 |
} |
|
114 |
|
|
115 |
|
|
116 |
} |
|
0 | 117 |
tags/org.gvsig.desktop-2.0.10/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wfs/schema/type/GMLInvalidFormatException.java | ||
---|---|---|
1 |
package org.gvsig.remoteclient.wfs.schema.type; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
6 |
* |
|
7 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
8 |
* |
|
9 |
* This program is free software; you can redistribute it and/or |
|
10 |
* modify it under the terms of the GNU General Public License |
|
11 |
* as published by the Free Software Foundation; either version 2 |
|
12 |
* of the License, or (at your option) any later version. |
|
13 |
* |
|
14 |
* This program is distributed in the hope that it will be useful, |
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 |
* GNU General Public License for more details. |
|
18 |
* |
|
19 |
* You should have received a copy of the GNU General Public License |
|
20 |
* along with this program; if not, write to the Free Software |
|
21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
22 |
* |
|
23 |
* For more information, contact: |
|
24 |
* |
|
25 |
* Generalitat Valenciana |
|
26 |
* Conselleria d'Infraestructures i Transport |
|
27 |
* Av. Blasco Ib??ez, 50 |
|
28 |
* 46010 VALENCIA |
|
29 |
* SPAIN |
|
30 |
* |
|
31 |
* +34 963862235 |
|
32 |
* gvsig@gva.es |
Also available in: Unified diff