Statistics
| Revision:

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

History | View | Annotate | Download (9.94 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 org.apache.commons.httpclient.NameValuePair;
48

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

    
62
/**
63
 * 
64
 * 
65
 */
66
    private URL url;
67

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

    
83
/**
84
 * 
85
 * 
86
 * 
87
 * @return 
88
 * @param upper 
89
 */
90
    public NameValuePair[] getHTTPGETCapabilities(boolean upper) {        
91
             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
    } 
117
/* (non-Javadoc)
118
     * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getHTTPGETDescribeFeature()
119
     */
120

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

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

    
161
/**
162
 * 
163
 * 
164
 * 
165
 * @return 
166
 */
167
    public String getHTTPPOSTCapabilities() {        
168
        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
    } 
176
/* (non-Javadoc)
177
     * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getHTTPPOSTDescribeFeature()
178
     */
179

    
180
/**
181
 * 
182
 * 
183
 * 
184
 * @return 
185
 * @param feature 
186
 */
187
    public String getHTTPPOSTDescribeFeature(String feature) {        
188
        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
    } 
197
/* (non-Javadoc)
198
     * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getHTTPPOSTFeature(es.gva.cit.catalogClient.querys.Query, int)
199
     */
200

    
201
/**
202
 * 
203
 * 
204
 * 
205
 * @return 
206
 * @param query 
207
 * @param firstRecord 
208
 */
209
    public String getHTTPPOSTFeature(Query query, int firstRecord) {        
210
        
211
        
212
     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
              "<wfs:Query typeName=\"" + query.getFeatures()[0].getName() + "\">" +
222
                  new WFSGFilter().getQuery(query) +
223
              "</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
    } 
282
/* (non-Javadoc)
283
     * @see es.gva.cit.gazetteer.drivers.messages.IProtocolMessages#getSOAPCapabilities()
284
     */
285

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

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

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