Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / libraries / libRemoteServices / src / org / gvsig / remoteClient / wfs / exceptions / ExceptionsFactory.java @ 18316

History | View | Annotate | Download (2.92 KB)

1
package org.gvsig.remoteClient.wfs.exceptions;
2

    
3
import java.io.IOException;
4

    
5
import org.gvsig.remoteClient.utils.CapabilitiesTags;
6
import org.kxml2.io.KXmlParser;
7
import org.xmlpull.v1.XmlPullParserException;
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: ExceptionsFactory.java 18271 2008-01-24 09:06:43Z jpiera $
52
 * $Log$
53
 * Revision 1.1  2007-02-09 14:11:01  jorpiell
54
 * Primer piloto del soporte para WFS 1.1 y para WFS-T
55
 *
56
 *
57
 */
58
/**
59
 * This class parses an exception and returns it
60
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
61
 */
62
public class ExceptionsFactory {
63
        
64
        public static WFSException parseExceptionReport(KXmlParser parser) throws XmlPullParserException, IOException {
65
                int currentTag;
66
                boolean end = false;                
67
                
68
                currentTag = parser.next();
69
                
70
                while (!end) 
71
                {
72
                        switch(currentTag)
73
                        {
74
                        case KXmlParser.START_TAG:
75
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.SERVICE_EXCEPTION)==0)
76
                                {
77
                                        String code = null;
78
                                        for (int i=0 ; i<parser.getAttributeCount() ; i++){
79
                                                String attName = parser.getAttributeName(i);
80
                                                if (attName.compareTo(CapabilitiesTags.CODE)==0){
81
                                                        code = parser.getAttributeValue(i);
82
                                                }
83
                                                if (code != null){
84
                                                        if (code.compareTo(CapabilitiesTags.INVALID_FORMAT)==0){
85
                                                                parser.next();
86
                                                                return new InvalidFormatException(parser.getText());
87
                                                        }                                                        
88
                                                }
89
                                        }
90
                                        parser.next();
91
                                        return new WFSException(code,parser.getText());
92
                                }                                         
93
                                break;
94
                        case KXmlParser.END_TAG:
95
                                if (parser.getName().compareTo(CapabilitiesTags.SERVICE_EXCEPTION_REPORT) == 0)
96
                                        end = true;
97
                                break;
98
                        case KXmlParser.TEXT:                   
99
                                break;
100
                        }
101
                        if (!end){
102
                                currentTag = parser.next();
103
                        }
104
                }   
105
                return new WFSException();
106
        }
107
}