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

Examples of ch.entwine.weblounge.common.impl.content.page.PageImpl


   *
   * @throws java.lang.Exception
   */
  @Before
  public void setUp() throws Exception {
    page = new PageImpl(new PageURIImpl(site, "/weblounge"));
    page.setTemplate("home");

    otherPage = new PageImpl(new PageURIImpl(site, "/weblounge/other"));
    otherPage.setTemplate("home");

    file = new FileResourceImpl(new FileResourceURIImpl(site));
  }
View Full Code Here


  public void testGetRevisions() {
    ResourceURI uri1 = new PageURIImpl(site, "/weblounge");
    ResourceURI uri2Live = new PageURIImpl(site, "/etc/weblounge");
    ResourceURI uri2Work = new PageURIImpl(site, "/etc/weblounge", Resource.WORK);

    Page page1 = new PageImpl(uri1);
    page1.setTemplate(template.getIdentifier());

    Page page2Live = new PageImpl(uri2Live);
    page2Live.setTemplate(template.getIdentifier());

    Page page2Work = new PageImpl(uri2Work);
    page2Work.setTemplate(template.getIdentifier());

    try {
      idx.add(page1);
      idx.add(page2Live);
      idx.add(page2Work);
View Full Code Here

        b.append(UUID.randomUUID().toString());
        b.append("/");
      }
      String path = b.toString();
      String id = UUID.randomUUID().toString();
      Page p = new PageImpl(new PageURIImpl(site, path, id));
      p.setTemplate("home");
      p.setTitle("title", english);
      pages.add(p);
      ResourceURI uri = idx.add(p);
      assertEquals(id, uri.getIdentifier());
      assertEquals(path, uri.getPath());
      assertEquals(i + 1, idx.getResourceCount());
    }

    // Test if everything can be found
    for (Page p : pages) {
      assertTrue(idx.exists(p.getURI()));
      assertEquals(p.getURI().getIdentifier(), idx.getIdentifier(p.getURI()));
      assertEquals(p.getURI().getPath(), idx.getPath(p.getURI()));
      assertEquals(1, idx.getRevisions(p.getURI()).length);
    }

  }
View Full Code Here

    // Add 10 sub pages
    for (int i = 0; i < 10; i++) {
      String id = UUID.randomUUID().toString();
      String path = PathUtils.concat(path1, id);
      ResourceURI uri = new PageURIImpl(site, path, id);
      Page p = new PageImpl(uri);
      p.setTemplate(template.getIdentifier());
      idx.add(p);

      String subPageId = UUID.randomUUID().toString();
      String subPath = PathUtils.concat(path, subPageId);
      uri = new PageURIImpl(site, subPath, subPageId);
      p = new PageImpl(uri);
      p.setTemplate(template.getIdentifier());
      idx.add(p);
    }

    SearchQuery q = new SearchQueryImpl(site).withTypes(Page.TYPE).withPathPrefix(path1);
    q.withLimit(100);
View Full Code Here

    // Make sure the user has editing rights
    if (!SecurityUtils.userHasRole(user, SystemRole.EDITOR))
      throw new WebApplicationException(Status.UNAUTHORIZED);

    // Parse the page and store it
    PageImpl page = null;
    URI uri = null;
    if (!StringUtils.isBlank(pageXml)) {
      logger.debug("Adding page to {}", pageURI);
      try {
        PageReader pageReader = new PageReader();
        page = pageReader.read(IOUtils.toInputStream(pageXml, "utf-8"), site);
        page.setIdentifier(pageURI.getIdentifier());
        page.setPath(pageURI.getPath());
        page.setVersion(pageURI.getVersion());
      } catch (IOException e) {
        logger.warn("Error reading page {} from request", pageURI);
        throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
      } catch (ParserConfigurationException e) {
        logger.warn("Error configuring parser to read updated page {}: {}", pageURI, e.getMessage());
        throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
      } catch (SAXException e) {
        logger.warn("Error parsing updated page {}: {}", pageURI, e.getMessage());
        throw new WebApplicationException(Status.BAD_REQUEST);
      }
    } else {
      logger.debug("Creating new page at {}", pageURI);
      page = new PageImpl(pageURI);
      page.setTemplate(site.getDefaultTemplate().getIdentifier());
      page.setCreated(user, new Date());
    }

    // Store the new page
    try {
      contentRepository.put(page, true);
View Full Code Here

   * {@inheritDoc}
   *
   * @see ch.entwine.weblounge.common.repository.ResourceSerializer#newResource(ch.entwine.weblounge.common.site.Site)
   */
  public Resource<ResourceContent> newResource(Site site) {
    return new PageImpl(new PageURIImpl(site));
  }
View Full Code Here

      ContentRepositoryException {
    // Make sure there is a home page
    ResourceURI homeURI = new ResourceURIImpl(Page.TYPE, site, "/");
    if (!existsInAnyVersion(homeURI)) {
      try {
        Page page = new PageImpl(homeURI);
        User siteAdmininstrator = new UserImpl(site.getAdministrator());
        page.setTemplate(site.getDefaultTemplate().getIdentifier());
        page.setCreated(siteAdmininstrator, new Date());
        page.setPublished(siteAdmininstrator, new Date(), null);
        put(page, true);
        logger.info("Created homepage for {}", site.getIdentifier());
      } catch (IOException e) {
        logger.warn("Error creating home page in empty site '{}': {}", site.getIdentifier(), e.getMessage());
      }
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.impl.content.page.PageImpl

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.