Statistics
| Revision:

root / trunk / applications / appCatalogAndGazetteerClient / src / es / gva / cit / gazetteer / adl / parsers / AdlCapabilitiesParser.java @ 15558

History | View | Annotate | Download (3.48 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.gazetteer.adl.parsers;
43

    
44
import java.net.MalformedURLException;
45
import java.net.URL;
46

    
47
import es.gva.cit.catalog.metadataxml.XMLNode;
48
import es.gva.cit.catalog.metadataxml.XMLTree;
49
import es.gva.cit.gazetteer.adl.drivers.ADLGazetteerServiceDriver;
50
import es.gva.cit.gazetteer.adl.protocols.ADLThesaurus;
51

    
52
/**
53
 * This Class parses the ADL getCapabilities file
54
 * 
55
 * 
56
 * @author Jorge Piera Llodra (piera_jor@gva.es)
57
 */
58
public class AdlCapabilitiesParser {
59
/**
60
 * 
61
 * 
62
 */
63
    ADLGazetteerServiceDriver driver;
64

    
65
/**
66
 * 
67
 * 
68
 * 
69
 * @param driver 
70
 */
71
    public  AdlCapabilitiesParser(ADLGazetteerServiceDriver driver) {        
72
        this.driver = driver;
73
    } 
74

    
75
/**
76
 * 
77
 * 
78
 * 
79
 * @return 
80
 * @param node 
81
 */
82
    public boolean parse(XMLNode node) {        
83
        if (node == null){
84
            driver.setServerAnswerReady("El servidor no soporta el protocolo " +
85
            "especificado");
86
            return false;
87
        }
88
        
89
        if (!(node.getName().equals("gazetteer-service"))){
90
            driver.setServerAnswerReady("El servidor no soporta el protocolo " +
91
            "especificado");
92
            return false;
93
        }
94
        
95
        driver.setServerAnswerReady(XMLTree.searchNodeValue(node,
96
        "get-capabilities-response->gazetteer-capabilities->description"));
97
                
98
        String host = XMLTree.searchNodeAtribute(node,
99
        "get-capabilities-response->gazetteer-capabilities->thesauri->thesaurus",
100
        "xlink:href");
101
        
102
        if (host == null){
103
            host = "http://middleware.alexandria.ucsb.edu:8080/thes/FTT";
104
            driver.setServerAnswerReady("No se ha podido cargar el "+
105
            "Tesauro correctamante. Se va ha usar el Tesauro de alejandr?a, " +
106
            "pero no se puede garantizar que el tesauro el servidor sea el mismo " +
107
            "(http://middleware.alexandria.ucsb.edu:8080/thes/FTT)");
108
        }
109
        
110
        try {
111
            ADLThesaurus t = new ADLThesaurus(new URL(host));
112
            driver.setFeatureTypes(t.getFeatures());
113
         } catch (MalformedURLException e) {
114
            // TODO Auto-generated catch block
115
            e.printStackTrace();
116
            driver.setServerAnswerReady("La URL del tesauro no es correcta");
117
            return false;
118
        }
119
         
120
        driver.setProjection("EPSG:4326");
121
        return true;
122
    } 
123
 }