Mercurial > dive4elements > river
changeset 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 | 905daf30221a |
children | 8264b02091ef |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/services/CSVExportService.java flys-client/src/main/java/de/intevation/flys/client/server/ExportServiceImpl.java flys-client/src/main/webapp/WEB-INF/web.xml |
diffstat | 4 files changed, 82 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Wed May 11 11:44:23 2011 +0000 +++ b/flys-client/ChangeLog Wed May 11 14:23:08 2011 +0000 @@ -1,3 +1,14 @@ +2011-05-11 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/server/ExportServiceImpl.java: + New. This service is a "proxy servlet" that enables the GUI to add + download buttons for exporting the computed data of the artifact server. + + * src/main/java/de/intevation/flys/client/client/services/CSVExportService.java: + Changed the URL part to query the CSV export ('export' -> 'csv'). + + * src/main/webapp/WEB-INF/web.xml: Registered the new ExportService. + 2011-05-11 Raimund Renkert <rrenkert@intevation.de> ISSUE 34
--- a/flys-client/src/main/java/de/intevation/flys/client/client/services/CSVExportService.java Wed May 11 11:44:23 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/CSVExportService.java Wed May 11 14:23:08 2011 +0000 @@ -13,7 +13,7 @@ * * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> */ -@RemoteServiceRelativePath("export") +@RemoteServiceRelativePath("csv") public interface CSVExportService extends RemoteService { /**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/ExportServiceImpl.java Wed May 11 14:23:08 2011 +0000 @@ -0,0 +1,57 @@ +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 data export from the artifact server. The + * response is directed directly to the output stream, so that a file dialog is + * opened. + * + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class ExportServiceImpl +extends HttpServlet +{ + public void doGet(HttpServletRequest req, HttpServletResponse resp) { + System.out.println("ExportServiceImpl.doGet"); + + try { + OutputStream out = resp.getOutputStream(); + + String serverUrl = req.getParameter("server"); + String uuid = req.getParameter("uuid"); + String mode = req.getParameter("mode"); + String type = req.getParameter("type"); + String locale = req.getParameter("locale"); + String fn = mode + "." + type; + + resp.setHeader("Content-Disposition", "attachment;filename=" + fn); + + Document request = ClientProtocolUtils.newOutCollectionDocument( + uuid, mode); + + HttpClient client = new HttpClientImpl(serverUrl, locale); + client.collectionOut(request, uuid, mode, out); + + out.close(); + out.flush(); + } + catch (IOException ioe) { + System.err.println(ioe.getMessage()); + } + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/webapp/WEB-INF/web.xml Wed May 11 11:44:23 2011 +0000 +++ b/flys-client/src/main/webapp/WEB-INF/web.xml Wed May 11 14:23:08 2011 +0000 @@ -138,13 +138,13 @@ </servlet-mapping> <servlet> - <servlet-name>waterlevel_export</servlet-name> + <servlet-name>csv</servlet-name> <servlet-class>de.intevation.flys.client.server.CSVExportServiceImpl</servlet-class> </servlet> <servlet-mapping> - <servlet-name>waterlevel_export</servlet-name> - <url-pattern>/flys/export</url-pattern> + <servlet-name>csv</servlet-name> + <url-pattern>/flys/csv</url-pattern> </servlet-mapping> <servlet> @@ -157,6 +157,16 @@ <url-pattern>/flys/chart</url-pattern> </servlet-mapping> + <servlet> + <servlet-name>ExportService</servlet-name> + <servlet-class>de.intevation.flys.client.server.ExportServiceImpl</servlet-class> + </servlet> + + <servlet-mapping> + <servlet-name>ExportService</servlet-name> + <url-pattern>/flys/export</url-pattern> + </servlet-mapping> + <!-- Default page to serve --> <welcome-file-list> <welcome-file>FLYS.html</welcome-file>