Revision 1187

View differences:

org.gvsig.catalog/tags/org.gvsig.catalog-2.0.223/org.gvsig.catalog.lib/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4

  
5
  <modelVersion>4.0.0</modelVersion>
6
  <artifactId>org.gvsig.catalog.lib</artifactId>
7
  <packaging>jar</packaging>
8
  <name>${project.artifactId}</name>
9

  
10
  <description>Web Catalog Service library (geodata search)</description>
11
  
12
  <parent>
13
      <groupId>org.gvsig</groupId>
14
      <artifactId>org.gvsig.catalog</artifactId>
15
      <version>2.0.223</version>
16
  </parent>
17
  
18
  <dependencies>
19
  
20
        <dependency>
21
            <groupId>org.slf4j</groupId>
22
            <artifactId>slf4j-api</artifactId>
23
            <scope>compile</scope>
24
        </dependency>
25
        <dependency>
26
            <groupId>org.gvsig</groupId>
27
            <artifactId>org.gvsig.tools.lib</artifactId>
28
            <scope>compile</scope>
29
        </dependency>
30
		<dependency>
31
			<groupId>org.gvsig</groupId>
32
			<artifactId>org.gvsig.compat.api</artifactId>
33
            <scope>compile</scope>
34
		</dependency>
35
		<dependency>
36
			<groupId>org.gvsig</groupId>
37
			<artifactId>org.gvsig.i18n</artifactId>
38
            <scope>compile</scope>
39
		</dependency>
40
		<dependency>
41
			<groupId>org.gvsig</groupId>
42
			<artifactId>org.gvsig.utils</artifactId>
43
            <scope>compile</scope>
44
		</dependency>
45
		<dependency>
46
			<groupId>org.gvsig</groupId>
47
			<artifactId>org.gvsig.remoteclient</artifactId>
48
            <scope>compile</scope>
49
		</dependency>
50
		<dependency>
51
			<groupId>xerces</groupId>
52
			<artifactId>xercesImpl</artifactId>
53
            <scope>compile</scope>
54
		</dependency>
55
		<dependency>
56
			<groupId>org.dspace</groupId>
57
			<artifactId>cql-java</artifactId>
58
		</dependency>		
59
		<dependency>
60
			<groupId>jdom</groupId>
61
			<artifactId>jdom</artifactId>
62
		</dependency>
63
		<dependency>
64
			<groupId>commons-beanutils</groupId>
65
			<artifactId>commons-beanutils</artifactId>
66
            <scope>compile</scope>
67
		</dependency>
68
		<dependency>
69
			<groupId>commons-httpclient</groupId>
70
			<artifactId>commons-httpclient</artifactId>
71
            <scope>compile</scope>
72
		</dependency>
73
		<dependency>
74
			<groupId>soap</groupId>
75
			<artifactId>soap</artifactId>
76
            <scope>compile</scope>
77
		</dependency>
78
   		<dependency>
79
		    <groupId>org.jzkit</groupId>
80
   			<artifactId>jzkit2-core</artifactId>
81
            <scope>compile</scope>
82
   		</dependency>
83
           <dependency>
84
		    <groupId>org.jzkit</groupId>
85
   			<artifactId>jzkit2-z3950</artifactId>
86
            <scope>compile</scope>
87
   		</dependency>
88
           <dependency>
89
		    <groupId>org.jzkit</groupId>
90
   			<artifactId>jzkit2-origin</artifactId>
91
   		</dependency>
92
	    <dependency>
93
		    <groupId>org.jzkit</groupId>
94
   			<artifactId>a2j-runtime</artifactId>
95
   		</dependency>
96
           <dependency>
97
		    <groupId>org.jzkit</groupId>
98
   			<artifactId>a2j</artifactId>
99
            <scope>compile</scope>
100
   		</dependency>
101
		<dependency>
102
			<groupId>org.springframework</groupId>
103
			<artifactId>spring</artifactId>
104
            <scope>compile</scope>
105
		</dependency>  
106
		<dependency>
107
		    <groupId>net.swing</groupId>
108
   			<artifactId>amic-util</artifactId>
109
            <scope>compile</scope>
110
   		</dependency>	
111
    
112
  </dependencies>
113
  
114
  <build>
115
  
116
		<!-- TODO: MAKE TESTS WORK AND REMOVE THIS OPTION -->
117
		<plugins>
118
			<plugin>
119
				<groupId>org.apache.maven.plugins</groupId>
120
				<artifactId>maven-surefire-plugin</artifactId>
121
				<configuration>
122
					<skipTests>true</skipTests>
123
				</configuration>
124
			</plugin>
125
		</plugins>
126
  
127
  </build>
128

  
129
</project>
0 130

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.223/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/CatalogAP.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
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;
43
import java.io.File;
44
import java.net.MalformedURLException;
45
import java.util.Locale;
46

  
47
import javax.swing.UIManager;
48
import javax.swing.UnsupportedLookAndFeelException;
49

  
50
import org.gvsig.catalog.ui.serverconnect.ServerConnectDialog;
51
import org.gvsig.i18n.Messages;
52
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
53

  
54
/**
55
 * This class is the launcher application
56
 * 
57
 * 
58
 * @author Jorge Piera Llodra (piera_jor@gva.es)
59
 */
60
public class CatalogAP {
61

  
62
	/**
63
	 * @param args 
64
	 */
65
	public static void main(String[] args) {
66
		new DefaultLibrariesInitializer().fullInitialize();
67
		
68
		Messages.addLocale(Locale.getDefault());
69
		try {
70
			Messages.addResourceFamily("text", new File("."));
71
		} catch (MalformedURLException e1) {
72
			System.err.println("Error obteniendo recurso de traduccion");
73

  
74
		}
75

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

  
88

  
89

  
90
		//ServerConnectDialogPanel frame = new ServerConnectDialogPanel();
91
		new ServerConnectDialog();
92
	} 
93
}
0 94

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.223/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/srw/filters/IDEESRWFilter.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42
package org.gvsig.catalog.srw.filters;
43
import org.gvsig.catalog.filters.AbstractFilter;
44
import org.gvsig.catalog.languages.FilterEncoding;
45
import org.gvsig.catalog.querys.CatalogQuery;
46
import org.gvsig.catalog.utils.Strings;
47
import org.gvsig.i18n.Messages;
48

  
49
/**
50
 * This class creates a RSW query for the IDEE server 
51
 * 
52
 * @author Jorge Piera Llodra (piera_jor@gva.es)
53
 */
54
public class IDEESRWFilter extends AbstractFilter {
55
	
56
	public  IDEESRWFilter() {        
57
		super();
58
	} 
59

  
60
	/**
61
	 * Return a CQL-Text query
62
	 * @param query 
63
	 * @return String
64
	 * @param profile 
65
	 */
66
	public String getQuery(CatalogQuery query) {        
67
		String pregunta = null;
68

  
69
		FilterEncoding filter = new FilterEncoding("", "*", "?", "\\");    
70

  
71
		if (query.getTitle() != null) {
72
			filter.addClauses("title", query.getTitle(), query.getTitleFilter(),
73
					"PropertyIsLike", "L", "And");
74
		}     
75

  
76
		if (query.isMinimized()){
77
			if (query.getAbstract() != null) {
78
				filter.addClauses("subject", Strings.addAsteriscsFromAnArray(query.getAbstract()),
79
						"Y", "PropertyIsLike", "L", "Or");
80
			}
81
		}else{
82
			if (query.getAbstract() != null) {
83
				filter.addClauses("subject", Strings.addAsteriscsFromAnArray(query.getAbstract()),
84
						"Y", "PropertyIsLike", "L", "And");
85
			}
86

  
87

  
88
		}
89

  
90
		pregunta = filter.toString();
91
		return pregunta;
92
	} 
93

  
94
	/**
95
	 * This function returns true only when the user has choosen the
96
	 * "Fully Outside Of" of the coordinates option.
97
	 * 
98
	 * 
99
	 * @return 
100
	 * @param translator 
101
	 * @param coordinatesOption 
102
	 */
103
	public boolean getCoordinatesOption(String coordinatesOption) {        
104
		if ((coordinatesOption.equals(Messages.getText("coordinatesEqual"))) ||
105
				(coordinatesOption.equals(Messages.getText("coordinatesContains"))) ||
106
				(coordinatesOption.equals(Messages.getText("coordinatesEnclose"))))
107
			return false;
108

  
109
		return true; 
110
	} 
111

  
112
}
0 113

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.223/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/srw/filters/SRWFilter.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
*
4
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
*
20
* For more information, contact:
21
*
22
*  Generalitat Valenciana
23
*   Conselleria d'Infraestructures i Transport
24
*   Av. Blasco Ib??ez, 50
25
*   46010 VALENCIA
26
*   SPAIN
27
*
28
*      +34 963862235
29
*   gvsig@gva.es
30
*      www.gvsig.gva.es
31
*
32
*    or
33
*
34
*   IVER T.I. S.A
35
*   Salamanca 50
36
*   46005 Valencia
37
*   Spain
38
*
39
*   +34 963163400
40
*   dac@iver.es
41
*/
42
package org.gvsig.catalog.srw.filters;
43
import org.gvsig.catalog.filters.AbstractFilter;
44
import org.gvsig.catalog.languages.CommonQueryLanguage;
45

  
46
/**
47
 * This class create que query in the language suported by the SRW protocol
48
 * 
49
 * 
50
 * @author Jorge Piera Llodra (piera_jor@gva.es)
51
 */
52
public class SRWFilter extends AbstractFilter {
53

  
54
/**
55
 * 
56
 * 
57
 */
58
    public  SRWFilter() {        
59
        super();
60
    } 
61

  
62
/**
63
 * Devuelve un query en el lenguaje que soporte el protocolo SRW
64
 * 
65
 * 
66
 * @param query 
67
 * @return String : query en el lenguaje soportado
68
 * @param profile 
69
 */
70
    public String getQuery(org.gvsig.catalog.querys.CatalogQuery query) {        
71
        String pregunta = null;
72
        // Construimos una RemoteBooleanQuery
73
        CommonQueryLanguage filter = new CommonQueryLanguage();
74
        
75
        if (query.getTitle() != null) {
76
            filter.addClauses("dc.title", query.getTitle(), query.getTitleFilter(),"And");
77
        }
78
        
79
        if (query.isMinimized()){
80
        	if (query.getAbstract() != null) {
81
        		filter.addClauses("dc.subject", query.getAbstract(), "E", "Or");
82
        	}
83
        }else{
84
        	if (query.getAbstract() != null) {
85
        		filter.addClauses("dc.subject", query.getAbstract(), "E", "And");
86
        	}
87
        	
88
        	if (query.getProvider() != null) {
89
                filter.addClauses("dc.creator", query.getProvider(), "E","And");
90
            }
91
        }        	
92
        	
93
        //if (this.getThemeKey() != null) 
94
        //query.addClauses("", this.getThemeKey(),"Y");
95
        //if (this.getScale() != null) 
96
        //query.addClauses("map_scale", this.getScale(),"E");
97
        
98
        //if (this.getDateFrom() != null) 
99
        //query.addClauses("2072", "210", "4",this.getDateFrom(),"E");
100
        //if (this.getDateTo() != null) 
101
        //query.addClauses("2073", "210", "2",this.getDateTo(),"E");
102
        pregunta = filter.toString();
103
        System.out.println(pregunta);
104
        return pregunta;
105
    } 
106
 }
0 107

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.223/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/srw/drivers/SRWCatalogServiceDriver.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 *  Generalitat Valenciana
23
 *   Conselleria d'Infraestructures i Transport
24
 *   Av. Blasco Ib??ez, 50
25
 *   46010 VALENCIA
26
 *   SPAIN
27
 *
28
 *      +34 963862235
29
 *   gvsig@gva.es
30
 *      www.gvsig.gva.es
31
 *
32
 *    or
33
 *
34
 *   IVER T.I. S.A
35
 *   Salamanca 50
36
 *   46005 Valencia
37
 *   Spain
38
 *
39
 *   +34 963163400
40
 *   dac@iver.es
41
 */
42
package org.gvsig.catalog.srw.drivers;
43
import java.net.MalformedURLException;
44
import java.net.URI;
45
import java.net.URL;
46
import java.util.Collection;
47
import java.util.StringTokenizer;
48

  
49
import org.gvsig.catalog.drivers.AbstractCatalogServiceDriver;
50
import org.gvsig.catalog.drivers.CatalogCapabilities;
51
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities;
52
import org.gvsig.catalog.drivers.GetRecordsReply;
53
import org.gvsig.catalog.metadataxml.XMLNode;
54
import org.gvsig.catalog.metadataxml.XMLTree;
55
import org.gvsig.catalog.protocols.HTTPGetProtocol;
56
import org.gvsig.catalog.protocols.SOAPProtocol;
57
import org.gvsig.catalog.querys.CatalogQuery;
58
import org.gvsig.catalog.srw.parsers.SrwCapabilitiesParser;
59
import org.gvsig.utils.swing.jcomboServer.ServerData;
60

  
61
/**
62
 * This class implements the CSW protocol.
63
 * 
64
 * 
65
 * @author Jorge Piera Llodra (piera_jor@gva.es)
66
 * @see http://www.loc.gov/z3950/agency/zing/srw/
67
 */
68
public class SRWCatalogServiceDriver extends AbstractCatalogServiceDriver {
69
	private String version = "1.1";
70
	private String recordXPath;
71
	private String resultSetTTL;
72

  
73
	/*
74
	 * (non-Javadoc)
75
	 * @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getCapabilities(java.net.URI)
76
	 */
77
	public DiscoveryServiceCapabilities getCapabilities(URI uri) {        
78
		URL url = null;
79
		try {
80
			url = uri.toURL();
81
		} catch (MalformedURLException e) {
82
			setServerAnswerReady("errorServerNotFound");
83
			return null;
84
		}        
85
		SRWMessages messages = new SRWMessages(this);
86
		Collection nodes = new HTTPGetProtocol().doQuery(url,
87
				messages.getHTTPGETCapabilities(true), 0);
88

  
89
		nodes = new SOAPProtocol().doQuery(url, messages.getSOAPCapabilities(), 0);
90
		new SrwCapabilitiesParser(this).parse((XMLNode)nodes.toArray()[0]);
91
		CatalogCapabilities capabilities = new CatalogCapabilities();
92
		capabilities.setVersion(version);
93
		capabilities.setServerMessage(getServerAnswerReady());
94
		return capabilities;
95
	} 
96

  
97
	/*
98
	 * (non-Javadoc)
99
	 * @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getRecords(java.net.URI, es.gva.cit.catalogClient.querys.Query, int)
100
	 */
101
	public GetRecordsReply getRecords(URI uri, CatalogQuery query, int firstRecord) {        
102
		URL url = null;
103
		try {
104
			url = uri.toURL();
105
		} catch (MalformedURLException e) {
106
			setServerAnswerReady("errorServerNotFound");
107
			return null;
108
		}        
109
		setQuery(query);
110
		SRWMessages messages = new SRWMessages(this);
111
		Collection nodes = new java.util.ArrayList();
112

  
113
		//TODO remove this comparation
114
		if (url.getHost().equals("idee.unizar.es")){
115
			try {
116
				url = new URL("http://idee.unizar.es/SRW/servlet/search/SRW");
117
			} catch (MalformedURLException e) {
118
				// It will never throws
119
			}
120
		}
121
	      
122
		XMLNode root = null;
123
		nodes = new SOAPProtocol().doQuery(url,
124
				messages.getSOAPRecords(getQuery(), firstRecord), firstRecord);
125
		root = (XMLNode)nodes.toArray()[0];
126
		root = root.getSubNode(0).getSubNode(0);
127

  
128
		String prefix = new StringTokenizer(root.getName(), ":").nextToken();
129
		if (prefix.equals(root.getName())) {
130
			prefix = "";
131
		} else {
132
			prefix = prefix + ":";
133
		}        
134
		int numberOfRecords = getNumberOfRecords(root,
135
				prefix + "numberOfRecords",
136
				null);
137

  
138
		if (numberOfRecords == -1) {
139
			return null;
140
		}   
141
		GetRecordsReply recordsReply = new GetRecordsReply(numberOfRecords);
142

  
143
		parseRecords(root,recordsReply,uri,prefix,numberOfRecords,firstRecord);		
144
		return recordsReply;
145
	} 
146

  
147
	/**
148
	 * Parser the XML
149
	 * @param node
150
	 * @param recordsReply
151
	 * @param uri
152
	 * @param prefix
153
	 * @param numberOfRecords
154
	 * @param firstRecord
155
	 */
156
	private void parseRecords(XMLNode node, GetRecordsReply recordsReply, URI uri, String prefix, int numberOfRecords, int firstRecord) {        
157

  
158
		XMLNode[] auxNodes = XMLTree.searchMultipleNode(node,
159
				prefix + "records->" + prefix + "record");
160
		for (int i = 1;	(i <= numberOfRecords) && (i <= 10) &&	(i <= (numberOfRecords - firstRecord + 1)); i++){
161
			recordsReply.addRecord(uri, auxNodes[i - 1]);
162
		}
163

  
164
	} 
165

  
166
	/**
167
	 * 
168
	 * 
169
	 * 
170
	 * @return Returns the recordXPath.
171
	 */
172
	public String getRecordXPath() {        
173
		return recordXPath;
174
	} 
175

  
176
	/**
177
	 * 
178
	 * 
179
	 * 
180
	 * @param recordXPath The recordXPath to set.
181
	 */
182
	public void setRecordXPath(String recordXPath) {        
183
		this.recordXPath = recordXPath;
184
	} 
185

  
186
	/**
187
	 * 
188
	 * 
189
	 * 
190
	 * @return Returns the resultSetTTL.
191
	 */
192
	public String getResultSetTTL() {        
193
		return resultSetTTL;
194
	} 
195

  
196
	/**
197
	 * 
198
	 * 
199
	 * 
200
	 * @param resultSetTTL The resultSetTTL to set.
201
	 */
202
	public void setResultSetTTL(String resultSetTTL) {        
203
		this.resultSetTTL = resultSetTTL;
204
	} 
205

  
206
	/**
207
	 * 
208
	 * 
209
	 * 
210
	 * @return Returns the version.
211
	 */
212
	public String getVersion() {        
213
		return version;
214
	} 
215

  
216
	/**
217
	 * 
218
	 * 
219
	 * 
220
	 * @param version The version to set.
221
	 */
222
	public void setVersion(String version) {        
223
		this.version = version;
224
	} 
225

  
226
	/*
227
	 * (non-Javadoc)
228
	 * @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#isProtocolSupported(java.net.URI)
229
	 */
230
	public boolean isProtocolSupported(URI uri) {        
231
		return SOAPProtocol.isProtocolSupported(null);
232
	} 
233

  
234
	/*
235
	 * (non-Javadoc)
236
	 * @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getServiceName()
237
	 */
238
	public String getServiceName() {
239
		return ServerData.SERVER_SUBTYPE_CATALOG_SRW;
240
	}
241

  
242
	/*
243
	 * (non-Javadoc)
244
	 * @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getDefaultPort()
245
	 */
246
	public int getDefaultPort() {		
247
		return 80;
248
	}
249

  
250
	/*
251
	 * (non-Javadoc)
252
	 * @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getDefaultSchema()
253
	 */
254
	public String getDefaultSchema() {
255
		return "http";
256
	} 
257
}
0 258

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.223/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/srw/drivers/SRWMessages.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
*
4
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
*
20
* For more information, contact:
21
*
22
*  Generalitat Valenciana
23
*   Conselleria d'Infraestructures i Transport
24
*   Av. Blasco Ib??ez, 50
25
*   46010 VALENCIA
26
*   SPAIN
27
*
28
*      +34 963862235
29
*   gvsig@gva.es
30
*      www.gvsig.gva.es
31
*
32
*    or
33
*
34
*   IVER T.I. S.A
35
*   Salamanca 50
36
*   46005 Valencia
37
*   Spain
38
*
39
*   +34 963163400
40
*   dac@iver.es
41
*/
42
/*
43
* CVS MESSAGES:
44
*
45
* $Id: SRWMessages.java 585 2007-09-03 10:21:55 +0000 (Mon, 03 Sep 2007) jpiera $
46
* $Log$
47
* Revision 1.6.10.1  2007/07/10 11:18:04  jorpiell
48
* Added the registers
49
*
50
* Revision 1.6  2006/03/21 07:13:52  jorpiell
51
* El gazetteer ya reproyecta. Se han tenido que modificar los parsers de todos los protocolos.
52
*
53
* Revision 1.4.2.2  2006/03/14 07:18:45  jorpiell
54
* Se ha a?adido la goma de borrar y se ha cambiado el tama?o de los botones
55
*
56
* Revision 1.5  2006/03/01 13:23:20  jorpiell
57
* Se ha a?adido al Head lo de la 0.6 y se ha hecho un commit
58
*
59
* Revision 1.4.2.1  2006/02/02 13:44:59  jorpiell
60
* Se ha tenido que cambiar el driver SRW para acceder al servidor de cat?logo de la IDEE. Adem?s se ha creado un nuevo filtro para este servidor
61
*
62
* Revision 1.4  2006/01/12 13:52:24  jorpiell
63
* Se ha a?adido un boton close en las dos pantallas de connect. Adem?s se ha cambiado el comportamiento de las ventanas para adaptarlo a la nueva forma de buscar multihilo
64
*
65
* Revision 1.3  2006/01/10 17:23:23  jorpiell
66
* Se ha hecho una peque?a modificaci?n en el gazeteer: ahora funcionan las b?squedas restringiendo el ?rea en el WFSG. Hay muchos cambios porque se ha hecho un CONTROL+SHIFT+O sobre todo el proyecto para eliminar los imports y para ordenarlos
67
*
68
* Revision 1.2  2006/01/10 09:32:49  jorpiell
69
* Se ha echo un commit de las versiones modificadas del catalogo y del gazetteer usando el Poseidon. Se han renombrado algunas clases por considerar que tenian un nombre confuso y se han cambiado algunas relaciones entre clases (con la intenci?n de separar GUI de la parte de control). Han habido clases que no han sido tocadas, pero como han sido formateadas usando el Poseidon TODAS las CLASES del proyecto han cambiado de versi?n.
70
*
71
* Revision 1.1  2005/12/22 08:31:43  jorpiell
72
* Aqui tambien se han producido muchos cambis, porque hemos acabado de cambiar la estructura del cat?logo: Se han creado todas las clases "XXXMessages", que sacan toda la parte de los mensajes de los drivers. Ademas se ha incluido en "CatalogClient" la operaci?n "getCapabilities", que libera a la interfaz de algunas operaciones que hac?a anteriormente.
73
*
74
*
75
*/
76
package org.gvsig.catalog.srw.drivers;
77
import org.apache.commons.httpclient.NameValuePair;
78
import org.gvsig.catalog.drivers.IProtocolMessages;
79
import org.gvsig.catalog.protocols.SOAPProtocol;
80
import org.gvsig.catalog.querys.CatalogQuery;
81
import org.gvsig.catalog.srw.filters.IDEESRWFilter;
82
import org.gvsig.catalog.srw.filters.SRWFilter;
83

  
84
/**
85
 * This class create the SRW protocol messages
86
 * 
87
 * 
88
 * @author Jorge Piera Llodra (piera_jor@gva.es)
89
 */
90
public class SRWMessages implements IProtocolMessages {
91
/**
92
 * 
93
 * 
94
 */
95
    private SRWCatalogServiceDriver driver;
96

  
97
/**
98
 * 
99
 * 
100
 * 
101
 * @param driver 
102
 */
103
    public  SRWMessages(SRWCatalogServiceDriver driver) {        
104
        this.driver = driver;
105
    } 
106

  
107
/**
108
 * 
109
 * 
110
 * 
111
 * @return 
112
 * @param upper 
113
 */
114
    public NameValuePair[] getHTTPGETCapabilities(boolean upper) {        
115
     NameValuePair nvp1 = new NameValuePair("OPERATION", "explain");
116
     NameValuePair nvp2 = new NameValuePair("VERSION", driver.getVersion());
117
        return new NameValuePair[] { nvp1, nvp2 };
118
    } 
119

  
120
/**
121
 * 
122
 * 
123
 * 
124
 * @return 
125
 */
126
    public NameValuePair[] getHTTPGETDescribeRecords() {        
127
        // TODO Auto-generated method stub
128
        return null;
129
    } 
130

  
131
/**
132
 * 
133
 * 
134
 * 
135
 * @return 
136
 * @param query 
137
 * @param firstRecord 
138
 */
139
    public NameValuePair[] getHTTPGETRecords(CatalogQuery query, int firstRecord) {        
140
       
141
        NameValuePair nvp1 = new NameValuePair("operation", "searchRetrieve");
142
        NameValuePair nvp2 = new NameValuePair("version", driver.getVersion());
143
        NameValuePair nvp3 = new NameValuePair("query", new SRWFilter().getQuery(query));
144
        NameValuePair nvp4 = new NameValuePair("maximumRecords", "10");
145
        NameValuePair nvp5 = new NameValuePair("recordPacking",
146
                driver.getOutputFormat());
147
        NameValuePair nvp6 = new NameValuePair("startRecord",
148
                new String(new Integer(firstRecord).toString()));
149
        return new NameValuePair[] { nvp1, nvp2, nvp3, nvp4, nvp5, nvp6 };
150
    } 
151

  
152
/**
153
 * 
154
 * 
155
 * 
156
 * @return 
157
 */
158
    public String getHTTPPOSTCapabilities() {        
159
        // TODO Auto-generated method stub
160
        return null;
161
    } 
162

  
163
/**
164
 * 
165
 * 
166
 * 
167
 * @return 
168
 */
169
    public String getHTTPPOSTDescribeRecords() {        
170
        // TODO Auto-generated method stub
171
        return null;
172
    } 
173

  
174
/**
175
 * 
176
 * 
177
 * 
178
 * @return 
179
 * @param query 
180
 * @param firstRecord 
181
 */
182
    public String getHTTPPOSTRecords(CatalogQuery query, int firstRecord) {        
183
        // TODO Auto-generated method stub
184
        return null;
185
    } 
186

  
187
/**
188
 * 
189
 * 
190
 * 
191
 * @return 
192
 */
193
    public String getSOAPCapabilities() {        
194
        String soapMessage =
195
            "<SRW:explainRequest xmlns:SRW=\"http://www.loc.gov/zing/srw/\">" +
196
            "<SRW:version>" + driver.getVersion() + "</SRW:version>" +
197
            "</SRW:explainRequest>";
198
        return SOAPProtocol.setSOAPMessage(soapMessage,null);
199
    } 
200

  
201
/**
202
 * 
203
 * 
204
 * 
205
 * @return 
206
 */
207
    public String getSOAPDescribeRecords() {        
208
        // TODO Auto-generated method stub
209
        return null;
210
    } 
211

  
212
/**
213
 * 
214
 * 
215
 * 
216
 * @return 
217
 * @param query 
218
 * @param firstRecord 
219
 */
220
    public String getSOAPRecords(CatalogQuery query, int firstRecord) {        
221
    	
222
        String soapMessage =
223
            "<srw:searchRetrieveRequest xmlns:srw=\"http://www.loc.gov/zing/srw/\">" +
224
            "<srw:query><![CDATA[" + new IDEESRWFilter().getQuery(query) + "]]></srw:query>" +
225
            "<srw:sortKeys xsi:nil=\"true\"/>" + "<srw:startRecord>" +
226
            driver.getStartPosition() + "</srw:startRecord>" + "<srw:maximumRecords>" +
227
            driver.getMaxRecords() + "</srw:maximumRecords>" + "<srw:recordPacking>" +
228
            driver.getOutputFormat() + "</srw:recordPacking>" + "<srw:recordSchema>" +
229
            driver.getOutputSchema()[0] + "</srw:recordSchema>" +
230
            "<srw:resultSetTTL>" + driver.getResultSetTTL() + "</srw:resultSetTTL>" +
231
            "</srw:searchRetrieveRequest>";
232
        return SOAPProtocol.setSOAPMessage(soapMessage,null);
233
    } 
234
 }
0 235

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.223/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/srw/parsers/SrwCapabilitiesParser.java
1

  
2
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
*
4
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
*
20
* For more information, contact:
21
*
22
*  Generalitat Valenciana
23
*   Conselleria d'Infraestructures i Transport
24
*   Av. Blasco Ib??ez, 50
25
*   46010 VALENCIA
26
*   SPAIN
27
*
28
*      +34 963862235
29
*   gvsig@gva.es
30
*      www.gvsig.gva.es
31
*
32
*    or
33
*
34
*   IVER T.I. S.A
35
*   Salamanca 50
36
*   46005 Valencia
37
*   Spain
38
*
39
*   +34 963163400
40
*   dac@iver.es
41
*/
42
package org.gvsig.catalog.srw.parsers;
43
import java.util.StringTokenizer;
44

  
45
import org.gvsig.catalog.metadataxml.XMLNode;
46
import org.gvsig.catalog.metadataxml.XMLTree;
47
import org.gvsig.catalog.srw.drivers.SRWCatalogServiceDriver;
48

  
49
/**
50
 * This class is used to parse the SRW capabilities
51
 * 
52
 * 
53
 * @author Jorge Piera Llodra (piera_jor@gva.es)
54
 */
55
public class SrwCapabilitiesParser {
56
/**
57
 * 
58
 * 
59
 */
60
    private SRWCatalogServiceDriver driver;
61

  
62
/**
63
 * 
64
 * 
65
 * 
66
 * @param driver 
67
 */
68
    public  SrwCapabilitiesParser(SRWCatalogServiceDriver driver) {        
69
        this.driver = driver;
70
    } 
71

  
72
/**
73
 * 
74
 * 
75
 * 
76
 * @return 
77
 * @param node 
78
 */
79
    public boolean parse(XMLNode node) {        
80
        if ((node == null) || (node.getName() == null)){
81
            driver.setServerAnswerReady("errorNotSupportedProtocol");
82
            return false;
83
        }
84
        
85
        if (node.getName().toLowerCase().equals("serviceexceptionreport")){
86
            driver.setServerAnswerReady("errorServerException");
87
            return false;
88
        }
89
       
90
            String prefix = new StringTokenizer(node.getName(), ":").nextToken();
91
            prefix = prefix + ":";
92
            driver.setOutputSchema(XMLTree.searchNodeValue(node,
93
                    prefix + "record->" + prefix + "recordSchema"));
94
            driver.setOutputFormat(XMLTree.searchNodeValue(node,
95
                    prefix + "record->" + prefix + "recordPacking"));
96
            driver.setStartPosition("1");
97
            driver.setMaxRecords("10");
98
            driver.setRecordXPath("");
99
            driver.setResultSetTTL("0");
100
            String title = XMLTree.searchNodeValue(node,
101
                    prefix + "record->" + prefix +
102
            "recordData->explain->databaseInfo->title");
103
            
104
            String description = XMLTree.searchNodeValue(node,
105
                    prefix + "record->" + prefix +
106
            "recordData->explain->databaseInfo->description");
107
            
108
            if (title != null){
109
            	driver.setServerAnswerReady(title + "\n");
110
            	if (description != null){
111
            		driver.setServerAnswerReady(driver.getServerAnswerReady() + 
112
            				description + "\n");
113
            	}            	
114
            }else{
115
            	driver.setServerAnswerReady("");
116
            	if (description != null){
117
            		driver.setServerAnswerReady(description + "\n");
118
            	}
119
            }         	         
120
          
121
            
122
            
123
            return true;
124
        
125
    } 
126
 }
0 127

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.223/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/ui/serverconnect/ServerConnectDialog.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.ui.serverconnect;
43
import java.awt.event.WindowEvent;
44
import java.awt.event.WindowListener;
45

  
46
import javax.swing.JFrame;
47

  
48
import org.gvsig.catalog.utils.Frames;
49

  
50
/**
51
 * This class implements the JFrame for the server
52
 * connect panel that will be used when the catalog
53
 * client is runned without gvSIG
54
 * @author Jorge Piera Llodr? (jorge.piera@iver.es)
55
 */
56
public class ServerConnectDialog extends JFrame implements WindowListener {
57
	private static final long serialVersionUID = 4678818428679670480L;
58

  
59
	public ServerConnectDialog() {        
60
		super();        
61
		initialize();
62
	} 
63

  
64
	/**
65
	 * This method initializes jDialog
66
	 * 
67
	 */
68
	protected void initialize() {        
69
		Frames.centerFrame(this, 625, 290);
70
		this.setTitle("Metadata catalog");
71
		setName("serverConnect");
72
		getContentPane().add(new ServerConnectDialogPanel(
73
				this));
74
		addWindowListener(this);
75
		setVisible(true);
76
	} 
77
	
78
	/*
79
	 * (non-Javadoc)
80
	 * @see java.awt.event.WindowListener#windowActivated(java.awt.event.WindowEvent)
81
	 */
82
	public void windowActivated(WindowEvent e) {        
83
		// TODO Auto-generated method stub
84
	} 
85

  
86
	/*
87
	 * (non-Javadoc)
88
	 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
89
	 */
90
	public void windowClosing(WindowEvent arg0) {        
91
		System.exit(0);
92
	} 
93
	
94
	/*
95
	 * (non-Javadoc)
96
	 * @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent)
97
	 */
98
	public void windowClosed(WindowEvent arg0) {        
99
		System.exit(0);
100
	} 
101
	
102
	/*
103
	 * (non-Javadoc)
104
	 * @see java.awt.event.WindowListener#windowDeactivated(java.awt.event.WindowEvent)
105
	 */
106
	public void windowDeactivated(WindowEvent e) {        
107
		// TODO Auto-generated method stub
108
	} 
109
	
110
	/*
111
	 * (non-Javadoc)
112
	 * @see java.awt.event.WindowListener#windowDeiconified(java.awt.event.WindowEvent)
113
	 */
114
	public void windowDeiconified(WindowEvent e) {        
115
		// TODO Auto-generated method stub
116
	} 
117
	
118
	/*
119
	 * (non-Javadoc)
120
	 * @see java.awt.event.WindowListener#windowIconified(java.awt.event.WindowEvent)
121
	 */
122
	public void windowIconified(WindowEvent e) {        
123
		// TODO Auto-generated method stub
124
	} 
125
	
126
	/*
127
	 * (non-Javadoc)
128
	 * @see java.awt.event.WindowListener#windowOpened(java.awt.event.WindowEvent)
129
	 */
130
	public void windowOpened(WindowEvent e) {        
131
		// TODO Auto-generated method stub
132
	} 
133
}
0 134

  
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.223/org.gvsig.catalog.lib/src/main/java/org/gvsig/catalog/ui/serverconnect/ServerConnectDialogPanel.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.ui.serverconnect;
43
import java.awt.BorderLayout;
44
import java.awt.Cursor;
45
import java.awt.event.ActionEvent;
46
import java.awt.event.ActionListener;
47
import java.util.Iterator;
48
import java.util.Map;
49

  
50
import javax.swing.Icon;
51
import javax.swing.ImageIcon;
52
import javax.swing.JFrame;
53
import javax.swing.JPanel;
54

  
55
import org.gvsig.catalog.CatalogClient;
56
import org.gvsig.catalog.CatalogLocator;
57
import org.gvsig.catalog.CatalogManager;
58
import org.gvsig.catalog.drivers.DiscoveryServiceCapabilities;
59
import org.gvsig.catalog.drivers.ICatalogServiceDriver;
60
import org.gvsig.catalog.ui.search.SearchDialog;
61
import org.gvsig.catalog.ui.serverproperties.ServerPropertiesDialog;
62
import org.gvsig.catalog.utils.CatalogConstants;
63
import org.gvsig.i18n.Messages;
64
import org.gvsig.utils.swing.jcomboServer.ServerData;
65
import org.slf4j.Logger;
66
import org.slf4j.LoggerFactory;
67

  
68
/**
69
 *
70
 *
71
 *
72
 * @author Jorge Piera Llodra (piera_jor@gva.es)
73
 */
74
public class ServerConnectDialogPanel extends JPanel implements ActionListener {
75
	private static final long serialVersionUID = 1224880378648403038L;
76
	 private static Logger logger =
77
		        LoggerFactory.getLogger(ServerConnectDialogPanel.class);
78

  
79
	private static final CatalogManager catalogManager = CatalogLocator.getCatalogManager();
80
	private ServerConnectPanel controlsPanel = null;
81
	private JFrame parent = null;
82
	protected CatalogClient client = null;
83
	protected String currentServer = "";
84
	private ConnectThread connectThread = null;
85

  
86
	/**
87
	 * Constructor
88
	 * @param parent
89
	 */
90
	public  ServerConnectDialogPanel(JFrame parent) {
91
		this.parent = parent;
92
		this.setLayout(new BorderLayout());
93
		add(getControlsPanel(),BorderLayout.CENTER);
94
		//Loads the servers
95
		int n_servers = loadServerList();
96

  
97
	      //Load the protocols
98
        controlsPanel.loadDrivers(
99
                catalogManager.getDrivers());
100
        getControlsPanel().setPropertiesIcon(getPropertiesIcon());
101

  
102
		if (n_servers == 0) {
103
		    return;
104
		}
105

  
106
		//Load the selected server protocol
107
		controlsPanel.updateProtocol();
108
		enableServerPropertiesButton();
109
	}
110

  
111
	protected Icon getPropertiesIcon(){
112
		return new ImageIcon("./gvSIG/extensiones/org.gvsig.catalog/images/serverProperties.png");
113
	}
114

  
115
	/**
116
	 * @return the main panel
117
	 */
118
	public ServerConnectPanel getControlsPanel() {
119
		if (controlsPanel == null) {
120
			controlsPanel = new ServerConnectPanel();
121
			controlsPanel.addActionListener(this);
122
			controlsPanel.enableSearchButton(false);
123
		}
124
		return controlsPanel;
125
	}
126

  
127
	/**
128
	 * Loads the list of used and default servers and returns its number
129
	 * @return
130
	 */
131
	private int loadServerList(){
132
	    Map<String,ServerData> serversMap=catalogManager.getServersPersistence();
133
	    if (serversMap!=null){
134
	        Iterator<String> iter = serversMap.keySet().iterator();
135
	        while (iter.hasNext()) {
136
	            String key=(String) iter.next();
137
	            ServerData server = (ServerData) serversMap.get(key);
138
	            controlsPanel.addServer(server);
139
	        }
140
	        return serversMap.size();
141
	    }
142
	    return 0;
143
	}
144

  
145
	/*
146
	 * (non-Javadoc)
147
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
148
	 */
149
	public void actionPerformed(ActionEvent e) {
150
		if (e.getActionCommand().compareTo(CatalogConstants.CONNECT_BUTTON_ACTION_COMMAND)==0) {
151
			connectButtonActionPerformed();
152
		}else if (e.getActionCommand().compareTo(CatalogConstants.SEARCH_BUTTON_ACTION_COMMAND)==0) {
153
			searchButtonActionPerformed();
154
		}else if (e.getActionCommand().compareTo(CatalogConstants.CLOSE_BUTTON_ACTION_COMMAND)==0) {
155
			closeButtonActionPerformed();
156
		}else if (e.getActionCommand().compareTo(CatalogConstants.PROTOCOL_COMBO_ACTION_COMMAND)==0){
157
			enableServerPropertiesButton();
158
		}else if (e.getActionCommand().compareTo(CatalogConstants.SERVERPROPERTIES_BUTTON_ACTION_COMMAND)==0) {
159
			serverPropertiesButtonActionPerformed();
160
		}else if (e.getActionCommand().compareTo(CatalogConstants.SERVER_COMBO_ACTION_COMMAND)==0) {
161
			controlsPanel.updateProtocol();
162
		}
163
	}
164

  
165
	/**
166
	 * Enable the server properties button
167
	 */
168
	private void enableServerPropertiesButton(){
169
		if(((ICatalogServiceDriver)controlsPanel.getDriver()).getProfile() == null){
170
			controlsPanel.enableServerPropertiesButton(false);
171
		}else{
172
			controlsPanel.enableServerPropertiesButton(true);
173
		}
174
	}
175

  
176
	/**
177
	 * Action when the search button is clicked
178
	 */
179
	protected void searchButtonActionPerformed() {
180
		setEnabled(false);
181
		new SearchDialog(client,parent);
182
	}
183

  
184
	/**
185
	 * It is thrown the the server properties button is clicked
186
	 */
187
	protected void serverPropertiesButtonActionPerformed(){
188
		createClient();
189
		new ServerPropertiesDialog(
190
				controlsPanel.getServer(),
191
				client,
192
				((ICatalogServiceDriver)controlsPanel.getDriver()).getProfile());
193
	}
194

  
195
	/**
196
	 * It is thrown the the connect button is clicked
197
	 */
198
	protected void connectButtonActionPerformed() {
199
		controlsPanel.enableSearchButton(false);
200
		createClient();
201
		if (connectThread != null){
202
			connectThread.stop();
203
		}
204
		connectThread = new ConnectThread();
205
		setCursor(new Cursor(Cursor.WAIT_CURSOR));
206
	}
207

  
208
	/**
209
	 * Create the catalog client
210
	 */
211
	protected void createClient(){
212
		ServerData serverData = null;
213
		if (client != null){
214
			serverData = client.getServerData();
215
		}
216
		client = new CatalogClient(controlsPanel.getServerAddress(),
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff