view flys-client/src/main/java/de/intevation/flys/client/server/ChartOutputServiceImpl.java @ 254:6838e4112eeb

Bugfix: the current locale string is used to fetch chart images now. flys-client/trunk@1864 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 09 May 2011 11:21:50 +0000
parents 7ea004d0ffbc
children b493d606fdef
line wrap: on
line source
package de.intevation.flys.client.server;

import java.io.OutputStream;
import java.io.IOException;

import org.w3c.dom.Document;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import de.intevation.artifacts.common.utils.ClientProtocolUtils;

import de.intevation.artifacts.httpclient.http.HttpClient;
import de.intevation.artifacts.httpclient.http.HttpClientImpl;


/**
 * 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 type      = req.getParameter("type");
            String locale    = req.getParameter("locale");
            String mimeType  = "image/png";

            Document request = ClientProtocolUtils.newOutCollectionDocument(
                uuid, type);

            HttpClient client = new HttpClientImpl(serverUrl, locale);
            client.collectionOut(request, uuid, "chart", out);

            out.close();
            out.flush();
        }
        catch (IOException ioe) {
            System.err.println(ioe.getMessage());
        }
    }
}

http://dive4elements.wald.intevation.org