ingo@78: package de.intevation.flys.client.server; ingo@78: ingo@78: import java.io.OutputStream; ingo@78: import java.io.IOException; 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@213: import de.intevation.artifacts.common.utils.ClientProtocolUtils; ingo@213: ingo@78: import de.intevation.artifacts.httpclient.http.HttpClient; ingo@78: import de.intevation.artifacts.httpclient.http.HttpClientImpl; 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@213: String type = req.getParameter("type"); ingo@254: String locale = req.getParameter("locale"); ingo@78: String mimeType = "image/png"; ingo@78: ingo@213: Document request = ClientProtocolUtils.newOutCollectionDocument( ingo@213: uuid, type); ingo@78: ingo@254: HttpClient client = new HttpClientImpl(serverUrl, locale); ingo@213: client.collectionOut(request, uuid, "chart", 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: }