Revision 36131
tags/v2_0_0_Build_2032/applications/appCatalog/src/org/gvsig/catalog/z3950/filters/Z3950Filter.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.z3950.filters; |
|
43 |
import org.gvsig.catalog.filters.AbstractFilter; |
|
44 |
import org.gvsig.catalog.languages.BasicEncodingRules; |
|
45 |
import org.gvsig.i18n.Messages; |
|
46 |
|
|
47 |
|
|
48 |
/** |
|
49 |
* |
|
50 |
* |
|
51 |
* |
|
52 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
53 |
*/ |
|
54 |
public class Z3950Filter extends AbstractFilter { |
|
55 |
private String database = null; |
|
56 |
|
|
57 |
public Z3950Filter(String database) { |
|
58 |
super(); |
|
59 |
this.database = database; |
|
60 |
} |
|
61 |
|
|
62 |
|
|
63 |
/* |
|
64 |
* (non-Javadoc) |
|
65 |
* @see es.gva.cit.catalog.filters.IFilter#getQuery(es.gva.cit.catalog.querys.CatalogQuery) |
|
66 |
*/ |
|
67 |
public String getQuery(org.gvsig.catalog.querys.CatalogQuery query) { |
|
68 |
// Create a RemoteBooleanQuery |
|
69 |
BasicEncodingRules filter = new BasicEncodingRules(); |
|
70 |
|
|
71 |
//Title (title, 4), Word List (6) |
|
72 |
if (query.getTitle() != null) { |
|
73 |
filter.addClauses("4", "6", "3", query.getTitle(), |
|
74 |
query.getTitleFilter(),"and"); |
|
75 |
} |
|
76 |
|
|
77 |
|
|
78 |
if (query.isMinimized()){ |
|
79 |
if (query.getAbstract() != null) { |
|
80 |
filter.addClauses("62", "6", "3", query.getAbstract(), "E", "or"); |
|
81 |
} |
|
82 |
}else{ |
|
83 |
if (query.getAbstract() != null) { |
|
84 |
filter.addClauses("62", "6", "3", query.getAbstract(), "E", "and"); |
|
85 |
} |
|
86 |
// Theme Keyword (themekey, 2002), Word List (6) |
|
87 |
if (query.getThemeKey() != null) { |
|
88 |
filter.addClauses("2002", "6", "3", query.getThemeKey(), "Y","and"); |
|
89 |
} |
|
90 |
// Source Scale Denominator (srcscale, 1024), Numeric String (109) |
|
91 |
if (query.getScale() != null) { |
|
92 |
if (query.getMinScale() != null){ |
|
93 |
filter.addClauses("1024", "109", "4", query.getMinScale(),"E","and"); |
|
94 |
} |
|
95 |
if (query.getMaxScale() != null){ |
|
96 |
filter.addClauses("1024", "109", "2", query.getMaxScale(),"E","and"); |
|
97 |
} |
|
98 |
} |
|
99 |
|
|
100 |
if (query.getProvider() != null) { |
|
101 |
filter.addClauses("1005", "6", "3", query.getProvider(), "E","and"); |
|
102 |
} |
|
103 |
// Beginning Date (begdate, 1012), Date(210) |
|
104 |
if (query.getDateFrom() != null) { |
|
105 |
filter.addClauses("1012", "210", "18", query.getDateFrom(), "E","and"); |
|
106 |
} |
|
107 |
// Ending Date (date, 1012 ), Date(210) |
|
108 |
if (query.getDateTo() != null) { |
|
109 |
filter.addClauses("1012", "210", "14", query.getDateTo(), "E","and"); |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
if ((query.getCoordenates() != null) && (query.isCoordinatesClicked())){ |
|
114 |
String sNorth = query.getCoordenates().getUly(); |
|
115 |
String sWest = query.getCoordenates().getUlx(); |
|
116 |
String sSouth = query.getCoordenates().getBry(); |
|
117 |
String sEast = query.getCoordenates().getBrx(); |
|
118 |
String sBounding = sNorth + " " + sWest + " " + sSouth + " " + |
|
119 |
sEast; |
|
120 |
String sRelation = getRelation(query.getCoordenatesFilter()); |
|
121 |
// Bounding Coordinates (bounding, 2060), Coordinate String (201) |
|
122 |
filter.addClauses("2060", "201", sRelation, sBounding, "E","and"); |
|
123 |
} |
|
124 |
//return query |
|
125 |
return filter.toString(database); |
|
126 |
} |
|
127 |
|
|
128 |
/** |
|
129 |
* Return a value for the option of the 'Coordenates Filter' |
|
130 |
* |
|
131 |
* @param relation String in the combo. Possible values: |
|
132 |
* encloses |
|
133 |
* overlaps |
|
134 |
* fullyOutsideOf |
|
135 |
* equals |
|
136 |
* |
|
137 |
* @return String |
|
138 |
* Possible values: |
|
139 |
* 9 -> encloses |
|
140 |
* 7 -> overlaps |
|
141 |
* 10 -> fullyOutsideOf |
|
142 |
* 3 -> equals |
|
143 |
* @param translator |
|
144 |
* @param relacion |
|
145 |
*/ |
|
146 |
private String getRelation(String relacion) { |
|
147 |
if (relacion.equals(Messages.getText("coordinatesEqual"))) { |
|
148 |
return "3"; |
|
149 |
} |
|
150 |
if (relacion.equals(Messages.getText("coordinatesContains"))) { |
|
151 |
return "7"; |
|
152 |
} |
|
153 |
if (relacion.equals(Messages.getText("coordinatesEnclose"))) { |
|
154 |
return "9"; |
|
155 |
} else { |
|
156 |
return "10"; |
|
157 |
} |
|
158 |
} |
|
159 |
} |
|
0 | 160 |
tags/v2_0_0_Build_2032/applications/appCatalog/src/org/gvsig/catalog/z3950/drivers/Z3950CatalogServiceDriver.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.z3950.drivers; |
|
43 |
import java.io.ByteArrayInputStream; |
|
44 |
import java.net.URI; |
|
45 |
import java.util.ArrayList; |
|
46 |
import java.util.Collection; |
|
47 |
|
|
48 |
import org.gvsig.catalog.drivers.AbstractCatalogServiceDriver; |
|
49 |
import org.gvsig.catalog.drivers.CatalogCapabilities; |
|
50 |
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities; |
|
51 |
import org.gvsig.catalog.drivers.GetRecordsReply; |
|
52 |
import org.gvsig.catalog.metadataxml.XMLNode; |
|
53 |
import org.gvsig.catalog.metadataxml.XMLTree; |
|
54 |
import org.gvsig.catalog.protocols.Z3950Protocol; |
|
55 |
import org.gvsig.catalog.querys.CatalogQuery; |
|
56 |
import org.gvsig.utils.swing.jcomboServer.ServerData; |
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
/** |
|
61 |
* This class implements the Z39.50 protocol. |
|
62 |
* |
|
63 |
* |
|
64 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
65 |
* @see http://www.loc.gov/z3950/agency/ |
|
66 |
*/ |
|
67 |
public class Z3950CatalogServiceDriver extends AbstractCatalogServiceDriver { |
|
68 |
|
|
69 |
/* |
|
70 |
* (non-Javadoc) |
|
71 |
* @see es.gva.cit.catalogClient.drivers.IDiscoveryServiceDriver#getCapabilities(java.net.URI) |
|
72 |
*/ |
|
73 |
public DiscoveryServiceCapabilities getCapabilities(URI uri) { |
|
74 |
Collection nodes = new ArrayList();; |
|
75 |
Z3950Messages messages = new Z3950Messages(this); |
|
76 |
String message = messages.getCapabilities(new Z3950Protocol().openConnection( |
|
77 |
uri)); |
|
78 |
ByteArrayInputStream buffer = new ByteArrayInputStream(message.getBytes()); |
|
79 |
nodes.add(XMLTree.xmlToTree(buffer)); |
|
80 |
|
|
81 |
setServerAnswerReady(XMLTree.searchNodeValue((XMLNode)nodes.toArray()[0], "Servidor")); |
|
82 |
CatalogCapabilities capabilities = new CatalogCapabilities(); |
|
83 |
capabilities.setVersion("3.0"); |
|
84 |
return capabilities; |
|
85 |
} |
|
86 |
|
|
87 |
/* |
|
88 |
* (non-Javadoc) |
|
89 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getRecords(java.net.URI, es.gva.cit.catalogClient.querys.Query, int) |
|
90 |
*/ |
|
91 |
public GetRecordsReply getRecords(URI uri, CatalogQuery query, int firstRecord) { |
|
92 |
setQuery(query); |
|
93 |
Z3950Messages messages = new Z3950Messages(this); |
|
94 |
String message = messages.getRecords(getQuery(),Z3950Protocol.getDatabase(uri)); |
|
95 |
System.out.println(message); |
|
96 |
new Z3950Protocol().doQuery(getRecordsReply(), uri, message, firstRecord); |
|
97 |
return getRecordsReply(); |
|
98 |
} |
|
99 |
|
|
100 |
/* |
|
101 |
* (non-Javadoc) |
|
102 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#isProtocolSupported(java.net.URI) |
|
103 |
*/ |
|
104 |
public boolean isProtocolSupported(URI uri) { |
|
105 |
return new Z3950Protocol().isProtocolSupported(uri); |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* @return |
|
110 |
*/ |
|
111 |
public String getQueryProfile() { |
|
112 |
return "Z3950"; |
|
113 |
} |
|
114 |
|
|
115 |
/* |
|
116 |
* (non-Javadoc) |
|
117 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getServiceName() |
|
118 |
*/ |
|
119 |
public String getServiceName() { |
|
120 |
return ServerData.SERVER_SUBTYPE_CATALOG_Z3950; |
|
121 |
} |
|
122 |
|
|
123 |
/* |
|
124 |
* (non-Javadoc) |
|
125 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getDefaultPort() |
|
126 |
*/ |
|
127 |
public int getDefaultPort() { |
|
128 |
return 2100; |
|
129 |
} |
|
130 |
|
|
131 |
/* |
|
132 |
* (non-Javadoc) |
|
133 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getDefaultSchema() |
|
134 |
*/ |
|
135 |
public String getDefaultSchema() { |
|
136 |
return "z3950"; |
|
137 |
} |
|
138 |
} |
|
0 | 139 |
tags/v2_0_0_Build_2032/applications/appCatalog/src/org/gvsig/catalog/z3950/drivers/Z3950Messages.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: Z3950Messages.java 585 2007-09-03 10:21:55 +0000 (Mon, 03 Sep 2007) jpiera $ |
|
46 |
* $Log$ |
|
47 |
* Revision 1.4.10.2 2006/11/15 00:08:08 jjdelcerro |
|
48 |
* *** empty log message *** |
|
49 |
* |
|
50 |
* Revision 1.6 2006/10/02 08:29:07 jorpiell |
|
51 |
* Modificados los cambios del Branch 10 al head |
|
52 |
* |
|
53 |
* Revision 1.4.10.1 2006/09/20 12:01:18 jorpiell |
|
54 |
* Se ha cambiado la versi?n de la jzkit, se ha incorporado la funcionalidad de cargar arcims |
|
55 |
* |
|
56 |
* Revision 1.5 2006/09/20 11:22:43 jorpiell |
|
57 |
* Se ha cambiado la versi?n de la librer?a jzkit de la 1 a la 2.0 |
|
58 |
* |
|
59 |
* Revision 1.4 2006/01/12 13:52:24 jorpiell |
|
60 |
* 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 |
|
61 |
* |
|
62 |
* Revision 1.3 2006/01/10 17:23:23 jorpiell |
|
63 |
* 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 |
|
64 |
* |
|
65 |
* Revision 1.2 2006/01/10 09:32:49 jorpiell |
|
66 |
* 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. |
|
67 |
* |
|
68 |
* Revision 1.1 2005/12/22 08:31:43 jorpiell |
|
69 |
* 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. |
|
70 |
* |
|
71 |
* |
|
72 |
*/ |
|
73 |
package org.gvsig.catalog.z3950.drivers; |
|
74 |
import org.gvsig.catalog.querys.CatalogQuery; |
|
75 |
import org.gvsig.catalog.z3950.filters.Z3950Filter; |
|
76 |
|
|
77 |
/** |
|
78 |
* This class is used to create all the Z3950 protocol |
|
79 |
* messages |
|
80 |
* |
|
81 |
* |
|
82 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
83 |
*/ |
|
84 |
public class Z3950Messages { |
|
85 |
/** |
|
86 |
* |
|
87 |
* |
|
88 |
*/ |
|
89 |
private Z3950CatalogServiceDriver driver = null; |
|
90 |
|
|
91 |
/** |
|
92 |
* |
|
93 |
* |
|
94 |
* |
|
95 |
* @param driver |
|
96 |
*/ |
|
97 |
public Z3950Messages(Z3950CatalogServiceDriver driver) { |
|
98 |
this.driver = driver; |
|
99 |
} |
|
100 |
|
|
101 |
/** |
|
102 |
* |
|
103 |
* |
|
104 |
* |
|
105 |
* @return |
|
106 |
* @param message |
|
107 |
*/ |
|
108 |
public String getCapabilities(String message) { |
|
109 |
return "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + "<Z3950> " + |
|
110 |
"<Servidor>" + message + "</Servidor>" + "</Z3950>"; |
|
111 |
|
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
115 |
* |
|
116 |
* |
|
117 |
* |
|
118 |
* @return |
|
119 |
* @param query |
|
120 |
*/ |
|
121 |
public String getRecords(CatalogQuery query,String database) { |
|
122 |
return new Z3950Filter(database).getQuery(query); |
|
123 |
} |
|
124 |
} |
|
0 | 125 |
tags/v2_0_0_Build_2032/applications/appCatalog/src/org/gvsig/catalog/csw/messages/CSWMessages2_0_0.java | ||
---|---|---|
1 |
package org.gvsig.catalog.csw.messages; |
|
2 |
|
|
3 |
import org.gvsig.catalog.csw.drivers.profiles.CSWAbstractProfile; |
|
4 |
import org.gvsig.catalog.csw.parsers.CSWConstants; |
|
5 |
|
|
6 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
7 |
* |
|
8 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
9 |
* |
|
10 |
* This program is free software; you can redistribute it and/or |
|
11 |
* modify it under the terms of the GNU General Public License |
|
12 |
* as published by the Free Software Foundation; either version 2 |
|
13 |
* of the License, or (at your option) any later version. |
|
14 |
* |
|
15 |
* This program is distributed in the hope that it will be useful, |
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
* GNU General Public License for more details. |
|
19 |
* |
|
20 |
* You should have received a copy of the GNU General Public License |
|
21 |
* along with this program; if not, write to the Free Software |
|
22 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
23 |
* |
|
24 |
* For more information, contact: |
|
25 |
* |
|
26 |
* Generalitat Valenciana |
|
27 |
* Conselleria d'Infraestructures i Transport |
|
28 |
* Av. Blasco Ib??ez, 50 |
|
29 |
* 46010 VALENCIA |
|
30 |
* SPAIN |
|
31 |
* |
|
32 |
* +34 963862235 |
|
33 |
* gvsig@gva.es |
|
34 |
* www.gvsig.gva.es |
|
35 |
* |
|
36 |
* or |
|
37 |
* |
|
38 |
* IVER T.I. S.A |
|
39 |
* Salamanca 50 |
|
40 |
* 46005 Valencia |
|
41 |
* Spain |
|
42 |
* |
|
43 |
* +34 963163400 |
|
44 |
* dac@iver.es |
|
45 |
*/ |
|
46 |
/* CVS MESSAGES: |
|
47 |
* |
|
48 |
* $Id$ |
|
49 |
* $Log$ |
|
50 |
* |
|
51 |
*/ |
|
52 |
/** |
|
53 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
54 |
*/ |
|
55 |
public class CSWMessages2_0_0 extends CSWAbstractMessages { |
|
56 |
|
|
57 |
public CSWMessages2_0_0(CSWAbstractProfile profile) { |
|
58 |
super(profile); |
|
59 |
} |
|
60 |
|
|
61 |
/* |
|
62 |
* (non-Javadoc) |
|
63 |
* @see es.gva.cit.catalog.csw.messages.CSWAbstractMessages#getContraintVersion() |
|
64 |
*/ |
|
65 |
protected String getContraintVersion() { |
|
66 |
return CSWConstants.CONSTRAINT_VERSION_2_0_0; |
|
67 |
} |
|
68 |
|
|
69 |
} |
|
0 | 70 |
tags/v2_0_0_Build_2032/applications/appCatalog/src/org/gvsig/catalog/csw/messages/CSWMessages2_0_1.java | ||
---|---|---|
1 |
package org.gvsig.catalog.csw.messages; |
|
2 |
|
|
3 |
import org.gvsig.catalog.csw.drivers.profiles.CSWAbstractProfile; |
|
4 |
import org.gvsig.catalog.csw.parsers.CSWConstants; |
|
5 |
|
|
6 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
7 |
* |
|
8 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
9 |
* |
|
10 |
* This program is free software; you can redistribute it and/or |
|
11 |
* modify it under the terms of the GNU General Public License |
|
12 |
* as published by the Free Software Foundation; either version 2 |
|
13 |
* of the License, or (at your option) any later version. |
|
14 |
* |
|
15 |
* This program is distributed in the hope that it will be useful, |
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
* GNU General Public License for more details. |
|
19 |
* |
|
20 |
* You should have received a copy of the GNU General Public License |
|
21 |
* along with this program; if not, write to the Free Software |
|
22 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
23 |
* |
|
24 |
* For more information, contact: |
|
25 |
* |
|
26 |
* Generalitat Valenciana |
|
27 |
* Conselleria d'Infraestructures i Transport |
|
28 |
* Av. Blasco Ib??ez, 50 |
|
29 |
* 46010 VALENCIA |
|
30 |
* SPAIN |
|
31 |
* |
|
32 |
* +34 963862235 |
|
33 |
* gvsig@gva.es |
|
34 |
* www.gvsig.gva.es |
|
35 |
* |
|
36 |
* or |
|
37 |
* |
|
38 |
* IVER T.I. S.A |
|
39 |
* Salamanca 50 |
|
40 |
* 46005 Valencia |
|
41 |
* Spain |
|
42 |
* |
|
43 |
* +34 963163400 |
|
44 |
* dac@iver.es |
|
45 |
*/ |
|
46 |
/* CVS MESSAGES: |
|
47 |
* |
|
48 |
* $Id$ |
|
49 |
* $Log$ |
|
50 |
* |
|
51 |
*/ |
|
52 |
/** |
|
53 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
54 |
*/ |
|
55 |
public class CSWMessages2_0_1 extends CSWAbstractMessages{ |
|
56 |
|
|
57 |
public CSWMessages2_0_1(CSWAbstractProfile profile) { |
|
58 |
super(profile); |
|
59 |
} |
|
60 |
|
|
61 |
/* |
|
62 |
* (non-Javadoc) |
|
63 |
* @see es.gva.cit.catalog.csw.messages.CSWAbstractMessages#getContraintVersion() |
|
64 |
*/ |
|
65 |
protected String getContraintVersion() { |
|
66 |
return CSWConstants.CONSTRAINT_VERSION_2_0_1; |
|
67 |
} |
|
68 |
|
|
69 |
|
|
70 |
} |
|
0 | 71 |
tags/v2_0_0_Build_2032/applications/appCatalog/src/org/gvsig/catalog/csw/messages/CSWAbstractMessages.java | ||
---|---|---|
1 |
package org.gvsig.catalog.csw.messages; |
|
2 |
|
|
3 |
import org.apache.commons.httpclient.NameValuePair; |
|
4 |
import org.gvsig.catalog.csw.drivers.CSWCapabilities; |
|
5 |
import org.gvsig.catalog.csw.drivers.profiles.CSWAbstractProfile; |
|
6 |
import org.gvsig.catalog.csw.parsers.CSWConstants; |
|
7 |
import org.gvsig.catalog.languages.FilterEncoding; |
|
8 |
import org.gvsig.catalog.querys.CatalogQuery; |
|
9 |
import org.gvsig.catalog.querys.Search; |
|
10 |
import org.gvsig.catalog.utils.CatalogConstants; |
|
11 |
import org.gvsig.catalog.utils.Strings; |
|
12 |
import org.gvsig.i18n.Messages; |
|
13 |
import org.gvsig.utils.swing.jcomboServer.ServerData; |
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
18 |
* |
|
19 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
20 |
* |
|
21 |
* This program is free software; you can redistribute it and/or |
|
22 |
* modify it under the terms of the GNU General Public License |
|
23 |
* as published by the Free Software Foundation; either version 2 |
|
24 |
* of the License, or (at your option) any later version. |
|
25 |
* |
|
26 |
* This program is distributed in the hope that it will be useful, |
|
27 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
28 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
29 |
* GNU General Public License for more details. |
|
30 |
* |
|
31 |
* You should have received a copy of the GNU General Public License |
|
32 |
* along with this program; if not, write to the Free Software |
|
33 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
34 |
* |
|
35 |
* For more information, contact: |
|
36 |
* |
|
37 |
* Generalitat Valenciana |
|
38 |
* Conselleria d'Infraestructures i Transport |
|
39 |
* Av. Blasco Ib??ez, 50 |
|
40 |
* 46010 VALENCIA |
|
41 |
* SPAIN |
|
42 |
* |
|
43 |
* +34 963862235 |
|
44 |
* gvsig@gva.es |
|
45 |
* www.gvsig.gva.es |
|
46 |
* |
|
47 |
* or |
|
48 |
* |
|
49 |
* IVER T.I. S.A |
|
50 |
* Salamanca 50 |
|
51 |
* 46005 Valencia |
|
52 |
* Spain |
|
53 |
* |
|
54 |
* +34 963163400 |
|
55 |
* dac@iver.es |
|
56 |
*/ |
|
57 |
/* CVS MESSAGES: |
|
58 |
* |
|
59 |
* $Id$ |
|
60 |
* $Log$ |
|
61 |
* |
|
62 |
*/ |
|
63 |
/** |
|
64 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
65 |
*/ |
|
66 |
public abstract class CSWAbstractMessages { |
|
67 |
private CSWCapabilities capabilities = null; |
|
68 |
private CatalogQuery query = null; |
|
69 |
private CSWAbstractProfile profile = null; |
|
70 |
|
|
71 |
/** |
|
72 |
* @param profile |
|
73 |
* The profile to create the query |
|
74 |
*/ |
|
75 |
public CSWAbstractMessages(CSWAbstractProfile profile) { |
|
76 |
super(); |
|
77 |
this.profile = profile; |
|
78 |
} |
|
79 |
|
|
80 |
public static NameValuePair[] getHTTPGETCapabilities() { |
|
81 |
NameValuePair nvp1 = new NameValuePair("request", CSWConstants.OPERATION_GETCAPABILITIES); |
|
82 |
NameValuePair nvp2 = new NameValuePair("service", ServerData.SERVER_SUBTYPE_CATALOG_CSW); |
|
83 |
NameValuePair nvp3 = new NameValuePair("acceptFormats","text/xml"); |
|
84 |
return new NameValuePair[] { nvp1, nvp2, nvp3 }; |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* The get capabilities operation started with lower case. |
|
89 |
* There are some servers that has this bug |
|
90 |
* @return |
|
91 |
*/ |
|
92 |
public static NameValuePair[] getHTTPGETCapabilitiesLower() { |
|
93 |
NameValuePair nvp1 = new NameValuePair("request", CSWConstants.OPERATION_GETCAPABILITIESToLOWER); |
|
94 |
NameValuePair nvp2 = new NameValuePair("service", ServerData.SERVER_SUBTYPE_CATALOG_CSW); |
|
95 |
NameValuePair nvp3 = new NameValuePair("acceptFormats","text/xml"); |
|
96 |
return new NameValuePair[] { nvp1, nvp2, nvp3 }; |
|
97 |
} |
|
98 |
|
|
99 |
public static NameValuePair[] getHTTPGETDescribeRecord(String version) { |
|
100 |
NameValuePair nvp1 = new NameValuePair("request", CSWConstants.OPERATION_DESCRIBERECORD); |
|
101 |
NameValuePair nvp2 = new NameValuePair("service", ServerData.SERVER_SUBTYPE_CATALOG_CSW); |
|
102 |
NameValuePair nvp3 = new NameValuePair("version", version); |
|
103 |
return new NameValuePair[] { nvp1, nvp2, nvp3 }; |
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* Creates and returns the GetRecords request |
|
108 |
* @param query |
|
109 |
* @param firstRecord |
|
110 |
* @return |
|
111 |
*/ |
|
112 |
public String getHTTPPostGetRecordsMessage(CSWCapabilities capabilities, CatalogQuery query, ServerData serverData, int firstRecord) { |
|
113 |
this.capabilities = capabilities; |
|
114 |
this.query = query; |
|
115 |
profile.setServerData(serverData); |
|
116 |
StringBuffer buffer = new StringBuffer(); |
|
117 |
buffer.append(createGetRecordsHeader(firstRecord)); |
|
118 |
return buffer.toString(); |
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
122 |
* Create the GetRecords header. |
|
123 |
* @param firstRecord |
|
124 |
* @return |
|
125 |
*/ |
|
126 |
protected String createGetRecordsHeader(int firstRecord){ |
|
127 |
StringBuffer buffer = new StringBuffer(); |
|
128 |
buffer.append(CatalogConstants.XML_HEADER_ENCODING); |
|
129 |
buffer.append("<" + CSWConstants.CSW_NAMESPACE + |
|
130 |
":" + CSWConstants.CSW_GET_RECORDS); |
|
131 |
buffer.append(" " + CSWConstants.CSW_SERVICE + "=\"" + ServerData.SERVER_SUBTYPE_CATALOG_CSW + "\" "); |
|
132 |
buffer.append(CSWConstants.CSW_VERSION + "=\"" + capabilities.getVersion() + "\" "); |
|
133 |
buffer.append(CatalogConstants.XML_NS + "=\"" +CSWConstants.CSW_NAMESPACE_URI + "\" "); |
|
134 |
buffer.append(CatalogConstants.XML_NS + ":" + CSWConstants.CSW_NAMESPACE + |
|
135 |
"=\"" + CSWConstants.CSW_NAMESPACE_URI + "\" "); |
|
136 |
buffer.append(CatalogConstants.XML_NS + ":" + CSWConstants.OGC_NAMESPACE + |
|
137 |
"=\"" + CSWConstants.OGC_NAMESPACE_URI + "\" "); |
|
138 |
buffer.append(CatalogConstants.XML_NS + ":" + CSWConstants.GML_NAMESPACE + |
|
139 |
"=\"" + CSWConstants.GML_NAMESPACE_URI + "\" "); |
|
140 |
buffer.append(CSWConstants.CSW_START_POSITION + "='" + firstRecord + "' "); |
|
141 |
buffer.append(CSWConstants.CSW_MAX_RECORDS + "='10' "); |
|
142 |
if (capabilities.getOutputFormat() != null){ |
|
143 |
buffer.append(CSWConstants.CSW_OUTPUTFORMAT + "=\"" + capabilities.getOutputFormat() + "\" "); |
|
144 |
} |
|
145 |
if (getOutputSchema(capabilities.getOutputSchema()) != null){ |
|
146 |
buffer.append(CSWConstants.CSW_OUTPUTSCHEMA + "=\"" + getOutputSchema(capabilities.getOutputSchema()) + "\" "); |
|
147 |
}else{ |
|
148 |
buffer.append(CSWConstants.CSW_OUTPUTSCHEMA + "=\"csw:IsoRecord\" "); |
|
149 |
} |
|
150 |
buffer.append("resultType=\"" + |
|
151 |
getResultType(capabilities.getResultType()) + "\">"); |
|
152 |
buffer.append(createGetRecordsQuery()); |
|
153 |
buffer.append("</" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.OPERATION_GETRECORDS + ">"); |
|
154 |
return buffer.toString(); |
|
155 |
} |
|
156 |
|
|
157 |
/** |
|
158 |
* Returns a common reslut type if the getCapabilities doesn't have |
|
159 |
* one. Sometimes it works. |
|
160 |
* |
|
161 |
* |
|
162 |
* @return Just one String |
|
163 |
* @param resultType The array of result types parsed. |
|
164 |
*/ |
|
165 |
protected String getResultType(String[] resultType) { |
|
166 |
if (resultType == null) |
|
167 |
return "results"; |
|
168 |
|
|
169 |
for (int i=0 ; i<resultType.length ; i++){ |
|
170 |
|
|
171 |
} |
|
172 |
return resultType[0]; |
|
173 |
} |
|
174 |
|
|
175 |
/** |
|
176 |
* Returns the OutputSchema. If the ISO19115 is supported, |
|
177 |
* we prefer this |
|
178 |
* @param OutputFormat The array of outputFormats parsed. |
|
179 |
* @return Just one String |
|
180 |
* @param outputSchemas |
|
181 |
*/ |
|
182 |
protected String getOutputSchema(String[] outputSchemas) { |
|
183 |
if (outputSchemas == null){ |
|
184 |
return null; |
|
185 |
} |
|
186 |
return outputSchemas[0]; |
|
187 |
} |
|
188 |
|
|
189 |
/** |
|
190 |
* @return the Query xml sub tree of the GetRecords |
|
191 |
* operation |
|
192 |
*/ |
|
193 |
protected String createGetRecordsQuery(){ |
|
194 |
StringBuffer buffer = new StringBuffer(); |
|
195 |
buffer.append("<" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.QUERY + " "); |
|
196 |
if (capabilities.getTypeNames() != null){ |
|
197 |
buffer.append(CSWConstants.TYPENAMES + "=\"" + |
|
198 |
Strings.getBlankSeparated(capabilities.getTypeNames()) + "\""); |
|
199 |
} |
|
200 |
buffer.append(">"); |
|
201 |
buffer.append(getElementSetNameLabel(query.getService())); |
|
202 |
buffer.append(createGetRecordsConstraint()); |
|
203 |
buffer.append("</" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.QUERY + ">"); |
|
204 |
return buffer.toString(); |
|
205 |
} |
|
206 |
|
|
207 |
/** |
|
208 |
* Create and return the ElementName and the ElementSetName tags |
|
209 |
* @param searchType |
|
210 |
* @return |
|
211 |
*/ |
|
212 |
protected String getElementSetNameLabel(Search searchType) { |
|
213 |
StringBuffer buffer = new StringBuffer(); |
|
214 |
buffer.append("<" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.ELEMENTSETNAME + ">"); |
|
215 |
buffer.append(CSWConstants.FULL); |
|
216 |
buffer.append("</" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.ELEMENTSETNAME + ">"); |
|
217 |
if (profile.getElementName() != null){ |
|
218 |
buffer.append("<" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.ELEMENTNAME + ">"); |
|
219 |
buffer.append(profile.getElementName()); |
|
220 |
buffer.append("</" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.ELEMENTNAME + ">"); |
|
221 |
} |
|
222 |
return buffer.toString(); |
|
223 |
} |
|
224 |
|
|
225 |
/** |
|
226 |
* @return the Constarint xml sub tree of the GetRecords |
|
227 |
* operation |
|
228 |
*/ |
|
229 |
protected String createGetRecordsConstraint(){ |
|
230 |
StringBuffer buffer = new StringBuffer(); |
|
231 |
buffer.append("<" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.CONSTRAINT); |
|
232 |
buffer.append(" " + CSWConstants.VERSION + "='" + getContraintVersion() + "'>"); |
|
233 |
buffer.append(createFilterEncoding()); |
|
234 |
buffer.append("</" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.CONSTRAINT + ">"); |
|
235 |
return buffer.toString(); |
|
236 |
} |
|
237 |
|
|
238 |
/** |
|
239 |
* @return the constraint version |
|
240 |
*/ |
|
241 |
protected abstract String getContraintVersion(); |
|
242 |
|
|
243 |
/** |
|
244 |
* Creates the filter encoding. It can be |
|
245 |
* overridden by the children classes. |
|
246 |
* @return |
|
247 |
* The filter encoding to use |
|
248 |
*/ |
|
249 |
protected FilterEncoding getFilterEncoding(){ |
|
250 |
return new FilterEncoding(); |
|
251 |
} |
|
252 |
|
|
253 |
/** |
|
254 |
* Creates the filter encoding query |
|
255 |
* @param query |
|
256 |
* @return |
|
257 |
*/ |
|
258 |
protected String createFilterEncoding(){ |
|
259 |
FilterEncoding filter = getFilterEncoding(); |
|
260 |
if (query.getTitle() != null){ |
|
261 |
filter.addClauses(profile.getTitle(), |
|
262 |
query.getTitle(), |
|
263 |
query.getTitleFilter(), |
|
264 |
FilterEncoding.PROPERTY_IS_LIKE, |
|
265 |
FilterEncoding.TYPE_LITERAL, |
|
266 |
FilterEncoding.AND); |
|
267 |
} |
|
268 |
if (query.isMinimized()){ |
|
269 |
if (query.getAbstract() != null) { |
|
270 |
filter.addClauses(profile.getAbstract(), |
|
271 |
query.getAbstract(), |
|
272 |
FilterEncoding.ANY_WORDS, |
|
273 |
FilterEncoding.PROPERTY_IS_LIKE, |
|
274 |
FilterEncoding.TYPE_LITERAL, |
|
275 |
FilterEncoding.OR); |
|
276 |
} |
|
277 |
}else{ |
|
278 |
if (query.getAbstract() != null) { |
|
279 |
filter.addClauses(profile.getAbstract(), |
|
280 |
query.getAbstract(), |
|
281 |
FilterEncoding.ANY_WORDS); |
|
282 |
} |
|
283 |
if (query.getThemeKey() != null) { |
|
284 |
filter.addClauses(profile.getKeywords(), query.getThemeKey(), |
|
285 |
FilterEncoding.ANY_WORDS); |
|
286 |
|
|
287 |
} |
|
288 |
if ((query.getTopic() != null) && (!query.getTopic().equals(Messages.getText("cathegoryAny")))) { |
|
289 |
filter.addClauses(profile.getTopic(), profile.getTopicValue(query.getTopic()), |
|
290 |
FilterEncoding.EXACT_WORDS); |
|
291 |
} |
|
292 |
if (query.getScale() != null) { |
|
293 |
filter.addClauses(profile.getScale(), query.getScale(), |
|
294 |
FilterEncoding.EXACT_WORDS); |
|
295 |
} |
|
296 |
if (query.getProvider() != null) { |
|
297 |
filter.addClauses(profile.getProvider(), |
|
298 |
filter.getWildCard() + query.getProvider() + filter.getWildCard(), |
|
299 |
FilterEncoding.EXACT_WORDS, |
|
300 |
FilterEncoding.PROPERTY_IS_EQUALS_TO, |
|
301 |
FilterEncoding.TYPE_LITERAL, |
|
302 |
FilterEncoding.AND); |
|
303 |
} |
|
304 |
|
|
305 |
if (query.getDateFrom() != null) { |
|
306 |
filter.addClauses(profile.getDateFrom(), query.getDateFrom(), |
|
307 |
FilterEncoding.EXACT_WORDS, |
|
308 |
FilterEncoding.PROPERTY_IS_GREATER_THAN, |
|
309 |
FilterEncoding.TYPE_LITERAL, |
|
310 |
FilterEncoding.AND); |
|
311 |
} |
|
312 |
if (query.getDateTo() != null) { |
|
313 |
filter.addClauses(profile.getDateTo(), query.getDateTo(), |
|
314 |
FilterEncoding.EXACT_WORDS, |
|
315 |
FilterEncoding.PROPERTY_IS_LESS_THAN, |
|
316 |
FilterEncoding.TYPE_LITERAL, |
|
317 |
FilterEncoding.AND); |
|
318 |
} |
|
319 |
} |
|
320 |
if ((query.getCoordenates() != null) && (query.isCoordinatesClicked())){ |
|
321 |
filter.addBoundingBox(query.getCoordenates(), profile.getCoordinates(), |
|
322 |
getCoordinatesOption(query.getCoordenatesFilter())); |
|
323 |
|
|
324 |
} |
|
325 |
return filter.toString(); |
|
326 |
} |
|
327 |
|
|
328 |
/** |
|
329 |
* This function returns true only when the user has choosen the |
|
330 |
* "Fully Outside Of" of the coordinates option. |
|
331 |
* @param coordinatesOption |
|
332 |
* @return |
|
333 |
*/ |
|
334 |
protected boolean getCoordinatesOption(String coordinatesOption) { |
|
335 |
if ((coordinatesOption.equals(Messages.getText("coordinatesEqual"))) || |
|
336 |
(coordinatesOption.equals(Messages.getText("coordinatesContains"))) || |
|
337 |
(coordinatesOption.equals(Messages.getText("coordinatesEnclose")))) |
|
338 |
return false; |
|
339 |
|
|
340 |
return true; |
|
341 |
} |
|
342 |
} |
|
0 | 343 |
tags/v2_0_0_Build_2032/applications/appCatalog/src/org/gvsig/catalog/csw/messages/CSWMessages0_9_0.java | ||
---|---|---|
1 |
package org.gvsig.catalog.csw.messages; |
|
2 |
|
|
3 |
import org.gvsig.catalog.csw.drivers.profiles.CSWAbstractProfile; |
|
4 |
import org.gvsig.catalog.csw.parsers.CSWConstants; |
|
5 |
import org.gvsig.catalog.languages.FilterEncoding; |
|
6 |
|
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
8 |
* |
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
10 |
* |
|
11 |
* This program is free software; you can redistribute it and/or |
|
12 |
* modify it under the terms of the GNU General Public License |
|
13 |
* as published by the Free Software Foundation; either version 2 |
|
14 |
* of the License, or (at your option) any later version. |
|
15 |
* |
|
16 |
* This program is distributed in the hope that it will be useful, |
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
* GNU General Public License for more details. |
|
20 |
* |
|
21 |
* You should have received a copy of the GNU General Public License |
|
22 |
* along with this program; if not, write to the Free Software |
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
24 |
* |
|
25 |
* For more information, contact: |
|
26 |
* |
|
27 |
* Generalitat Valenciana |
|
28 |
* Conselleria d'Infraestructures i Transport |
|
29 |
* Av. Blasco Ib??ez, 50 |
|
30 |
* 46010 VALENCIA |
|
31 |
* SPAIN |
|
32 |
* |
|
33 |
* +34 963862235 |
|
34 |
* gvsig@gva.es |
|
35 |
* www.gvsig.gva.es |
|
36 |
* |
|
37 |
* or |
|
38 |
* |
|
39 |
* IVER T.I. S.A |
|
40 |
* Salamanca 50 |
|
41 |
* 46005 Valencia |
|
42 |
* Spain |
|
43 |
* |
|
44 |
* +34 963163400 |
|
45 |
* dac@iver.es |
|
46 |
*/ |
|
47 |
/* CVS MESSAGES: |
|
48 |
* |
|
49 |
* $Id$ |
|
50 |
* $Log$ |
|
51 |
* |
|
52 |
*/ |
|
53 |
/** |
|
54 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
55 |
*/ |
|
56 |
public class CSWMessages0_9_0 extends CSWAbstractMessages{ |
|
57 |
private static final String TYPENAMES = "Dataset"; |
|
58 |
private static final String ESCAPECHAR = "escape"; |
|
59 |
|
|
60 |
public CSWMessages0_9_0(CSWAbstractProfile profile) { |
|
61 |
super(profile); |
|
62 |
} |
|
63 |
|
|
64 |
/* |
|
65 |
* (non-Javadoc) |
|
66 |
* @see es.gva.cit.catalog.csw.messages.CSWAbstractMessages#getContraintVersion() |
|
67 |
*/ |
|
68 |
protected String getContraintVersion() { |
|
69 |
return CSWConstants.CONSTRAINT_VERSION_0_9_0; |
|
70 |
} |
|
71 |
|
|
72 |
/* |
|
73 |
* (non-Javadoc) |
|
74 |
* @see es.gva.cit.catalog.csw.messages.CSWAbstractMessages#createGetRecordsQuery() |
|
75 |
*/ |
|
76 |
protected String createGetRecordsQuery(){ |
|
77 |
StringBuffer buffer = new StringBuffer(); |
|
78 |
buffer.append("<" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.QUERY + " "); |
|
79 |
buffer.append(CSWConstants.TYPENAMES + "=\"" + TYPENAMES + "\""); |
|
80 |
buffer.append(">"); |
|
81 |
buffer.append("<" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.ELEMENTSETNAME + " "); |
|
82 |
buffer.append(CSWConstants.TYPENAMES + "=\"" + TYPENAMES + "\""); |
|
83 |
buffer.append(">"); |
|
84 |
buffer.append(CSWConstants.FULL); |
|
85 |
buffer.append("</" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.ELEMENTSETNAME + ">"); |
|
86 |
buffer.append(createGetRecordsConstraint()); |
|
87 |
buffer.append("</" + CSWConstants.CSW_NAMESPACE + ":" + CSWConstants.QUERY + ">"); |
|
88 |
return buffer.toString(); |
|
89 |
} |
|
90 |
|
|
91 |
/* |
|
92 |
* (non-Javadoc) |
|
93 |
* @see es.gva.cit.catalog.csw.messages.CSWAbstractMessages#getFilterEncoding() |
|
94 |
*/ |
|
95 |
protected FilterEncoding getFilterEncoding(){ |
|
96 |
FilterEncoding filter = super.getFilterEncoding(); |
|
97 |
filter.setEscapeCharLabel(ESCAPECHAR); |
|
98 |
return filter; |
|
99 |
} |
|
100 |
|
|
101 |
} |
tags/v2_0_0_Build_2032/applications/appCatalog/src/org/gvsig/catalog/csw/messages/CSWMessagesFactory.java | ||
---|---|---|
1 |
package org.gvsig.catalog.csw.messages; |
|
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
|
|
5 |
import org.gvsig.catalog.csw.drivers.profiles.CSWAbstractProfile; |
|
6 |
import org.gvsig.catalog.csw.parsers.CSWConstants; |
|
7 |
import org.gvsig.catalog.exceptions.NotSupportedVersionException; |
|
8 |
|
|
9 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
10 |
* |
|
11 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
12 |
* |
|
13 |
* This program is free software; you can redistribute it and/or |
|
14 |
* modify it under the terms of the GNU General Public License |
|
15 |
* as published by the Free Software Foundation; either version 2 |
|
16 |
* of the License, or (at your option) any later version. |
|
17 |
* |
|
18 |
* This program is distributed in the hope that it will be useful, |
|
19 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 |
* GNU General Public License for more details. |
|
22 |
* |
|
23 |
* You should have received a copy of the GNU General Public License |
|
24 |
* along with this program; if not, write to the Free Software |
|
25 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
26 |
* |
|
27 |
* For more information, contact: |
|
28 |
* |
|
29 |
* Generalitat Valenciana |
|
30 |
* Conselleria d'Infraestructures i Transport |
|
31 |
* Av. Blasco Ib??ez, 50 |
|
32 |
* 46010 VALENCIA |
|
33 |
* SPAIN |
|
34 |
* |
|
35 |
* +34 963862235 |
|
36 |
* gvsig@gva.es |
|
37 |
* www.gvsig.gva.es |
|
38 |
* |
|
39 |
* or |
|
40 |
* |
|
41 |
* IVER T.I. S.A |
|
42 |
* Salamanca 50 |
|
43 |
* 46005 Valencia |
|
44 |
* Spain |
|
45 |
* |
|
46 |
* +34 963163400 |
|
47 |
* dac@iver.es |
|
48 |
*/ |
|
49 |
/* CVS MESSAGES: |
|
50 |
* |
|
51 |
* $Id$ |
|
52 |
* $Log$ |
|
53 |
* |
|
54 |
*/ |
|
55 |
/** |
|
56 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
57 |
*/ |
|
58 |
public class CSWMessagesFactory { |
|
59 |
private static HashMap messages = null; |
|
60 |
|
|
61 |
static{ |
|
62 |
messages = new HashMap(); |
|
63 |
messages.put(CSWConstants.VERSION_0_9_0, CSWMessages0_9_0.class); |
|
64 |
messages.put(CSWConstants.VERSION_2_0_0, CSWMessages2_0_0.class); |
|
65 |
messages.put(CSWConstants.VERSION_2_0_1, CSWMessages2_0_1.class); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* Gets a messages class |
|
70 |
* @param version |
|
71 |
* The CSW version |
|
72 |
* @param profile |
|
73 |
* The CSW profile |
|
74 |
* @return |
|
75 |
* A CSWAbstractMessages class |
|
76 |
* @throws NotSupportedVersionException |
|
77 |
*/ |
|
78 |
public static CSWAbstractMessages getMessages(String version, CSWAbstractProfile profile) throws NotSupportedVersionException{ |
|
79 |
if ((version != null) && (messages.containsKey(version))){ |
|
80 |
Class clazz = (Class)messages.get(version); |
|
81 |
Class[] parameters = {CSWAbstractProfile.class}; |
|
82 |
Object[] args = {profile}; |
|
83 |
try { |
|
84 |
return (CSWAbstractMessages)clazz.getConstructor(parameters).newInstance(args); |
|
85 |
} catch (Exception e) { |
|
86 |
throw new NotSupportedVersionException(e); |
|
87 |
} |
|
88 |
} |
|
89 |
throw new NotSupportedVersionException(); |
|
90 |
} |
|
91 |
} |
|
0 | 92 |
tags/v2_0_0_Build_2032/applications/appCatalog/src/org/gvsig/catalog/csw/drivers/CSWCatalogServiceDriver.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.csw.drivers; |
|
43 |
import java.net.MalformedURLException; |
|
44 |
import java.net.URI; |
|
45 |
import java.net.URL; |
|
46 |
import java.util.Collection; |
|
47 |
|
|
48 |
import org.gvsig.catalog.csw.drivers.profiles.CSWAbstractProfile; |
|
49 |
import org.gvsig.catalog.csw.messages.CSWAbstractMessages; |
|
50 |
import org.gvsig.catalog.csw.messages.CSWMessagesFactory; |
|
51 |
import org.gvsig.catalog.csw.parsers.CSWCapabilitiesParser; |
|
52 |
import org.gvsig.catalog.csw.parsers.CSWDescribeRecordParser; |
|
53 |
import org.gvsig.catalog.drivers.AbstractCatalogServiceDriver; |
|
54 |
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities; |
|
55 |
import org.gvsig.catalog.drivers.GetRecordsReply; |
|
56 |
import org.gvsig.catalog.exceptions.NotSupportedVersionException; |
|
57 |
import org.gvsig.catalog.metadataxml.XMLNode; |
|
58 |
import org.gvsig.catalog.protocols.HTTPGetProtocol; |
|
59 |
import org.gvsig.catalog.protocols.HTTPPostProtocol; |
|
60 |
import org.gvsig.catalog.querys.CatalogQuery; |
|
61 |
|
|
62 |
import java.util.Hashtable; |
|
63 |
|
|
64 |
|
|
65 |
/** |
|
66 |
* This class implements the CSW protocol. |
|
67 |
* |
|
68 |
* |
|
69 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
70 |
* @see http://portal.opengeospatial.org/files/?artifact_id=5929&version=1 |
|
71 |
*/ |
|
72 |
public abstract class CSWCatalogServiceDriver extends AbstractCatalogServiceDriver { |
|
73 |
protected CSWCapabilities capabilities = null; |
|
74 |
protected CSWAbstractProfile profile = null; |
|
75 |
private static Hashtable servers = new Hashtable(); |
|
76 |
|
|
77 |
/** |
|
78 |
* @return |
|
79 |
* @param url |
|
80 |
* @throws NotSupportedVersionException |
|
81 |
*/ |
|
82 |
public DiscoveryServiceCapabilities getCapabilities(URI uri) throws NotSupportedVersionException { |
|
83 |
URL url = null; |
|
84 |
try { |
|
85 |
url = uri.toURL(); |
|
86 |
} catch (MalformedURLException e) { |
|
87 |
setServerAnswerReady("errorServerNotFound"); |
|
88 |
return null; |
|
89 |
} |
|
90 |
Collection nodes = new java.util.ArrayList(); |
|
91 |
nodes = new HTTPGetProtocol().doQuery(url, CSWAbstractMessages.getHTTPGETCapabilities(), 0); |
|
92 |
CSWCapabilitiesParser parser = new CSWCapabilitiesParser(url, this); |
|
93 |
capabilities = parser.parse((XMLNode)nodes.toArray()[0]); |
|
94 |
//There are servers that need the getCapabilities operation (instead of GetCapabilities) |
|
95 |
if (!(capabilities.isAvailable()) && (capabilities.getException() != null)){ |
|
96 |
CSWException exception = capabilities.getException(); |
|
97 |
if ((exception.getCode().equals(CSWException.CODE_ERROR)) && |
|
98 |
(exception.getSubcode().equals(CSWException.SUBCODE_ERROR))){ |
|
99 |
nodes = new HTTPGetProtocol().doQuery(url, CSWAbstractMessages.getHTTPGETCapabilitiesLower(), 0); |
|
100 |
capabilities = parser.parse((XMLNode)nodes.toArray()[0]); |
|
101 |
} |
|
102 |
} |
|
103 |
//If the version can be retrieved the CSWAbstractMessages object |
|
104 |
//cant be created |
|
105 |
setMessages(uri,url); |
|
106 |
return capabilities; |
|
107 |
} |
|
108 |
|
|
109 |
/* |
|
110 |
* (non-Javadoc) |
|
111 |
* @see es.gva.cit.catalog.drivers.ICatalogServiceDriver#getRecords(java.net.URI, es.gva.cit.catalog.querys.CatalogQuery, int) |
|
112 |
*/ |
|
113 |
public GetRecordsReply getRecords(URI uri, CatalogQuery query, |
|
114 |
int firstRecord) { |
|
115 |
URL url = capabilities.getOperations().getGetRecordsURLPost(); |
|
116 |
setQuery(query); |
|
117 |
Collection nodes = new java.util.ArrayList(); |
|
118 |
try { |
|
119 |
System.out.println(getMessages(uri).getHTTPPostGetRecordsMessage(capabilities, getQuery(), getServerData(), firstRecord)); |
|
120 |
nodes = new HTTPPostProtocol().doQuery(url, |
|
121 |
getMessages(uri).getHTTPPostGetRecordsMessage(capabilities, getQuery(), getServerData(), firstRecord), |
|
122 |
firstRecord); |
|
123 |
} catch (NotSupportedVersionException e) { |
|
124 |
//This exception never will be thrown |
|
125 |
} |
|
126 |
|
|
127 |
if (nodes == null) |
|
128 |
return null; |
|
129 |
|
|
130 |
XMLNode root = (XMLNode)nodes.toArray()[0]; |
|
131 |
int numberOfRecords = getNumberOfRecords(root); |
|
132 |
if (numberOfRecords == -1) { |
|
133 |
return null; |
|
134 |
} |
|
135 |
|
|
136 |
getRecordsReply().setNumRecords(numberOfRecords); |
|
137 |
XMLNode[] results = retrieveResults(root); |
|
138 |
for (int i=0 ; i<results.length ; i++){ |
|
139 |
getRecordsReply().addRecord(uri, results[i]); |
|
140 |
} |
|
141 |
return getRecordsReply(); |
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* Retrieve and parse the results |
|
146 |
* @param root |
|
147 |
* XML root node |
|
148 |
* @return |
|
149 |
*/ |
|
150 |
protected abstract XMLNode[] retrieveResults(XMLNode root); |
|
151 |
|
|
152 |
/** |
|
153 |
* This function returns the number of records that have been retrieved. |
|
154 |
* It Reads a Node value. |
|
155 |
* |
|
156 |
* |
|
157 |
* @return The number of records |
|
158 |
* @param node The answer tree |
|
159 |
*/ |
|
160 |
protected int getNumberOfRecords(XMLNode node) { |
|
161 |
int numberOfRecords = getNumberOfRecords(node,"csw:SearchResults","numberOfRecordsMatched"); |
|
162 |
if (numberOfRecords == -1) |
|
163 |
numberOfRecords = getNumberOfRecords(node,"SearchResults","numberOfRecordsMatched"); |
|
164 |
|
|
165 |
return numberOfRecords; |
|
166 |
} |
|
167 |
|
|
168 |
/* |
|
169 |
* (non-Javadoc) |
|
170 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getDefaultPort() |
|
171 |
*/ |
|
172 |
public int getDefaultPort() { |
|
173 |
return 80; |
|
174 |
} |
|
175 |
|
|
176 |
/* |
|
177 |
* (non-Javadoc) |
|
178 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getDefaultSchema() |
|
179 |
*/ |
|
180 |
public String getDefaultSchema() { |
|
181 |
return "http"; |
|
182 |
} |
|
183 |
|
|
184 |
/* |
|
185 |
* (non-Javadoc) |
|
186 |
* @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#isProtocolSupported(java.net.URI) |
|
187 |
*/ |
|
188 |
public boolean isProtocolSupported(URI uri) { |
|
189 |
return true; |
|
190 |
} |
|
191 |
|
|
192 |
/** |
|
193 |
* @return the class to generate the messages. It depends |
|
194 |
* of the server version |
|
195 |
* @throws NotSupportedVersionException |
|
196 |
*/ |
|
197 |
private CSWAbstractMessages getMessages(URI uri) throws NotSupportedVersionException{ |
|
198 |
if (servers.containsKey(uri)){ |
|
199 |
return (CSWAbstractMessages)servers.get(uri); |
|
200 |
} |
|
201 |
CSWAbstractMessages messages = CSWMessagesFactory.getMessages(capabilities.getVersion(), |
|
202 |
(CSWAbstractProfile)getProfile()); |
|
203 |
servers.put(uri, messages); |
|
204 |
return messages; |
|
205 |
} |
|
206 |
|
|
207 |
/** |
|
208 |
* Create and sets the Messages obejct if it is possible |
|
209 |
* @param uri |
|
210 |
* Server URI |
|
211 |
* @param url |
|
212 |
* Server url |
|
213 |
* @throws NotSupportedVersionException |
|
214 |
*/ |
|
215 |
private void setMessages(URI uri,URL url)throws NotSupportedVersionException{ |
|
216 |
Collection nodes = new java.util.ArrayList(); |
|
217 |
nodes = new HTTPGetProtocol().doQuery(url, CSWAbstractMessages.getHTTPGETDescribeRecord(capabilities.getVersion()), 0); |
|
218 |
CSWDescribeRecordParser parser = new CSWDescribeRecordParser(url, this); |
|
219 |
parser.parse((XMLNode)nodes.toArray()[0]); |
|
220 |
} |
|
221 |
} |
|
0 | 222 |
tags/v2_0_0_Build_2032/applications/appCatalog/src/org/gvsig/catalog/csw/drivers/CSWCapabilities.java | ||
---|---|---|
1 |
package org.gvsig.catalog.csw.drivers; |
|
2 |
|
|
3 |
import java.net.URL; |
|
4 |
|
|
5 |
import org.gvsig.catalog.csw.parsers.CSWSupportedProtocolOperations; |
|
6 |
import org.gvsig.catalog.drivers.CatalogCapabilities; |
|
7 |
|
|
8 |
|
|
9 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
10 |
* |
|
11 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
12 |
* |
|
13 |
* This program is free software; you can redistribute it and/or |
|
14 |
* modify it under the terms of the GNU General Public License |
|
15 |
* as published by the Free Software Foundation; either version 2 |
|
16 |
* of the License, or (at your option) any later version. |
|
17 |
* |
|
18 |
* This program is distributed in the hope that it will be useful, |
|
19 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 |
* GNU General Public License for more details. |
|
22 |
* |
|
23 |
* You should have received a copy of the GNU General Public License |
|
24 |
* along with this program; if not, write to the Free Software |
|
25 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
26 |
* |
|
27 |
* For more information, contact: |
|
28 |
* |
|
29 |
* Generalitat Valenciana |
|
30 |
* Conselleria d'Infraestructures i Transport |
|
31 |
* Av. Blasco Ib??ez, 50 |
|
32 |
* 46010 VALENCIA |
|
33 |
* SPAIN |
|
34 |
* |
|
35 |
* +34 963862235 |
|
36 |
* gvsig@gva.es |
|
37 |
* www.gvsig.gva.es |
|
38 |
* |
|
39 |
* or |
|
40 |
* |
|
41 |
* IVER T.I. S.A |
|
42 |
* Salamanca 50 |
|
43 |
* 46005 Valencia |
|
44 |
* Spain |
|
45 |
* |
|
46 |
* +34 963163400 |
|
47 |
* dac@iver.es |
|
48 |
*/ |
|
49 |
/* CVS MESSAGES: |
|
50 |
* |
|
51 |
* $Id$ |
|
52 |
* $Log$ |
|
53 |
* |
|
54 |
*/ |
|
55 |
/** |
|
56 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
57 |
*/ |
|
58 |
public class CSWCapabilities extends CatalogCapabilities { |
|
59 |
private CSWSupportedProtocolOperations operations = null; |
|
60 |
private String responseHandler = null; |
|
61 |
private String hopCount = null; |
|
62 |
private String distributedSearch = null; |
|
63 |
private String constraint = null; |
|
64 |
private String[] CONSTRAINTLANGUAGE = null; |
|
65 |
private String[] elementSetName = null; |
|
66 |
private String[] typeNames = null; |
|
67 |
private String[] resultType = null; |
|
68 |
private String[] NAMESPACE = null; |
|
69 |
private String[] outputFormat = null; |
|
70 |
private String[] outputSchema = null; |
|
71 |
private CSWException exception = null; |
|
72 |
|
|
73 |
/** |
|
74 |
* @return the exception |
|
75 |
*/ |
|
76 |
public CSWException getException() { |
|
77 |
return exception; |
|
78 |
} |
|
79 |
|
|
80 |
/** |
|
81 |
* @param exception the exception to set |
|
82 |
*/ |
|
83 |
public void setException(CSWException exception) { |
|
84 |
this.exception = exception; |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* @return the outputSchema |
Also available in: Unified diff