svn-gvsig-desktop / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / gazetteer / drivers / IDECGazetteerServiceDriver.java @ 3081
History | View | Annotate | Download (5.08 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package es.gva.cit.gazetteer.drivers; |
42 |
|
43 |
import java.net.URL; |
44 |
|
45 |
import org.apache.commons.httpclient.NameValuePair; |
46 |
|
47 |
import es.gva.cit.catalogClient.metadataXML.XMLNode; |
48 |
import es.gva.cit.catalogClient.protocols.HTTPGetProtocol; |
49 |
import es.gva.cit.gazetteer.parsers.idec.IdecCapabilitiesParser; |
50 |
import es.gva.cit.gazetteer.parsers.idec.IdecFeatureParser; |
51 |
import es.gva.cit.catalogClient.protocols.HTTPPostProtocol; |
52 |
import es.gva.cit.gazetteer.querys.Feature; |
53 |
import es.gva.cit.gazetteer.querys.Query; |
54 |
import es.gva.cit.gazetteer.querys.ThesaurusName; |
55 |
|
56 |
|
57 |
/**
|
58 |
* This class connects with the IDEC gazetteer service
|
59 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
60 |
*/
|
61 |
public class IDECGazetteerServiceDriver extends AsbtractGazetteerServiceDriver { |
62 |
/* (non-Javadoc)
|
63 |
* @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getCapabilities(java.net.URL)
|
64 |
*/
|
65 |
public XMLNode[] getCapabilities(URL url) { |
66 |
XMLNode[] nodes = null; |
67 |
|
68 |
System.out.println("**************GET*************"); |
69 |
nodes = new HTTPGetProtocol().doQuery(url, getMessageCapabilities(), 0); |
70 |
|
71 |
return nodes;
|
72 |
} |
73 |
|
74 |
/**
|
75 |
* It creates the name-value pairs for the getCapabilities request
|
76 |
* @return
|
77 |
* Name-Value pair array
|
78 |
*/
|
79 |
public NameValuePair[] getMessageCapabilities() { |
80 |
NameValuePair nvp1 = new NameValuePair("wsdl", ""); |
81 |
return new NameValuePair[] { nvp1 }; |
82 |
} |
83 |
|
84 |
/* (non-Javadoc)
|
85 |
* @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getFeature(java.net.URL, es.gva.cit.gazetteer.querys.Query)
|
86 |
*/
|
87 |
public XMLNode[] getFeature(URL url, Query query) { |
88 |
XMLNode[] nodes = null; |
89 |
setQuery(query); |
90 |
|
91 |
|
92 |
System.out.println("*************POST*************"); |
93 |
nodes = new HTTPPostProtocol().doQuery(url,getPOSTGetFeature(query),0); |
94 |
return nodes;
|
95 |
|
96 |
} |
97 |
|
98 |
/**
|
99 |
* It creates the XML for the getFeature request
|
100 |
*
|
101 |
* @return
|
102 |
* Name-value pair with a XML request
|
103 |
*/
|
104 |
public String getPOSTGetFeature(Query query) { |
105 |
return "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + |
106 |
"<SOAP-ENV:Envelope SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:si=\"http://soapinterop.org/xsd\" xmlns:tns=\"urn:idecwsdl\">" +
|
107 |
"<SOAP-ENV:Body><tns:getCoordenadesUTM xmlns:tns=\"urn:idecwsdl\">" +
|
108 |
"<key xsi:type=\"xsd:string\">CV81HP6</key>" +
|
109 |
"<toponim xsi:type=\"xsd:string\">" + query.getName() + "</toponim>" + |
110 |
"</tns:getCoordenadesUTM>" +
|
111 |
"</SOAP-ENV:Body>" +
|
112 |
"</SOAP-ENV:Envelope>";
|
113 |
}; |
114 |
|
115 |
/* (non-Javadoc)
|
116 |
* @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#isProtocolSupported(java.net.URL)
|
117 |
*/
|
118 |
public boolean isProtocolSupported(URL url) { |
119 |
// TODO Auto-generated method stub
|
120 |
return true; |
121 |
} |
122 |
|
123 |
|
124 |
/* (non-Javadoc)
|
125 |
* @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#describeFeatureType(java.net.URL, java.lang.String)
|
126 |
*/
|
127 |
public XMLNode[] describeFeatureType(URL url, String feature) { |
128 |
// TODO Auto-generated method stub
|
129 |
return null; |
130 |
} |
131 |
|
132 |
|
133 |
/* (non-Javadoc)
|
134 |
* @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#setParameters(org.w3c.dom.Node[])
|
135 |
*/
|
136 |
public boolean setParameters(XMLNode[] nodes) { |
137 |
return new IdecCapabilitiesParser(this).parse(nodes[0]); |
138 |
} |
139 |
|
140 |
/* (non-Javadoc)
|
141 |
* @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#parseFeatures(org.w3c.dom.Node, es.gva.cit.gazetteer.querys.ThesaurusName, java.lang.String)
|
142 |
*/
|
143 |
public Feature[] parseFeatures(XMLNode node, ThesaurusName currentFeature, String attribute) { |
144 |
return new IdecFeatureParser().parse(node); |
145 |
} |
146 |
} |