Exemplo n.º 1
0
 @Override
 public void process(TemplatingContext templatingContext) throws ProcessingException {
   RequestParameters parameters = RequestParameters.getRequestParameters(context);
   super.process(templatingContext);
   if (parameters.get("exportType").equals("full") || parameters.get("exportType").equals("xml")) {
     templatingContext.put("recordDetails", recordDetailsExport);
     templatingContext.put("dateConverter", new PatternDateConverter("yyyyMMdd"));
   }
   if (parameters.get("exportType").equals("xml")) {
     HttpContext httpContext = HttpContext.getHttpContext(context);
     httpContext.setContentType("application/xml");
   }
 }
Exemplo n.º 2
0
  /** {@inheritDoc} */
  public void process(
      Parameters parameters,
      MVCContext mvcContext,
      TemplatingContext templatingContext,
      HttpContext httpContext,
      I18nContext i18nContext,
      CoralSession coralSession)
      throws ProcessingException {
    String skin = parameters.get("skin");

    String path = parameters.get("path");
    SiteResource site = getSite();
    path = path.replace(',', '/');
    boolean asText = parameters.get("type", "binary").equals("text");
    boolean asXML = parameters.get("type", "binary").equals("xml");
    try {
      String contentType;
      String contents;
      if (asText) {
        contentType = "text/plain";
        contents = skinService.getContentFileContents(site, skin, path, httpContext.getEncoding());
      } else if (asXML) {
        contentType = "text/xml";
        contents = skinService.getContentFileContents(site, skin, path, httpContext.getEncoding());
        contents =
            "<?xml version=\"1.0\" encoding=\""
                + httpContext.getEncoding()
                + "\"?>\n"
                + "<contents>\n"
                + "  <![CDATA["
                + contents
                + "]]>\n"
                + "</contents>\n";
      } else {
        contentType = "application/octet-stream";
        contents = skinService.getContentFileContents(site, skin, path, httpContext.getEncoding());
      }
      httpContext.disableCache();
      httpContext.setResponseLength(StringUtils.getByteCount(contents, httpContext.getEncoding()));
      fileDownload.dumpData(
          new ByteArrayInputStream(contents.getBytes(httpContext.getEncoding())),
          contentType,
          (new Date()).getTime());
    } catch (IOException e) {
      logger.error("Couldn't write to output", e);
    } catch (Exception e) {
      templatingContext.put("errorResult", "result.exception");
      templatingContext.put("stackTrace", new StackTrace(e).toStringArray());
      logger.error("exception occured", e);
    }
  }
Exemplo n.º 3
0
 public void prepareDefault(Context context) throws ProcessingException {
   Parameters parameters = RequestParameters.getRequestParameters(context);
   CoralSession coralSession = (CoralSession) context.getAttribute(CoralSession.class);
   HttpContext httpContext = HttpContext.getHttpContext(context);
   I18nContext i18nContext = I18nContext.getI18nContext(context);
   TemplatingContext templatingContext = TemplatingContext.getTemplatingContext(context);
   SiteResource site = getSite();
   try {
     templatingContext.put("styles", Arrays.asList(styleService.getStyles(coralSession, site)));
     long parent_node_id = parameters.getLong("parent_node_id", -1);
     if (parent_node_id == -1) {
       templatingContext.put("parent_node", getHomePage());
     } else {
       templatingContext.put(
           "parent_node",
           NavigationNodeResourceImpl.getNavigationNodeResource(coralSession, parent_node_id));
     }
   } catch (Exception e) {
     throw new ProcessingException("Screen Error " + e);
   }
 }