svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.remoteclient / src / main / java / org / gvsig / remoteclient / wfs / exceptions / ExceptionsFactory.java @ 40559
History | View | Annotate | Download (5.4 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.remoteclient.wfs.exceptions; |
25 |
|
26 |
import java.io.IOException; |
27 |
|
28 |
import org.kxml2.io.KXmlParser; |
29 |
import org.xmlpull.v1.XmlPullParserException; |
30 |
|
31 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
32 |
|
33 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
34 |
*
|
35 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
36 |
*
|
37 |
* This program is free software; you can redistribute it and/or
|
38 |
* modify it under the terms of the GNU General Public License
|
39 |
* as published by the Free Software Foundation; either version 2
|
40 |
* of the License, or (at your option) any later version.
|
41 |
*
|
42 |
* This program is distributed in the hope that it will be useful,
|
43 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
44 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
45 |
* GNU General Public License for more details.
|
46 |
*
|
47 |
* You should have received a copy of the GNU General Public License
|
48 |
* along with this program; if not, write to the Free Software
|
49 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
50 |
*
|
51 |
* For more information, contact:
|
52 |
*
|
53 |
* Generalitat Valenciana
|
54 |
* Conselleria d'Infraestructures i Transport
|
55 |
* Av. Blasco Ib??ez, 50
|
56 |
* 46010 VALENCIA
|
57 |
* SPAIN
|
58 |
*
|
59 |
* +34 963862235
|
60 |
* gvsig@gva.es
|
61 |
* www.gvsig.gva.es
|
62 |
*
|
63 |
* or
|
64 |
*
|
65 |
* IVER T.I. S.A
|
66 |
* Salamanca 50
|
67 |
* 46005 Valencia
|
68 |
* Spain
|
69 |
*
|
70 |
* +34 963163400
|
71 |
* dac@iver.es
|
72 |
*/
|
73 |
/* CVS MESSAGES:
|
74 |
*
|
75 |
* $Id: ExceptionsFactory.java 34133 2010-11-15 11:32:55Z jpiera $
|
76 |
* $Log$
|
77 |
* Revision 1.1 2007-02-09 14:11:01 jorpiell
|
78 |
* Primer piloto del soporte para WFS 1.1 y para WFS-T
|
79 |
*
|
80 |
*
|
81 |
*/
|
82 |
/**
|
83 |
* This class parses an exception and returns it
|
84 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
85 |
*/
|
86 |
public class ExceptionsFactory { |
87 |
|
88 |
public static WFSException parseServiceExceptionReport(KXmlParser parser) throws XmlPullParserException, IOException { |
89 |
int currentTag;
|
90 |
boolean end = false; |
91 |
|
92 |
currentTag = parser.next(); |
93 |
|
94 |
while (!end)
|
95 |
{ |
96 |
switch(currentTag)
|
97 |
{ |
98 |
case KXmlParser.START_TAG:
|
99 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.SERVICE_EXCEPTION)==0) |
100 |
{ |
101 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
102 |
String attName = parser.getAttributeName(i);
|
103 |
String code = null; |
104 |
if (attName.compareTo(CapabilitiesTags.CODE)==0){ |
105 |
code = parser.getAttributeValue(i); |
106 |
} |
107 |
if (code != null){ |
108 |
if (code.compareTo(CapabilitiesTags.INVALID_FORMAT)==0){ |
109 |
parser.next(); |
110 |
return new InvalidFormatException(parser.getText()); |
111 |
} |
112 |
//Code unspecified
|
113 |
parser.next(); |
114 |
return new WFSException(code,parser.getText()); |
115 |
} |
116 |
} |
117 |
} |
118 |
break;
|
119 |
case KXmlParser.END_TAG:
|
120 |
if (parser.getName().compareTo(CapabilitiesTags.SERVICE_EXCEPTION_REPORT) == 0) |
121 |
end = true;
|
122 |
break;
|
123 |
case KXmlParser.TEXT:
|
124 |
break;
|
125 |
} |
126 |
if (!end){
|
127 |
currentTag = parser.next(); |
128 |
} |
129 |
} |
130 |
return new WFSException(); |
131 |
} |
132 |
|
133 |
public static WFSException parseExceptionReport(KXmlParser parser) throws XmlPullParserException, IOException { |
134 |
int currentTag;
|
135 |
boolean end = false; |
136 |
|
137 |
currentTag = parser.next(); |
138 |
|
139 |
String code = null; |
140 |
|
141 |
while (!end)
|
142 |
{ |
143 |
switch(currentTag)
|
144 |
{ |
145 |
case KXmlParser.START_TAG:
|
146 |
if (CapabilitiesTags.EXCEPTION.equals(parser.getName()))
|
147 |
{ |
148 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
149 |
String attName = parser.getAttributeName(i);
|
150 |
if (CapabilitiesTags.EXCEPTION_CODE.equals(attName)){
|
151 |
code = parser.getAttributeValue(i); |
152 |
} |
153 |
} |
154 |
} else if (CapabilitiesTags.EXCEPTION_TEXT.equals(parser.getName())){ |
155 |
parser.next(); |
156 |
return new WFSException(code, parser.getText()); |
157 |
} |
158 |
break;
|
159 |
case KXmlParser.END_TAG:
|
160 |
if (CapabilitiesTags.EXCEPTION_REPORT.equals(parser.getName()))
|
161 |
end = true;
|
162 |
break;
|
163 |
case KXmlParser.TEXT:
|
164 |
break;
|
165 |
} |
166 |
if (!end){
|
167 |
currentTag = parser.next(); |
168 |
} |
169 |
} |
170 |
return new WFSException(); |
171 |
} |
172 |
} |