Package org.saiku.web.svg

Examples of org.saiku.web.svg.Converter


      @FormParam("type") @DefaultValue("png") String type,
      @FormParam("svg") String svg,
      @FormParam("size") Integer size) {
    try {
      final String imageType = type.toUpperCase();
      Converter converter = Converter.byType(imageType);
      if (converter == null) {
        throw new Exception("Image convert is null");
      }


      //       resp.setContentType(converter.getContentType());
      //       resp.setHeader("Content-disposition", "attachment; filename=chart." + converter.getExtension());
      //       final Integer size = req.getParameter("size") != null? Integer.parseInt(req.getParameter("size")) : null;
      //       final String svgDocument = req.getParameter("svg");
      //       if (svgDocument == null)
      //       {
      //           resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Missing 'svg' parameter");
      //           return;
      //       }
      if (StringUtils.isBlank(svg)) {
        throw new Exception("Missing 'svg' parameter");
      }
      final InputStream in = new ByteArrayInputStream(svg.getBytes("UTF-8"));
      final ByteArrayOutputStream out = new ByteArrayOutputStream();
      converter.convert(in, out, size);
      out.flush();
      byte[] doc = out.toByteArray();
      return Response.ok(doc).type(converter.getContentType()).header(
          "content-disposition",
          "attachment; filename = chart." + converter.getExtension()).header(
          "content-length", doc.length).build();
    } catch (Exception e) {
      LOG.error("Error exporting Chart to  " + type, e);
      return Response.serverError().entity(e.getMessage()).status(Status.INTERNAL_SERVER_ERROR).build();
    }
View Full Code Here

TOP

Related Classes of org.saiku.web.svg.Converter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.