Examples of ThumbnailData


Examples of com.google.walkaround.wave.server.attachment.ThumbnailDirectory.ThumbnailData

      throw NotFoundException.withInternalMessage("Attachment id unknown: " + id);
    }
    BlobKey key = metadata.getBlobKey();
    // TODO(danilatos): Factor out some of this code into a separate method so that
    // thumbnails can be eagerly created at upload time.
    ThumbnailData thumbnail = thumbnailDirectory.getWithoutTx(key);

    if (thumbnail == null) {
      log.info("Generating and storing thumbnail for " + key);

      ImageMetadata thumbDimensions = metadata.getThumbnail();

      if (thumbDimensions == null) {
        // TODO(danilatos): Provide a default thumbnail
        throw NotFoundException.withInternalMessage("No thumbnail available for attachment " + id);
      }

      byte[] thumbnailBytes = rawService.getResizedImageBytes(key,
          thumbDimensions.getWidth(), thumbDimensions.getHeight());

      thumbnail = new ThumbnailData(key, thumbnailBytes);

      if (thumbnailBytes.length > maxThumbnailSavedSizeBytes) {
        log.warning("Thumbnail for " + key + " too large to store " +
            "(" + thumbnailBytes.length + " bytes)");
        // TODO(danilatos): Cache this condition in memcache.
        throw NotFoundException.withInternalMessage("Thumbnail too large for attachment " + id);
      }

      thumbnailDirectory.getOrAdd(thumbnail);

    } else {
      log.info("Using already stored thumbnail for " + key);
    }

    // TODO(danilatos): Other headers for mime type, fileName + "Thumbnail", etc?
    resp.getOutputStream().write(thumbnail.getBytes());

    return null;
  }
View Full Code Here

Examples of com.google.walkaround.wave.server.attachment.ThumbnailDirectory.ThumbnailData

    return e.id;
  }

  @Override
  protected ThumbnailData parse(Entity e) {
    return new ThumbnailData(new BlobKey(e.getKey().getName()),
        DatastoreUtil.getExistingProperty(e, THUMBNAIL_BYTES_PROPERTY, Blob.class).getBytes());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.