ingo@78: package de.intevation.flys.client.server; ingo@78: ingo@78: import java.io.OutputStream; ingo@78: import java.io.IOException; ingo@78: import java.util.HashMap; ingo@78: import java.util.Map; ingo@78: ingo@78: import org.w3c.dom.Document; ingo@78: ingo@78: import javax.servlet.http.HttpServlet; ingo@78: import javax.servlet.http.HttpServletRequest; ingo@78: import javax.servlet.http.HttpServletResponse; ingo@78: ingo@78: import de.intevation.artifacts.httpclient.http.HttpClient; ingo@78: import de.intevation.artifacts.httpclient.http.HttpClientImpl; ingo@78: import de.intevation.artifacts.httpclient.objects.Artifact; ingo@78: import de.intevation.artifacts.httpclient.utils.ArtifactProtocolUtils; ingo@78: ingo@78: ingo@78: /** ingo@78: * This service is used to request a chart from the artifact server. The ingo@78: * response is directed directly to the output stream, so the image that is ingo@78: * retrieved is displayed in the UI afterwards. ingo@78: * ingo@78: * @author Ingo Weinzierl ingo@78: */ ingo@78: public class ChartOutputServiceImpl ingo@78: extends HttpServlet ingo@78: { ingo@78: public void doGet(HttpServletRequest req, HttpServletResponse resp) { ingo@78: System.out.println("ChartOutputServiceImpl.doGet"); ingo@78: ingo@78: try { ingo@78: OutputStream out = resp.getOutputStream(); ingo@78: ingo@78: String serverUrl = req.getParameter("server"); ingo@78: String uuid = req.getParameter("uuid"); ingo@78: String hash = req.getParameter("hash"); ingo@78: String width = req.getParameter("width"); ingo@78: String height = req.getParameter("height"); ingo@78: String target = req.getParameter("target"); ingo@78: String mimeType = "image/png"; ingo@78: ingo@78: Map opts = new HashMap(); ingo@78: opts.put("width", width); ingo@78: opts.put("height", height); ingo@78: opts.put("mimeType", mimeType); ingo@78: opts.put("points", "false"); ingo@78: ingo@78: Document chart = ArtifactProtocolUtils.createChartDocument( ingo@78: new Artifact(hash, uuid), opts); ingo@78: ingo@78: HttpClient client = new HttpClientImpl(serverUrl); ingo@78: client.out(new Artifact(uuid, hash), chart, target, out); ingo@78: ingo@78: out.close(); ingo@78: out.flush(); ingo@78: } ingo@78: catch (IOException ioe) { ingo@78: System.err.println(ioe.getMessage()); ingo@78: } ingo@78: } ingo@78: }