Statistics
| Revision:

svn-gvsig-desktop / tags / v10_RC2c / applications / appCatalogYNomenclatorClient / src / es / gva / cit / gazetteer / wfsg / drivers / WFSGMessages.java @ 8745

History | View | Annotate | Download (9.95 KB)

1

    
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
package es.gva.cit.gazetteer.wfsg.drivers;
43
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
import java.net.URL;
47
import java.util.TreeMap;
48

    
49
import org.apache.commons.httpclient.NameValuePair;
50

    
51
/**
52
 * This class has methods that return the WFSG opearions messages.
53
 * 
54
 * 
55
 * @author Jorge Piera Llodra (piera_jor@gva.es)
56
 */
57
public class WFSGMessages implements IProtocolMessages {
58
/**
59
 * 
60
 * 
61
 */
62
    private WFSGazetteerServiceDriver driver;
63

    
64
/**
65
 * 
66
 * 
67
 */
68
    private URL url;
69

    
70
/**
71
 * 
72
 * 
73
 * 
74
 * @param driver 
75
 * @param url 
76
 */
77
    public  WFSGMessages(WFSGazetteerServiceDriver driver, URL url) {        
78
        this.driver = driver;
79
        this.url = url;
80
    } 
81
/* (non-Javadoc)
82
     * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getHTTPGETCapabilities(boolean)
83
     */
84

    
85
/**
86
 * 
87
 * 
88
 * 
89
 * @return 
90
 * @param upper 
91
 */
92
    public NameValuePair[] getHTTPGETCapabilities(boolean upper) {        
93
        NameValuePair nvp1;       
94
        
95
                String queryString = url.getFile().substring(url.getFile().indexOf('?')+1);
96
                
97
                String[] params = queryString.split("&");
98
                NameValuePair[] nvp = new NameValuePair[params.length + 2];
99
                for (int i = 0; i < params.length; i++) {
100
                        if (params[i]!= null){
101
                                String[] nameValue = params[i].split("=");
102
                                if (nameValue.length == 1){
103
                                        nvp[i] = new NameValuePair(nameValue[0],"");
104
                                }else if(nameValue.length == 2){
105
                                        nvp[i] = new NameValuePair(nameValue[0],nameValue[1]);                                        
106
                                }
107
                        }
108
                }
109
                                
110
        if (upper){
111
                nvp[nvp.length-2] = new NameValuePair("request", "GetCapabilities");
112
        }else{
113
                nvp[nvp.length-2] = new NameValuePair("request", "getCapabilities");
114
        }
115
        nvp[nvp.length-1] = new NameValuePair("service", "WFS");
116
        
117
        return nvp;
118
    } 
119
/* (non-Javadoc)
120
     * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getHTTPGETDescribeFeature()
121
     */
122

    
123
/**
124
 * 
125
 * 
126
 * 
127
 * @return 
128
 * @param feature 
129
 */
130
    public NameValuePair[] getHTTPGETDescribeFeature(String feature) {        
131
        NameValuePair nvp1 = new NameValuePair("request", "DescribeFeatureType");
132
        NameValuePair nvp2 = new NameValuePair("typename", feature);
133
         
134
        return new NameValuePair[] {
135
            nvp1, nvp2
136
        };
137
    } 
138
/* (non-Javadoc)
139
     * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getHTTPGETFeatures(es.gva.cit.catalogClient.querys.Query, int)
140
     */
141

    
142
/**
143
 * 
144
 * 
145
 * 
146
 * @return 
147
 * @param query 
148
 * @param firstRecord 
149
 */
150
    public NameValuePair[] getHTTPGETFeatures(Query query, int firstRecord) {        
151
        
152
        NameValuePair nvp1 = new NameValuePair("request", "getFeature");
153
        NameValuePair nvp2 = new NameValuePair("typename", new WFSGFilter().getQuery(query));
154
         
155
        return new NameValuePair[] {
156
            nvp1, nvp2
157
        };
158
    } 
159
/* (non-Javadoc)
160
     * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getHTTPPOSTCapabilities()
161
     */
162

    
163
/**
164
 * 
165
 * 
166
 * 
167
 * @return 
168
 */
169
    public String getHTTPPOSTCapabilities() {        
170
        return "<?xml version=\"1.0\" ?>" +
171
             "<GetCapabilities " +
172
             "service=\"WFS\" " +
173
             "xmlns:csw=\"http://www.opengis.net/wfs\" " +
174
             "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
175
                        "xsi:schemaLocation=\"http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd\">" +
176
             "</GetCapabilities>";
177
    } 
178
/* (non-Javadoc)
179
     * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getHTTPPOSTDescribeFeature()
180
     */
181

    
182
/**
183
 * 
184
 * 
185
 * 
186
 * @return 
187
 * @param feature 
188
 */
189
    public String getHTTPPOSTDescribeFeature(String feature) {        
190
        return "<DescribeFeatureType " +
191
                        "version=\"1.0.0\" " +
192
                        "service=\"WFS\" " +
193
                        "xmlns=\"http://www.opengis.net/wfs\" " +
194
                        "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
195
                        "xsi:schemaLocation=\"http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd\">" +
196
                        "<TypeName>" + feature + "</TypeName>" +
197
                        "</DescribeFeatureType>";            
198
    } 
199
/* (non-Javadoc)
200
     * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getHTTPPOSTFeature(es.gva.cit.catalogClient.querys.Query, int)
201
     */
202

    
203
/**
204
 * 
205
 * 
206
 * 
207
 * @return 
208
 * @param query 
209
 * @param firstRecord 
210
 */
211
    public String getHTTPPOSTFeature(Query query, int firstRecord) {        
212
        
213
        
214
     String message = "<wfs:GetFeature service=\"WFS\" version=\"1.0.0\" " +
215
              "outputFormat=\"GML2\" " +
216
              "xmlns:topp=\"http://www.openplans.org/topp\" " +
217
              "xmlns:wfs=\"http://www.opengis.net/wfs\" " +
218
              "xmlns:ogc=\"http://www.opengis.net/ogc\" " +
219
              "xmlns:gml=\"http://www.opengis.net/gml\" " +
220
              "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
221
              "xsi:schemaLocation=\"http://www.opengis.net/wfs " +
222
              "http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd\">" +
223
              "<wfs:Query typeName=\"" + query.getFeatures()[0].getName() + "\">" +
224
                  new WFSGFilter().getQuery(query) +
225
              "</wfs:Query>" +
226
              "</wfs:GetFeature>"; 
227
       
228
        /* String message = "<GetFeature " +
229
                      "xmlns:wfs=\"http://www.opengis.net/wfs\" " +
230
                      "xmlns:ogc=\"http://www.opengis.net/ogc\" " +
231
                      "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\" " +
232
                      "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
233
                      "xsi:schemaLocation=\"http://www.opengis.net/wfs ../wfs/1.1.0/WFS.xsd\" " +
234
                      "version=\"1.1.0\" " +
235
                      "service=\"WFS\" " +
236
                      "outputFormat=\"text/xml\">" +
237
                      "<Query typename=\"" + query.getFeature().getName() + "\">" +
238
                      wfsQuery.getQuery() + 
239
                      "</Query>" +
240
                      "</GetFeature>";                 
241
     */
242
         
243
         /*String message = "<wfs-g:GetFeatureRequest " +
244
                 "xmlns:wfs-g=\"http://www.opengis.net/wfs-g\" " +
245
                 "xmlns:ogc=\"http://www.opengis.net/ogc\" " +
246
                 "xmlns:gml=\"http://www.opengis.net/gml\" " +
247
                 "xmlns:wfs=\"http://www.opengis.net/wfs\" " +
248
                 "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
249
                 "xsi:schemaLocation=\"http://www.opengis.net/wfs-g ../../gazetteer/0.9/WFS-G_GetFeatureRequest.xsd\" " +
250
                 "version=\"1.0.0\" service=\"WFS\">" +
251
                 "<wfs:Query typename=\"" + query.getFeature().getName() + "\">" +
252
                 wfsQuery.getQuery() + 
253
                 "</wfs:Query>" +
254
                 "</wfs-g:GetFeatureRequest>";                 
255
        */
256
         
257
        /* String message = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" +
258
                "<GetFeature outputFormat=\"GML2\" " +
259
                         "xmlns:gml=\"http://www.opengis.net/gml\" " +
260
                         "xmlns:wfs=\"http://www.opengis.net/wfs\" " +
261
                         "xmlns:ogc=\"http://www.opengis.net/ogc\">" +
262
                         "<Query typeName=\"" + query.getFeature().getName() + "\">" +
263
                         "<ogc:Filter>" + 
264
                                 "<ogc:And>" +
265
                                    "<ogc:BBOX>" +
266
                                     "<ogc:PropertyName>the_geom</ogc:PropertyName>" +
267
                                    "<gml:Box srsName=\"http://www.opengis.net/gml/srs/epsg.xml#4326\">" +
268
                                       "<gml:coordinates>-75.102613,40.212597 -72.361859,41.512517</gml:coordinates>" +
269
                                    "</gml:Box>" +
270
                                    "</ogc:BBOX>" +
271
                                    "<ogc:PropertyIsLike wildCard=\"%\" singleChar=\"?\" escape=\"/\">" +
272
                                            "<ogc:PropertyName>geographicIdentifier</ogc:PropertyName>" +
273
                                            "<ogc:Literal>Bo%</ogc:Literal>" +
274
                                    "</ogc:PropertyIsLike>" +
275
                            "</ogc:And>" +
276
                       "</ogc:Filter>" +
277
                         "</Query>" +
278
                         "</GetFeature>";
279
                 */        
280
         System.out.println(message);
281
             
282
         return message;
283
    } 
284
/* (non-Javadoc)
285
     * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getSOAPCapabilities()
286
     */
287

    
288
/**
289
 * 
290
 * 
291
 * 
292
 * @return 
293
 */
294
    public String getSOAPCapabilities() {        
295
        // TODO Auto-generated method stub
296
        return null;
297
    } 
298
/* (non-Javadoc)
299
     * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getSOAPDescribeFeature()
300
     */
301

    
302
/**
303
 * 
304
 * 
305
 * 
306
 * @return 
307
 * @param feature 
308
 */
309
    public String getSOAPDescribeFeature(String feature) {        
310
        // TODO Auto-generated method stub
311
        return null;
312
    } 
313
/* (non-Javadoc)
314
     * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getSOAPFeature(es.gva.cit.catalogClient.querys.Query, int)
315
     */
316

    
317
/**
318
 * 
319
 * 
320
 * 
321
 * @return 
322
 * @param query 
323
 * @param firstRecord 
324
 */
325
    public String getSOAPFeature(Query query, int firstRecord) {        
326
        // TODO Auto-generated method stub
327
        return null;
328
    } 
329
 }