svn-gvsig-desktop / branches / v06 / applications / appCatalogYNomenclatorClient / src / es / gva / cit / gazetteer / adl / drivers / ADLGazetteerServiceDriver.java @ 4813
History | View | Annotate | Download (5.42 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.adl.drivers; |
43 |
import es.gva.cit.catalogClient.metadataXML.XMLNode; |
44 |
import es.gva.cit.catalogClient.protocols.HTTPPostProtocol; |
45 |
import es.gva.cit.gazetteer.adl.filters.ADLFilter; |
46 |
import es.gva.cit.gazetteer.adl.parsers.AdlCapabilitiesParser; |
47 |
import es.gva.cit.gazetteer.adl.parsers.AdlFeatureParser; |
48 |
import es.gva.cit.gazetteer.drivers.AsbtractGazetteerServiceDriver; |
49 |
import es.gva.cit.gazetteer.querys.Feature; |
50 |
import es.gva.cit.gazetteer.querys.Query; |
51 |
import es.gva.cit.gazetteer.querys.ThesaurusName; |
52 |
import java.net.URL; |
53 |
import java.util.Collection; |
54 |
|
55 |
/**
|
56 |
* This class implements the driver to connect with a ADL gazetteer service
|
57 |
*
|
58 |
*
|
59 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
60 |
* @see http://alexandria.sdc.ucsb.edu/
|
61 |
*/
|
62 |
public class ADLGazetteerServiceDriver extends AsbtractGazetteerServiceDriver { |
63 |
|
64 |
/**
|
65 |
* It invokes the getCapabilities operation
|
66 |
*
|
67 |
*
|
68 |
* @return
|
69 |
* @param url
|
70 |
*/
|
71 |
public Collection getCapabilities(URL url) { |
72 |
Collection nodes = new java.util.ArrayList(); |
73 |
System.out.println("**************POST*************"); |
74 |
nodes = new HTTPPostProtocol().doQuery(url,
|
75 |
getPOSTMessageCapabilities(), 0);
|
76 |
|
77 |
return nodes;
|
78 |
} |
79 |
|
80 |
/**
|
81 |
* It creates the XML for the getCapabilities request
|
82 |
*
|
83 |
*
|
84 |
* @return Name-value pair with a XML request
|
85 |
*/
|
86 |
private String getPOSTMessageCapabilities() { |
87 |
return "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + |
88 |
"<gazetteer-service " +
|
89 |
"xmlns=\"http://www.alexandria.ucsb.edu/gazetteer\" " +
|
90 |
"version=\"1.2\">" +
|
91 |
"<get-capabilities-request/>" +
|
92 |
"</gazetteer-service>";
|
93 |
|
94 |
} |
95 |
|
96 |
/**
|
97 |
* It invokes the getFeature operation
|
98 |
*
|
99 |
*
|
100 |
* @return
|
101 |
* @param url
|
102 |
* @param query
|
103 |
*/
|
104 |
public Collection getFeature(URL url, Query query) { |
105 |
Collection nodes = new java.util.ArrayList(); |
106 |
setQuery(query); |
107 |
|
108 |
|
109 |
System.out.println("**************POST*************"); |
110 |
System.out.println(getPOSTGetFeature(getQuery(),true)); |
111 |
nodes = new HTTPPostProtocol().doQuery(url,
|
112 |
getPOSTGetFeature(getQuery(),true), 0); |
113 |
|
114 |
if (nodes == null){ |
115 |
System.out.println(getPOSTGetFeature(getQuery(),false)); |
116 |
nodes = new HTTPPostProtocol().doQuery(url,
|
117 |
getPOSTGetFeature(getQuery(),false), 0); |
118 |
} |
119 |
return nodes;
|
120 |
|
121 |
} |
122 |
|
123 |
/**
|
124 |
* It creates the XML for the getFeature request
|
125 |
*
|
126 |
*
|
127 |
* @return Name-value pair with a XML request
|
128 |
* @param query
|
129 |
*/
|
130 |
private String getPOSTGetFeature(Query query,boolean withAccents) { |
131 |
|
132 |
return "<gazetteer-service " + |
133 |
"xmlns=\"http://www.alexandria.ucsb.edu/gazetteer\" " +
|
134 |
"xmlns:gml=\"http://www.opengis.net/gml\" " +
|
135 |
"version=\"1.2\">" +
|
136 |
new ADLFilter(withAccents).getQuery(query) +
|
137 |
"</gazetteer-service>" ;
|
138 |
} |
139 |
/* (non-Javadoc)
|
140 |
* @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#isProtocolSupported(java.net.URL)
|
141 |
*/
|
142 |
|
143 |
/**
|
144 |
*
|
145 |
*
|
146 |
*
|
147 |
* @return
|
148 |
* @param url
|
149 |
*/
|
150 |
public boolean isProtocolSupported(URL url) { |
151 |
// TODO Auto-generated method stub
|
152 |
return true; |
153 |
} |
154 |
/* (non-Javadoc)
|
155 |
* @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#setParameters(org.w3c.dom.Node[])
|
156 |
*/
|
157 |
|
158 |
/**
|
159 |
*
|
160 |
*
|
161 |
*
|
162 |
* @return
|
163 |
* @param url
|
164 |
* @param feature
|
165 |
*/
|
166 |
public Collection describeFeatureType(URL url, String feature) { |
167 |
// TODO Auto-generated method stub
|
168 |
return null; |
169 |
} |
170 |
/* (non-Javadoc)
|
171 |
* @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#setParameters(org.w3c.dom.Node[])
|
172 |
*/
|
173 |
|
174 |
/**
|
175 |
*
|
176 |
*
|
177 |
*
|
178 |
* @return
|
179 |
* @param nodes
|
180 |
*/
|
181 |
public boolean setParameters(Collection nodes) { |
182 |
return new AdlCapabilitiesParser(this).parse((XMLNode)nodes.toArray()[0]); |
183 |
} |
184 |
/* (non-Javadoc)
|
185 |
* @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#parseFeatures(org.w3c.dom.Node)
|
186 |
*/
|
187 |
|
188 |
/**
|
189 |
*
|
190 |
*
|
191 |
*
|
192 |
* @return
|
193 |
* @param node
|
194 |
* @param currentFeature
|
195 |
* @param attribute
|
196 |
*/
|
197 |
public Feature[] parseFeatures(XMLNode node, ThesaurusName currentFeature, String attribute) { |
198 |
return new AdlFeatureParser().parse(node); |
199 |
} |
200 |
} |