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

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


        String decocedTargetUrl = null;
        String encoding = request.getCharacterEncoding();
        if (encoding == null)
          encoding = "utf-8";
        decocedTargetUrl = URLDecoder.decode(targetPage, encoding);
        target = new PageURIImpl(site, decocedTargetUrl);
      } catch (UnsupportedEncodingException e) {
        logger.warn("Error while decoding target url {}: {}", targetPage, e.getMessage());
        target = new PageURIImpl(site, "/");
      }
    }

    // Check the action configuration
    else if (action instanceof HTMLAction) {
      HTMLAction htmlAction = (HTMLAction) action;
      if (htmlAction.getPageURI() != null) {
        target = htmlAction.getPageURI();
        targetForced = true;
      }
    }

    // Nothing found, let's choose the site's homepage
    if (target == null) {
      target = new PageURIImpl(site, "/");
    }

    // We are about to render the action output in the composers of the target
    // page. This is why we have to make sure that this target page exists,
    // otherwise the user will get a 404.
    ContentRepository contentRepository = site.getContentRepository();
    if (contentRepository == null) {
      logger.warn("Content repository not available to read target page for action '{}'", action, target);
      return null;
    }

    // Does the page exist?
    page = (Page) contentRepository.get(target);
    if (page == null) {
      if (targetForced) {
        logger.warn("Output of action '{}' is configured to render on non existing page {}", action, target);
        return null;
      }

      // Fall back to site homepage
      target = new PageURIImpl(site, "/");
      page = (Page) contentRepository.get(target);
      if (page == null) {
        logger.debug("Site {} has no homepage as fallback to render actions", site);
        return null;
      }
View Full Code Here


            pageURI = getPageURIForAction(action, request);
            requestURI = pageURI;
          } else if (path.startsWith(URI_PREFIX)) {
            String uriSuffix = StringUtils.substringBefore(path.substring(URI_PREFIX.length()), "/");
            uriSuffix = URLDecoder.decode(uriSuffix, "utf-8");
            ResourceURI uri = new PageURIImpl(site, null, uriSuffix, request.getVersion());
            requestURI = uri;
            WebUrl requestedUrl = request.getRequestedUrl();
            if (requestedUrl.hasLanguagePathSegment()) {
              String requestedPath = UrlUtils.concat(path, request.getLanguage().getIdentifier());
              String requestedUriSuffix = StringUtils.substringBefore(requestedPath.substring(URI_PREFIX.length()), "/");
              requestedUriSuffix = URLDecoder.decode(requestedUriSuffix, "utf-8");
              requestedURI = new PageURIImpl(site, requestedUriSuffix, null, request.getVersion());
            }
          } else {
            long version = isEditing ? Resource.WORK : Resource.LIVE;
            ResourceURI uri = new PageURIImpl(request);
            uri.setVersion(version);
            requestURI = uri;
            WebUrl requestedUrl = request.getRequestedUrl();
            if (requestedUrl.hasLanguagePathSegment()) {
              String requestedPath = UrlUtils.concat(path, request.getLanguage().getIdentifier());
              requestedPath = URLDecoder.decode(requestedPath, "utf-8");
              requestedURI = new PageURIImpl(site, requestedPath, null, version);
            }
          }

          // Is this a request with potential path clashes?
          if (requestedURI != null) {
View Full Code Here

        String decocedTargetUrl = null;
        String encoding = request.getCharacterEncoding();
        if (encoding == null)
          encoding = "utf-8";
        decocedTargetUrl = URLDecoder.decode(targetUrl, encoding);
        target = new PageURIImpl(site, decocedTargetUrl);
      } catch (UnsupportedEncodingException e) {
        logger.warn("Error while decoding target url {}: {}", targetUrl, e.getMessage());
        target = new PageURIImpl(site, "/");
      }
    }

    // Nothing found, let's choose the site's homepage
    if (target == null) {
      target = new PageURIImpl(site, "/");
    }

    return target;
  }
View Full Code Here

        String decocedTargetUrl = null;
        String encoding = request.getCharacterEncoding();
        if (encoding == null)
          encoding = "utf-8";
        decocedTargetUrl = URLDecoder.decode(targetPage, encoding);
        target = new PageURIImpl(site, decocedTargetUrl);
      } catch (UnsupportedEncodingException e) {
        logger.warn("Error while decoding target url {}: {}", targetPage, e.getMessage());
        target = new PageURIImpl(site, "/");
      }
    }

    // Nothing found, let's choose the site's homepage
    if (target == null) {
      target = new PageURIImpl(site, "/");
    }

    // We are about to render the action output in the composers of the target
    // page. This is why we have to make sure that this target page exists,
    // otherwise the user will get a 404.
    ContentRepository contentRepository = site.getContentRepository();
    if (contentRepository == null) {
      logger.warn("Content repository not available to read target page {}", target);
      return null;
    }

    // Does the page exist?
    page = (Page) contentRepository.get(target);
    if (page == null) {
      if (targetForced) {
        logger.warn("Output of search request is configured to render on non existing page {}", target);
        return null;
      }

      // Fall back to site homepage
      target = new PageURIImpl(site, "/");
      page = (Page) contentRepository.get(target);
      if (page == null) {
        logger.debug("Site {} has no homepage as fallback to render search result", site);
        return null;
      }
View Full Code Here

   */
  @Before
  public void setUp() throws Exception {

    // Setup uris
    page1URI = new PageURIImpl(site, page1path, page1uuid);
    page2URI = new PageURIImpl(site, page2path, page2uuid);
    imageURI = new ImageResourceURIImpl(site, imagePath, imageUuid);
    documentURI = new FileResourceURIImpl(site, documentPath, documentUuid);

    // Prepare the pages
    PageReader pageReader = new PageReader();
View Full Code Here

   * @throws IllegalStateException
   */
  @Test
  public void testDeleteResourceURIBoolean() throws IllegalStateException,
  ContentRepositoryException, IOException {
    ResourceURI workURI = new PageURIImpl(site, page1path, page1uuid, WORK);
    Page workPage = new PageImpl(workURI);
    workPage.setTemplate(template.getIdentifier());
    int resources = populateRepository();
    int revisions = resources;

View Full Code Here

    String oldPath = page1URI.getPath();
    String newPath = "/new/path";

    repository.move(page1URI, newPath, false);
    assertEquals(resources, repository.getResourceCount() - 1);
    assertNull(repository.get(new PageURIImpl(site, oldPath)));
    assertNotNull(repository.get(new PageURIImpl(site, newPath)));

    // Test null target path
    try {
      repository.move(documentURI, null, false);
      fail("Managed to move a resource to a null path");
View Full Code Here

    for (int i = 0; i < pages; i++) {
      String id = UUID.randomUUID().toString();
      ResourceURI uri = null;
      if (subpath != null) {
        subpath = PathUtils.concat(subpath, id);
        uri = new PageURIImpl(site, subpath, id);
      } else {
        subpath = root;
        rootURI = new PageURIImpl(site, root, id);
        uri = new PageURIImpl(site, root, id);
      }
      Page p = new PageImpl(uri);
      p.setTemplate(template.getIdentifier());
      repository.put(p);
    }
View Full Code Here

  ContentRepositoryException, IOException {
    populateRepository();
    Resource<?> r = repository.get(page1URI);
    assertNotNull(r);
    assertEquals(page1URI.getIdentifier(), r.getIdentifier());
    assertNull(repository.get(new PageURIImpl(site, "/abc")));
    assertNull(repository.get(new PageURIImpl(site, null, "a-b-c-d")));
    assertNull(repository.get(new PageURIImpl(page1URI, WORK)));
  }
View Full Code Here

   * @throws IllegalStateException
   */
  @Test
  public void testGetVersions() throws ContentRepositoryException,
  IllegalStateException, IOException {
    ResourceURI live1URI = new PageURIImpl(site, "/weblounge");
    ResourceURI live2URI = new PageURIImpl(site, "/etc/weblounge");
    ResourceURI work2URI = new PageURIImpl(site, "/etc/weblounge", WORK);

    Page page1Live = new PageImpl(live1URI);
    Page page2Live = new PageImpl(live2URI);
    Page page2Work = new PageImpl(work2URI);

View Full Code Here

TOP

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

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.