Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/ExportServiceImpl.java @ 274:71a7533555d0
Added a service to export data from the artifact server.
flys-client/trunk@1900 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 11 May 2011 14:23:08 +0000 |
parents | |
children | 8ea213bd8fba |
comparison
equal
deleted
inserted
replaced
273:905daf30221a | 274:71a7533555d0 |
---|---|
1 package de.intevation.flys.client.server; | |
2 | |
3 import java.io.OutputStream; | |
4 import java.io.IOException; | |
5 | |
6 import org.w3c.dom.Document; | |
7 | |
8 import javax.servlet.http.HttpServlet; | |
9 import javax.servlet.http.HttpServletRequest; | |
10 import javax.servlet.http.HttpServletResponse; | |
11 | |
12 import de.intevation.artifacts.common.utils.ClientProtocolUtils; | |
13 | |
14 import de.intevation.artifacts.httpclient.http.HttpClient; | |
15 import de.intevation.artifacts.httpclient.http.HttpClientImpl; | |
16 | |
17 | |
18 /** | |
19 * This service is used to request a data export from the artifact server. The | |
20 * response is directed directly to the output stream, so that a file dialog is | |
21 * opened. | |
22 * | |
23 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
24 */ | |
25 public class ExportServiceImpl | |
26 extends HttpServlet | |
27 { | |
28 public void doGet(HttpServletRequest req, HttpServletResponse resp) { | |
29 System.out.println("ExportServiceImpl.doGet"); | |
30 | |
31 try { | |
32 OutputStream out = resp.getOutputStream(); | |
33 | |
34 String serverUrl = req.getParameter("server"); | |
35 String uuid = req.getParameter("uuid"); | |
36 String mode = req.getParameter("mode"); | |
37 String type = req.getParameter("type"); | |
38 String locale = req.getParameter("locale"); | |
39 String fn = mode + "." + type; | |
40 | |
41 resp.setHeader("Content-Disposition", "attachment;filename=" + fn); | |
42 | |
43 Document request = ClientProtocolUtils.newOutCollectionDocument( | |
44 uuid, mode); | |
45 | |
46 HttpClient client = new HttpClientImpl(serverUrl, locale); | |
47 client.collectionOut(request, uuid, mode, out); | |
48 | |
49 out.close(); | |
50 out.flush(); | |
51 } | |
52 catch (IOException ioe) { | |
53 System.err.println(ioe.getMessage()); | |
54 } | |
55 } | |
56 } | |
57 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |