Revision 55

View differences:

org.gvsig.catalog/branches/org.gvsig.catalog-CSW2.0.2/org.gvsig.catalog/org.gvsig.catalog.lib/src/test/java/org/gvsig/catalog/catalog/drivers/ExampleNewDriver.java
1
package org.gvsig.catalog.catalog.drivers;
2

  
3
import java.net.URI;
4

  
5
import org.gvsig.catalog.CatalogLocator;
6
import org.gvsig.catalog.CatalogManager;
7
import org.gvsig.catalog.drivers.AbstractCatalogServiceDriver;
8
import org.gvsig.catalog.drivers.CatalogCapabilities;
9
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities;
10
import org.gvsig.catalog.drivers.GetRecordsReply;
11
import org.gvsig.catalog.querys.CatalogQuery;
12
import org.gvsig.catalog.schemas.Record;
13
import org.gvsig.catalog.ui.search.SearchAditionalPropertiesPanel;
14

  
15

  
16
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
17
 *
18
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
19
 *
20
 * This program is free software; you can redistribute it and/or
21
 * modify it under the terms of the GNU General Public License
22
 * as published by the Free Software Foundation; either version 2
23
 * of the License, or (at your option) any later version.
24
 *
25
 * This program is distributed in the hope that it will be useful,
26
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
 * GNU General Public License for more details.
29
 *
30
 * You should have received a copy of the GNU General Public License
31
 * along with this program; if not, write to the Free Software
32
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
33
 *
34
 * For more information, contact:
35
 *
36
 *  Generalitat Valenciana
37
 *   Conselleria d'Infraestructures i Transport
38
 *   Av. Blasco Ib??ez, 50
39
 *   46010 VALENCIA
40
 *   SPAIN
41
 *
42
 *      +34 963862235
43
 *   gvsig@gva.es
44
 *      www.gvsig.gva.es
45
 *
46
 *    or
47
 *
48
 *   IVER T.I. S.A
49
 *   Salamanca 50
50
 *   46005 Valencia
51
 *   Spain
52
 *
53
 *   +34 963163400
54
 *   dac@iver.es
55
 */
56
/* CVS MESSAGES:
57
 *
58
 * $Id: ExampleNewDriver.java 537 2007-07-26 11:21:10Z jpiera $
59
 * $Log$
60
 * Revision 1.1.2.1  2007/07/13 12:00:35  jorpiell
61
 * Add the posibility to add a new panel
62
 *
63
 *
64
 */
65
/**
66
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
67
 */
68
public class ExampleNewDriver extends AbstractCatalogServiceDriver {
69
	private static final CatalogManager catalogManager = CatalogLocator.getCatalogManager();
70
	
71
	/*
72
	 * (non-Javadoc)
73
	 * @see es.gva.cit.catalogClient.drivers.IDiscoveryServiceDriver#getCapabilities(java.net.URI)
74
	 */
75
	public DiscoveryServiceCapabilities getCapabilities(URI uri) {
76
		return new CatalogCapabilities();
77
	}
78

  
79
	/*
80
	 * (non-Javadoc)
81
	 * @see es.gva.cit.catalog.drivers.ICatalogServiceDriver#getRecords(java.net.URI, es.gva.cit.catalog.querys.CatalogQuery, int)
82
	 */
83
	public GetRecordsReply getRecords(URI uri, CatalogQuery query,
84
			int firstRecord) {
85
		GetRecordsReply reply = new GetRecordsReply(1);
86
		Record record = catalogManager.createRecord(uri, null);
87
		record.setTitle("Record example");
88
		record.setAbstract_("Just for testing");
89
		reply.addRecord(record);
90
		return reply;
91
	}
92

  
93
	/*
94
	 * (non-Javadoc)
95
	 * @see es.gva.cit.catalog.drivers.IDiscoveryServiceDriver#getServiceName()
96
	 */
97
	public String getServiceName() {
98
		return "My catalog service";
99
	}
100

  
101
	/*
102
	 * (non-Javadoc)
103
	 * @see es.gva.cit.gazetteer.drivers.IGazetteerServiceDriver#getAditionalSearchPanel()
104
	 */
105
	public SearchAditionalPropertiesPanel getAditionalSearchPanel(){
106
		return new ExampleNewPanel();
107
	}
108

  
109

  
110

  
111

  
112
}
0 113

  
org.gvsig.catalog/branches/org.gvsig.catalog-CSW2.0.2/org.gvsig.catalog/org.gvsig.catalog.lib/src/test/java/org/gvsig/catalog/catalog/drivers/ExampleNewDriverTest.java
1
package org.gvsig.catalog.catalog.drivers;
2

  
3
import javax.swing.UIManager;
4
import javax.swing.UnsupportedLookAndFeelException;
5

  
6
import org.gvsig.catalog.CatalogLocator;
7
import org.gvsig.catalog.ui.serverconnect.ServerConnectDialog;
8
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
9

  
10

  
11
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
12
 *
13
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
 *
15
 * This program is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU General Public License
17
 * as published by the Free Software Foundation; either version 2
18
 * of the License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
 *
29
 * For more information, contact:
30
 *
31
 *  Generalitat Valenciana
32
 *   Conselleria d'Infraestructures i Transport
33
 *   Av. Blasco Ib??ez, 50
34
 *   46010 VALENCIA
35
 *   SPAIN
36
 *
37
 *      +34 963862235
38
 *   gvsig@gva.es
39
 *      www.gvsig.gva.es
40
 *
41
 *    or
42
 *
43
 *   IVER T.I. S.A
44
 *   Salamanca 50
45
 *   46005 Valencia
46
 *   Spain
47
 *
48
 *   +34 963163400
49
 *   dac@iver.es
50
 */
51
/* CVS MESSAGES:
52
 *
53
 * $Id: ExampleNewDriverTest.java 512 2007-07-24 11:25:43Z jorpiell $
54
 * $Log$
55
 * Revision 1.1.2.2  2007/07/24 11:25:42  jorpiell
56
 * The registers has been refactorized
57
 *
58
 * Revision 1.1.2.1  2007/07/13 12:00:35  jorpiell
59
 * Add the posibility to add a new panel
60
 *
61
 *
62
 */
63
/**
64
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
65
 */
66
public class ExampleNewDriverTest {
67

  
68
	/**
69
	 * @param args
70
	 */
71
	public static void main(String[] args) {
72
		new DefaultLibrariesInitializer().fullInitialize();
73
//		DefaultCatalogLibrary library = new DefaultCatalogLibrary();
74
//		library.initialize();
75
//		library.postInitialize();
76

  
77
		CatalogLocator.getCatalogManager().register("My catalog service", ExampleNewDriver.class);
78
		//Get the currently installed look and feel
79
		UIManager.getLookAndFeel();
80
		// Install a different look and feel; specifically, the Windows look and feel
81
		try {
82
			UIManager.setLookAndFeel(
83
					"com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
84
		} catch (InstantiationException e) {
85
		} catch (ClassNotFoundException e) {
86
		} catch (UnsupportedLookAndFeelException e) {
87
		} catch (IllegalAccessException e) {
88
		}
89

  
90
		new ServerConnectDialog();
91
	}
92

  
93
}
0 94

  
org.gvsig.catalog/branches/org.gvsig.catalog-CSW2.0.2/org.gvsig.catalog/org.gvsig.catalog.lib/src/test/java/org/gvsig/catalog/catalog/drivers/ExampleNewPanel.java
1
package org.gvsig.catalog.catalog.drivers;
2

  
3
import java.util.Properties;
4

  
5
import javax.swing.JLabel;
6
import javax.swing.JTextField;
7

  
8
import org.gvsig.catalog.ui.search.SearchAditionalPropertiesPanel;
9

  
10

  
11
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
12
 *
13
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
 *
15
 * This program is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU General Public License
17
 * as published by the Free Software Foundation; either version 2
18
 * of the License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
 *
29
 * For more information, contact:
30
 *
31
 *  Generalitat Valenciana
32
 *   Conselleria d'Infraestructures i Transport
33
 *   Av. Blasco Ib??ez, 50
34
 *   46010 VALENCIA
35
 *   SPAIN
36
 *
37
 *      +34 963862235
38
 *   gvsig@gva.es
39
 *      www.gvsig.gva.es
40
 *
41
 *    or
42
 *
43
 *   IVER T.I. S.A
44
 *   Salamanca 50
45
 *   46005 Valencia
46
 *   Spain
47
 *
48
 *   +34 963163400
49
 *   dac@iver.es
50
 */
51
/* CVS MESSAGES:
52
 *
53
 * $Id: ExampleNewPanel.java 537 2007-07-26 11:21:10Z jpiera $
54
 * $Log$
55
 * Revision 1.1.2.1  2007/07/13 12:00:35  jorpiell
56
 * Add the posibility to add a new panel
57
 *
58
 *
59
 */
60
/**
61
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
62
 */
63
public class ExampleNewPanel extends SearchAditionalPropertiesPanel{
64
	JLabel label = null;
65
	JTextField text = null;
66
	
67
	public ExampleNewPanel(){
68
		label = new JLabel();
69
		text = new JTextField();		
70
		setLayout(new java.awt.BorderLayout());
71
		label.setText("Label");
72
		add(label, java.awt.BorderLayout.WEST);		
73
		add(text, java.awt.BorderLayout.CENTER);
74
	}
75
	
76
	/*
77
	 * (non-Javadoc)
78
	 * @see es.gva.cit.gazetteer.ui.search.SearchAditionalPropertiesPanel#getProperties()
79
	 */
80
	public Properties getProperties() {
81
		Properties properties = new Properties();
82
		properties.put("PROP1", text.getText());
83
		return properties;
84
	}
85

  
86
}
0 87

  
org.gvsig.catalog/branches/org.gvsig.catalog-CSW2.0.2/org.gvsig.catalog/org.gvsig.catalog.lib/src/test/java/org/gvsig/catalog/catalog/utils/URIUtilsTest.java
1
package org.gvsig.catalog.catalog.utils;
2

  
3
import java.net.URI;
4
import java.net.URISyntaxException;
5

  
6
import junit.framework.TestCase;
7

  
8
import org.gvsig.catalog.utils.URIUtils;
9

  
10
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11
 *
12
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
13
 *
14
 * This program is free software; you can redistribute it and/or
15
 * modify it under the terms of the GNU General Public License
16
 * as published by the Free Software Foundation; either version 2
17
 * of the License, or (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program; if not, write to the Free Software
26
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
27
 *
28
 * For more information, contact:
29
 *
30
 *  Generalitat Valenciana
31
 *   Conselleria d'Infraestructures i Transport
32
 *   Av. Blasco Ib??ez, 50
33
 *   46010 VALENCIA
34
 *   SPAIN
35
 *
36
 *      +34 963862235
37
 *   gvsig@gva.es
38
 *      www.gvsig.gva.es
39
 *
40
 *    or
41
 *
42
 *   IVER T.I. S.A
43
 *   Salamanca 50
44
 *   46005 Valencia
45
 *   Spain
46
 *
47
 *   +34 963163400
48
 *   dac@iver.es
49
 */
50
/* CVS MESSAGES:
51
 *
52
 * $Id: URIUtilsTest.java,v 1.1.2.1 2007/07/10 11:18:04 jorpiell Exp $
53
 * $Log: URIUtilsTest.java,v $
54
 * Revision 1.1.2.1  2007/07/10 11:18:04  jorpiell
55
 * Added the registers
56
 *
57
 *
58
 */
59
/**
60
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
61
 */
62
public class URIUtilsTest extends TestCase {
63
	
64
	public void test1() throws URISyntaxException{
65
		URI uri = URIUtils.createUri("http://www.upv.es", "http", 80);	
66
		assertEquals(uri.getHost(), "www.upv.es");
67
		assertEquals(uri.getScheme(), "http");
68
		assertEquals(uri.getPort(), 80);
69
		assertEquals(uri.getPath(), "");
70
	}
71
	
72
	public void test2() throws URISyntaxException{
73
		URI uri = URIUtils.createUri("www.upv.es", "http", 80);	
74
		assertEquals(uri.getHost(), "www.upv.es");
75
		assertEquals(uri.getScheme(), "http");
76
		assertEquals(uri.getPort(), 80);
77
		assertEquals(uri.getPath(), "");
78
	}
79
	
80
	public void test3() throws URISyntaxException{
81
		URI uri = URIUtils.createUri("www.upv.es", "z3950", 2100);	
82
		assertEquals(uri.getHost(), "www.upv.es");
83
		assertEquals(uri.getScheme(), "z3950");
84
		assertEquals(uri.getPort(), 2100);
85
		assertEquals(uri.getPath(), "");
86
	}
87
	
88
	public void test4() throws URISyntaxException{
89
		URI uri = URIUtils.createUri("http://193.144.250.29/webservices/services/IDEC_GeoServeisPort", "http", 80);	
90
		assertEquals(uri.getHost(), "193.144.250.29");
91
		assertEquals(uri.getScheme(), "http");
92
		assertEquals(uri.getPort(), 80);
93
		assertEquals(uri.getPath(), "/webservices/services/IDEC_GeoServeisPort");
94
	}
95
}
0 96

  
org.gvsig.catalog/branches/org.gvsig.catalog-CSW2.0.2/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/csw/parsers/CSWExceptionParser.java
1
package org.gvsig.catalog.csw.parsers;
2

  
3
import org.gvsig.catalog.csw.drivers.CSWException;
4
import org.gvsig.catalog.metadataxml.XMLNode;
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 CSWExceptionParser {
56

  
57
	public static CSWException parse(XMLNode node){
58
		CSWException exception = new CSWException();
59
		XMLNode exNode = node.searchNode(CSWConstants.OWSEXCEPTION);
60
		if (exNode != null){
61
			exception = new CSWException();
62
			exception.setCode(exNode.searchAtribute(CSWConstants.OWSEXCEPTIONCODE));
63
			exception.setSubcode(exNode.searchAtribute(CSWConstants.OWSEXCEPTIONSUBCODE));
64
			exception.setReason(exNode.searchAtribute(CSWConstants.OWSEXCEPTIONREASON));
65
			exception.setAbstract(exNode.getText());
66
		}
67
		return exception;
68
	}
69
}
0 70

  
org.gvsig.catalog/branches/org.gvsig.catalog-CSW2.0.2/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/csw/parsers/CSWSupportedProtocolOperations.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.parsers;
43

  
44
import java.net.MalformedURLException;
45
import java.net.URL;
46
import java.util.HashMap;
47

  
48
/**
49
 * This class is use like a structure. It saves what protocol is
50
 * supported by each CSW operation. Each attribute is an array that
51
 * can contain next values: GET, POST or SOAP
52
 * 
53
 * 
54
 * @author Jorge Piera Llodra (piera_jor@gva.es)
55
 */
56
public class CSWSupportedProtocolOperations {
57
	private HashMap getCapabilities = null;;
58
	private HashMap describeRecords = null;
59
	private HashMap getDomain = null;
60
	private HashMap getRecords = null;
61
	private HashMap getRecordsById = null;
62
	private HashMap transaction = null;
63
	private HashMap harvest = null;
64
	private HashMap getExtrinsicContent = null;
65
	private URL url = null;
66

  
67
	public CSWSupportedProtocolOperations(URL url){
68
		this.url = url;
69
		getCapabilities = new HashMap();
70
		describeRecords = new HashMap();
71
		getDomain = new HashMap();
72
		getRecords = new HashMap();
73
		getRecordsById = new HashMap();
74
		transaction = new HashMap();
75
		harvest = new HashMap();
76
		getExtrinsicContent = new HashMap();
77
	}	
78
	
79
	/**
80
	 * Add a new URL
81
	 * @param operation
82
	 * Table of the opeartion
83
	 * @param protocol
84
	 * Protocol
85
	 * @param sUrl
86
	 * URL to parse
87
	 * @throws MalformedURLException 
88
	 */
89
	private void addOperation(HashMap operation, String protocol, String sUrl) throws MalformedURLException{
90
		URL url = new URL(sUrl);
91
		operation.put(protocol, url);
92
	}
93
	
94
	/**
95
	 * @return Returns the describeRecords.
96
	 */
97
	public HashMap getDescribeRecords() {        
98
		return describeRecords;
99
	} 
100

  
101
	/**
102
	 * @param describeRecords The describeRecords to set.
103
	 * @throws MalformedURLException 
104
	 */
105
	public void addDescribeRecord(String protocol, String url) throws MalformedURLException {        
106
		addOperation(describeRecords,protocol, url);
107
	} 
108

  
109
	/**
110
	 * @return Returns the getCapabilities.
111
	 */
112
	public HashMap getGetCapabilities() {        
113
		return getCapabilities;
114
	} 
115

  
116
	/**
117
	 * @param getCapabilities The getCapabilities to set.
118
	 */
119
	public void addGetCapabilities(String protocol, String url) throws MalformedURLException {        
120
		addOperation(getCapabilities,protocol, url);
121
	} 
122

  
123
	/**
124
	 * @return Returns the getDomain.
125
	 */
126
	public HashMap getGetDomain() {        
127
		return getDomain;
128
	} 
129

  
130
	/**
131
	 * @param getDomain The getDomain to set.
132
	 */
133
	public void addGetDomain(String protocol, String url) throws MalformedURLException {        
134
		addOperation(getDomain,protocol, url);
135
	} 
136
	
137
	/**
138
	 * @return Returns the getRecords.
139
	 */
140
	public HashMap getGetRecords() {        
141
		return getRecords;
142
	} 
143

  
144
	/**
145
	 * @param getRecords The getRecords to set.
146
	 */
147
	public void addGetRecords(String protocol, String url) throws MalformedURLException {        
148
		addOperation(getRecords,protocol, url);
149
	} 
150

  
151
	/**
152
	 * @return Returns the getRecordsById.
153
	 */
154
	public HashMap getGetRecordsById() {        
155
		return getRecordsById;
156
	} 
157

  
158
	/**
159
	 * @param getRecordsById The getRecordsById to set.
160
	 */
161
	public void addGetRecordsById(String protocol, String url) throws MalformedURLException {        
162
		addOperation(getRecordsById,protocol, url);
163
	} 
164
	/**
165
	 * @return Returns the harvest.
166
	 */
167
	public HashMap getHarvest() {        
168
		return harvest;
169
	} 
170

  
171
	/**
172
	 * @param harvest The harvest to set.
173
	 */
174
	public void addHarvest(String protocol, String url) throws MalformedURLException {        
175
		addOperation(harvest,protocol, url);
176
	} 
177

  
178
	/**
179
	 * @return Returns the transaction.
180
	 */
181
	public HashMap getTransaction() {        
182
		return transaction;
183
	} 
184

  
185
	/**
186
	 * @param transaction The transaction to set.
187
	 */
188
	public void setTransaction(String protocol, String url) throws MalformedURLException {        
189
		addOperation(transaction,protocol, url);
190
	}
191

  
192
	/**
193
	 * @return the URL for the getRecords operation
194
	 * using the HTTP Post method
195
	 */
196
	public URL getGetRecordsURLPost() {
197
		Object obj = getRecords.get(CSWConstants.POST);
198
		if (obj != null){
199
			return (URL)obj;
200
		}
201
		return url;
202
	}
203

  
204
	/**
205
	 * @param getCapabilities the getCapabilities to set
206
	 */
207
	public void setGetCapabilities(HashMap getCapabilities) {
208
		this.getCapabilities = getCapabilities;
209
	}
210

  
211
	/**
212
	 * @param describeRecords the describeRecords to set
213
	 */
214
	public void setDescribeRecords(HashMap describeRecords) {
215
		this.describeRecords = describeRecords;
216
	}
217

  
218
	/**
219
	 * @param getDomain the getDomain to set
220
	 */
221
	public void setGetDomain(HashMap getDomain) {
222
		this.getDomain = getDomain;
223
	}
224

  
225
	/**
226
	 * @param getRecords the getRecords to set
227
	 */
228
	public void setGetRecords(HashMap getRecords) {
229
		this.getRecords = getRecords;
230
	}
231

  
232
	/**
233
	 * @param getRecordsById the getRecordsById to set
234
	 */
235
	public void setGetRecordsById(HashMap getRecordsById) {
236
		this.getRecordsById = getRecordsById;
237
	}
238

  
239
	/**
240
	 * @param transaction the transaction to set
241
	 */
242
	public void setTransaction(HashMap transaction) {
243
		this.transaction = transaction;
244
	}
245

  
246
	/**
247
	 * @param harvest the harvest to set
248
	 */
249
	public void setHarvest(HashMap harvest) {
250
		this.harvest = harvest;
251
	}
252

  
253
	/**
254
	 * @param url the url to set
255
	 */
256
	public void setUrl(URL url) {
257
		this.url = url;
258
	}
259

  
260
	/**
261
	 * @return the getExtrinsicContent
262
	 */
263
	public HashMap getGetExtrinsicContent() {
264
		return getExtrinsicContent;
265
	}
266

  
267
	/**
268
	 * @param getExtrinsicContent the getExtrinsicContent to set
269
	 */
270
	public void setGetExtrinsicContent(HashMap getExtrinsicContent) {
271
		this.getExtrinsicContent = getExtrinsicContent;
272
	} 
273
	
274
	/**
275
	 * @param getDomain The getDomain to set.
276
	 */
277
	public void addGetExtrinsicContent(String protocol, String url) throws MalformedURLException {        
278
		addOperation(getExtrinsicContent,protocol, url);
279
	} 
280
}
0 281

  
org.gvsig.catalog/branches/org.gvsig.catalog-CSW2.0.2/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/csw/parsers/CSWConstants.java
1
package org.gvsig.catalog.csw.parsers;
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
/* CVS MESSAGES:
43
 *
44
 * $Id$
45
 * $Log$
46
 *
47
 */
48
/**
49
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
50
 */
51
public class CSWConstants {
52
	public static final String VERSION = "version";
53
			
54
	//Capabilities 0.9.0
55
	public static final String VERSION_0_9_0 = "0.9.0";
56
	public static final String CONSTRAINT_VERSION_0_9_0 = "1.0.20";
57
	
58
	//Capabilities 2.0.0
59
	public static final String VERSION_2_0_0 = "2.0.0";
60
	public static final String CONSTRAINT_VERSION_2_0_0 = "1.0.0";
61
	
62
	//Capabilities 2.0.1
63
	public static final String VERSION_2_0_1 = "2.0.1";
64
	public static final String CONSTRAINT_VERSION_2_0_1 = "1.1.0";
65
	public static final String SERVICE_IDENTIFICATION= "ServiceIdentification";
66
	public static final String SERVICE_PROVIDER = "ServiceProvider";
67
	public static final String OPERATIONS_METADATA= "OperationsMetadata";
68
	public static final String SERVICE_TYPE_VERSION = "ServiceTypeVersion";
69
	
70
	//Capabilities 2.0.2
71
	public static final String VERSION_2_0_2 = "2.0.2";
72
	public static final String CONSTRAINT_VERSION_2_0_2 = "1.1.0";
73
	
74
	//Service identification
75
	public static final String TITLE = "Title";	
76
	public static final String ABSTRACT = "Abstract";
77
	
78
	//Common tags
79
	public static final String OPERATION = "Operation";
80
	public static final String PARAMETER = "Parameter"; 
81
	public static final String PARAMETER_VALUE = "Value";
82
	public static final String PARAMETER_NAME = "name";
83
	public static final String DEFAULTVALUE = "DefaultValue";
84
	public static final String TYPENAME = "typeName";
85
	public static final String TYPENAMES = "typeNames";
86
	public static final String OUTPUTFORMAT = "outputFormat";
87
	public static final String OUTPUTSCHEMA = "outputSchema";
88
	public static final String RESULTTYPE = "resultType";
89
	public static final String CONSTRAINTLANGUAGE = "CONSTRAINTLANGUAGE";
90
	public static final String FILTER = "FILTER";
91
	public static final String TEXT_XML = "text/xml";
92
	public static final String APPLICATION_XML = "application/xml";
93
	public static final String ELEMENTSETNAME = "ElementSetName";
94
	public static final String ELEMENTNAME = "ElementName";
95
	public static final String FULL = "full";
96
	public static final String CONSTRAINT = "Constraint";
97
	
98
	//Protocols
99
	public static final String DCP = "DCP";
100
	public static final String HTTP = "HTTP";
101
	public static final String GET = "Get";
102
	public static final String POST = "Post";
103
	
104
	//Operations
105
	public static final String OPERATION_GETCAPABILITIES = "GetCapabilities";
106
	//Some server only support the getCapabilities request (started with lower case)
107
	public static final String OPERATION_GETCAPABILITIESToLOWER = "getCapabilities";
108
	public static final String OPERATION_DESCRIBERECORD = "DescribeRecord";
109
	public static final String OPERATION_GETDOMAIN = "GetDomain";
110
	public static final String OPERATION_GETRECORDS = "GetRecords";
111
	public static final String OPERATION_GETRECORDSBYID = "GetRecordsById";
112
	public static final String OPERATION_HARVEST = "Harvest";	
113
	public static final String OPERATION_TRANSACTION = "Transaction";
114
	
115
	public static final String CSW_NAMESPACE = "csw";
116
	public static final String CSW_NAMESPACE_URI = "http://www.opengis.net/cat/csw";
117
	public static final String OGC_NAMESPACE = "ogc";
118
	public static final String OGC_NAMESPACE_URI = "http://www.opengis.net/ogc";
119
	public static final String GML_NAMESPACE = "gml";
120
	public static final String GML_NAMESPACE_URI = "http://www.opengis.net/gml";
121
	public static final String CSW_GET_RECORDS = "GetRecords";
122
	public static final String CSW_SERVICE = "service";
123
	public static final String CSW_VERSION = "version";
124
	public static final String CSW_START_POSITION = "startPosition";
125
	public static final String CSW_MAX_RECORDS = "maxRecords";
126
	public static final String CSW_OUTPUTFORMAT = "outputFormat";
127
	public static final String CSW_OUTPUTSCHEMA = "outputSchema";
128
	public static final String QUERY = "Query";
129
	public static final String SEARCH_RESULTS = "SearchResults";
130
	public static final String XLINK_HREF = "xlink:href";
131
	
132
	//Exceptions
133
	public static final String OWSEXCEPTION = "OWSException";
134
	public static final String OWSEXCEPTIONCODE = "code";
135
	public static final String OWSEXCEPTIONSUBCODE = "subcode";
136
	public static final String OWSEXCEPTIONREASON = "reason";
137
	
138
	//ebRIM
139
	public static final String REQUEST = "request";
140
	public static final String EXTRISIC_CONTENT = "getExtrinsicContent";
141
	public static final String ID = "id";
142
	public static final String HOME = "home";
143
	
144
	//Describe Record
145
	public static final String SCHEMA_COMPONENT = "SchemaComponent";
146
	public static final String SCHEMA = "schema";
147
	
148
	//Error codes
149
	public static final String SERVICE_EXPECTION_REPORT = "ServiceExceptionReport";
150
}
0 151

  
org.gvsig.catalog/branches/org.gvsig.catalog-CSW2.0.2/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/csw/parsers/CSWDescribeRecordParser.java
1
package org.gvsig.catalog.csw.parsers;
2

  
3
import java.net.URL;
4

  
5
import org.gvsig.catalog.csw.drivers.CSWCapabilities;
6
import org.gvsig.catalog.csw.drivers.CSWCatalogServiceDriver;
7
import org.gvsig.catalog.metadataxml.XMLNode;
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 CSWDescribeRecordParser {
59
	private URL url = null;
60
	private CSWCatalogServiceDriver driver = null;
61
	private CSWCapabilities capabilities = null; 
62
	
63
	public CSWDescribeRecordParser(URL url, CSWCatalogServiceDriver driver) {
64
		this.url = url;
65
		this.driver = driver;
66
	}
67

  
68
	/*
69
	 * (non-Javadoc)
70
	 * @see es.gva.cit.catalogClient.csw.parsers.CSWAbstractCapabilitiesParser#parse(es.gva.cit.catalogClient.metadataxml.XMLNode)
71
	 */
72
	public void parse(XMLNode node) {
73
		parseSchemaComponent(node.searchNode(CSWConstants.SCHEMA_COMPONENT));
74
		
75
	}
76
	
77
	/**
78
	 * Parses the SchemaComponent tag
79
	 * @param node
80
	 */
81
	private void parseSchemaComponent(XMLNode node){
82
		if (node == null){
83
			return;
84
		}
85
		XMLNode schema = node.searchNode(CSWConstants.SCHEMA);
86
	}
87
}
0 88

  
org.gvsig.catalog/branches/org.gvsig.catalog-CSW2.0.2/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/csw/parsers/CSWCapabilitiesParser.java
1
package org.gvsig.catalog.csw.parsers;
2

  
3
import java.net.MalformedURLException;
4
import java.net.URL;
5
import java.util.HashMap;
6

  
7
import org.gvsig.catalog.csw.drivers.CSWCapabilities;
8
import org.gvsig.catalog.csw.drivers.CSWCatalogServiceDriver;
9
import org.gvsig.catalog.metadataxml.XMLNode;
10
import org.gvsig.catalog.metadataxml.XMLTree;
11
import org.gvsig.catalog.utils.Strings;
12

  
13

  
14

  
15
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
16
 *
17
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
18
 *
19
 * This program is free software; you can redistribute it and/or
20
 * modify it under the terms of the GNU General Public License
21
 * as published by the Free Software Foundation; either version 2
22
 * of the License, or (at your option) any later version.
23
 *
24
 * This program is distributed in the hope that it will be useful,
25
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
 * GNU General Public License for more details.
28
 *
29
 * You should have received a copy of the GNU General Public License
30
 * along with this program; if not, write to the Free Software
31
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
32
 *
33
 * For more information, contact:
34
 *
35
 *  Generalitat Valenciana
36
 *   Conselleria d'Infraestructures i Transport
37
 *   Av. Blasco Ib??ez, 50
38
 *   46010 VALENCIA
39
 *   SPAIN
40
 *
41
 *      +34 963862235
42
 *   gvsig@gva.es
43
 *      www.gvsig.gva.es
44
 *
45
 *    or
46
 *
47
 *   IVER T.I. S.A
48
 *   Salamanca 50
49
 *   46005 Valencia
50
 *   Spain
51
 *
52
 *   +34 963163400
53
 *   dac@iver.es
54
 */
55
/* CVS MESSAGES:
56
 *
57
 * $Id: CSWCapabilitiesParserv2_0_1.java,v 1.1.2.1 2007/07/23 07:14:24 jorpiell Exp $
58
 * $Log: CSWCapabilitiesParserv2_0_1.java,v $
59
 * Revision 1.1.2.1  2007/07/23 07:14:24  jorpiell
60
 * Catalog refactoring
61
 *
62
 *
63
 */
64
/**
65
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
66
 */
67
public class CSWCapabilitiesParser{
68
	private URL url = null;
69
	private CSWCatalogServiceDriver driver = null;
70
	private CSWCapabilities capabilities = null; 
71
	
72
	public CSWCapabilitiesParser(URL url, CSWCatalogServiceDriver driver) {
73
		this.url = url;
74
		this.driver = driver;
75
	}
76

  
77
	/*
78
	 * (non-Javadoc)
79
	 * @see es.gva.cit.catalogClient.csw.parsers.CSWAbstractCapabilitiesParser#parse(es.gva.cit.catalogClient.metadataxml.XMLNode)
80
	 */
81
	public CSWCapabilities parse(XMLNode node) {		
82
		capabilities = new CSWCapabilities(url);
83
		if (node.getName().endsWith(CSWConstants.SERVICE_EXPECTION_REPORT)){
84
			capabilities.setException(CSWExceptionParser.parse(node));
85
			capabilities.setAvailable(false);
86
			capabilities.setServerMessage(node.getXmlTree());
87
		}
88
		parseHeaderAttributes(node);
89
		parseServiceIdentification(node.searchNode(CSWConstants.SERVICE_IDENTIFICATION));
90
		parseServiceProvider(node.searchNode(CSWConstants.SERVICE_PROVIDER));
91
		parseOperationsMetadata(node.searchNode(CSWConstants.OPERATIONS_METADATA));
92
		return capabilities;
93
	}
94

  
95
	/**
96
	 * Parse the header attributes
97
	 */
98
	private void parseHeaderAttributes(XMLNode node){
99
		capabilities.setVersion(node.searchAtribute(CSWConstants.VERSION));
100
	}
101
	
102
	/**
103
	 * Parse the service identification tag
104
	 * @param node
105
	 */
106
	private void parseServiceIdentification(XMLNode node){
107
		if (node != null){		
108
			XMLNode title = node.searchNode(CSWConstants.TITLE);
109
			XMLNode abstract_ = node.searchNode(CSWConstants.ABSTRACT);
110
			String sTitle = "";
111
			if (title != null){
112
				sTitle = title.getText() + "\n";
113
			}
114
			if (abstract_ != null){
115
				sTitle = sTitle + abstract_.getText();
116
			}
117
			driver.setServerAnswerReady(sTitle);
118
			capabilities.setServerMessage(sTitle);
119
			XMLNode version = node.searchNode(CSWConstants.SERVICE_TYPE_VERSION);
120
			if (version != null){
121
				capabilities.setVersion(version.getText());
122
			}
123
			
124
		}
125
	}
126

  
127
	/**
128
	 * Parse the service provider tag
129
	 * @param node
130
	 */
131
	private void parseServiceProvider(XMLNode node){
132
		if (node != null){		
133

  
134
		}
135
	}
136

  
137
	/**
138
	 * Parse the operations metadata tag
139
	 * @param node
140
	 */
141
	private void parseOperationsMetadata(XMLNode node){
142
		if (node != null){		
143
			XMLNode[] operations = XMLTree.searchMultipleNode(node, CSWConstants.OPERATION);
144
			for (int i = 0; i < operations.length; i++) {
145
				String sOperation = XMLTree.searchAtribute(operations[i], "name");
146
				
147
				if (sOperation.equals(CSWConstants.OPERATION_GETCAPABILITIES)){
148
					parseCapabilities(operations[i]);
149
				}
150
				if (sOperation.equals(CSWConstants.OPERATION_DESCRIBERECORD)){
151
					parseDescribeRecord(operations[i]);
152
				}
153
				if (sOperation.equals(CSWConstants.OPERATION_GETDOMAIN)){
154
					parseGetDomain(operations[i]);
155
				}
156
				if (sOperation.equals(CSWConstants.OPERATION_GETRECORDS)){
157
					parseGetRecords(operations[i]);
158
				}
159
				if (sOperation.equals(CSWConstants.OPERATION_GETRECORDSBYID)){
160
					parseGetRecordsByID(operations[i]);
161
				}
162
				if (sOperation.equals(CSWConstants.OPERATION_TRANSACTION)){
163
					parseTransaction(operations[i]);
164
				}
165
				if (sOperation.equals(CSWConstants.OPERATION_HARVEST)){
166
					parseHarvest(operations[i]);
167
				}
168
			} 
169
			//Patch for the Galdos severs
170
			if (capabilities.getVersion().equals(CSWConstants.VERSION_0_9_0)){
171
				capabilities.getOperations().getGetExtrinsicContent().put(
172
						CSWConstants.GET,url);
173
			}
174
		}
175
	}
176
	
177
	/**
178
	 * Parse the capabilitioes operation
179
	 * @param node
180
	 */
181
	private void parseCapabilities(XMLNode node) {        
182
		capabilities.getOperations().setGetCapabilities(getSupportedProtocols(node));
183
		XMLNode[] parameters = XMLTree.searchMultipleNode(node, CSWConstants.PARAMETER);
184
		for (int i = 0; i < parameters.length; i++) {
185
			String sParameter = XMLTree.searchAtribute(parameters[i], CSWConstants.PARAMETER_NAME);
186
			String[] values = XMLTree.searchMultipleNodeValue(parameters[i], CSWConstants.PARAMETER_VALUE);
187
			if ((sParameter.toLowerCase().equals(CSWConstants.VERSION)) &&
188
					(values != null) &&
189
					values.length == 1){
190
				capabilities.setVersion(values[0]);
191
			}
192
		}
193
	} 
194

  
195
	/**
196
 	 * It parses the describe record operation
197
	 * @param node 
198
	 * @param prefix 
199
	 */
200
	private void parseDescribeRecord(XMLNode node) {        
201
		capabilities.getOperations().setDescribeRecords(getSupportedProtocols(node));
202
		XMLNode[] parameters = XMLTree.searchMultipleNode(node, CSWConstants.PARAMETER);
203
		for (int i = 0; i < parameters.length; i++) {
204
			String sParameter = XMLTree.searchAtribute(parameters[i], CSWConstants.PARAMETER_NAME);
205
			String[] values = XMLTree.searchMultipleNodeValue(parameters[i], CSWConstants.PARAMETER_VALUE);
206
			if ((sParameter.equals(CSWConstants.TYPENAME)) &&
207
					(values != null)){					
208
				capabilities.setTypeNames(values);
209
			}
210
		}
211
	} 
212

  
213
	/**
214
	 * It parses the getRecordsByID operation
215
	 * @param node 
216
	 * @param prefix 
217
	 */
218
	private void parseGetRecordsByID(XMLNode node) {        
219
		capabilities.getOperations().setGetRecordsById(getSupportedProtocols(node));
220
	} 
221

  
222
	/**
223
     * It parses the getDomain operation
224
	 * @param node 
225
	 * @param prefix 
226
	 */
227
	private void parseGetDomain(XMLNode node) {        
228
		capabilities.getOperations().setGetDomain(getSupportedProtocols(node));
229
	} 
230

  
231
	/**
232
	 * It parses the getRecords operation
233
	 * @param node 
234
	 * @param prefix 
235
	 */
236
	private void parseGetRecords(XMLNode node){
237
		capabilities.getOperations().setGetRecords(getSupportedProtocols(node));
238
		XMLNode[] parameters = XMLTree.searchMultipleNode(node, CSWConstants.PARAMETER);
239
		for (int i = 0; i < parameters.length; i++) {
240
			String sParameter = XMLTree.searchAtribute(parameters[i], CSWConstants.PARAMETER_NAME);
241
			String[] values = XMLTree.searchMultipleNodeValue(parameters[i], CSWConstants.PARAMETER_VALUE);
242
			String[] defaultValue = XMLTree.searchMultipleNodeValue(parameters[i], CSWConstants.DEFAULTVALUE);
243
			if (sParameter.equals("TypeName")) {
244
				capabilities.setTypeNames(Strings.join(defaultValue, values));
245
			}
246
			if (sParameter.equals(CSWConstants.OUTPUTFORMAT)) {
247
				if (!(Strings.find(CSWConstants.TEXT_XML, defaultValue) ||
248
						Strings.find(CSWConstants.TEXT_XML, values))) {
249
					if (!(Strings.find(CSWConstants.APPLICATION_XML, defaultValue) ||
250
							Strings.find(CSWConstants.APPLICATION_XML, values))) {
251
						capabilities.setServerMessage("El servidor no devuelve " +
252
						"texto en formato XML");
253
						return;
254
					}
255
				}
256
			}
257
			driver.setOutputFormat(CSWConstants.TEXT_XML);
258
			if (sParameter.equals(CSWConstants.OUTPUTSCHEMA)) {
259
				driver.setOutputSchema(Strings.join(defaultValue, values));
260
			}
261

  
262

  
263
			if (sParameter.equals(CSWConstants.RESULTTYPE)) {
264
				capabilities.setResultType(Strings.join(defaultValue, values));
265
			}
266
			if (sParameter.equals(CSWConstants.ELEMENTSETNAME)) {
267
				capabilities.setElementSetName(Strings.join(defaultValue, values));
268
			}
269
			if (sParameter.equals(CSWConstants.CONSTRAINTLANGUAGE)) {
270
				capabilities.setCONSTRAINTLANGUAGE(Strings.join(defaultValue, values));
271
				for (int j = 0; j < capabilities.getCONSTRAINTLANGUAGE().length;
272
				j++) {
273
					if (capabilities.getCONSTRAINTLANGUAGE()[j].toUpperCase().equals("FILTER")) {
274
						break;
275
					} else {
276
						capabilities.setServerMessage("errorFENotSupported");
277

  
278
					}
279
				}
280
			}
281
		}		
282
	} 
283

  
284
	/**
285
	 *  * It parses the Transaction operation
286
	 * @param node 
287
	 * @param prefix 
288
	 */
289
	private void parseTransaction(XMLNode node) {        
290
		capabilities.getOperations().setTransaction(getSupportedProtocols(node));
291
	} 
292

  
293
	/**
294
	 * It parses the Harvest operation
295
	 * @param node 
296
	 * @param prefix 
297
	 */
298
	private void parseHarvest(XMLNode node) {        
299
		capabilities.getOperations().setHarvest(getSupportedProtocols(node));
300
	} 
301
	
302
	/**
303
	 * This function returns the supported protocols of an operation
304
	 * defined by node.
305
	 * @return 
306
	 * @param node Node that contains the operation information
307
	 */
308
	private HashMap getSupportedProtocols(XMLNode node) {        
309
		HashMap operations = new HashMap();
310

  
311
		XMLNode protocols = XMLTree.searchNode(node, CSWConstants.DCP);
312

  
313
		XMLNode HTTPoperations = XMLTree.searchNode(protocols,CSWConstants.HTTP);
314
		XMLNode[] childNodes = HTTPoperations.getSubnodes();
315
		for (int i=0 ; i<childNodes.length ; i++){			
316
			String sUrl = XMLTree.searchAtribute(childNodes[i],CSWConstants.XLINK_HREF);
317
			URL url = null;
318
			try {
319
				url = new URL(sUrl);
320
				if ((childNodes[i].getName().endsWith(CSWConstants.GET))){
321
					operations.put(CSWConstants.GET,
322
							url);
323
				}
324
				if ((childNodes[i].getName().endsWith(CSWConstants.POST))){
325
					operations.put(CSWConstants.POST,
326
							url);
327
				}
328

  
329
			} catch (MalformedURLException e) {
330
				//The URL can be added
331
			}			
332
		}
333
		return operations;
334
	}
335
}
0 336

  
org.gvsig.catalog/branches/org.gvsig.catalog-CSW2.0.2/org.gvsig.catalog/org.gvsig.catalog.lib/src/main/java/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
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
16
 *
17
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
18
 *
19
 * This program is free software; you can redistribute it and/or
20
 * modify it under the terms of the GNU General Public License
21
 * as published by the Free Software Foundation; either version 2
22
 * of the License, or (at your option) any later version.
23
 *
24
 * This program is distributed in the hope that it will be useful,
25
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
 * GNU General Public License for more details.
28
 *
29
 * You should have received a copy of the GNU General Public License
30
 * along with this program; if not, write to the Free Software
31
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
32
 *
33
 * For more information, contact:
34
 *
35
 *  Generalitat Valenciana
36
 *   Conselleria d'Infraestructures i Transport
37
 *   Av. Blasco Ib??ez, 50
38
 *   46010 VALENCIA
39
 *   SPAIN
40
 *
41
 *      +34 963862235
42
 *   gvsig@gva.es
43
 *      www.gvsig.gva.es
44
 *
45
 *    or
46
 *
47
 *   IVER T.I. S.A
48
 *   Salamanca 50
49
 *   46005 Valencia
50
 *   Spain
51
 *
52
 *   +34 963163400
53
 *   dac@iver.es
54
 */
55
/* CVS MESSAGES:
56
 *
57
 * $Id$
58
 * $Log$
59
 *
60
 */
61
/**
62
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
63
 */
64
public abstract class CSWAbstractMessages {
65
	protected CSWCapabilities capabilities = null;
66
	protected CatalogQuery query = null;
67
	protected CSWAbstractProfile profile = null;
68
	
69
	/**
70
	 * @param profile
71
	 * The profile to create the query
72
	 */
73
	public CSWAbstractMessages(CSWAbstractProfile profile) {
74
		super();
75
		this.profile = profile;		
76
	}
77

  
78
	public static NameValuePair[] getHTTPGETCapabilities() {        
79
		NameValuePair nvp1 = new NameValuePair("request", CSWConstants.OPERATION_GETCAPABILITIES);
80
		NameValuePair nvp2 = new NameValuePair("service", ServerData.SERVER_SUBTYPE_CATALOG_CSW);
81
		NameValuePair nvp3 = new NameValuePair("acceptFormats","text/xml");
82
		return new NameValuePair[] { nvp1, nvp2, nvp3 };
83
	} 
84
	
85
	/**
86
	 * The get capabilities operation started with lower case.
87
	 * There are some servers that has this bug 
88
	 * @return
89
	 */
90
	public static NameValuePair[] getHTTPGETCapabilitiesLower() {        
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff