svn-gvsig-desktop / tags / v1_0_2_Build_908 / applications / appCatalogYNomenclatorClient / src / es / gva / cit / gazetteer / wfsg / drivers / WFSGMessages.java @ 11054
History | View | Annotate | Download (9.94 KB)
1 | 3566 | jorpiell | |
---|---|---|---|
2 | 3214 | jorpiell | /* 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 | package es.gva.cit.gazetteer.wfsg.drivers; |
||
43 | 3566 | jorpiell | import es.gva.cit.gazetteer.drivers.IProtocolMessages; |
44 | import es.gva.cit.gazetteer.querys.Query; |
||
45 | import es.gva.cit.gazetteer.wfsg.filters.WFSGFilter; |
||
46 | 3613 | jorpiell | import java.net.URL; |
47 | import org.apache.commons.httpclient.NameValuePair; |
||
48 | 3214 | jorpiell | |
49 | /**
|
||
50 | * This class has methods that return the WFSG opearions messages.
|
||
51 | 3566 | jorpiell | *
|
52 | *
|
||
53 | 3214 | jorpiell | * @author Jorge Piera Llodra (piera_jor@gva.es)
|
54 | */
|
||
55 | 3566 | jorpiell | public class WFSGMessages implements IProtocolMessages { |
56 | /**
|
||
57 | *
|
||
58 | *
|
||
59 | */
|
||
60 | 3214 | jorpiell | private WFSGazetteerServiceDriver driver;
|
61 | 3566 | jorpiell | |
62 | /**
|
||
63 | *
|
||
64 | *
|
||
65 | */
|
||
66 | 3214 | jorpiell | private URL url; |
67 | 3566 | jorpiell | |
68 | /**
|
||
69 | *
|
||
70 | *
|
||
71 | *
|
||
72 | * @param driver
|
||
73 | * @param url
|
||
74 | */
|
||
75 | public WFSGMessages(WFSGazetteerServiceDriver driver, URL url) { |
||
76 | 3214 | jorpiell | this.driver = driver;
|
77 | this.url = url;
|
||
78 | 3566 | jorpiell | } |
79 | /* (non-Javadoc)
|
||
80 | 3214 | jorpiell | * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getHTTPGETCapabilities(boolean)
|
81 | */
|
||
82 | 3566 | jorpiell | |
83 | /**
|
||
84 | *
|
||
85 | *
|
||
86 | *
|
||
87 | * @return
|
||
88 | * @param upper
|
||
89 | */
|
||
90 | public NameValuePair[] getHTTPGETCapabilities(boolean upper) { |
||
91 | 8765 | jjdelcerro | NameValuePair nvp1; |
92 | |||
93 | String queryString = url.getFile().substring(url.getFile().indexOf('?')+1); |
||
94 | |||
95 | String[] params = queryString.split("&"); |
||
96 | NameValuePair[] nvp = new NameValuePair[params.length + 2]; |
||
97 | for (int i = 0; i < params.length; i++) { |
||
98 | if (params[i]!= null){ |
||
99 | String[] nameValue = params[i].split("="); |
||
100 | if (nameValue.length == 1){ |
||
101 | nvp[i] = new NameValuePair(nameValue[0],""); |
||
102 | }else if(nameValue.length == 2){ |
||
103 | nvp[i] = new NameValuePair(nameValue[0],nameValue[1]); |
||
104 | } |
||
105 | } |
||
106 | } |
||
107 | |||
108 | if (upper){
|
||
109 | nvp[nvp.length-2] = new NameValuePair("request", "GetCapabilities"); |
||
110 | }else{
|
||
111 | nvp[nvp.length-2] = new NameValuePair("request", "getCapabilities"); |
||
112 | } |
||
113 | nvp[nvp.length-1] = new NameValuePair("service", "WFS"); |
||
114 | |||
115 | return nvp;
|
||
116 | 3566 | jorpiell | } |
117 | /* (non-Javadoc)
|
||
118 | 3214 | jorpiell | * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getHTTPGETDescribeFeature()
|
119 | */
|
||
120 | |||
121 | 3566 | jorpiell | /**
|
122 | *
|
||
123 | *
|
||
124 | *
|
||
125 | * @return
|
||
126 | * @param feature
|
||
127 | */
|
||
128 | public NameValuePair[] getHTTPGETDescribeFeature(String feature) { |
||
129 | 3214 | jorpiell | NameValuePair nvp1 = new NameValuePair("request", "DescribeFeatureType"); |
130 | NameValuePair nvp2 = new NameValuePair("typename", feature); |
||
131 | |||
132 | return new NameValuePair[] { |
||
133 | nvp1, nvp2 |
||
134 | }; |
||
135 | 3566 | jorpiell | } |
136 | /* (non-Javadoc)
|
||
137 | 3214 | jorpiell | * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getHTTPGETFeatures(es.gva.cit.catalogClient.querys.Query, int)
|
138 | */
|
||
139 | |||
140 | 3566 | jorpiell | /**
|
141 | *
|
||
142 | *
|
||
143 | *
|
||
144 | * @return
|
||
145 | * @param query
|
||
146 | * @param firstRecord
|
||
147 | */
|
||
148 | public NameValuePair[] getHTTPGETFeatures(Query query, int firstRecord) { |
||
149 | |||
150 | 3214 | jorpiell | NameValuePair nvp1 = new NameValuePair("request", "getFeature"); |
151 | 3566 | jorpiell | NameValuePair nvp2 = new NameValuePair("typename", new WFSGFilter().getQuery(query)); |
152 | 3214 | jorpiell | |
153 | return new NameValuePair[] { |
||
154 | nvp1, nvp2 |
||
155 | }; |
||
156 | 3566 | jorpiell | } |
157 | /* (non-Javadoc)
|
||
158 | 3214 | jorpiell | * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getHTTPPOSTCapabilities()
|
159 | */
|
||
160 | 3566 | jorpiell | |
161 | /**
|
||
162 | *
|
||
163 | *
|
||
164 | *
|
||
165 | * @return
|
||
166 | */
|
||
167 | public String getHTTPPOSTCapabilities() { |
||
168 | 3214 | jorpiell | return "<?xml version=\"1.0\" ?>" + |
169 | "<GetCapabilities " +
|
||
170 | "service=\"WFS\" " +
|
||
171 | "xmlns:csw=\"http://www.opengis.net/wfs\" " +
|
||
172 | "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
|
||
173 | "xsi:schemaLocation=\"http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd\">" +
|
||
174 | "</GetCapabilities>";
|
||
175 | 3566 | jorpiell | } |
176 | /* (non-Javadoc)
|
||
177 | 3214 | jorpiell | * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getHTTPPOSTDescribeFeature()
|
178 | */
|
||
179 | 3566 | jorpiell | |
180 | /**
|
||
181 | *
|
||
182 | *
|
||
183 | *
|
||
184 | * @return
|
||
185 | * @param feature
|
||
186 | */
|
||
187 | public String getHTTPPOSTDescribeFeature(String feature) { |
||
188 | 3214 | jorpiell | return "<DescribeFeatureType " + |
189 | "version=\"1.0.0\" " +
|
||
190 | "service=\"WFS\" " +
|
||
191 | "xmlns=\"http://www.opengis.net/wfs\" " +
|
||
192 | "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
|
||
193 | "xsi:schemaLocation=\"http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd\">" +
|
||
194 | "<TypeName>" + feature + "</TypeName>" + |
||
195 | "</DescribeFeatureType>";
|
||
196 | 3566 | jorpiell | } |
197 | /* (non-Javadoc)
|
||
198 | 3214 | jorpiell | * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getHTTPPOSTFeature(es.gva.cit.catalogClient.querys.Query, int)
|
199 | */
|
||
200 | 3566 | jorpiell | |
201 | /**
|
||
202 | *
|
||
203 | *
|
||
204 | *
|
||
205 | * @return
|
||
206 | * @param query
|
||
207 | * @param firstRecord
|
||
208 | */
|
||
209 | public String getHTTPPOSTFeature(Query query, int firstRecord) { |
||
210 | 3214 | jorpiell | |
211 | 3566 | jorpiell | |
212 | 3214 | jorpiell | String message = "<wfs:GetFeature service=\"WFS\" version=\"1.0.0\" " + |
213 | "outputFormat=\"GML2\" " +
|
||
214 | "xmlns:topp=\"http://www.openplans.org/topp\" " +
|
||
215 | "xmlns:wfs=\"http://www.opengis.net/wfs\" " +
|
||
216 | "xmlns:ogc=\"http://www.opengis.net/ogc\" " +
|
||
217 | "xmlns:gml=\"http://www.opengis.net/gml\" " +
|
||
218 | "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
|
||
219 | "xsi:schemaLocation=\"http://www.opengis.net/wfs " +
|
||
220 | "http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd\">" +
|
||
221 | 3311 | jorpiell | "<wfs:Query typeName=\"" + query.getFeatures()[0].getName() + "\">" + |
222 | 3566 | jorpiell | new WFSGFilter().getQuery(query) +
|
223 | 3214 | jorpiell | "</wfs:Query>" +
|
224 | "</wfs:GetFeature>";
|
||
225 | |||
226 | /* String message = "<GetFeature " +
|
||
227 | "xmlns:wfs=\"http://www.opengis.net/wfs\" " +
|
||
228 | "xmlns:ogc=\"http://www.opengis.net/ogc\" " +
|
||
229 | "xmlns:cv300=\"http://sercartlin:8080/geoserver/wfs/DescribeFeatureType?typeName=cv300:hidro_txt_300k,cv300:poblacion_pnt_300k,cv300:poblacion50_pol_300k,cv300:orogsecun_txt_300k,cv300:orogsecun_pnt_300k,cv300:comunic_txt_300k,cv300:comunic_lin_300k,cv300:hidro_lin_300k,cv300:embalses_pol_300k,cv300:poblacion50_txt_300k,cv300:orogpral_txt_300k,cv300:limites_pol_300k\" " +
|
||
230 | "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
|
||
231 | "xsi:schemaLocation=\"http://www.opengis.net/wfs ../wfs/1.1.0/WFS.xsd\" " +
|
||
232 | "version=\"1.1.0\" " +
|
||
233 | "service=\"WFS\" " +
|
||
234 | "outputFormat=\"text/xml\">" +
|
||
235 | "<Query typename=\"" + query.getFeature().getName() + "\">" +
|
||
236 | wfsQuery.getQuery() +
|
||
237 | "</Query>" +
|
||
238 | "</GetFeature>";
|
||
239 | */
|
||
240 | |||
241 | /*String message = "<wfs-g:GetFeatureRequest " +
|
||
242 | "xmlns:wfs-g=\"http://www.opengis.net/wfs-g\" " +
|
||
243 | "xmlns:ogc=\"http://www.opengis.net/ogc\" " +
|
||
244 | "xmlns:gml=\"http://www.opengis.net/gml\" " +
|
||
245 | "xmlns:wfs=\"http://www.opengis.net/wfs\" " +
|
||
246 | "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
|
||
247 | "xsi:schemaLocation=\"http://www.opengis.net/wfs-g ../../gazetteer/0.9/WFS-G_GetFeatureRequest.xsd\" " +
|
||
248 | "version=\"1.0.0\" service=\"WFS\">" +
|
||
249 | "<wfs:Query typename=\"" + query.getFeature().getName() + "\">" +
|
||
250 | wfsQuery.getQuery() +
|
||
251 | "</wfs:Query>" +
|
||
252 | "</wfs-g:GetFeatureRequest>";
|
||
253 | */
|
||
254 | |||
255 | /* String message = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" +
|
||
256 | "<GetFeature outputFormat=\"GML2\" " +
|
||
257 | "xmlns:gml=\"http://www.opengis.net/gml\" " +
|
||
258 | "xmlns:wfs=\"http://www.opengis.net/wfs\" " +
|
||
259 | "xmlns:ogc=\"http://www.opengis.net/ogc\">" +
|
||
260 | "<Query typeName=\"" + query.getFeature().getName() + "\">" +
|
||
261 | "<ogc:Filter>" +
|
||
262 | "<ogc:And>" +
|
||
263 | "<ogc:BBOX>" +
|
||
264 | "<ogc:PropertyName>the_geom</ogc:PropertyName>" +
|
||
265 | "<gml:Box srsName=\"http://www.opengis.net/gml/srs/epsg.xml#4326\">" +
|
||
266 | "<gml:coordinates>-75.102613,40.212597 -72.361859,41.512517</gml:coordinates>" +
|
||
267 | "</gml:Box>" +
|
||
268 | "</ogc:BBOX>" +
|
||
269 | "<ogc:PropertyIsLike wildCard=\"%\" singleChar=\"?\" escape=\"/\">" +
|
||
270 | "<ogc:PropertyName>geographicIdentifier</ogc:PropertyName>" +
|
||
271 | "<ogc:Literal>Bo%</ogc:Literal>" +
|
||
272 | "</ogc:PropertyIsLike>" +
|
||
273 | "</ogc:And>" +
|
||
274 | "</ogc:Filter>" +
|
||
275 | "</Query>" +
|
||
276 | "</GetFeature>";
|
||
277 | */
|
||
278 | System.out.println(message);
|
||
279 | |||
280 | return message;
|
||
281 | 3566 | jorpiell | } |
282 | /* (non-Javadoc)
|
||
283 | 3214 | jorpiell | * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getSOAPCapabilities()
|
284 | */
|
||
285 | 3566 | jorpiell | |
286 | /**
|
||
287 | *
|
||
288 | *
|
||
289 | *
|
||
290 | * @return
|
||
291 | */
|
||
292 | public String getSOAPCapabilities() { |
||
293 | 3214 | jorpiell | // TODO Auto-generated method stub
|
294 | return null; |
||
295 | 3566 | jorpiell | } |
296 | /* (non-Javadoc)
|
||
297 | 3214 | jorpiell | * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getSOAPDescribeFeature()
|
298 | */
|
||
299 | 3566 | jorpiell | |
300 | /**
|
||
301 | *
|
||
302 | *
|
||
303 | *
|
||
304 | * @return
|
||
305 | * @param feature
|
||
306 | */
|
||
307 | public String getSOAPDescribeFeature(String feature) { |
||
308 | 3214 | jorpiell | // TODO Auto-generated method stub
|
309 | return null; |
||
310 | 3566 | jorpiell | } |
311 | /* (non-Javadoc)
|
||
312 | 3214 | jorpiell | * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getSOAPFeature(es.gva.cit.catalogClient.querys.Query, int)
|
313 | */
|
||
314 | 3566 | jorpiell | |
315 | /**
|
||
316 | *
|
||
317 | *
|
||
318 | *
|
||
319 | * @return
|
||
320 | * @param query
|
||
321 | * @param firstRecord
|
||
322 | */
|
||
323 | public String getSOAPFeature(Query query, int firstRecord) { |
||
324 | 3214 | jorpiell | // TODO Auto-generated method stub
|
325 | return null; |
||
326 | 3566 | jorpiell | } |
327 | } |