Package ch.entwine.weblounge.common.content

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


      } else if (searchResult.getHitCount() > 1) {
        logger.error("The repository contains already more than one element of {}", recordIdentifier);
      } else {
        Resource<?> resource = parseResource(record);
        resource.setPublished(harvesterUser, date, null);
        ResourceContent content = parseResourceContent(record);

        if (resource == null || content == null)
          return;

        addResource(resource);
        content.setSource(recordIdentifier);
        addContent(resource.getURI(), content);
        logger.info("Harvesting resource " + recordIdentifier);
      }
    }
  }
View Full Code Here


   * @see java.lang.Object#equals(java.lang.Object)
   */
  @Override
  public boolean equals(Object obj) {
    if (obj instanceof ResourceContent) {
      ResourceContent c = (ResourceContent) obj;
      if (!StringUtils.trimToEmpty(filename).equals(StringUtils.trimToEmpty(c.getFilename())))
        return false;
      if (!StringUtils.trimToEmpty(author).equals(StringUtils.trimToEmpty(c.getAuthor())))
        return false;
      return language.equals(c.getLanguage());
    }
    return false;
  }
View Full Code Here

      logger.error("Error trying to look up resource {} from {}", resourceId, repository);
      return SKIP_BODY;
    }

    Resource<?> resource = null;
    ResourceContent resourceContent = null;

    // Try to determine the language
    Language language = request.getLanguage();

    // Store the result in the jsp page context
View Full Code Here

    String newfilename = "newimage.jpeg";
    String mimetype = "image/png";
    Language language = jpegContent.getLanguage();
    ImageContent updatedContent = new ImageContentImpl(newfilename, language, mimetype, 1000, 600);
    r = repository.putContent(imageURI, updatedContent, pngContentURL.openStream());
    ResourceContent c = r.getContent(language);
    assertEquals(pngFileSize, c.getSize());
    assertEquals(mimetype, c.getMimetype());

    // Try to add content items to non-existing resources
    try {
      ResourceURI uri = new ImageResourceURIImpl(site, "/x/y/z");
      repository.putContent(uri, jpegContent, jpegContentURL.openStream());
View Full Code Here

      DispatchUtils.sendNotModified(request, response);
      return true;
    }

    // Load the image contents from the repository
    ResourceContent resourceContents = resource.getContent(language);

    // Add mime type header
    String contentType = resourceContents.getMimetype();
    if (contentType == null)
      contentType = MediaType.APPLICATION_OCTET_STREAM;

    // Set the content type
    String characterEncoding = response.getCharacterEncoding();
    if (StringUtils.isNotBlank(characterEncoding))
      response.setContentType(contentType + "; charset=" + characterEncoding.toLowerCase());
    else
      response.setContentType(contentType);

    // Browser caches and proxies are allowed to keep a copy
    response.setHeader("Cache-Control", "public, max-age=" + revalidationTime);

    // Set Expires header
    response.setDateHeader("Expires", expirationDate);

    // Write the image back to the client
    InputStream previewInputStream = null;
    try {
      if (previewFile.isFile() && previewFile.lastModified() >= resourceContents.getCreationDate().getTime()) {
        previewInputStream = new FileInputStream(previewFile);
      } else {
        previewInputStream = createPreview(request, response, resource, language, style, previewGenerator, previewFile, contentRepository);
      }
View Full Code Here

        logger.info("Creating original preview of {} at {}", new String[] {
            resource.getIdentifier(),
            pathToImageFile });

      // Get hold of the content
      ResourceContent resourceContents = resource.getContent(language);

      // Get the mime type
      final String mimetype = resourceContents.getMimetype();
      final String format = mimetype.substring(mimetype.indexOf("/") + 1);

      boolean scalingFailed = false;

      InputStream is = null;
View Full Code Here

      logger.error("Error trying to look up resource {} from {}", searchResultItem.getId(), repository);
      return SKIP_BODY;
    }

    Resource<?> resource = null;
    ResourceContent resourceContent = null;

    try {
      resource = repository.get(uri);
      resource.switchTo(request.getLanguage());
      resourceContent = resource.getContent(request.getLanguage());
View Full Code Here

   */
  public String getSuffix(Resource<?> resource, Language language,
      ImageStyle style) {

    // Load the resource
    ResourceContent content = resource.getContent(language);
    if (content == null) {
      content = resource.getOriginalContent();
      if (content == null) {
        logger.warn("Trying to get filename suffix for {}, which has no content", resource);
        return null;
      }
    }

    // Get the file name
    String filename = content.getFilename();
    if (StringUtils.isBlank(filename)) {
      logger.warn("Trying to get filename suffix for {}, which has no filename", resource);
      return null;
    }

View Full Code Here

   *      ch.entwine.weblounge.common.content.image.ImageStyle)
   */
  public String getSuffix(Resource<?> resource, Language language,
      ImageStyle style) {
    // Load the resource
    ResourceContent content = resource.getContent(language);
    if (content == null) {
      content = resource.getOriginalContent();
      if (content == null) {
        logger.warn("Trying to get filename suffix for {}, which has no content", resource);
        return null;
      }
    }

    // Get the file name
    String filename = content.getFilename();
    if (StringUtils.isBlank(filename)) {
      logger.warn("Trying to get filename suffix for {}, which has no filename", resource);
      return null;
    }

View Full Code Here

    ResourceURI resourceURI = resource.getURI();
    String resourceType = resourceURI.getType();

    // Create the filename
    ResourceContent content = resource.getContent(language);

    // Initiate creation of previews
    InputStream resourceInputStream = null;
    InputStream contentRepositoryIs = null;
    FileOutputStream fos = null;
    File scaledResourceFile = null;

    try {
      scaledResourceFile = ImageStyleUtils.getScaledFile(resource, language, style);

      // Find the modification date
      long lastModified = ResourceUtils.getModificationDate(resource, language).getTime();

      // Create the file if it doesn't exist or if it is out dated. Note that
      // the last modified date of a file has a precision of seconds
      if (!scaledResourceFile.isFile() || FileUtils.isFileOlder(scaledResourceFile, new Date(lastModified))) {
        contentRepositoryIs = contentRepository.getContent(resourceURI, language);

        // Is this local content?
        if (contentRepositoryIs == null && content != null && content.getExternalLocation() != null) {
          contentRepositoryIs = content.getExternalLocation().openStream();
        }

        // Create the parent directory
        File scaledResourceDir = scaledResourceFile.getParentFile();
        if (!scaledResourceDir.isDirectory() && !scaledResourceDir.mkdirs()) {
View Full Code Here

TOP

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

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.