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

Examples of ch.entwine.weblounge.common.impl.content.ResourceURIImpl


        imagePath = "/" + uriSuffix;
        fileName = FilenameUtils.getName(imagePath);
      }

      // Try to load the resource
      resourceURI = new ResourceURIImpl(null, site, imagePath, id);
      resource = contentRepository.get(resourceURI);
      if (resource == null) {
        logger.debug("No resource found at {}", resourceURI);
        return false;
      }
View Full Code Here


   *
   * @param uri
   *          the image uri
   */
  public ImageResourceImpl(ResourceURI uri) {
    super(new ResourceURIImpl(TYPE, uri.getSite(), uri.getPath(), uri.getIdentifier(), uri.getVersion()));
  }
View Full Code Here

   *
   * @param uri
   *          the image uri
   */
  public MovieResourceImpl(ResourceURI uri) {
    super(new ResourceURIImpl(TYPE, uri.getSite(), uri.getPath(), uri.getIdentifier(), uri.getVersion()));
  }
View Full Code Here

   *
   * @param uri
   *          the page uri
   */
  public PageImpl(ResourceURI uri) {
    super(new ResourceURIImpl(TYPE, uri.getSite(), uri.getPath(), uri.getIdentifier(), uri.getVersion()));
    this.composers = new HashMap<String, List<Pagelet>>();
  }
View Full Code Here

   *
   * @param uri
   *          the file uri
   */
  public FileResourceImpl(ResourceURI uri) {
    super(new ResourceURIImpl(TYPE, uri.getSite(), uri.getPath(), uri.getIdentifier(), uri.getVersion()));
    setLanguageResolution(LanguageResolution.Original);
  }
View Full Code Here

        while (entries.hasMoreElements()) {
          URL entry = entries.nextElement();
          String path = FilenameUtils.getPath(entry.getPath());
          path = path.substring(resourcePathPrefix.length() - 1);
          long v = ResourceUtils.getVersion(FilenameUtils.getBaseName(entry.getPath()));
          ResourceURI resourceURI = new ResourceURIImpl(serializer.getType(), site, path, v);
          resourceURIs.add(resourceURI);
          logger.trace("Found revision '{}' of {} {}", new Object[] {
              v,
              resourceURI.getType(),
              entry });
        }
      }
    }
View Full Code Here

   */
  public synchronized void move(ResourceURI uri, String path)
      throws IOException, ContentRepositoryException, IllegalStateException {

    // Do it this way to make sure we have identical path trimming
    ResourceURI newURI = new ResourceURIImpl(uri.getType(), uri.getSite(), StringUtils.trimToNull(path), uri.getIdentifier(), uri.getVersion());
    path = newURI.getPath();

    searchIdx.move(uri, path);
  }
View Full Code Here

      throw new IllegalArgumentException("Page uri cannot be null");

    List<ResourceURI> uris = new ArrayList<ResourceURI>();
    long[] versions = index.getRevisions(uri);
    for (long version : versions) {
      uris.add(new ResourceURIImpl(uri, version));
    }
    return uris.toArray(new ResourceURI[uris.size()]);

  }
View Full Code Here

    Site site = getSite(request);
    WritableContentRepository contentRepository = (WritableContentRepository) getContentRepository(site, true);

    // Create the page uri
    ResourceURIImpl pageURI = null;
    String uuid = UUID.randomUUID().toString();
    if (!StringUtils.isBlank(path)) {
      try {
        if (!path.startsWith("/"))
          path = "/" + path;
        WebUrl url = new WebUrlImpl(site, path);
        path = url.getPath();
      } catch (IllegalArgumentException e) {
        logger.warn("Tried to create a page with an invalid path '{}': {}", path, e.getMessage());
        throw new WebApplicationException(Status.BAD_REQUEST);
      }
    } else {
      path = "/" + uuid.replaceAll("-", "");
    }

    pageURI = new PageURIImpl(site, path, uuid, Resource.WORK);

    // Make sure the page doesn't exist
    try {
      if (contentRepository.existsInAnyVersion(new GeneralResourceURIImpl(site, pageURI.getPath()))) {
        logger.warn("Tried to create already existing page {} in site '{}'", pageURI, site);
        throw new WebApplicationException(Status.CONFLICT);
      }
    } catch (IllegalArgumentException e) {
      logger.warn("Tried to create a page with an invalid path '{}': {}", path, e.getMessage());
      throw new WebApplicationException(Status.BAD_REQUEST);
    } catch (ContentRepositoryException e) {
      logger.warn("Page lookup {} failed for site '{}'", pageURI, site);
      throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
    }

    // Get the user
    User user = securityService.getUser();
    if (user == null)
      throw new WebApplicationException(Status.UNAUTHORIZED);

    // 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);
      uri = new URI(UrlUtils.concat(request.getRequestURL().toString(), pageURI.getIdentifier()));
    } catch (URISyntaxException e) {
      logger.warn("Error creating a uri for page {}: {}", pageURI, e.getMessage());
      throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
    } catch (SecurityException e) {
      logger.warn("Tried to update page {} of site '{}' without permission", pageURI, site);
View Full Code Here

    // Finally, perform the unpublish operation, including saving the current
    // live version of the page as the new work version.
    try {
      contentRepository.delete(liveURI);
      ResourceURI workURI = new ResourceURIImpl(liveURI, Resource.WORK);
      if (!contentRepository.exists(workURI)) {
        logger.debug("Creating work version of {}", workURI);
        PageReader reader = new PageReader();
        Page workPage = reader.read(IOUtils.toInputStream(livePage.toXml(), "utf-8"), site);
        workPage.setVersion(Resource.WORK);
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.impl.content.ResourceURIImpl

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.