Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/server/DistanceInfoXML.java @ 835:c89a42950d11
Removed the digitize controls from map widget that is used in the floodmap state.
flys-client/trunk@2548 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 24 Aug 2011 09:26:33 +0000 |
parents | 4a7ece57f44c |
children | ab8eb2f544f2 |
line wrap: on
line source
package de.intevation.flys.client.server; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; import org.w3c.dom.Document; import org.w3c.dom.Element; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import de.intevation.artifacts.common.ArtifactNamespaceContext; import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.artifacts.httpclient.exceptions.ConnectionException; import de.intevation.artifacts.httpclient.http.HttpClient; import de.intevation.artifacts.httpclient.http.HttpClientImpl; import de.intevation.artifacts.httpclient.http.response.StreamResponseHandler; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class DistanceInfoXML extends HttpServlet { public static final String ERROR_NO_DISTANCEINFO_FOUND = "error_no_distanceinfo_found"; public void doGet(HttpServletRequest req, HttpServletResponse resp) { System.out.println("DistanceInfoXML.doGet"); String river = req.getParameter("river"); String url = req.getParameter("server"); String filter = req.getParameter("filter"); Document doc = XMLUtils.newDocument(); XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( doc, ArtifactNamespaceContext.NAMESPACE_URI, ArtifactNamespaceContext.NAMESPACE_PREFIX); Element riverEl = ec.create("river"); riverEl.setTextContent(river); doc.appendChild(riverEl); if (filter != null && filter.length() > 0) { Element typeEl = ec.create("filter"); typeEl.setTextContent(filter); riverEl.appendChild(typeEl); } HttpClient client = new HttpClientImpl(url); try { InputStream in = (InputStream) client.callService( url, "distanceinfo", doc, new StreamResponseHandler()); OutputStream out = resp.getOutputStream(); byte[] b = new byte[4096]; int i; while ((i = in.read(b)) >= 0) { out.write(b, 0, i); } out.flush(); out.close(); } catch (ConnectionException ce) { System.err.println(ce.getLocalizedMessage()); } catch (IOException ioe) { System.err.println(ioe.getLocalizedMessage()); } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :