Statistics
| Revision:

gvsig-catalog / org.gvsig.catalog / branches / org.gvsig.catalog-CSW2.0.2 / org.gvsig.catalog / org.gvsig.catalog.lib / src / main / java / org / gvsig / catalog / srw / parsers / SrwCapabilitiesParser.java @ 55

History | View | Annotate | Download (3.62 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 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
 }