Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_2_Build_916 / libraries / libRemoteServices / src / org / gvsig / remoteClient / wms / wms_1_1_1 / WMSProtocolHandler1_1_1.java @ 12327

History | View | Annotate | Download (17 KB)

1 3323 ldiaz
2
package org.gvsig.remoteClient.wms.wms_1_1_1;
3
4 4500 jaume
import java.io.BufferedReader;
5 3516 jaume
import java.io.ByteArrayInputStream;
6 3323 ldiaz
import java.io.File;
7 4500 jaume
import java.io.FileInputStream;
8 3323 ldiaz
import java.io.FileNotFoundException;
9
import java.io.FileReader;
10
import java.io.IOException;
11 11382 jaume
import java.io.StringReader;
12 3516 jaume
import java.util.ArrayList;
13 3323 ldiaz
import java.util.TreeMap;
14
15
import org.gvsig.remoteClient.utils.CapabilitiesTags;
16 3516 jaume
import org.gvsig.remoteClient.utils.ExceptionTags;
17
import org.kxml2.io.KXmlParser;
18 3323 ldiaz
import org.xmlpull.v1.XmlPullParserException;
19
20
/**
21
 * <p>
22
 * Describes the handler to comunicate to a WMS 1.1.1
23
 * </p>
24
 */
25
public class WMSProtocolHandler1_1_1 extends org.gvsig.remoteClient.wms.WMSProtocolHandler {
26 3592 jaume
        private WMSLayer1_1_1 fakeRootLayer;
27 11382 jaume
28 3323 ldiaz
        public WMSProtocolHandler1_1_1()
29
        {
30 3341 ldiaz
                this.version = "1.1.1";
31
                this.name = "WMS1.1.1";
32 11382 jaume
                this.serviceInfo = new ServiceInformation();
33 3341 ldiaz
                this.layers = new TreeMap();
34 3323 ldiaz
        }
35 11382 jaume
36 3323 ldiaz
//------------------------------------------------------------------------------
37 11382 jaume
// Parsing methods....
38
//------------------------------------------------------------------------------
39 3323 ldiaz
/**
40
 * <p>Parse the xml data retrieved from the WMS, it will parse the WMS Capabilities</p>
41 11382 jaume
 *
42 3323 ldiaz
 */
43
    public void parse(File f)
44 11382 jaume
    {
45 5539 jaume
            rootLayer = null;
46 11382 jaume
            FileReader reader = null;
47 3323 ldiaz
            try
48
            {
49
                    reader = new FileReader(f);
50 4500 jaume
                    BufferedReader br = new BufferedReader(reader);
51
                    char[] buffer = new char[100];
52
                    br.read(buffer);
53 11382 jaume
                    String string = new String(buffer);
54
55
                     // patch for ArcIMS + WMS connector > 9.0 bug
56
            int a = string.toLowerCase().indexOf("<?xml");
57
            if (a !=-1)
58
                    string = string.substring(a, string.length());
59
            // end patch
60
61
                    StringBuffer st = new StringBuffer(string);
62 4500 jaume
                    String searchText = "encoding=\"";
63
                    int index = st.indexOf(searchText);
64
                    if (index>-1) {
65
                            st.delete(0, index+searchText.length());
66
                            encoding = st.substring(0, st.indexOf("\""));
67
                    }
68
            } catch(FileNotFoundException ex)        {
69 3404 jaume
                    ex.printStackTrace();
70 4500 jaume
            } catch (IOException e) {
71
                        e.printStackTrace();
72
                }
73 11382 jaume
74 3323 ldiaz
            int tag;
75
            KXmlParser kxmlParser = null;
76
            kxmlParser = new KXmlParser();
77
            try
78
            {
79 11382 jaume
                    reader = new FileReader(f);
80
                    BufferedReader br = new BufferedReader(reader);
81
82
                     // patch for ArcIMS + WMS connector > 9.0 bug
83
                    char[] buffer = new char[(int) f.length()];
84
                    br.read(buffer);
85
                    String string = new String(buffer);
86
                    int a = string.toLowerCase().indexOf("<?xml");
87
            if (a !=-1) {
88
                    string = string.substring(a, string.length());
89
                    kxmlParser.setInput(new StringReader(string));
90
            } else
91
                    // end patch
92
                    kxmlParser.setInput(new FileInputStream(f), encoding);
93
94 3323 ldiaz
                        kxmlParser.nextTag();
95 11382 jaume
                    if ( kxmlParser.getEventType() != KXmlParser.END_DOCUMENT )
96
                    {
97
                            kxmlParser.require(KXmlParser.START_TAG, null, CapabilitiesTags.CAPABILITIES_ROOT1_1_1);
98 3323 ldiaz
                            tag = kxmlParser.nextTag();
99
                                 while(tag != KXmlParser.END_DOCUMENT)
100
                                 {
101 3655 jaume
                     switch(tag)
102 3323 ldiaz
                                         {
103 11382 jaume
104 3323 ldiaz
                                                case KXmlParser.START_TAG:
105
                                                        if (kxmlParser.getName().compareTo(CapabilitiesTags.SERVICE )==0)
106
                                                        {
107
                                                                parseServiceTag(kxmlParser);
108 11382 jaume
                                                        }
109 3323 ldiaz
                                                        else if (kxmlParser.getName().compareTo(CapabilitiesTags.CAPABILITY)==0)
110
                                                        {
111
                                                                parseCapabilityTag(kxmlParser);
112
                                                        }
113
                                                        break;
114 11382 jaume
                                                case KXmlParser.END_TAG:
115 3323 ldiaz
                                                        break;
116
                                                case KXmlParser.TEXT:
117 11382 jaume
                                                        //System.out.println("[TEXT]["+kxmlParser.getText()+"]");
118 3323 ldiaz
                                                break;
119
                                         }
120
                                     tag = kxmlParser.next();
121
                             }
122 3516 jaume
                            kxmlParser.require(KXmlParser.END_DOCUMENT, null, null);
123 3323 ldiaz
                    }
124
            }
125
            catch(XmlPullParserException parser_ex){
126 3404 jaume
                    parser_ex.printStackTrace();
127 3323 ldiaz
            }
128 11382 jaume
                   catch (IOException ioe) {
129 3404 jaume
                           ioe.printStackTrace();
130 3592 jaume
                } finally {
131 11382 jaume
132 3592 jaume
        }
133 11382 jaume
                   // In the parsing process the layer has been filled
134
    }
135
136 3323 ldiaz
    /**
137
     * <p>Parses the Service Information </p>
138 11382 jaume
     */
139
    private void parseServiceTag(KXmlParser parser) throws IOException, XmlPullParserException
140 3323 ldiaz
    {
141
            int currentTag;
142
            boolean end = false;
143 11382 jaume
144 3323 ldiaz
            parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.SERVICE);
145
            currentTag = parser.next();
146 11382 jaume
147
            while (!end)
148 3323 ldiaz
            {
149
                         switch(currentTag)
150
                         {
151
                                case KXmlParser.START_TAG:
152
                                        if (parser.getName().compareTo(CapabilitiesTags.NAME)==0)
153
                                        {
154 11382 jaume
                                                serviceInfo.name = parser.nextText();
155
                                        }
156 3323 ldiaz
                                        else if (parser.getName().compareTo(CapabilitiesTags.TITLE)==0)
157
                                        {
158 11382 jaume
                                                serviceInfo.title = parser.nextText();
159 3323 ldiaz
                                        }
160
                                        else if (parser.getName().compareTo(CapabilitiesTags.ABSTRACT)==0)
161
                                        {
162 11382 jaume
                                                serviceInfo.abstr = parser.nextText();
163 3323 ldiaz
                                        }
164 4222 jaume
                                        else if (parser.getName().compareTo(CapabilitiesTags.ONLINERESOURCE)==0)
165
                                        {
166
                                            String value = new String();
167
                                        value = parser.getAttributeValue("", CapabilitiesTags.XLINK_HREF);
168
                                        if (value != null){
169
                                                serviceInfo.online_resource = value;
170
                                        }
171
                                        }
172 3323 ldiaz
                                        else if ((parser.getName().compareTo(CapabilitiesTags.KEYWORDLIST)==0) ||
173
                                                        (parser.getName().compareTo(CapabilitiesTags.CONTACTINFORMATION)==0))
174
                                        {
175
                                                parser.skipSubTree();
176 11382 jaume
                                        }
177 3323 ldiaz
                                        break;
178
                                case KXmlParser.END_TAG:
179
                                        if (parser.getName().compareTo(CapabilitiesTags.SERVICE) == 0)
180
                                                end = true;
181
                                        break;
182 11382 jaume
                                case KXmlParser.TEXT:
183 3323 ldiaz
                                break;
184
                         }
185 3655 jaume
             if (!end)
186
                 currentTag = parser.next();
187 3323 ldiaz
            }
188 3655 jaume
            parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.SERVICE);
189 3323 ldiaz
    }
190
    /**
191
     * <p>Parses the Capability Tag </p>
192 11382 jaume
     */
193 3323 ldiaz
    private void parseCapabilityTag(KXmlParser parser) throws IOException, XmlPullParserException
194 11382 jaume
    {
195 3323 ldiaz
            int currentTag;
196
            boolean end = false;
197 11382 jaume
198 3323 ldiaz
            parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.CAPABILITY);
199
            currentTag = parser.next();
200 11382 jaume
201
            while (!end)
202 3323 ldiaz
            {
203
                         switch(currentTag)
204
                         {
205
                                case KXmlParser.START_TAG:
206
                                        if (parser.getName().compareTo(CapabilitiesTags.REQUEST)==0)
207
                                        {
208 11382 jaume
                                                parseRequestTag(parser);
209
                                        }
210 3323 ldiaz
                                        else if (parser.getName().compareTo(CapabilitiesTags.EXCEPTION)==0)
211
                                        {
212 4222 jaume
                                                //TODO:
213
                                                //Add to serviceInfo the supported formats for the exceptions????
214 3323 ldiaz
                                        }
215
                                        else if (parser.getName().compareTo(CapabilitiesTags.LAYER)==0)
216
                                        {
217
                                                WMSLayer1_1_1 lyr = new WMSLayer1_1_1();
218 4222 jaume
                                                lyr.parse(parser, layers);
219 11382 jaume
220 3592 jaume
                        if (rootLayer == null)
221
                            rootLayer = lyr;
222
                        else {
223
                            // Handles when there is no general root layer, will use
224
                            // a fake non-queryable one.
225
                            if (!rootLayer.equals(getFakeRootLayer())){
226
                                WMSLayer1_1_1 aux = (WMSLayer1_1_1) rootLayer;
227
                                rootLayer  = getFakeRootLayer();
228
                                rootLayer.getChildren().add(aux);
229
                            }
230
                            rootLayer.getChildren().add(lyr);
231
                        }
232 11382 jaume
233 3483 jaume
                        if (lyr.getName()!=null)
234 11382 jaume
                                                    layers.put(lyr.getName(), lyr);
235
236
//                        Collection layerCollection = layers.values();
237 4222 jaume
//                        Iterator iter = layerCollection.iterator();
238
//                        while (iter.hasNext())
239
//                        {
240 11382 jaume
//                                WMSLayer1_1_1 layer = (WMSLayer1_1_1)iter.next();
241 4222 jaume
//                                                    //Add all the SRS that the layer supports to the WMSProtocolHandler if they dont exist already
242
//                                                    for (i=0;i<layer.getAllSrs().size();i++)
243 11382 jaume
//                                                    {
244 4222 jaume
////                                                        if (!layer.srs.contains(layer.getAllSrs().elementAt(i)))
245
////                                                        {
246
////                                                            this.srs.add(layer.getAllSrs().elementAt(i));
247
////                                                        }
248 11382 jaume
//                                                    }
249
//                        }
250 3323 ldiaz
                                        }
251
                                        else if ((parser.getName().compareTo(CapabilitiesTags.VENDORSPECIFICCAPABILITIES)==0) ||
252
                                                        (parser.getName().compareTo(CapabilitiesTags.USERDEFINEDSYMBOLIZATION )==0))
253 11382 jaume
254 3323 ldiaz
                                        {
255
                                                parser.skipSubTree();
256 11382 jaume
                                        }
257 3323 ldiaz
                                        break;
258
                                case KXmlParser.END_TAG:
259
                                        if (parser.getName().compareTo(CapabilitiesTags.CAPABILITY) == 0)
260
                                                end = true;
261
                                        break;
262 11382 jaume
                                case KXmlParser.TEXT:
263 3323 ldiaz
                                break;
264
                         }
265 4222 jaume
                         if (!end)
266
                                 currentTag = parser.next();
267 3323 ldiaz
            }
268 11382 jaume
            //parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.CAPABILITY);
269 3323 ldiaz
    }
270 11382 jaume
271 3323 ldiaz
    /**
272
     * <p>Parses the Request tag </p>
273 11382 jaume
     */
274 3323 ldiaz
    private void parseRequestTag(KXmlParser parser) throws IOException, XmlPullParserException
275 11382 jaume
    {
276 3323 ldiaz
            int currentTag;
277
            boolean end = false;
278 11382 jaume
279 3323 ldiaz
            parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.REQUEST);
280
            currentTag = parser.next();
281 11382 jaume
282
            while (!end)
283 3323 ldiaz
            {
284
                         switch(currentTag)
285
                         {
286
                                case KXmlParser.START_TAG:
287
                                        if (parser.getName().compareTo(CapabilitiesTags.GETCAPABILITIES)==0)
288
                                        {
289 11382 jaume
                                                serviceInfo.operations.put(CapabilitiesTags.GETCAPABILITIES, null);
290
                                        }
291 3323 ldiaz
                                        else if (parser.getName().compareTo(CapabilitiesTags.GETMAP)==0)
292
                                        {
293 4222 jaume
                                                // put a null to this key?
294
                                                // or leave it like it was with a CODE in a vector specifying this operation.
295 11382 jaume
                                                // WMSProtocolHandler.GETMAP_OPERATION
296
                                                serviceInfo.operations.put(CapabilitiesTags.GETMAP, null);
297 4222 jaume
                                                parseGetMapTag(parser);
298 3323 ldiaz
                                        }
299
                                        else if (parser.getName().compareTo(CapabilitiesTags.GETFEATUREINFO)==0)
300
                                        {
301 4222 jaume
                                                //serviceInfo.operations.put(WMSProtocolHandler.GETFEATUREINFO_OPERATION)
302
                                                serviceInfo.operations.put(CapabilitiesTags.GETFEATUREINFO, null);
303
                                                parseGetFeatureInfoTag(parser);
304 11382 jaume
                                        }
305 3687 ldiaz
                                        else if (parser.getName().compareTo(CapabilitiesTags.DESCRIBELAYER)==0)
306
                                        {
307 4222 jaume
                                                //serviceInfo.operations.put(WMSProtocolHandler.DESCRIBELAYER_OPERATION)
308 11382 jaume
                                                serviceInfo.operations.put(CapabilitiesTags.DESCRIBELAYER, null);
309
                                        }
310 8765 jjdelcerro
                                        else if (parser.getName().compareTo(CapabilitiesTags.GETLEGENDGRAPHIC)==0)
311
                                        {
312
                                                serviceInfo.operations.put(CapabilitiesTags.GETLEGENDGRAPHIC, null);
313
                                                parseGetLegendGraphicTag(parser);
314
                                        }
315 3323 ldiaz
                                        break;
316
                                case KXmlParser.END_TAG:
317
                                        if (parser.getName().compareTo(CapabilitiesTags.REQUEST) == 0)
318
                                                end = true;
319
                                        break;
320 11382 jaume
                                case KXmlParser.TEXT:
321 3323 ldiaz
                                break;
322
                         }
323 4222 jaume
                         if(!end)
324
                                 currentTag = parser.next();
325 3323 ldiaz
            }
326
            // TODO: does not get such a tag when arrives here!!!!!!
327 11382 jaume
            //parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.REQUEST);
328 3323 ldiaz
    }
329 11382 jaume
330 4222 jaume
    /**
331
     * <p>Parses the GetMap tag </p>
332 11382 jaume
     */
333 4222 jaume
    private void parseGetMapTag(KXmlParser parser) throws IOException, XmlPullParserException
334 11382 jaume
    {
335 4222 jaume
            int currentTag;
336
            boolean end = false;
337 11382 jaume
338 4222 jaume
            parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.GETMAP);
339
            currentTag = parser.next();
340 11382 jaume
341
            while (!end)
342 4222 jaume
            {
343
                         switch(currentTag)
344
                         {
345
                                case KXmlParser.START_TAG:
346
                                        if (parser.getName().compareTo(CapabilitiesTags.FORMAT)==0)
347
                                        {
348
                                                serviceInfo.formats.add(parser.nextText());
349 11382 jaume
                                        }
350 4222 jaume
                                        else if (parser.getName().compareTo(CapabilitiesTags.DCPTYPE)==0)
351 11382 jaume
                                        {
352 4222 jaume
                                                currentTag = parser.nextTag();
353
                                                if(parser.getName().compareTo(CapabilitiesTags.HTTP)==0)
354
                                                {
355
                                                        currentTag = parser.nextTag();
356
                                                        if(parser.getName().compareTo(CapabilitiesTags.GET)==0)
357
                                                        {
358
                                                                currentTag = parser.nextTag();
359
                                                                if (parser.getName().compareTo(CapabilitiesTags.ONLINERESOURCE)==0)
360
                                                                {
361
                                                                        String value = new String();
362
                                                                        value = parser.getAttributeValue("", CapabilitiesTags.XLINK_HREF);
363
                                                                        if (value != null){
364
                                                                                serviceInfo.operations.put(CapabilitiesTags.GETMAP, value);
365
                                                                        }
366
                                                                }
367
                                                        }
368
                                                }
369 11382 jaume
                                        }
370 4222 jaume
                                        break;
371
                                case KXmlParser.END_TAG:
372
                                        if (parser.getName().compareTo(CapabilitiesTags.GETMAP) == 0)
373
                                                end = true;
374
                                        break;
375 11382 jaume
                                case KXmlParser.TEXT:
376 4222 jaume
                                break;
377
                         }
378
                         if(!end)
379
                                 currentTag = parser.next();
380 11382 jaume
            }
381
    }
382
383 4222 jaume
    /**
384 8765 jjdelcerro
     * <p>Parses the GetFeatureInfoTag tag </p>
385 11382 jaume
     */
386 4222 jaume
    private void parseGetFeatureInfoTag(KXmlParser parser) throws IOException, XmlPullParserException
387 11382 jaume
    {
388 4222 jaume
            int currentTag;
389
            boolean end = false;
390 11382 jaume
391 4222 jaume
            parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.GETFEATUREINFO);
392
            currentTag = parser.next();
393 11382 jaume
394
            while (!end)
395 4222 jaume
            {
396
                         switch(currentTag)
397
                         {
398
                                case KXmlParser.START_TAG:
399
                                        if (parser.getName().compareTo(CapabilitiesTags.FORMAT)==0)
400
                                        {
401
                                                //TODO:
402
                                                // add the supported formats by the GetFeatureInfo request
403
                                                //serviceInfo.formats.add(parser.nextText());
404 11382 jaume
                                        }
405 4222 jaume
                                        else if (parser.getName().compareTo(CapabilitiesTags.DCPTYPE)==0)
406 11382 jaume
                                        {
407 4222 jaume
                                                currentTag = parser.nextTag();
408
                                                if(parser.getName().compareTo(CapabilitiesTags.HTTP)==0)
409
                                                {
410
                                                        currentTag = parser.nextTag();
411
                                                        if(parser.getName().compareTo(CapabilitiesTags.GET)==0)
412
                                                        {
413
                                                                currentTag = parser.nextTag();
414
                                                                if (parser.getName().compareTo(CapabilitiesTags.ONLINERESOURCE)==0)
415
                                                                {
416
                                                                        String value = new String();
417
                                                                        value = parser.getAttributeValue("", CapabilitiesTags.XLINK_HREF);
418
                                                                        if (value != null){
419 4623 ldiaz
                                                                                serviceInfo.operations.put(CapabilitiesTags.GETFEATUREINFO, value);
420 4222 jaume
                                                                        }
421
                                                                }
422
                                                        }
423
                                                }
424 11382 jaume
                                        }
425 4222 jaume
                                        break;
426
                                case KXmlParser.END_TAG:
427
                                        if (parser.getName().compareTo(CapabilitiesTags.GETFEATUREINFO) == 0)
428
                                                end = true;
429
                                        break;
430 11382 jaume
                                case KXmlParser.TEXT:
431 4222 jaume
                                break;
432
                         }
433
                         if(!end)
434
                                 currentTag = parser.next();
435 11382 jaume
            }
436
    }
437 3516 jaume
438 8765 jjdelcerro
    /**
439
     * <p>Parses the GetFeatureInfoTag tag </p>
440 11382 jaume
     */
441 8765 jjdelcerro
    private void parseGetLegendGraphicTag(KXmlParser parser) throws IOException, XmlPullParserException
442 11382 jaume
    {
443 8765 jjdelcerro
            int currentTag;
444
            boolean end = false;
445 11382 jaume
446 8765 jjdelcerro
            parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.GETLEGENDGRAPHIC);
447
            currentTag = parser.next();
448 11382 jaume
449
            while (!end)
450 8765 jjdelcerro
            {
451
                         switch(currentTag)
452
                         {
453
                                case KXmlParser.START_TAG:
454
                                        if (parser.getName().compareTo(CapabilitiesTags.FORMAT)==0)
455
                                        {
456
                                                //TODO:
457
                                                // add the supported formats by the GetLegendGraphic request
458
                                                //serviceInfo.formats.add(parser.nextText());
459 11382 jaume
                                        }
460 8765 jjdelcerro
                                        else if (parser.getName().compareTo(CapabilitiesTags.DCPTYPE)==0)
461 11382 jaume
                                        {
462 8765 jjdelcerro
                                                currentTag = parser.nextTag();
463
                                                if(parser.getName().compareTo(CapabilitiesTags.HTTP)==0)
464
                                                {
465
                                                        currentTag = parser.nextTag();
466
                                                        if(parser.getName().compareTo(CapabilitiesTags.GET)==0)
467
                                                        {
468
                                                                currentTag = parser.nextTag();
469
                                                                if (parser.getName().compareTo(CapabilitiesTags.ONLINERESOURCE)==0)
470
                                                                {
471
                                                                        String value = new String();
472
                                                                        value = parser.getAttributeValue("", CapabilitiesTags.XLINK_HREF);
473
                                                                        if (value != null){
474
                                                                                serviceInfo.operations.put(CapabilitiesTags.GETLEGENDGRAPHIC, value);
475
                                                                        }
476
                                                                }
477
                                                        }
478
                                                }
479 11382 jaume
                                        }
480 8765 jjdelcerro
                                        break;
481
                                case KXmlParser.END_TAG:
482
                                        if (parser.getName().compareTo(CapabilitiesTags.GETLEGENDGRAPHIC) == 0)
483
                                                end = true;
484
                                        break;
485 11382 jaume
                                case KXmlParser.TEXT:
486 8765 jjdelcerro
                                break;
487
                         }
488
                         if(!end)
489
                                 currentTag = parser.next();
490 11382 jaume
            }
491
    }
492
493
494 3592 jaume
    private WMSLayer1_1_1 getFakeRootLayer(){
495
        if (fakeRootLayer == null){
496
            fakeRootLayer = new WMSLayer1_1_1();
497
            fakeRootLayer.setTitle(serviceInfo.title);
498
            fakeRootLayer.setQueryable(false);
499
            fakeRootLayer.setName(null);
500
        }
501
        return fakeRootLayer;
502
    }
503 3516 jaume
    /* (non-Javadoc)
504
     * @see org.gvsig.remoteClient.wms.WMSProtocolHandler#parseException(byte[])
505
     */
506
    protected String parseException(byte[] data) {
507
        ArrayList errors = new ArrayList();
508
        KXmlParser kxmlParser = new KXmlParser();
509
        try
510
        {
511 11382 jaume
            kxmlParser.setInput(new ByteArrayInputStream(data), encoding);
512 3516 jaume
            int tag;
513 11382 jaume
514 3824 ldiaz
            boolean end = false;
515
            tag = kxmlParser.nextTag();
516 11382 jaume
517 8765 jjdelcerro
            //Comentar temporalmente para subsanar el hecho de que SimonCit me devuelve las capabilities en un GetLegendGraphic!!!
518 3824 ldiaz
            kxmlParser.require(KXmlParser.START_TAG, null, ExceptionTags.EXCEPTION_ROOT);
519 11382 jaume
520
            while (!end)
521 3824 ldiaz
            {
522
                switch(tag)
523
                {
524
                    case KXmlParser.START_TAG:
525 3516 jaume
                            if (kxmlParser.getName().compareTo(ExceptionTags.SERVICE_EXCEPTION)==0){
526
                                String errorCode = kxmlParser.getAttributeValue("", ExceptionTags.CODE);
527
                                errorCode = (errorCode != null) ? "["+errorCode+"] " : "";
528
                                String errorMessage = kxmlParser.nextText();
529
                                errors.add(errorCode+errorMessage);
530
                            }
531
                            break;
532 11382 jaume
                    case KXmlParser.END_TAG:
533 3824 ldiaz
                            if (kxmlParser.getName().compareTo(ExceptionTags.EXCEPTION_ROOT) == 0)
534
                                end = true;
535 11382 jaume
                            break;
536 3516 jaume
                     }
537 3824 ldiaz
                        if (!end)
538
                        {
539
                                tag = kxmlParser.nextTag();
540
                        }
541 3516 jaume
                 }
542 3824 ldiaz
                }
543 3516 jaume
        catch(XmlPullParserException parser_ex){
544
            System.out.println(parser_ex.getMessage());
545
            parser_ex.printStackTrace();
546
        }
547 11382 jaume
        catch (IOException ioe) {
548
            ioe.printStackTrace();
549 3516 jaume
        }
550
        String message = errors.size()>0? "" : null;
551
        for (int i = 0; i < errors.size(); i++) {
552
            message += (String) errors.get(i)+"\n";
553
        }
554
        return message;
555
    }
556 11382 jaume
557 3323 ldiaz
  }