sascha@2489: package de.intevation.flys.client.server; sascha@2489: sascha@2489: import com.google.gwt.user.server.rpc.RemoteServiceServlet; sascha@2489: sascha@2493: import de.intevation.artifacts.common.utils.XMLUtils; sascha@2493: import de.intevation.artifacts.common.utils.XSLTransformer; sascha@2493: sascha@2493: import de.intevation.artifacts.httpclient.exceptions.ConnectionException; sascha@2493: sascha@2493: import de.intevation.artifacts.httpclient.http.HttpClient; sascha@2493: import de.intevation.artifacts.httpclient.http.HttpClientImpl; sascha@2493: sascha@2489: import de.intevation.flys.client.client.services.FixingsOverviewService; sascha@2489: sascha@2489: import de.intevation.flys.client.shared.exceptions.ServerException; sascha@2489: sascha@2493: import java.io.IOException; sascha@2493: import java.io.InputStream; sascha@2493: sascha@2493: import org.apache.log4j.Logger; sascha@2493: sascha@2493: import org.w3c.dom.Document; sascha@2493: sascha@2489: public class FixingsOverviewServiceImpl sascha@2489: extends RemoteServiceServlet sascha@2489: implements FixingsOverviewService sascha@2489: { sascha@2493: private static final Logger log = sascha@2493: Logger.getLogger(FixingsOverviewServiceImpl.class); sascha@2493: sascha@2493: public static final String SERVICE_NAME = "fixings-overview"; sascha@2493: sascha@2493: public static final String XSL_TRANSFORM = sascha@2493: "/WEB-INF/stylesheets/fixoverview2html.xsl"; sascha@2493: sascha@2489: @Override sascha@2489: public String generateOverview( sascha@2493: String locale, sascha@2489: String uuid, sascha@2489: boolean checkboxes, sascha@2489: String filter sascha@2489: ) sascha@2489: throws ServerException sascha@2489: { sascha@2493: log.info("FixingsOverviewServiceImpl.doGet"); sascha@2493: sascha@2493: if (filter == null || filter.length() == 0) { sascha@2493: log.warn("Missing 'filter' parameter."); sascha@2493: return ""; sascha@2493: } sascha@2493: sascha@2493: Document filterDoc = XMLUtils.jsonToXML(filter); sascha@2493: sascha@2493: if (filterDoc == null) { sascha@2493: log.warn("Creating filter document failed."); sascha@2493: return ""; sascha@2493: } sascha@2493: sascha@2493: InputStream transform = sascha@2493: getServletContext().getResourceAsStream(XSL_TRANSFORM); sascha@2493: sascha@2493: try { sascha@2493: String url = getServletContext().getInitParameter("server-url"); sascha@2493: HttpClient client = new HttpClientImpl(url, locale); sascha@2493: Document resultDoc = sascha@2493: client.callService(url, SERVICE_NAME, filterDoc); sascha@2493: XSLTransformer xformer = new XSLTransformer(); sascha@2493: xformer.addParameter("project-uuid", uuid); sascha@2493: xformer.addParameter( sascha@2493: "render-checkboxes", checkboxes ? "true()" : "false()"); sascha@2493: String result = xformer.transform(resultDoc, transform); sascha@2493: return result != null ? result : ""; sascha@2493: } sascha@2493: catch (ConnectionException ce) { sascha@2493: log.error(ce); sascha@2493: } sascha@2493: finally { sascha@2493: try { transform.close(); } sascha@2493: catch (IOException ioe) {} sascha@2493: } sascha@2493: sascha@2489: return ""; sascha@2489: } sascha@2489: } sascha@2489: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :