Package ch.entwine.weblounge.common.site

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


    this.uri = uri;
    this.composerId = composer;
    this.pageletIndex = pageletIndex;
    this.environment = environment;

    Site site = uri.getSite();
    Module module = site.getModule(pagelet.getModule());
    if (module != null) {
      renderer = module.getRenderer(pagelet.getIdentifier());
      renderer.setEnvironment(environment);
    }
  }
View Full Code Here


   */
  @SuppressWarnings("unchecked")
  public void execute(String name, Dictionary<String, Serializable> ctx)
      throws JobException {

    Site site = (Site) ctx.get(Site.class.getName());

    // Get hold of the content repository
    WritableContentRepository contentRepository = null;
    if (site.getContentRepository().isReadOnly())
      throw new JobException(this, "Content repository of site '" + site + "' is read only");
    contentRepository = (WritableContentRepository) site.getContentRepository();

    // Read the configuration value for the repository url
    String repositoryUrl = (String) ctx.get(OPT_REPOSITORY_URL);
    if (StringUtils.isBlank(repositoryUrl))
      throw new JobException(this, "Configuration option '" + OPT_REPOSITORY_URL + "' is missing from the job configuration");

    // Make sure the url is well formed
    URL url = null;
    try {
      url = new URL(repositoryUrl);
    } catch (MalformedURLException e) {
      throw new JobException(this, "Repository url '" + repositoryUrl + "' is malformed: " + e.getMessage());
    }

    // Read the configuration value for the flavors
    String presentationTrackFlavor = (String) ctx.get(OPT_PRSENTATION_TRACK_FLAVORS);
    if (StringUtils.isBlank(presentationTrackFlavor))
      throw new JobException(this, "Configuration option '" + OPT_PRSENTATION_TRACK_FLAVORS + "' is missing from the job configuration");

    String presenterTrackFlavor = (String) ctx.get(OPT_PRESENTER_TRACK_FLAVORS);
    if (StringUtils.isBlank(presenterTrackFlavor))
      throw new JobException(this, "Configuration option '" + OPT_PRESENTER_TRACK_FLAVORS + "' is missing from the job configuration");

    String dcEpisodeFlavor = (String) ctx.get(OPT_EPISODE_DC_FLAVORS);
    if (StringUtils.isBlank(dcEpisodeFlavor))
      throw new JobException(this, "Configuration option '" + OPT_EPISODE_DC_FLAVORS + "' is missing from the job configuration");

    String dcSeriesFlavor = (String) ctx.get(OPT_SERIES_DC_FLAVORS);
    if (StringUtils.isBlank(dcSeriesFlavor))
      throw new JobException(this, "Configuration option '" + OPT_SERIES_DC_FLAVORS + "' is missing from the job configuration");
   
    String mimesTypes = (String) ctx.get(OPT_MIMETYPES);
    if (StringUtils.isBlank(mimesTypes))
      throw new JobException(this, "Configuration option '" + OPT_MIMETYPES + "' is missing from the job configuration");
   
   
    // Read the configuration value for the handler class
    String handlerClass = (String) ctx.get(OPT_HANDLER_CLASS);
    if (StringUtils.isBlank(handlerClass))
      throw new JobException(this, "Configuration option '" + OPT_HANDLER_CLASS + "' is missing from the job configuration");

    UserImpl harvesterUser = new UserImpl(name, site.getIdentifier(), "Harvester");

    RecordHandler handler;
    try {
      Class<? extends AbstractWebloungeRecordHandler> c = (Class<? extends AbstractWebloungeRecordHandler>) Thread.currentThread().getContextClassLoader().loadClass(handlerClass);
      Class<?> paramTypes[] = new Class[8];
View Full Code Here

  private void loadContent(boolean inheritFromParent) throws SecurityException,
  ContentRepositoryException, ContentRepositoryUnavailableException {

    try {
      WebUrl url = getRequest().getUrl();
      Site site = request.getSite();
      ContentRepository contentRepository = site.getContentRepository();
      if (contentRepository == null) {
        logger.debug("Content repository unavailable for site '{}'", site.getIdentifier());
        throw new ContentRepositoryUnavailableException("Repository is offline");
      }

      targetPage = (Page) getRequest().getAttribute(WebloungeRequest.PAGE);
View Full Code Here

   */
  @Override
  public int doEndTag() throws JspException {
    logger.debug("Rendering composer " + id);

    Site site = request.getSite();
    ComposerImpl composer = new ComposerImpl(id);
    JspWriter writer = pageContext.getOut();

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

    try {

      // Flush all input that has been written to the response so far.
      writer.flush();
      try {

        // Add tags for this composer
        response.addTag(CacheTag.Composer, id);

        // Flush all output so far
        writer.flush();

        // Start the composer
        beforeComposer(writer);
        renderingState = RenderingState.InsideComposer;
        writer.flush();

        // Load the pagelets
        composer.setPagelets(getContent());

        // Set composer
        request.setAttribute(WebloungeRequest.COMPOSER, composer);

        // Check for action handler
        if (action != null && action instanceof HTMLAction) {
          HTMLAction htmlAction = (HTMLAction) action;
          logger.debug("Action handler found");

          if (targetPage != null) {
            String templateId = targetPage.getTemplate();
            PageTemplate template = site.getTemplate(templateId);
            if (template != null && id.equalsIgnoreCase(template.getStage())) {
              template.setEnvironment(request.getEnvironment());
              if (htmlAction.startStage(request, response, composer) == HTMLAction.SKIP_COMPOSER) {
                return EVAL_PAGE;
              }
View Full Code Here

   *           if writing to the jsp fails
   */
  protected void doPagelet(Pagelet pagelet, int position, JspWriter writer,
      boolean isGhostContent) throws IOException {

    Site site = request.getSite();
    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();

      } catch (Throwable e) {
        // String params = RequestUtils.getParameters(request);
        String msg = "Error rendering '" + renderer + "' on " + site.getIdentifier() + "://" + url;
        String reason = "";
        Throwable o = e.getCause();
        if (o != null) {
          reason = o.getMessage();
          msg += ": " + reason;
View Full Code Here

  public int doStartTag() throws JspException {
    super.doStartTag();

    WebloungeRequest request = getRequest();
    User user = request.getUser();
    Site site = request.getSite();
    if (hasOneOf(user, site) && hasAllOf(user, site))
      return EVAL_BODY_INCLUDE;
    else
      return SKIP_BODY;
  }
View Full Code Here

      @PathParam("composer") String composerId,
      @PathParam("pageletindex") int pagelet,
      @QueryParam("language") String language) {

    // Load the site
    Site site = getSite(request);
    if (site == null)
      throw new WebApplicationException(Status.NOT_FOUND);

    // Return the editor
    ResourceURI uri = new PageURIImpl(site, null, pageURI, Resource.WORK);
View Full Code Here

      @PathParam("composer") String composerId,
      @PathParam("pageletindex") int pageletIndex,
      @QueryParam("language") String language, @FormParam("page") String pageXml) {

    // Load the site
    Site site = getSite(request);
    if (site == null)
      throw new WebApplicationException(Status.NOT_FOUND);

    ResourceURI uri = new PageURIImpl(site, null, pageURI, Resource.WORK);
    String renderedPagelet;
View Full Code Here

      @PathParam("composer") String composerId,
      @PathParam("pageletindex") int pageletIndex,
      @QueryParam("language") String language) {

    // Load the site
    Site site = getSite(request);
    if (site == null)
      throw new WebApplicationException(Status.NOT_FOUND);

    ResourceURI uri = new PageURIImpl(site, null, pageURI, Resource.WORK);
    String renderedPagelet;
View Full Code Here

   * @throws WebApplicationException
   *           if the site is not found or is not running
   */
  protected Site getSite(HttpServletRequest request)
      throws WebApplicationException {
    Site site = sites.findSiteByURL(UrlUtils.toURL(request, false, false));
    if (site == null) {
      throw new WebApplicationException(Status.NOT_FOUND);
    } else if (!site.isOnline()) {
      throw new WebApplicationException(Status.SERVICE_UNAVAILABLE);
    }
    return site;
  }
View Full Code Here

TOP

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

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.