Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/ChartOutputServiceImpl.java @ 78:9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
flys-client/trunk@1584 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 28 Mar 2011 10:45:45 +0000 |
parents | |
children | 7ea004d0ffbc |
comparison
equal
deleted
inserted
replaced
77:5b5ec0403844 | 78:9ca5160cf080 |
---|---|
1 package de.intevation.flys.client.server; | |
2 | |
3 import java.io.OutputStream; | |
4 import java.io.IOException; | |
5 import java.util.HashMap; | |
6 import java.util.Map; | |
7 | |
8 import org.w3c.dom.Document; | |
9 | |
10 import javax.servlet.http.HttpServlet; | |
11 import javax.servlet.http.HttpServletRequest; | |
12 import javax.servlet.http.HttpServletResponse; | |
13 | |
14 import de.intevation.artifacts.httpclient.http.HttpClient; | |
15 import de.intevation.artifacts.httpclient.http.HttpClientImpl; | |
16 import de.intevation.artifacts.httpclient.objects.Artifact; | |
17 import de.intevation.artifacts.httpclient.utils.ArtifactProtocolUtils; | |
18 | |
19 | |
20 /** | |
21 * This service is used to request a chart from the artifact server. The | |
22 * response is directed directly to the output stream, so the image that is | |
23 * retrieved is displayed in the UI afterwards. | |
24 * | |
25 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
26 */ | |
27 public class ChartOutputServiceImpl | |
28 extends HttpServlet | |
29 { | |
30 public void doGet(HttpServletRequest req, HttpServletResponse resp) { | |
31 System.out.println("ChartOutputServiceImpl.doGet"); | |
32 | |
33 try { | |
34 OutputStream out = resp.getOutputStream(); | |
35 | |
36 String serverUrl = req.getParameter("server"); | |
37 String uuid = req.getParameter("uuid"); | |
38 String hash = req.getParameter("hash"); | |
39 String width = req.getParameter("width"); | |
40 String height = req.getParameter("height"); | |
41 String target = req.getParameter("target"); | |
42 String mimeType = "image/png"; | |
43 | |
44 Map opts = new HashMap(); | |
45 opts.put("width", width); | |
46 opts.put("height", height); | |
47 opts.put("mimeType", mimeType); | |
48 opts.put("points", "false"); | |
49 | |
50 Document chart = ArtifactProtocolUtils.createChartDocument( | |
51 new Artifact(hash, uuid), opts); | |
52 | |
53 HttpClient client = new HttpClientImpl(serverUrl); | |
54 client.out(new Artifact(uuid, hash), chart, target, out); | |
55 | |
56 out.close(); | |
57 out.flush(); | |
58 } | |
59 catch (IOException ioe) { | |
60 System.err.println(ioe.getMessage()); | |
61 } | |
62 } | |
63 } |