view flys-client/src/main/java/de/intevation/flys/client/server/MapUrlServiceImpl.java @ 4488:5041105d2edd

Check if response code from GGInA is 200 OK Only parse the GGInA response if the status code is 200 OK. This improves the error message if GGInA is not available and shows the real reason instead of a JDOM error while parsing the response.
author Björn Ricks <bjoern.ricks@intevation.de>
date Wed, 14 Nov 2012 10:36:21 +0100
parents 8d27d2d33d70
children
line wrap: on
line source
package de.intevation.flys.client.server;

import java.io.InputStream;

import java.util.Map;
import java.util.HashMap;

import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Element;

import org.apache.log4j.Logger;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

import de.intevation.artifacts.common.utils.XMLUtils;

import de.intevation.flys.client.shared.exceptions.ServerException;
import de.intevation.flys.client.client.services.MapUrlService;


public class MapUrlServiceImpl
extends      RemoteServiceServlet
implements   MapUrlService
{

    private static final Logger logger =
        Logger.getLogger(MapUrlServiceImpl.class);


    public Map<String, String> getUrls()
    throws ServerException
    {
        logger.info("MapUrlServiceImpl.getUrls");
        Map<String, String> urls = new HashMap<String, String>();

        InputStream in = getServletContext().getResourceAsStream("/WEB-INF/wms-services.xml");

        Document doc = XMLUtils.parseDocument(in);

        NodeList list = doc.getElementsByTagName("wms");
        for (int i = 0; i < list.getLength(); i++) {
            Element e = (Element) list.item(i);
            urls.put(e.getAttribute("url"), e.getAttribute("name"));
        }

        return urls;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org