Mercurial > dive4elements > river
view flys-client/src/main/java/de/intevation/flys/client/server/ChartOutputServiceImpl.java @ 94:eb54fb9f5f2c
Fixed some issues.
flys-client/trunk@1607 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Tue, 29 Mar 2011 12:51:09 +0000 |
parents | 9ca5160cf080 |
children | 7ea004d0ffbc |
line wrap: on
line source
package de.intevation.flys.client.server; import java.io.OutputStream; import java.io.IOException; import java.util.HashMap; import java.util.Map; import org.w3c.dom.Document; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import de.intevation.artifacts.httpclient.http.HttpClient; import de.intevation.artifacts.httpclient.http.HttpClientImpl; import de.intevation.artifacts.httpclient.objects.Artifact; import de.intevation.artifacts.httpclient.utils.ArtifactProtocolUtils; /** * This service is used to request a chart from the artifact server. The * response is directed directly to the output stream, so the image that is * retrieved is displayed in the UI afterwards. * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class ChartOutputServiceImpl extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) { System.out.println("ChartOutputServiceImpl.doGet"); try { OutputStream out = resp.getOutputStream(); String serverUrl = req.getParameter("server"); String uuid = req.getParameter("uuid"); String hash = req.getParameter("hash"); String width = req.getParameter("width"); String height = req.getParameter("height"); String target = req.getParameter("target"); String mimeType = "image/png"; Map opts = new HashMap(); opts.put("width", width); opts.put("height", height); opts.put("mimeType", mimeType); opts.put("points", "false"); Document chart = ArtifactProtocolUtils.createChartDocument( new Artifact(hash, uuid), opts); HttpClient client = new HttpClientImpl(serverUrl); client.out(new Artifact(uuid, hash), chart, target, out); out.close(); out.flush(); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } } }