Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libRemoteServices / src / org / gvsig / remoteclient / wfs / exceptions / ExceptionsFactory.java @ 33738

History | View | Annotate | Download (2.89 KB)

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

    
3
import java.io.IOException;
4

    
5
import org.kxml2.io.KXmlParser;
6
import org.xmlpull.v1.XmlPullParserException;
7

    
8
import org.gvsig.remoteclient.utils.CapabilitiesTags;
9

    
10
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
11
 *
12
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
13
 *
14
 * This program is free software; you can redistribute it and/or
15
 * modify it under the terms of the GNU General Public License
16
 * as published by the Free Software Foundation; either version 2
17
 * of the License, or (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program; if not, write to the Free Software
26
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
27
 *
28
 * For more information, contact:
29
 *
30
 *  Generalitat Valenciana
31
 *   Conselleria d'Infraestructures i Transport
32
 *   Av. Blasco Ib??ez, 50
33
 *   46010 VALENCIA
34
 *   SPAIN
35
 *
36
 *      +34 963862235
37
 *   gvsig@gva.es
38
 *      www.gvsig.gva.es
39
 *
40
 *    or
41
 *
42
 *   IVER T.I. S.A
43
 *   Salamanca 50
44
 *   46005 Valencia
45
 *   Spain
46
 *
47
 *   +34 963163400
48
 *   dac@iver.es
49
 */
50
/* CVS MESSAGES:
51
 *
52
 * $Id: ExceptionsFactory.java 33738 2010-10-21 11:54:20Z jpiera $
53
 * $Log$
54
 * Revision 1.1  2007-02-09 14:11:01  jorpiell
55
 * Primer piloto del soporte para WFS 1.1 y para WFS-T
56
 *
57
 *
58
 */
59
/**
60
 * This class parses an exception and returns it
61
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
62
 */
63
public class ExceptionsFactory {
64
        
65
        public static WFSException parseExceptionReport(KXmlParser parser) throws XmlPullParserException, IOException {
66
                int currentTag;
67
                boolean end = false;                
68
                
69
                currentTag = parser.next();
70
                
71
                while (!end) 
72
                {
73
                        switch(currentTag)
74
                        {
75
                        case KXmlParser.START_TAG:
76
                                if (parser.getName().compareToIgnoreCase(CapabilitiesTags.SERVICE_EXCEPTION)==0)
77
                                {
78
                                        for (int i=0 ; i<parser.getAttributeCount() ; i++){
79
                                                String attName = parser.getAttributeName(i);
80
                                                String code = null;
81
                                                if (attName.compareTo(CapabilitiesTags.CODE)==0){
82
                                                        code = parser.getAttributeValue(i);
83
                                                }
84
                                                if (code != null){
85
                                                        if (code.compareTo(CapabilitiesTags.INVALID_FORMAT)==0){
86
                                                                parser.next();
87
                                                                return new InvalidFormatException(parser.getText());
88
                                                        }
89
                                                        //Code unspecified
90
                                                        parser.next();
91
                                                        return new WFSException(code,parser.getText());
92
                                                }
93
                                        }
94
                                }                                         
95
                                break;
96
                        case KXmlParser.END_TAG:
97
                                if (parser.getName().compareTo(CapabilitiesTags.SERVICE_EXCEPTION_REPORT) == 0)
98
                                        end = true;
99
                                break;
100
                        case KXmlParser.TEXT:                   
101
                                break;
102
                        }
103
                        if (!end){
104
                                currentTag = parser.next();
105
                        }
106
                }   
107
                return new WFSException();
108
        }
109
}