Package ch.entwine.weblounge.common.site

Examples of ch.entwine.weblounge.common.site.ActionException


   */
  protected void include(WebloungeRequest request, WebloungeResponse response,
      PageletRenderer renderer, Pagelet data) throws ActionException {
    if (renderer == null) {
      String msg = "The renderer passed to include in action '" + this + "' was <null>!";
      throw new ActionException(new IllegalArgumentException(msg));
    }

    if (data != null)
      request.setAttribute(WebloungeRequest.PAGELET, data);

View Full Code Here


   *           if the passed renderer cannot be found.
   */
  protected void include(WebloungeRequest request, WebloungeResponse response,
      String module, String renderer, Pagelet data) throws ActionException {
    if (module == null)
      throw new ActionException(new IllegalArgumentException("Module is null!"));
    if (renderer == null)
      throw new ActionException(new IllegalArgumentException("Renderer is null!"));
    Module m = getSite().getModule(module);
    if (m == null) {
      String msg = "Trying to include renderer from unknown module '" + module + "'";
      throw new ActionException(new IllegalArgumentException(msg));
    }
    include(request, response, m, renderer, data);
  }
View Full Code Here

   *           if the passed renderer cannot be found.
   */
  protected void include(WebloungeRequest request, WebloungeResponse response,
      Module module, String renderer, Pagelet data) throws ActionException {
    if (module == null)
      throw new ActionException(new IllegalArgumentException("Module is null!"));
    if (renderer == null)
      throw new ActionException(new IllegalArgumentException("Renderer is null!"));
    PageletRenderer r = module.getRenderer(renderer);
    if (r == null) {
      String msg = "Trying to include unknown renderer '" + renderer + "'";
      throw new ActionException(new IllegalArgumentException(msg));
    }
    logger.debug("Including renderer {}", renderer);

    // Add the pagelet's header elements to the response
    for (HTMLHeadElement header : r.getHTMLHeaders()) {
View Full Code Here

  protected void returnXML(Element doc, Transformer transformer)
      throws ActionException {
    try {
      transformer.transform(new DOMSource(doc), new StreamResult(response.getWriter()));
    } catch (TransformerException e) {
      throw new ActionException("Unable to create xml response", e);
    } catch (IOException e) {
      throw new ActionException("Unable to send xml response", e);
    }
  }
View Full Code Here

  protected void returnXML(Element doc) throws ActionException {
    try {
      Transformer transformer = transformerFactory.newTransformer();
      returnXML(doc, transformer);
    } catch (Throwable t) {
      throw new ActionException("Unable to create an xml transformer", t);
    }
  }
View Full Code Here

   */
  protected void returnJSON(Object json) throws ActionException {
    try {
      mapper.writeValue(response.getWriter(), json);
    } catch (IOException e) {
      throw new ActionException("Unable to send json response", e);
    }
  }
View Full Code Here

  public void startJSON(WebloungeRequest request, WebloungeResponse response)
      throws IOException, ActionException {
    try {
      String language = RequestUtils.getParameter(request, LANGUAGE_PARAM);
      if (language == null)
        throw new ActionException(HttpServletResponse.SC_BAD_REQUEST);
      Map<String, String> data = new HashMap<String, String>();
      String encoding = response.getCharacterEncoding();
      if (encoding == null)
        encoding = "utf-8";
      data.put(language, new String(greeting.getBytes(encoding), encoding));
      ObjectMapper mapper = new ObjectMapper();
      mapper.writeValue(response.getOutputStream(), data);
    } catch (IOException e) {
      throw new ActionException("Unable to send json response", e);
    }
  }
View Full Code Here

      root.appendChild(greetingNode);
      TransformerFactory factory = TransformerFactory.newInstance();
      Transformer transformer = factory.newTransformer();
      transformer.transform(new DOMSource(doc), new StreamResult(response.getWriter()));
    } catch (Throwable t) {
      throw new ActionException("Unable to create and send xml response", t);
    }
  }
View Full Code Here

    Map<String, String> allGreetings = TestSiteUtils.loadGreetings();
    try {
      language = getLanguage(request);
      greeting = allGreetings.get(language);
    } catch (IllegalStateException e) {
      throw new ActionException("Language parameter '" + LANGUAGE_PARAM + "' was not specified");
    }

    // Load the template
    String codeTemplate = StringUtils.trimToNull(request.getParameter(CODE_TEMPLATE));
    if (codeTemplate != null) {
View Full Code Here

      // Include another pagelet
      include(request, response, PAGELET_ID, null);
      return HTMLAction.SKIP_COMPOSER;
    } catch (IOException e) {
      throw new ActionException("Unable to send json response", e);
    }
  }
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.site.ActionException

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.