Package ch.entwine.weblounge.common.content

Examples of ch.entwine.weblounge.common.content.ResourceURI


    // Get the renderer id that has been registered with the url. For this,
    // we first have to load the page data, then get the associated renderer
    // bundle.
    try {
      Page page = null;
      ResourceURI pageURI = null;
      Site site = request.getSite();

      // Check if a page was passed as an attribute
      if (request.getAttribute(WebloungeRequest.PAGE) != null) {
        page = (Page) request.getAttribute(WebloungeRequest.PAGE);
        pageURI = page.getURI();
      }

      // Load the page from the content repository
      else {
        ContentRepository contentRepository = site.getContentRepository();
        if (contentRepository == null) {
          logger.debug("No content repository found for site '{}'", site);
          return false;
        } else if (contentRepository.isIndexing()) {
          logger.debug("Content repository of site '{}' is currently being indexed", site);
          DispatchUtils.sendServiceUnavailable(request, response);
          return true;
        }

        ResourceURI requestURI = null;
        ResourceURI requestedURI = null;

        // Load the page. Note that we are taking care of the special case where
        // a user may have created a page with a url that matches a valid
        // language identifier, in which case it would have been stripped from
        // request.getUrl().
        try {
          if (action != null) {
            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");
View Full Code Here


   *          the weblounge request
   * @return the target page
   */
  protected ResourceURI getPageURIForAction(Action action,
      WebloungeRequest request) {
    ResourceURI target = null;
    Site site = request.getSite();

    // Check if a target-page parameter was passed
    if (request.getParameter(HTMLAction.TARGET_PAGE) != null) {
      String targetUrl = request.getParameter(HTMLAction.TARGET_PAGE);
View Full Code Here

    }

    // Check if the request uri matches the special uri for files. If so, try
    // to extract the id from the last part of the path. If not, check if there
    // is a file with the current path.
    ResourceURI fileURI = null;
    Resource<? extends FileContent> fileResource = null;
    try {
      String id = null;
      String filePath = null;
View Full Code Here

    }

    // Check if the request uri matches the special uri for images. If so, try
    // to extract the id from the last part of the path. If not, check if there
    // is an image with the current path.
    ResourceURI imageURI = null;
    ImageResource imageResource = null;
    try {
      String id = null;
      String imagePath = null;
View Full Code Here

    }

    // Check if the request uri matches the special uri for previews. If so, try
    // to extract the id from the last part of the path. If not, check if there
    // is an image with the current path.
    ResourceURI resourceURI = null;
    Resource<?> resource = null;
    try {
      String id = null;
      String imagePath = null;
View Full Code Here

    long resourceLastModified = ResourceUtils.getModificationDate(resource, language).getTime();

    // Create the preview if this is the first request
    if (firstOne) {

      ResourceURI resourceURI = resource.getURI();

      if (style != null)
        logger.info("Creating preview of {} with style '{}' at {}", new String[] {
            resource.getIdentifier(),
            style.getIdentifier(),
View Full Code Here

      // The search result item seems to be coming from the search index

      // Convert the search result item into a resource search result item
      ResourceSearchResultItem resourceItem = (ResourceSearchResultItem) item;
      ResourceURI uri = resourceItem.getResourceURI();

      ResourceSerializer<?, ?> serializer = serializerService.getSerializerByType(uri.getType());
      if (serializer == null) {
        logger.debug("Skipping search result since it's type ({}) is unknown", uri.getType());
        continue;
      }

      // Load the resource
      Resource<?> resource = serializer.toResource(site, resourceItem.getMetadata());
View Full Code Here

   *           if the target page cannot be loaded
   */
  protected Page getTargetPage(WebloungeRequest request)
      throws ContentRepositoryException {

    ResourceURI target = null;
    Page page = null;
    Site site = request.getSite();
    boolean targetForced = false;

    // Check if a target-page parameter was passed
View Full Code Here

    assertEquals(0, repository.find(livePreferredQuery).getDocumentCount());
    assertEquals(0, repository.find(workOnlyQuery).getDocumentCount());
    assertEquals(0, repository.find(liveOnlyQuery).getDocumentCount());

    // Create URI and pages and add them to the repository
    ResourceURI liveOnlyURI = new PageURIImpl(site, "/liveonly", LIVE);
    ResourceURI liveAndWorkLiveURI = new PageURIImpl(site, "/liveandwork", LIVE);
    ResourceURI liveAndWorkWorkURI = new PageURIImpl(site, "/liveandwork", WORK);
    ResourceURI workOnlyURI = new PageURIImpl(site, "/workonly", WORK);

    Page liveOnly = new PageImpl(liveOnlyURI);
    liveOnly.setTemplate(template.getIdentifier());
    Page liveAndWorkLive = new PageImpl(liveAndWorkLiveURI);
    liveAndWorkLive.setTemplate(template.getIdentifier());
View Full Code Here

      throw new JspException();
    }

    // Create the image uri, either from the id or the path. If none is
    // specified, and we are not in jsp compilation mode, issue a warning
    ResourceURI uri = null;
    if (StringUtils.isNotBlank(imageId))
      uri = new ImageResourceURIImpl(site, null, imageId);
    if (uri == null && StringUtils.isNotBlank(imagePath))
      uri = new ImageResourceURIImpl(site, imagePath, null);
    if (uri == null && imageSubjects != null && imageSubjects.size() > 0) {
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.content.ResourceURI

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.