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

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


    if (composerId == null)
      throw new IllegalArgumentException("Composer must not be null");
    if (pageletIndex < 0)
      throw new IllegalArgumentException("Pagelet index must be a positive integer");

    Page page = getPage(site, pageURI);
    if (page == null) {
      logger.warn("Client requested pagelet editor for non existing page {}", pageURI);
      return null;
    }

    // Load the composer
    Composer composer = page.getComposer(composerId);
    if (composer == null) {
      logger.warn("Client requested pagelet editor for non existing composer '{}' on page {}", composerId, pageURI);
      return null;
    }
View Full Code Here


      logger.warn("No content repository found for site '{}'", site);
      throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
    }

    // Load the page
    Page page = null;
    try {
      page = (Page) contentRepository.get(pageURI);
    } catch (ContentRepositoryException e) {
      logger.error("Error trying to access content repository {}: {}", contentRepository, e);
      throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
View Full Code Here

   */
  public String getRenderer(Site site, ResourceURI pageURI, String composerId,
      int pageletIndex, String language, Environment environment)
          throws IOException {

    Page page = getPage(site, pageURI);
    if (page == null) {
      logger.warn("Client requested pagelet renderer for non existing page {}", pageURI);
      return null;
    }

    // Load the composer
    Composer composer = page.getComposer(composerId);
    if (composer == null) {
      logger.warn("Client requested pagelet renderer for non existing composer {} on page {}", composerId, pageURI);
      return null;
    }

View Full Code Here

  public String getRenderer(Site site, ResourceURI pageURI, String composerId,
      int pageletIndex, String pageXml, String language, Environment environment)
          throws IOException, ParserConfigurationException, SAXException {

    InputStream is = null;
    Page page = null;
    try {
      PageReader pageReader = new PageReader();
      is = IOUtils.toInputStream(pageXml, "utf-8");
      page = pageReader.read(is, site);
    } finally {
      IOUtils.closeQuietly(is);
    }

    // Load the composer
    Composer composer = page.getComposer(composerId);
    if (composer == null) {
      logger.warn("Client requested pagelet renderer for non existing composer {} on page {}", composerId, pageURI);
      return null;
    }
View Full Code Here

      Pagelet[] content = contentProvider.getPagelets(id);
      Pagelet[] ghostContent = new Pagelet[0];

      // If composer is empty and ghost content is enabled, go up the page
      // hierarchy and try to find content for this composer
      Page contentPage = contentProvider;
      if (content.length == 0 && inheritFromParent) {
        String pageUrl = contentPage.getURI().getPath();
        while (ghostContent.length == 0 && pageUrl.length() > 1) {
          if (pageUrl.endsWith("/") && !"/".equals(pageUrl))
            pageUrl = pageUrl.substring(0, pageUrl.length() - 1);
          int urlSeparator = pageUrl.lastIndexOf("/");
          if (urlSeparator < 0) {
            contentPage = null;
            break;
          } else {
            pageUrl = pageUrl.substring(0, urlSeparator);
            if ("".equals(pageUrl))
              pageUrl = "/";
            ResourceURI pageURI = new PageURIImpl(site, pageUrl);
            try {
              contentPage = (Page) contentRepository.get(pageURI);
            } catch (SecurityException e) {
              logger.debug("Prevented loading of protected content from inherited page {} for composer {}", pageURI, id);
            }

            // Did we find anything? If not, keep looking...
            if (contentPage == null) {
              logger.debug("Ancestor page {} could not be loaded", pageUrl);
              continue;
            }

            // If potential ghost content is available, keep it
            if (!contentPage.equals(targetPage)) {
              ghostContentProvider = contentPage;
              ghostContent = contentPage.getPagelets(id);
            }

          }
        }
      }
View Full Code Here

      pages = repository.find(query);
    }

    boolean found = false;
    PageSearchResultItem item = null;
    Page page = null;
    WebUrl url = null;

    // Look for the next header
    while (!found && index < pages.getItems().length) {
      SearchResultItem candidateItem = pages.getItems()[index];
      if (!(candidateItem instanceof PageSearchResultItem)) {
        index++;
        continue;
      }
      item = (PageSearchResultItem) candidateItem;

      // Store the important properties
      url = item.getUrl();
      page = item.getPage();

      // TODO security check

      found = true;
    }

    // Set the headline in the request and add caching information
    if (found && page != null) {
      this.page = page;
      this.preview = new ComposerImpl("stage", page.getPreview());
      this.url = url;
      pageContext.setAttribute(PageListTagExtraInfo.PREVIEW_PAGE, page);
      pageContext.setAttribute(PageListTagExtraInfo.PREVIEW, preview);
     
      // Add cache tags
      response.addTag(CacheTag.Resource, page.getURI().getIdentifier());
      if (url != null)
        response.addTag(CacheTag.Url, url.getPath());
     
      // Adjust modification date
      response.setModificationDate(page.getLastModified());
    }

    return found;
  }
View Full Code Here

    } catch (ContentRepositoryException e) {
      logger.error("Error trying to look up page {} from {}", pageId, repository);
      return SKIP_BODY;
    }

    Page page = null;

    // Store the result in the jsp page context
    try {
      page = (Page) repository.get(uri);
      language = LanguageUtils.getPreferredLanguage(page, request, site);
      if (language != null)
        page.switchTo(language);
    } catch (ContentRepositoryException e) {
      logger.warn("Error trying to load page " + uri + ": " + e.getMessage(), e);
      return SKIP_BODY;
    }

    // TODO: Check the permissions

    // Store the page and the page content in the request
    stashAndSetAttribute(PageTagExtraInfo.PAGE, page);
   
    // Add the cache tags to the response
    response.addTag(CacheTag.Resource, page.getURI().getIdentifier());
    response.addTag(CacheTag.Url, page.getURI().getPath());
   
    // Adjust the modification time
    response.setModificationDate(page.getLastModified());

    return EVAL_BODY_INCLUDE;
  }
View Full Code Here

      // Get the messages from the server
      try {
        for (Message message : inbox.getMessages()) {
          if (!message.isSet(Flag.SEEN)) {
            try {
              Page page = aggregate(message, site);
              message.setFlag(Flag.DELETED, true);
              repository.put(page, true);
              logger.info("E-Mail message published at {}", page.getURI());
            } catch (Exception e) {
              logger.info("E-Mail message discarded: {}", e.getMessage());
              message.setFlag(Flag.SEEN, true);
              // TODO: Reply to sender if the "from" field exists
            }
View Full Code Here

   */
  protected Page aggregate(Message message, Site site) throws IOException,
  MessagingException, IllegalArgumentException {

    ResourceURI uri = new PageURIImpl(site, UUID.randomUUID().toString());
    Page page = new PageImpl(uri);
    Language language = site.getDefaultLanguage();

    // Extract title and subject. Without these two, creating a page is not
    // feasible, therefore both messages throw an IllegalArgumentException if
    // the fields are not present.
    String title = getSubject(message);
    String author = getAuthor(message);

    // Collect default settings
    PageTemplate template = site.getDefaultTemplate();
    if (template == null)
      throw new IllegalStateException("Missing default template in site '" + site + "'");
    String stage = template.getStage();
    if (StringUtils.isBlank(stage))
      throw new IllegalStateException("Missing stage definition in template '" + template.getIdentifier() + "'");

    // Standard fields
    page.setTitle(title, language);
    page.setTemplate(template.getIdentifier());
    page.setPublished(new UserImpl(site.getAdministrator()), message.getReceivedDate(), null);

    // TODO: Translate e-mail "from" into site user and throw if no such
    // user can be found
    page.setCreated(site.getAdministrator(), message.getSentDate());

    // Start looking at the message body
    String contentType = message.getContentType();
    if (StringUtils.isBlank(contentType))
      throw new IllegalArgumentException("Message content type is unspecified");
View Full Code Here

   * Writes the title tag to the output.
   *
   * @see javax.servlet.jsp.tagext.Tag#doEndTag()
   */
  public int doEndTag() throws JspException {
    Page p = (Page) request.getAttribute(WebloungeRequest.PAGE);
    Language l = getRequest().getLanguage();
    try {
      pageContext.getOut().write(p.getTitle(l));
    } catch (IOException e) {
      logger.warn("Error writing title element to page");
    }
    return super.doEndTag();
  }
View Full Code Here

TOP

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

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.