Revision 801
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.147/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/DiscoveryServiceClient.java | ||
---|---|---|
1 |
package org.gvsig.catalog; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.net.Authenticator; |
|
5 |
import java.net.PasswordAuthentication; |
|
6 |
import java.net.Socket; |
|
7 |
import java.net.URI; |
|
8 |
import java.net.URISyntaxException; |
|
9 |
import java.net.UnknownHostException; |
|
10 |
import java.util.Properties; |
|
11 |
|
|
12 |
import org.apache.commons.httpclient.HttpConnection; |
|
13 |
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities; |
|
14 |
import org.gvsig.catalog.drivers.IDiscoveryServiceDriver; |
|
15 |
import org.gvsig.catalog.exceptions.NotSupportedProtocolException; |
|
16 |
import org.gvsig.catalog.exceptions.NotSupportedVersionException; |
|
17 |
import org.gvsig.catalog.exceptions.ServerIsNotReadyException; |
|
18 |
import org.gvsig.catalog.querys.DiscoveryServiceQuery; |
|
19 |
import org.gvsig.catalog.ui.search.SearchAditionalPropertiesPanel; |
|
20 |
import org.gvsig.catalog.utils.URIUtils; |
|
21 |
|
|
22 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
23 |
* |
|
24 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
25 |
* |
|
26 |
* This program is free software; you can redistribute it and/or |
|
27 |
* modify it under the terms of the GNU General Public License |
|
28 |
* as published by the Free Software Foundation; either version 2 |
|
29 |
* of the License, or (at your option) any later version. |
|
30 |
* |
|
31 |
* This program is distributed in the hope that it will be useful, |
|
32 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
33 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
34 |
* GNU General Public License for more details. |
|
35 |
* |
|
36 |
* You should have received a copy of the GNU General Public License |
|
37 |
* along with this program; if not, write to the Free Software |
|
38 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
39 |
* |
|
40 |
* For more information, contact: |
|
41 |
* |
|
42 |
* Generalitat Valenciana |
|
43 |
* Conselleria d'Infraestructures i Transport |
|
44 |
* Av. Blasco Ib??ez, 50 |
|
45 |
* 46010 VALENCIA |
|
46 |
* SPAIN |
|
47 |
* |
|
48 |
* +34 963862235 |
|
49 |
* gvsig@gva.es |
|
50 |
* www.gvsig.gva.es |
|
51 |
* |
|
52 |
* or |
|
53 |
* |
|
54 |
* IVER T.I. S.A |
|
55 |
* Salamanca 50 |
|
56 |
* 46005 Valencia |
|
57 |
* Spain |
|
58 |
* |
|
59 |
* +34 963163400 |
|
60 |
* dac@iver.es |
|
61 |
*/ |
|
62 |
/* CVS MESSAGES: |
|
63 |
* |
|
64 |
* $Id$ |
|
65 |
* $Log$ |
|
66 |
* |
|
67 |
*/ |
|
68 |
/** |
|
69 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
70 |
*/ |
|
71 |
public class DiscoveryServiceClient { |
|
72 |
/** |
|
73 |
* The server URI |
|
74 |
*/ |
|
75 |
private URI uri = null; |
|
76 |
/** |
|
77 |
* The driver to make the querys |
|
78 |
*/ |
|
79 |
private IDiscoveryServiceDriver driver; |
|
80 |
/** |
|
81 |
* The service capabilities |
|
82 |
*/ |
|
83 |
private DiscoveryServiceCapabilities capabilities; |
|
84 |
/** |
|
85 |
* The server status message |
|
86 |
*/ |
|
87 |
private String serverStatus = null; |
|
88 |
|
|
89 |
public DiscoveryServiceClient(String sUri,IDiscoveryServiceDriver driver) { |
|
90 |
setDriver(driver); |
|
91 |
if (driver == null){ |
|
92 |
serverStatus = "errorServerNotFound"; |
|
93 |
}else{ |
|
94 |
try { |
|
95 |
this.uri = URIUtils.createUri(sUri, |
|
96 |
driver.getDefaultSchema(), |
|
97 |
driver.getDefaultPort()); |
|
98 |
} catch (URISyntaxException e) { |
|
99 |
serverStatus = "errorServerNotFound"; |
|
100 |
} |
|
101 |
} |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* It make a getCapabilities operation |
|
106 |
* @return the service version |
|
107 |
* @throws ServerIsNotReadyException |
|
108 |
*/ |
|
109 |
public DiscoveryServiceCapabilities getCapabilities() throws ServerIsNotReadyException { |
|
110 |
if (serverIsReady()){ |
|
111 |
try { |
|
112 |
if (getDriver().isProtocolSupported(getUri())) { |
|
113 |
capabilities = getDriver().getCapabilities(getUri()); |
|
114 |
return capabilities; |
|
115 |
} |
|
116 |
} catch (NotSupportedProtocolException e) { |
|
117 |
capabilities = new DiscoveryServiceCapabilities(); |
|
118 |
capabilities.setAvailable(false); |
|
119 |
capabilities.setServerMessage("notSupportedProtocol"); |
|
120 |
} catch (NotSupportedVersionException e) { |
|
121 |
capabilities = new DiscoveryServiceCapabilities(); |
|
122 |
capabilities.setAvailable(false); |
|
123 |
capabilities.setServerMessage("notSupportedVersion"); |
|
124 |
} |
|
125 |
} |
|
126 |
return capabilities; |
|
127 |
} |
|
128 |
|
|
129 |
/** |
|
130 |
* It tries if the server is ready |
|
131 |
* @return boolean |
|
132 |
* true --> server is ready |
|
133 |
* false --> server is not ready |
|
134 |
*/ |
|
135 |
public boolean serverIsReady() throws ServerIsNotReadyException { |
|
136 |
Properties systemSettings = System.getProperties(); |
|
137 |
|
|
138 |
|
|
139 |
Object isProxyEnabled = systemSettings.get("http.proxySet"); |
|
140 |
if ((isProxyEnabled == null) || (isProxyEnabled.equals("false"))){ |
|
141 |
Socket sock; |
|
142 |
try{ |
|
143 |
sock = new Socket(getUri().getHost(), |
|
144 |
getUri().getPort()); |
|
145 |
} catch (UnknownHostException e) { |
|
146 |
throw new ServerIsNotReadyException(e); |
|
147 |
} catch (IOException e) { |
|
148 |
throw new ServerIsNotReadyException(e); |
|
149 |
} |
|
150 |
return (sock != null); |
|
151 |
}else{ |
|
152 |
Object host = systemSettings.get("http.proxyHost"); |
|
153 |
Object port = systemSettings.get("http.proxyPort"); |
|
154 |
Object user = systemSettings.get("http.proxyUserName"); |
|
155 |
Object password = systemSettings.get("http.proxyPassword"); |
|
156 |
if ((host != null) && (port != null)){ |
|
157 |
int iPort = 80; |
|
158 |
try{ |
|
159 |
iPort = Integer.parseInt((String)port); |
|
160 |
}catch (Exception e) { |
|
161 |
//Use 80 |
|
162 |
} |
|
163 |
HttpConnection connection = new HttpConnection(getUri().getHost(), |
|
164 |
getUri().getPort()); |
|
165 |
connection.setProxyHost((String)host); |
|
166 |
connection.setProxyPort(iPort); |
|
167 |
Authenticator.setDefault(new SimpleAuthenticator( |
|
168 |
user,password)); |
|
169 |
|
|
170 |
try { |
|
171 |
connection.open(); |
|
172 |
connection.close(); |
|
173 |
} catch (IOException e) { |
|
174 |
throw new ServerIsNotReadyException(e); |
|
175 |
} |
|
176 |
} |
|
177 |
} |
|
178 |
return true; |
|
179 |
} |
|
180 |
|
|
181 |
/** |
|
182 |
* @return the server URI |
|
183 |
*/ |
|
184 |
public URI getUri() { |
|
185 |
return uri; |
|
186 |
} |
|
187 |
|
|
188 |
/** |
|
189 |
* @return Return the server URI like a String |
|
190 |
*/ |
|
191 |
public String getSUri() { |
|
192 |
return uri.toString(); |
|
193 |
} |
|
194 |
|
|
195 |
/** |
|
196 |
* @return Returns the driver. |
|
197 |
*/ |
|
198 |
protected IDiscoveryServiceDriver getDriver() { |
|
199 |
return driver; |
|
200 |
} |
|
201 |
|
|
202 |
/** |
|
203 |
* |
|
204 |
* @param driver the driver to set |
|
205 |
*/ |
|
206 |
protected void setDriver(IDiscoveryServiceDriver driver) { |
|
207 |
this.driver = driver; |
|
208 |
} |
|
209 |
|
|
210 |
/** |
|
211 |
* @return the server protocol |
|
212 |
*/ |
|
213 |
public String getProtocol() { |
|
214 |
return driver.getServiceName(); |
|
215 |
} |
|
216 |
|
|
217 |
/** |
|
218 |
* Gets the aditional panel |
|
219 |
* @return |
|
220 |
*/ |
|
221 |
public SearchAditionalPropertiesPanel getAditionalSearchPanel(){ |
|
222 |
return driver.getAditionalSearchPanel(); |
|
223 |
} |
|
224 |
|
|
225 |
/** |
|
226 |
* Gets a query |
|
227 |
* @return |
|
228 |
*/ |
|
229 |
public DiscoveryServiceQuery createQuery(){ |
|
230 |
return driver.createQuery(); |
|
231 |
} |
|
232 |
|
|
233 |
private class SimpleAuthenticator |
|
234 |
extends Authenticator |
|
235 |
{ |
|
236 |
private String username, |
|
237 |
password; |
|
238 |
|
|
239 |
public SimpleAuthenticator(Object username, Object password) |
|
240 |
{ |
|
241 |
if (username != null){ |
|
242 |
this.username = (String)username; |
|
243 |
} |
|
244 |
if (password != null){ |
|
245 |
this.password = (String)password; |
|
246 |
} |
|
247 |
} |
|
248 |
|
|
249 |
protected PasswordAuthentication getPasswordAuthentication() |
|
250 |
{ |
|
251 |
return new PasswordAuthentication( |
|
252 |
username,password.toCharArray()); |
|
253 |
} |
|
254 |
} |
|
255 |
|
|
256 |
} |
|
0 | 257 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.147/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/filters/IFilter.java | ||
---|---|---|
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 org.gvsig.catalog.filters; |
|
43 |
import org.gvsig.catalog.querys.CatalogQuery; |
|
44 |
/** |
|
45 |
* All the clases that implement a "Query" class must to |
|
46 |
* implemet this interface |
|
47 |
* |
|
48 |
* |
|
49 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
50 |
*/ |
|
51 |
public interface IFilter { |
|
52 |
/** |
|
53 |
* |
|
54 |
* |
|
55 |
* |
|
56 |
* @return |
|
57 |
* @param query |
|
58 |
* @param profile |
|
59 |
*/ |
|
60 |
public String getQuery(CatalogQuery query); |
|
61 |
} |
|
62 |
//Return the query that will be used for the driver |
|
63 |
|
|
64 |
|
|
0 | 65 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.147/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/filters/AdditionalClauses.java | ||
---|---|---|
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 org.gvsig.catalog.filters; |
|
43 |
|
|
44 |
/** |
|
45 |
* This class is used like an structure. It contains the fields needed to add a new |
|
46 |
* operation to the query language. |
|
47 |
* |
|
48 |
* |
|
49 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
50 |
*/ |
|
51 |
public class AdditionalClauses { |
|
52 |
|
|
53 |
/** |
|
54 |
* |
|
55 |
* |
|
56 |
*/ |
|
57 |
private String property; |
|
58 |
|
|
59 |
/** |
|
60 |
* |
|
61 |
* |
|
62 |
*/ |
|
63 |
private String value; |
|
64 |
|
|
65 |
/** |
|
66 |
* |
|
67 |
* |
|
68 |
*/ |
|
69 |
private String concorancia; |
|
70 |
|
|
71 |
/** |
|
72 |
* |
|
73 |
* |
|
74 |
*/ |
|
75 |
private String relationship; |
|
76 |
|
|
77 |
/** |
|
78 |
* |
|
79 |
* |
|
80 |
*/ |
|
81 |
private String type; |
|
82 |
|
|
83 |
/** |
|
84 |
* |
|
85 |
* |
|
86 |
* |
|
87 |
* @param property |
|
88 |
* @param value |
|
89 |
* @param concorancia |
|
90 |
* @param relationship |
|
91 |
* @param type |
|
92 |
*/ |
|
93 |
public AdditionalClauses(String property, String value, String concorancia, String relationship, String type) { |
|
94 |
super(); |
|
95 |
this.property = property; |
|
96 |
this.value = value; |
|
97 |
this.concorancia = concorancia; |
|
98 |
this.relationship = relationship; |
|
99 |
this.type = type; |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* |
|
104 |
* |
|
105 |
* |
|
106 |
* @return Returns the concorancia. |
|
107 |
*/ |
|
108 |
public String getConcorancia() { |
|
109 |
return concorancia; |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* |
|
114 |
* |
|
115 |
* |
|
116 |
* @return Returns the property. |
|
117 |
*/ |
|
118 |
public String getProperty() { |
|
119 |
return property; |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* |
|
124 |
* |
|
125 |
* |
|
126 |
* @return Returns the relationship. |
|
127 |
*/ |
|
128 |
public String getRelationship() { |
|
129 |
return relationship; |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
133 |
* |
|
134 |
* |
|
135 |
* |
|
136 |
* @return Returns the type. |
|
137 |
*/ |
|
138 |
public String getType() { |
|
139 |
return type; |
|
140 |
} |
|
141 |
|
|
142 |
/** |
|
143 |
* |
|
144 |
* |
|
145 |
* |
|
146 |
* @return Returns the value. |
|
147 |
*/ |
|
148 |
public String getValue() { |
|
149 |
return value; |
|
150 |
} |
|
151 |
} |
|
0 | 152 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.147/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/filters/AbstractFilter.java | ||
---|---|---|
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 |
/* |
|
43 |
* CVS MESSAGES: |
|
44 |
* |
|
45 |
* $Id: AbstractFilter.java 561 2007-07-27 06:49:30 +0000 (Fri, 27 Jul 2007) jpiera $ |
|
46 |
* $Log$ |
|
47 |
* Revision 1.4 2006/01/18 09:57:01 jorpiell |
|
48 |
* Eliminados algunos ficheros innecesarios |
|
49 |
* |
|
50 |
* Revision 1.3 2006/01/12 13:52:24 jorpiell |
|
51 |
* Se ha a?adido un boton close en las dos pantallas de connect. Adem?s se ha cambiado el comportamiento de las ventanas para adaptarlo a la nueva forma de buscar multihilo |
|
52 |
* |
|
53 |
* Revision 1.2 2006/01/10 09:32:48 jorpiell |
|
54 |
* Se ha echo un commit de las versiones modificadas del catalogo y del gazetteer usando el Poseidon. Se han renombrado algunas clases por considerar que tenian un nombre confuso y se han cambiado algunas relaciones entre clases (con la intenci?n de separar GUI de la parte de control). Han habido clases que no han sido tocadas, pero como han sido formateadas usando el Poseidon TODAS las CLASES del proyecto han cambiado de versi?n. |
|
55 |
* |
|
56 |
* Revision 1.1 2005/12/22 08:31:43 jorpiell |
|
57 |
* Aqui tambien se han producido muchos cambis, porque hemos acabado de cambiar la estructura del cat?logo: Se han creado todas las clases "XXXMessages", que sacan toda la parte de los mensajes de los drivers. Ademas se ha incluido en "CatalogClient" la operaci?n "getCapabilities", que libera a la interfaz de algunas operaciones que hac?a anteriormente. |
|
58 |
* |
|
59 |
* |
|
60 |
*/ |
|
61 |
package org.gvsig.catalog.filters; |
|
62 |
|
|
63 |
/** |
|
64 |
* |
|
65 |
* |
|
66 |
*/ |
|
67 |
public abstract class AbstractFilter implements IFilter { |
|
68 |
} |
|
0 | 69 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.147/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/srw/parsers/SrwCapabilitiesParser.java | ||
---|---|---|
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 org.gvsig.catalog.srw.parsers; |
|
43 |
import java.util.StringTokenizer; |
|
44 |
|
|
45 |
import org.gvsig.catalog.metadataxml.XMLNode; |
|
46 |
import org.gvsig.catalog.metadataxml.XMLTree; |
|
47 |
import org.gvsig.catalog.srw.drivers.SRWCatalogServiceDriver; |
|
48 |
|
|
49 |
/** |
|
50 |
* This class is used to parse the SRW capabilities |
|
51 |
* |
|
52 |
* |
|
53 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
54 |
*/ |
|
55 |
public class SrwCapabilitiesParser { |
|
56 |
/** |
|
57 |
* |
|
58 |
* |
|
59 |
*/ |
|
60 |
private SRWCatalogServiceDriver driver; |
|
61 |
|
|
62 |
/** |
|
63 |
* |
|
64 |
* |
|
65 |
* |
|
66 |
* @param driver |
|
67 |
*/ |
|
68 |
public SrwCapabilitiesParser(SRWCatalogServiceDriver driver) { |
|
69 |
this.driver = driver; |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* |
|
74 |
* |
|
75 |
* |
|
76 |
* @return |
|
77 |
* @param node |
|
78 |
*/ |
|
79 |
public boolean parse(XMLNode node) { |
|
80 |
if ((node == null) || (node.getName() == null)){ |
|
81 |
driver.setServerAnswerReady("errorNotSupportedProtocol"); |
|
82 |
return false; |
|
83 |
} |
|
84 |
|
|
85 |
if (node.getName().toLowerCase().equals("serviceexceptionreport")){ |
|
86 |
driver.setServerAnswerReady("errorServerException"); |
|
87 |
return false; |
|
88 |
} |
|
89 |
|
|
90 |
String prefix = new StringTokenizer(node.getName(), ":").nextToken(); |
|
91 |
prefix = prefix + ":"; |
|
92 |
driver.setOutputSchema(XMLTree.searchNodeValue(node, |
|
93 |
prefix + "record->" + prefix + "recordSchema")); |
|
94 |
driver.setOutputFormat(XMLTree.searchNodeValue(node, |
|
95 |
prefix + "record->" + prefix + "recordPacking")); |
|
96 |
driver.setStartPosition("1"); |
|
97 |
driver.setMaxRecords("10"); |
|
98 |
driver.setRecordXPath(""); |
|
99 |
driver.setResultSetTTL("0"); |
|
100 |
String title = XMLTree.searchNodeValue(node, |
|
101 |
prefix + "record->" + prefix + |
|
102 |
"recordData->explain->databaseInfo->title"); |
|
103 |
|
|
104 |
String description = XMLTree.searchNodeValue(node, |
|
105 |
prefix + "record->" + prefix + |
|
106 |
"recordData->explain->databaseInfo->description"); |
|
107 |
|
|
108 |
if (title != null){ |
|
109 |
driver.setServerAnswerReady(title + "\n"); |
|
110 |
if (description != null){ |
|
111 |
driver.setServerAnswerReady(driver.getServerAnswerReady() + |
|
112 |
description + "\n"); |
|
113 |
} |
|
114 |
}else{ |
|
115 |
driver.setServerAnswerReady(""); |
|
116 |
if (description != null){ |
|
117 |
driver.setServerAnswerReady(description + "\n"); |
|
118 |
} |
|
119 |
} |
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
return true; |
|
124 |
|
|
125 |
} |
|
126 |
} |
|
0 | 127 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.147/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/srw/filters/IDEESRWFilter.java | ||
---|---|---|
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 org.gvsig.catalog.srw.filters; |
|
43 |
import org.gvsig.catalog.filters.AbstractFilter; |
|
44 |
import org.gvsig.catalog.languages.FilterEncoding; |
|
45 |
import org.gvsig.catalog.querys.CatalogQuery; |
|
46 |
import org.gvsig.catalog.utils.Strings; |
|
47 |
import org.gvsig.i18n.Messages; |
|
48 |
|
|
49 |
/** |
|
50 |
* This class creates a RSW query for the IDEE server |
|
51 |
* |
|
52 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
53 |
*/ |
|
54 |
public class IDEESRWFilter extends AbstractFilter { |
|
55 |
|
|
56 |
public IDEESRWFilter() { |
|
57 |
super(); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* Return a CQL-Text query |
|
62 |
* @param query |
|
63 |
* @return String |
|
64 |
* @param profile |
|
65 |
*/ |
|
66 |
public String getQuery(CatalogQuery query) { |
|
67 |
String pregunta = null; |
|
68 |
|
|
69 |
FilterEncoding filter = new FilterEncoding("", "*", "?", "\\"); |
|
70 |
|
|
71 |
if (query.getTitle() != null) { |
|
72 |
filter.addClauses("title", query.getTitle(), query.getTitleFilter(), |
|
73 |
"PropertyIsLike", "L", "And"); |
|
74 |
} |
|
75 |
|
|
76 |
if (query.isMinimized()){ |
|
77 |
if (query.getAbstract() != null) { |
|
78 |
filter.addClauses("subject", Strings.addAsteriscsFromAnArray(query.getAbstract()), |
|
79 |
"Y", "PropertyIsLike", "L", "Or"); |
|
80 |
} |
|
81 |
}else{ |
|
82 |
if (query.getAbstract() != null) { |
|
83 |
filter.addClauses("subject", Strings.addAsteriscsFromAnArray(query.getAbstract()), |
|
84 |
"Y", "PropertyIsLike", "L", "And"); |
|
85 |
} |
|
86 |
|
|
87 |
|
|
88 |
} |
|
89 |
|
|
90 |
pregunta = filter.toString(); |
|
91 |
return pregunta; |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* This function returns true only when the user has choosen the |
|
96 |
* "Fully Outside Of" of the coordinates option. |
|
97 |
* |
|
98 |
* |
|
99 |
* @return |
|
100 |
* @param translator |
|
101 |
* @param coordinatesOption |
|
102 |
*/ |
|
103 |
public boolean getCoordinatesOption(String coordinatesOption) { |
|
104 |
if ((coordinatesOption.equals(Messages.getText("coordinatesEqual"))) || |
|
105 |
(coordinatesOption.equals(Messages.getText("coordinatesContains"))) || |
|
106 |
(coordinatesOption.equals(Messages.getText("coordinatesEnclose")))) |
|
107 |
return false; |
|
108 |
|
|
109 |
return true; |
|
110 |
} |
|
111 |
|
|
112 |
} |
|
0 | 113 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.147/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/srw/filters/SRWFilter.java | ||
---|---|---|
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 org.gvsig.catalog.srw.filters; |
|
43 |
import org.gvsig.catalog.filters.AbstractFilter; |
|
44 |
import org.gvsig.catalog.languages.CommonQueryLanguage; |
|
45 |
|
|
46 |
/** |
|
47 |
* This class create que query in the language suported by the SRW protocol |
|
48 |
* |
|
49 |
* |
|
50 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
51 |
*/ |
|
52 |
public class SRWFilter extends AbstractFilter { |
|
53 |
|
|
54 |
/** |
|
55 |
* |
|
56 |
* |
|
57 |
*/ |
|
58 |
public SRWFilter() { |
|
59 |
super(); |
|
60 |
} |
|
61 |
|
|
62 |
/** |
|
63 |
* Devuelve un query en el lenguaje que soporte el protocolo SRW |
|
64 |
* |
|
65 |
* |
|
66 |
* @param query |
|
67 |
* @return String : query en el lenguaje soportado |
|
68 |
* @param profile |
|
69 |
*/ |
|
70 |
public String getQuery(org.gvsig.catalog.querys.CatalogQuery query) { |
|
71 |
String pregunta = null; |
|
72 |
// Construimos una RemoteBooleanQuery |
|
73 |
CommonQueryLanguage filter = new CommonQueryLanguage(); |
|
74 |
|
|
75 |
if (query.getTitle() != null) { |
|
76 |
filter.addClauses("dc.title", query.getTitle(), query.getTitleFilter(),"And"); |
|
77 |
} |
|
78 |
|
|
79 |
if (query.isMinimized()){ |
|
80 |
if (query.getAbstract() != null) { |
|
81 |
filter.addClauses("dc.subject", query.getAbstract(), "E", "Or"); |
|
82 |
} |
|
83 |
}else{ |
|
84 |
if (query.getAbstract() != null) { |
|
85 |
filter.addClauses("dc.subject", query.getAbstract(), "E", "And"); |
|
86 |
} |
|
87 |
|
|
88 |
if (query.getProvider() != null) { |
|
89 |
filter.addClauses("dc.creator", query.getProvider(), "E","And"); |
|
90 |
} |
|
91 |
} |
|
92 |
|
|
93 |
//if (this.getThemeKey() != null) |
|
94 |
//query.addClauses("", this.getThemeKey(),"Y"); |
|
95 |
//if (this.getScale() != null) |
|
96 |
//query.addClauses("map_scale", this.getScale(),"E"); |
|
97 |
|
|
98 |
//if (this.getDateFrom() != null) |
|
99 |
//query.addClauses("2072", "210", "4",this.getDateFrom(),"E"); |
|
100 |
//if (this.getDateTo() != null) |
|
101 |
//query.addClauses("2073", "210", "2",this.getDateTo(),"E"); |
|
102 |
pregunta = filter.toString(); |
|
103 |
System.out.println(pregunta); |
|
104 |
return pregunta; |
|
105 |
} |
|
106 |
} |
|
0 | 107 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.147/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/srw/drivers/SRWCatalogServiceDriver.java | ||
---|---|---|
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 org.gvsig.catalog.srw.drivers; |
|
43 |
import java.net.MalformedURLException; |
|
44 |
import java.net.URI; |
|
45 |
import java.net.URL; |
|
46 |
import java.util.Collection; |
|
47 |
import java.util.StringTokenizer; |
|
48 |
|
|
49 |
import org.gvsig.catalog.drivers.AbstractCatalogServiceDriver; |
|
50 |
import org.gvsig.catalog.drivers.CatalogCapabilities; |
|
51 |
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities; |
|
52 |
import org.gvsig.catalog.drivers.GetRecordsReply; |
|
53 |
import org.gvsig.catalog.metadataxml.XMLNode; |
|
54 |
import org.gvsig.catalog.metadataxml.XMLTree; |
|
55 |
import org.gvsig.catalog.protocols.HTTPGetProtocol; |
|
56 |
import org.gvsig.catalog.protocols.SOAPProtocol; |
|
57 |
import org.gvsig.catalog.querys.CatalogQuery; |
|
58 |
import org.gvsig.catalog.srw.parsers.SrwCapabilitiesParser; |
|
59 |
import org.gvsig.utils.swing.jcomboServer.ServerData; |
|
60 |
|
|
61 |
/** |
|
62 |
* This class implements the CSW protocol. |
|
63 |
* |
|
64 |
* |
|
65 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
66 |
* @see http://www.loc.gov/z3950/agency/zing/srw/ |
|
67 |
*/ |
|
68 |
public class SRWCatalogServiceDriver extends AbstractCatalogServiceDriver { |
|
69 |
private String version = "1.1"; |
|
70 |
private String recordXPath; |
|
71 |
private String resultSetTTL; |
|
72 |
|
|
73 |
/* |
|
74 |
* (non-Javadoc) |
|
75 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getCapabilities(java.net.URI) |
|
76 |
*/ |
|
77 |
public DiscoveryServiceCapabilities getCapabilities(URI uri) { |
|
78 |
URL url = null; |
|
79 |
try { |
|
80 |
url = uri.toURL(); |
|
81 |
} catch (MalformedURLException e) { |
|
82 |
setServerAnswerReady("errorServerNotFound"); |
|
83 |
return null; |
|
84 |
} |
|
85 |
SRWMessages messages = new SRWMessages(this); |
|
86 |
Collection nodes = new HTTPGetProtocol().doQuery(url, |
|
87 |
messages.getHTTPGETCapabilities(true), 0); |
|
88 |
|
|
89 |
nodes = new SOAPProtocol().doQuery(url, messages.getSOAPCapabilities(), 0); |
|
90 |
new SrwCapabilitiesParser(this).parse((XMLNode)nodes.toArray()[0]); |
|
91 |
CatalogCapabilities capabilities = new CatalogCapabilities(); |
|
92 |
capabilities.setVersion(version); |
|
93 |
capabilities.setServerMessage(getServerAnswerReady()); |
|
94 |
return capabilities; |
|
95 |
} |
|
96 |
|
|
97 |
/* |
|
98 |
* (non-Javadoc) |
|
99 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getRecords(java.net.URI, es.gva.cit.catalogClient.querys.Query, int) |
|
100 |
*/ |
|
101 |
public GetRecordsReply getRecords(URI uri, CatalogQuery query, int firstRecord) { |
|
102 |
URL url = null; |
|
103 |
try { |
|
104 |
url = uri.toURL(); |
|
105 |
} catch (MalformedURLException e) { |
|
106 |
setServerAnswerReady("errorServerNotFound"); |
|
107 |
return null; |
|
108 |
} |
|
109 |
setQuery(query); |
|
110 |
SRWMessages messages = new SRWMessages(this); |
|
111 |
Collection nodes = new java.util.ArrayList(); |
|
112 |
|
|
113 |
//TODO remove this comparation |
|
114 |
if (url.getHost().equals("idee.unizar.es")){ |
|
115 |
try { |
|
116 |
url = new URL("http://idee.unizar.es/SRW/servlet/search/SRW"); |
|
117 |
} catch (MalformedURLException e) { |
|
118 |
// It will never throws |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
XMLNode root = null; |
|
123 |
nodes = new SOAPProtocol().doQuery(url, |
|
124 |
messages.getSOAPRecords(getQuery(), firstRecord), firstRecord); |
|
125 |
root = (XMLNode)nodes.toArray()[0]; |
|
126 |
root = root.getSubNode(0).getSubNode(0); |
|
127 |
|
|
128 |
String prefix = new StringTokenizer(root.getName(), ":").nextToken(); |
|
129 |
if (prefix.equals(root.getName())) { |
|
130 |
prefix = ""; |
|
131 |
} else { |
|
132 |
prefix = prefix + ":"; |
|
133 |
} |
|
134 |
int numberOfRecords = getNumberOfRecords(root, |
|
135 |
prefix + "numberOfRecords", |
|
136 |
null); |
|
137 |
|
|
138 |
if (numberOfRecords == -1) { |
|
139 |
return null; |
|
140 |
} |
|
141 |
GetRecordsReply recordsReply = new GetRecordsReply(numberOfRecords); |
|
142 |
|
|
143 |
parseRecords(root,recordsReply,uri,prefix,numberOfRecords,firstRecord); |
|
144 |
return recordsReply; |
|
145 |
} |
|
146 |
|
|
147 |
/** |
|
148 |
* Parser the XML |
|
149 |
* @param node |
|
150 |
* @param recordsReply |
|
151 |
* @param uri |
|
152 |
* @param prefix |
|
153 |
* @param numberOfRecords |
|
154 |
* @param firstRecord |
|
155 |
*/ |
|
156 |
private void parseRecords(XMLNode node, GetRecordsReply recordsReply, URI uri, String prefix, int numberOfRecords, int firstRecord) { |
|
157 |
|
|
158 |
XMLNode[] auxNodes = XMLTree.searchMultipleNode(node, |
|
159 |
prefix + "records->" + prefix + "record"); |
|
160 |
for (int i = 1; (i <= numberOfRecords) && (i <= 10) && (i <= (numberOfRecords - firstRecord + 1)); i++){ |
|
161 |
recordsReply.addRecord(uri, auxNodes[i - 1]); |
|
162 |
} |
|
163 |
|
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* |
|
168 |
* |
|
169 |
* |
|
170 |
* @return Returns the recordXPath. |
|
171 |
*/ |
|
172 |
public String getRecordXPath() { |
|
173 |
return recordXPath; |
|
174 |
} |
|
175 |
|
|
176 |
/** |
|
177 |
* |
|
178 |
* |
|
179 |
* |
|
180 |
* @param recordXPath The recordXPath to set. |
|
181 |
*/ |
|
182 |
public void setRecordXPath(String recordXPath) { |
|
183 |
this.recordXPath = recordXPath; |
|
184 |
} |
|
185 |
|
|
186 |
/** |
|
187 |
* |
|
188 |
* |
|
189 |
* |
|
190 |
* @return Returns the resultSetTTL. |
|
191 |
*/ |
|
192 |
public String getResultSetTTL() { |
|
193 |
return resultSetTTL; |
|
194 |
} |
|
195 |
|
|
196 |
/** |
|
197 |
* |
|
198 |
* |
|
199 |
* |
|
200 |
* @param resultSetTTL The resultSetTTL to set. |
|
201 |
*/ |
|
202 |
public void setResultSetTTL(String resultSetTTL) { |
|
203 |
this.resultSetTTL = resultSetTTL; |
|
204 |
} |
|
205 |
|
|
206 |
/** |
|
207 |
* |
|
208 |
* |
|
209 |
* |
|
210 |
* @return Returns the version. |
|
211 |
*/ |
|
212 |
public String getVersion() { |
|
213 |
return version; |
|
214 |
} |
|
215 |
|
|
216 |
/** |
|
217 |
* |
|
218 |
* |
|
219 |
* |
|
220 |
* @param version The version to set. |
|
221 |
*/ |
|
222 |
public void setVersion(String version) { |
|
223 |
this.version = version; |
|
224 |
} |
|
225 |
|
|
226 |
/* |
|
227 |
* (non-Javadoc) |
|
228 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#isProtocolSupported(java.net.URI) |
|
229 |
*/ |
|
230 |
public boolean isProtocolSupported(URI uri) { |
|
231 |
return SOAPProtocol.isProtocolSupported(null); |
|
232 |
} |
|
233 |
|
|
234 |
/* |
|
235 |
* (non-Javadoc) |
|
236 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getServiceName() |
|
237 |
*/ |
|
238 |
public String getServiceName() { |
|
239 |
return ServerData.SERVER_SUBTYPE_CATALOG_SRW; |
|
240 |
} |
|
241 |
|
|
242 |
/* |
|
243 |
* (non-Javadoc) |
|
244 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getDefaultPort() |
|
245 |
*/ |
|
246 |
public int getDefaultPort() { |
|
247 |
return 80; |
|
248 |
} |
|
249 |
|
|
250 |
/* |
|
251 |
* (non-Javadoc) |
|
252 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getDefaultSchema() |
|
253 |
*/ |
|
254 |
public String getDefaultSchema() { |
|
255 |
return "http"; |
|
256 |
} |
|
257 |
} |
|
0 | 258 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.147/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/srw/drivers/SRWMessages.java | ||
---|---|---|
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 |
/* |
|
43 |
* CVS MESSAGES: |
|
44 |
* |
|
45 |
* $Id: SRWMessages.java 585 2007-09-03 10:21:55 +0000 (Mon, 03 Sep 2007) jpiera $ |
|
46 |
* $Log$ |
|
47 |
* Revision 1.6.10.1 2007/07/10 11:18:04 jorpiell |
|
48 |
* Added the registers |
|
49 |
* |
|
50 |
* Revision 1.6 2006/03/21 07:13:52 jorpiell |
|
51 |
* El gazetteer ya reproyecta. Se han tenido que modificar los parsers de todos los protocolos. |
|
52 |
* |
|
53 |
* Revision 1.4.2.2 2006/03/14 07:18:45 jorpiell |
|
54 |
* Se ha a?adido la goma de borrar y se ha cambiado el tama?o de los botones |
|
55 |
* |
|
56 |
* Revision 1.5 2006/03/01 13:23:20 jorpiell |
|
57 |
* Se ha a?adido al Head lo de la 0.6 y se ha hecho un commit |
|
58 |
* |
|
59 |
* Revision 1.4.2.1 2006/02/02 13:44:59 jorpiell |
|
60 |
* Se ha tenido que cambiar el driver SRW para acceder al servidor de cat?logo de la IDEE. Adem?s se ha creado un nuevo filtro para este servidor |
|
61 |
* |
|
62 |
* Revision 1.4 2006/01/12 13:52:24 jorpiell |
|
63 |
* Se ha a?adido un boton close en las dos pantallas de connect. Adem?s se ha cambiado el comportamiento de las ventanas para adaptarlo a la nueva forma de buscar multihilo |
|
64 |
* |
|
65 |
* Revision 1.3 2006/01/10 17:23:23 jorpiell |
|
66 |
* Se ha hecho una peque?a modificaci?n en el gazeteer: ahora funcionan las b?squedas restringiendo el ?rea en el WFSG. Hay muchos cambios porque se ha hecho un CONTROL+SHIFT+O sobre todo el proyecto para eliminar los imports y para ordenarlos |
|
67 |
* |
|
68 |
* Revision 1.2 2006/01/10 09:32:49 jorpiell |
|
69 |
* Se ha echo un commit de las versiones modificadas del catalogo y del gazetteer usando el Poseidon. Se han renombrado algunas clases por considerar que tenian un nombre confuso y se han cambiado algunas relaciones entre clases (con la intenci?n de separar GUI de la parte de control). Han habido clases que no han sido tocadas, pero como han sido formateadas usando el Poseidon TODAS las CLASES del proyecto han cambiado de versi?n. |
|
70 |
* |
|
71 |
* Revision 1.1 2005/12/22 08:31:43 jorpiell |
|
72 |
* Aqui tambien se han producido muchos cambis, porque hemos acabado de cambiar la estructura del cat?logo: Se han creado todas las clases "XXXMessages", que sacan toda la parte de los mensajes de los drivers. Ademas se ha incluido en "CatalogClient" la operaci?n "getCapabilities", que libera a la interfaz de algunas operaciones que hac?a anteriormente. |
|
73 |
* |
|
74 |
* |
|
75 |
*/ |
|
76 |
package org.gvsig.catalog.srw.drivers; |
|
77 |
import org.apache.commons.httpclient.NameValuePair; |
|
78 |
import org.gvsig.catalog.drivers.IProtocolMessages; |
|
79 |
import org.gvsig.catalog.protocols.SOAPProtocol; |
|
80 |
import org.gvsig.catalog.querys.CatalogQuery; |
|
81 |
import org.gvsig.catalog.srw.filters.IDEESRWFilter; |
|
82 |
import org.gvsig.catalog.srw.filters.SRWFilter; |
|
83 |
|
|
84 |
/** |
|
85 |
* This class create the SRW protocol messages |
|
86 |
* |
|
87 |
* |
|
88 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
89 |
*/ |
|
90 |
public class SRWMessages implements IProtocolMessages { |
|
91 |
/** |
|
92 |
* |
|
93 |
* |
|
94 |
*/ |
|
95 |
private SRWCatalogServiceDriver driver; |
|
96 |
|
|
97 |
/** |
|
98 |
* |
|
99 |
* |
|
100 |
* |
|
101 |
* @param driver |
|
102 |
*/ |
|
103 |
public SRWMessages(SRWCatalogServiceDriver driver) { |
|
104 |
this.driver = driver; |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* |
|
109 |
* |
|
110 |
* |
|
111 |
* @return |
|
112 |
* @param upper |
|
113 |
*/ |
|
114 |
public NameValuePair[] getHTTPGETCapabilities(boolean upper) { |
|
115 |
NameValuePair nvp1 = new NameValuePair("OPERATION", "explain"); |
|
116 |
NameValuePair nvp2 = new NameValuePair("VERSION", driver.getVersion()); |
|
117 |
return new NameValuePair[] { nvp1, nvp2 }; |
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* |
|
122 |
* |
|
123 |
* |
|
124 |
* @return |
|
125 |
*/ |
|
126 |
public NameValuePair[] getHTTPGETDescribeRecords() { |
|
127 |
// TODO Auto-generated method stub |
|
128 |
return null; |
|
129 |
} |
|
130 |
|
|
131 |
/** |
|
132 |
* |
|
133 |
* |
|
134 |
* |
|
135 |
* @return |
|
136 |
* @param query |
|
137 |
* @param firstRecord |
|
138 |
*/ |
|
139 |
public NameValuePair[] getHTTPGETRecords(CatalogQuery query, int firstRecord) { |
|
140 |
|
|
141 |
NameValuePair nvp1 = new NameValuePair("operation", "searchRetrieve"); |
|
142 |
NameValuePair nvp2 = new NameValuePair("version", driver.getVersion()); |
|
143 |
NameValuePair nvp3 = new NameValuePair("query", new SRWFilter().getQuery(query)); |
|
144 |
NameValuePair nvp4 = new NameValuePair("maximumRecords", "10"); |
|
145 |
NameValuePair nvp5 = new NameValuePair("recordPacking", |
|
146 |
driver.getOutputFormat()); |
|
147 |
NameValuePair nvp6 = new NameValuePair("startRecord", |
|
148 |
new String(new Integer(firstRecord).toString())); |
|
149 |
return new NameValuePair[] { nvp1, nvp2, nvp3, nvp4, nvp5, nvp6 }; |
|
150 |
} |
|
151 |
|
|
152 |
/** |
|
153 |
* |
|
154 |
* |
|
155 |
* |
|
156 |
* @return |
|
157 |
*/ |
|
158 |
public String getHTTPPOSTCapabilities() { |
|
159 |
// TODO Auto-generated method stub |
|
160 |
return null; |
|
161 |
} |
|
162 |
|
|
163 |
/** |
|
164 |
* |
|
165 |
* |
|
166 |
* |
|
167 |
* @return |
|
168 |
*/ |
|
169 |
public String getHTTPPOSTDescribeRecords() { |
|
170 |
// TODO Auto-generated method stub |
|
171 |
return null; |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* |
|
176 |
* |
|
177 |
* |
|
178 |
* @return |
|
179 |
* @param query |
|
180 |
* @param firstRecord |
|
181 |
*/ |
|
182 |
public String getHTTPPOSTRecords(CatalogQuery query, int firstRecord) { |
|
183 |
// TODO Auto-generated method stub |
|
184 |
return null; |
|
185 |
} |
|
186 |
|
|
187 |
/** |
|
188 |
* |
|
189 |
* |
|
190 |
* |
|
191 |
* @return |
|
192 |
*/ |
|
193 |
public String getSOAPCapabilities() { |
|
194 |
String soapMessage = |
|
195 |
"<SRW:explainRequest xmlns:SRW=\"http://www.loc.gov/zing/srw/\">" + |
|
196 |
"<SRW:version>" + driver.getVersion() + "</SRW:version>" + |
|
197 |
"</SRW:explainRequest>"; |
|
198 |
return SOAPProtocol.setSOAPMessage(soapMessage,null); |
|
199 |
} |
|
200 |
|
|
201 |
/** |
|
202 |
* |
|
203 |
* |
|
204 |
* |
|
205 |
* @return |
|
206 |
*/ |
|
207 |
public String getSOAPDescribeRecords() { |
|
208 |
// TODO Auto-generated method stub |
|
209 |
return null; |
|
210 |
} |
|
211 |
|
|
212 |
/** |
|
213 |
* |
|
214 |
* |
|
215 |
* |
|
216 |
* @return |
|
217 |
* @param query |
|
218 |
* @param firstRecord |
|
219 |
*/ |
|
220 |
public String getSOAPRecords(CatalogQuery query, int firstRecord) { |
|
221 |
|
|
222 |
String soapMessage = |
|
223 |
"<srw:searchRetrieveRequest xmlns:srw=\"http://www.loc.gov/zing/srw/\">" + |
|
224 |
"<srw:query><![CDATA[" + new IDEESRWFilter().getQuery(query) + "]]></srw:query>" + |
|
225 |
"<srw:sortKeys xsi:nil=\"true\"/>" + "<srw:startRecord>" + |
|
226 |
driver.getStartPosition() + "</srw:startRecord>" + "<srw:maximumRecords>" + |
|
227 |
driver.getMaxRecords() + "</srw:maximumRecords>" + "<srw:recordPacking>" + |
|
228 |
driver.getOutputFormat() + "</srw:recordPacking>" + "<srw:recordSchema>" + |
|
229 |
driver.getOutputSchema()[0] + "</srw:recordSchema>" + |
|
230 |
"<srw:resultSetTTL>" + driver.getResultSetTTL() + "</srw:resultSetTTL>" + |
|
231 |
"</srw:searchRetrieveRequest>"; |
|
232 |
return SOAPProtocol.setSOAPMessage(soapMessage,null); |
|
233 |
} |
|
234 |
} |
|
0 | 235 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.147/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/CatalogAP.java | ||
---|---|---|
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 |
Also available in: Unified diff