Package ch.entwine.weblounge.common.content.page

Examples of ch.entwine.weblounge.common.content.page.PageletRenderer


    if (module == null) {
      logger.warn("Client requested pagelet renderer for non existing module {}", pagelet.getModule());
      return null;
    }

    PageletRenderer renderer = module.getRenderer(pagelet.getIdentifier());
    if (renderer == null) {
      logger.warn("Client requested pagelet renderer for non existing renderer on pagelet {}", pagelet.getIdentifier());
      return null;
    }

    // Load the contents of the renderer url
    renderer.setEnvironment(environment);
    URL rendererURL = renderer.getRenderer();
    String rendererContent = null;
    if (rendererURL != null) {
      try {
        rendererContent = loadContents(rendererURL, site, page, composer, pagelet, environment, language);
      } catch (ServletException e) {
View Full Code Here


    if (module == null) {
      logger.warn("Client requested pagelet renderer for non existing module {}", pagelet.getModule());
      return null;
    }

    PageletRenderer renderer = module.getRenderer(pagelet.getIdentifier());
    if (renderer == null) {
      logger.warn("Client requested pagelet renderer for non existing renderer on pagelet {}", pagelet.getIdentifier());
      return null;
    }

    // Load the contents of the renderer url
    renderer.setEnvironment(environment);
    URL rendererURL = renderer.getRenderer();
    String rendererContent = null;
    if (rendererURL != null) {
      try {
        rendererContent = loadContents(rendererURL, site, page, composer, pagelet, environment, language);
      } catch (ServletException e) {
View Full Code Here

    WebUrl url = request.getUrl();
    long version = request.getVersion();

    Action action = (Action) request.getAttribute(WebloungeRequest.ACTION);

    PageletRenderer renderer = null;

    try {

      String moduleId = pagelet.getModule();
      String rendererId = pagelet.getIdentifier();

      // Check access rights
      // Permission p = SystemPermission.READ;
      // if (!pagelet.checkOne(p, user.getRoleClosure()) &&
      // !pagelet.check(p, user)) {
      // logger.debug("Skipping pagelet " + i + " in composer " + composer
      // + " due to insufficient rights");
      // continue p;
      // }

      // Check publishing dates
      // TODO: Fix this. pagelet.isPublished() currently returns false,
      // as both from and to dates are null (see PublishingCtx)
      // if (!(request.getVersion() == Resource.WORK) && !pagelet.isPublished())
      // {
      // logger.debug("Skipping pagelet " + position + " in composer " + id +
      // " since it is not yet published");
      // return;
      // }

      // Select the actual renderer by method and have it render the
      // request. Since renderers are being pooled by the bundle, we
      // have to return it after the request has finished.

      Module m = site.getModule(moduleId);
      if (m == null) {
        logger.warn("Unable to render '{}' on {}://{}: module '{}' not installed", new Object[] {
            rendererId,
            site,
            request.getRequestedUrl(),
            moduleId });
        return;
      }

      // Load renderer
      renderer = m.getRenderer(rendererId);
      if (renderer == null) {
        logger.warn("No suitable renderer '" + moduleId + "/" + rendererId + "' found to handle " + url);
        return;
      }

      // Flush all data that has been created previously
      writer.flush();

      response.addTag(CacheTag.Position, Integer.toString(position));

      // Pass control to callback
      int beforePageletResult = beforePagelet(pagelet, position, writer, isGhostContent);

      // Do we need to process this pagelet?
      if (beforePageletResult == SKIP_PAGELET) {
        // At least close pagelet properly before returning
        try {
          afterPagelet(pagelet, position, writer);
        } catch (ContentRepositoryException e) {
          logger.warn("Failed to close pagelet: {}", e.getMessage());
          response.invalidate();
        } catch (ContentRepositoryUnavailableException e) {
          logger.warn("Failed to close pagelet due to missing content repository");
          response.invalidate();
        }

        return;
      }

      renderingState = RenderingState.InsidePagelet;
      writer.flush();

      // Check whether this request is being controlled by an action. If
      // so, we have to call the action on composer and pagelet start

      if (action != null && action instanceof HTMLAction) {
        HTMLAction htmlAction = (HTMLAction) action;
        try {
          if (htmlAction.startPagelet(request, response, pagelet) == HTMLAction.SKIP_PAGELET) {
            return;
          }
        } catch (Exception e) {
          logger.warn("Exception while rendering pagelet through action " + action + " on " + url, e);
          response.invalidate();
        }
      }

      // Add the pagelet's includes to the request's head section
      for (HTMLHeadElement header : renderer.getHTMLHeaders()) {
        if (!HTMLInclude.Use.Editor.equals(header.getUse()))
          response.addHTMLHeader(header);
      }

      logger.debug("Rendering pagelet " + renderer);

      // Render pagelet
      try {
        renderer.render(request, response);
        // if (orientation_ == ORIENTATION_VERTICAL) {
        // writer.println("<br class=\"weblounge\"/>");
        // }
        writer.flush();
View Full Code Here

      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()) {
      if (!HTMLInclude.Use.Editor.equals(header.getUse()))
        response.addHTMLHeader(header);
    }

    include(request, response, r, data);
View Full Code Here

          continue;
        }
      }

      // Create the pagelet
      PageletRenderer pageletRenderer = (PageletRenderer) renderer;
      PageletImpl pagelet = new PageletImpl(pageletRenderer);
      pagelet.setContent(resource);

      // Add the pagelet's data
      for (ResourceMetadata<?> metadata : resourceItem.getMetadata()) {
View Full Code Here

      List<SyndContent> entryContent = new ArrayList<SyndContent>();
      Composer composer = new ComposerImpl("preview", page.getPreview());

      for (Pagelet pagelet : composer.getPagelets()) {
        Module module = site.getModule(pagelet.getModule());
        PageletRenderer renderer = null;
        if (module == null) {
          logger.warn("Skipping pagelet {} in feed due to missing module '{}'", pagelet, pagelet.getModule());
          continue;
        }

        renderer = module.getRenderer(pagelet.getIdentifier());
        if (renderer == null) {
          logger.warn("Skipping pagelet {} in feed due to missing renderer '{}/{}'", new Object[] { pagelet, pagelet.getModule(), pagelet.getIdentifier() });
          continue;
        }

        URL rendererURL = renderer.getRenderer(RendererType.Feed.toString());
        Environment environment = request.getEnvironment();
        if (rendererURL == null)
          rendererURL = renderer.getRenderer();
        if (rendererURL != null) {
          String rendererContent = null;
          try {
            pagelet.switchTo(language);
            rendererContent = loadContents(rendererURL, site, page, composer, pagelet, environment);
View Full Code Here

      boolean hasEditor = false;

      Site site = getTargetPage().getURI().getSite();
      Module module = site.getModule(pagelet.getModule());
      if (module != null) {
        PageletRenderer renderer = module.getRenderer(pagelet.getIdentifier());
        if (renderer.getEditor() != null)
          hasEditor = true;
      }

      writer.print("<div class=\"pagelet ");
View Full Code Here

    module.setName(name);

    // pagelets
    NodeList pageletNodes = XPathHelper.selectList(config, "m:pagelets/m:pagelet", xpathProcessor);
    for (int i = 0; i < pageletNodes.getLength(); i++) {
      PageletRenderer pagelet = PageletRendererImpl.fromXml(pageletNodes.item(i), xpathProcessor);
      module.addRenderer(pagelet);
    }

    // actions
    NodeList actionNodes = XPathHelper.selectList(config, "m:actions/m:action", xpathProcessor);
View Full Code Here

      // precompilation
      Page page = new MockPageImpl(site);
      Pagelet pagelet = null;
      for (Module m : site.getModules()) {
        if (m.getRenderers().length > 0) {
          PageletRenderer r = m.getRenderers()[0];
          PageletURI pageletURI = new PageletURIImpl(page.getURI(), PageTemplate.DEFAULT_STAGE, 0);
          pagelet = new PageletImpl(pageletURI, m.getIdentifier(), r.getIdentifier());
        }
      }

      // Collect all renderers from modules and ask for precompilation
      List<URL> rendererUrls = new ArrayList<URL>();
View Full Code Here

   */
  @Override
  public boolean equals(Object o) {
    if (!(o instanceof PageletRenderer))
      return false;
    PageletRenderer r = (PageletRenderer) o;
    if (module != null && !module.equals(r.getModule()))
      return false;
    return super.equals(o);
  }
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.content.page.PageletRenderer

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.