Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / z3950 / drivers / Z3950CatalogServiceDriver.java @ 7394

History | View | Annotate | Download (4.03 KB)

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 es.gva.cit.catalogClient.z3950.drivers;
43
import es.gva.cit.catalogClient.drivers.AbstractCatalogServiceDriver;
44
import es.gva.cit.catalogClient.metadataXML.XMLNode;
45
import es.gva.cit.catalogClient.metadataXML.XMLTree;
46
import es.gva.cit.catalogClient.protocols.Z3950Protocol;
47
import es.gva.cit.catalogClient.querys.Query;
48
import java.io.ByteArrayInputStream;
49
import java.net.URL;
50
import java.util.ArrayList;
51
import java.util.Collection;
52

    
53
/**
54
 * This class implements the Z39.50 protocol.
55
 * 
56
 * 
57
 * @author Jorge Piera Llodra (piera_jor@gva.es)
58
 * @see http://www.loc.gov/z3950/agency/
59
 */
60
public class Z3950CatalogServiceDriver extends AbstractCatalogServiceDriver {
61
/* (non-Javadoc)
62
     * @see ICatalogServerDriver#GetCapabilities(java.lang.String, java.lang.String)
63
     */
64

    
65
/**
66
 * 
67
 * 
68
 * 
69
 * @return 
70
 * @param url 
71
 */
72
    public Collection getCapabilities(URL url) {        
73
        Collection nodes = new ArrayList();;
74
        Z3950Messages messages = new Z3950Messages(this);
75
        String message = messages.getCapabilities(new Z3950Protocol().openConnection(
76
                    url));
77
        ByteArrayInputStream buffer = new ByteArrayInputStream(message.getBytes());
78
        nodes.add(XMLTree.xmlToTree(buffer));
79
        return nodes;
80
    } 
81
/* (non-Javadoc)
82
     * @see ICatalogServerDriver#GetRecords(java.lang.String, java.lang.String, java.lang.String, int, int, java.lang.String, java.lang.String)
83
     */
84

    
85
/**
86
 * 
87
 * 
88
 * 
89
 * @return 
90
 * @param url 
91
 * @param query 
92
 * @param firstRecord 
93
 */
94
    public Collection getRecords(URL url, Query query, int firstRecord) {        
95
        Collection nodes = new java.util.ArrayList();
96
        setQuery(query);
97
        Z3950Messages messages = new Z3950Messages(this);
98
        
99
        String message = messages.getRecords(getQuery(),Z3950Protocol.getDatabase(url));
100
        System.out.println(message);
101
        nodes = new Z3950Protocol().doQuery(url, message, firstRecord);
102
        return nodes;
103
    } 
104
/* (non-Javadoc)
105
     * @see catalogClient.ICatalogServerDriver#setParameters(java.util.Properties)
106
     */
107

    
108
/**
109
 * 
110
 * 
111
 * 
112
 * @return 
113
 * @param nodes 
114
 * @param url 
115
 */
116
    public boolean setParameters(Collection nodes, URL url) {        
117
        // TODO Auto-generated method stub
118
        setServerAnswerReady(XMLTree.searchNodeValue((XMLNode)nodes.toArray()[0], "Servidor"));
119
        return true;
120
    } 
121
/* (non-Javadoc)
122
     * @see es.gva.cit.catalogClient.drivers.ICatalogServiveDriver#isTheProtocol(java.net.URL)
123
     */
124

    
125
/**
126
 * 
127
 * 
128
 * 
129
 * @return 
130
 * @param url 
131
 */
132
    public boolean isProtocolSupported(URL url) {        
133
        return new Z3950Protocol().isProtocolSupported(url);
134
    } 
135
/* (non-Javadoc)
136
     * @see es.gva.cit.catalogClient.drivers.ICatalogServiceDriver#getServerPofile()
137
     */
138

    
139
/**
140
 * 
141
 * 
142
 * 
143
 * @return 
144
 */
145
    public String getQueryProfile() {        
146
        // TODO Auto-generated method stub
147
        return "Z3950";
148
    } 
149
 }