Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/FixingsOverviewServiceImpl.java @ 2493:f905c936ffff
Added the XSL transformation to generate the fixings overview.
flys-client/trunk@4286 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 20 Apr 2012 15:23:27 +0000 |
parents | 2a504b6d9a1b |
children | 87ac5c532523 |
comparison
equal
deleted
inserted
replaced
2492:e64e0d094843 | 2493:f905c936ffff |
---|---|
1 package de.intevation.flys.client.server; | 1 package de.intevation.flys.client.server; |
2 | 2 |
3 import com.google.gwt.user.server.rpc.RemoteServiceServlet; | 3 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
4 | |
5 import de.intevation.artifacts.common.utils.XMLUtils; | |
6 import de.intevation.artifacts.common.utils.XSLTransformer; | |
7 | |
8 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; | |
9 | |
10 import de.intevation.artifacts.httpclient.http.HttpClient; | |
11 import de.intevation.artifacts.httpclient.http.HttpClientImpl; | |
4 | 12 |
5 import de.intevation.flys.client.client.services.FixingsOverviewService; | 13 import de.intevation.flys.client.client.services.FixingsOverviewService; |
6 | 14 |
7 import de.intevation.flys.client.shared.exceptions.ServerException; | 15 import de.intevation.flys.client.shared.exceptions.ServerException; |
8 | 16 |
17 import java.io.IOException; | |
18 import java.io.InputStream; | |
19 | |
20 import org.apache.log4j.Logger; | |
21 | |
22 import org.w3c.dom.Document; | |
23 | |
9 public class FixingsOverviewServiceImpl | 24 public class FixingsOverviewServiceImpl |
10 extends RemoteServiceServlet | 25 extends RemoteServiceServlet |
11 implements FixingsOverviewService | 26 implements FixingsOverviewService |
12 { | 27 { |
28 private static final Logger log = | |
29 Logger.getLogger(FixingsOverviewServiceImpl.class); | |
30 | |
31 public static final String SERVICE_NAME = "fixings-overview"; | |
32 | |
33 public static final String XSL_TRANSFORM = | |
34 "/WEB-INF/stylesheets/fixoverview2html.xsl"; | |
35 | |
13 @Override | 36 @Override |
14 public String generateOverview( | 37 public String generateOverview( |
38 String locale, | |
15 String uuid, | 39 String uuid, |
16 boolean checkboxes, | 40 boolean checkboxes, |
17 String filter | 41 String filter |
18 ) | 42 ) |
19 throws ServerException | 43 throws ServerException |
20 { | 44 { |
21 // TODO: Implement me! | 45 log.info("FixingsOverviewServiceImpl.doGet"); |
46 | |
47 if (filter == null || filter.length() == 0) { | |
48 log.warn("Missing 'filter' parameter."); | |
49 return ""; | |
50 } | |
51 | |
52 Document filterDoc = XMLUtils.jsonToXML(filter); | |
53 | |
54 if (filterDoc == null) { | |
55 log.warn("Creating filter document failed."); | |
56 return ""; | |
57 } | |
58 | |
59 InputStream transform = | |
60 getServletContext().getResourceAsStream(XSL_TRANSFORM); | |
61 | |
62 try { | |
63 String url = getServletContext().getInitParameter("server-url"); | |
64 HttpClient client = new HttpClientImpl(url, locale); | |
65 Document resultDoc = | |
66 client.callService(url, SERVICE_NAME, filterDoc); | |
67 XSLTransformer xformer = new XSLTransformer(); | |
68 xformer.addParameter("project-uuid", uuid); | |
69 xformer.addParameter( | |
70 "render-checkboxes", checkboxes ? "true()" : "false()"); | |
71 String result = xformer.transform(resultDoc, transform); | |
72 return result != null ? result : ""; | |
73 } | |
74 catch (ConnectionException ce) { | |
75 log.error(ce); | |
76 } | |
77 finally { | |
78 try { transform.close(); } | |
79 catch (IOException ioe) {} | |
80 } | |
81 | |
22 return ""; | 82 return ""; |
23 } | 83 } |
24 } | 84 } |
25 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 85 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |