Package org.waveprotocol.box.attachment.impl

Examples of org.waveprotocol.box.attachment.impl.AttachmentMetadataImpl


      WaveletName waveletName, String fileName, ParticipantId creator) throws IOException {
    AttachmentData data = store.getAttachment(attachmentId);
    if (data == null) {
      throw new IOException("No such atachment " + attachmentId.serialise());
    }
    AttachmentMetadata metadata = new AttachmentMetadataImpl();
    metadata.setAttachmentId(attachmentId.serialise());
    metadata.setAttachmentUrl(AttachmentServlet.ATTACHMENT_URL + "/" + attachmentId.serialise());
    metadata.setThumbnailUrl(AttachmentServlet.THUMBNAIL_URL + "/" + attachmentId.serialise());
    metadata.setWaveRef(waveletName2WaveRef(waveletName));
    metadata.setFileName(fileName);
    String contentType = getMimeType(fileName);
    metadata.setMimeType(contentType);
    metadata.setSize(data.getSize());
    metadata.setCreator((creator != null) ? creator.getAddress() : "");
    BufferedImage image = null;
    try {
      image = ImageIO.read(data.getInputStream());
    } catch (IOException ex) {
      LOG.log(Level.SEVERE, "Identifying attachment", ex);
    }
    if (image != null) {
      ImageMetadata imageMetadata = new ImageMetadataImpl();
      imageMetadata.setWidth(image.getWidth());
      imageMetadata.setHeight(image.getHeight());
      metadata.setImageMetadata(imageMetadata);
      try {
        BufferedImage thumbnail = makeThumbnail(image);
        storeThumbnail(attachmentId, thumbnail);
        ImageMetadata thumbnailMetadata = new ImageMetadataImpl();
        thumbnailMetadata.setWidth(thumbnail.getWidth());
        thumbnailMetadata.setHeight(thumbnail.getHeight());
        metadata.setThumbnailMetadata(thumbnailMetadata);
      } catch (IOException ex) {
        LOG.log(Level.SEVERE, "Building attachment thumbnail", ex);
      }
    } else {
      ImageMetadata thumbnailMetadata = new ImageMetadataImpl();
      thumbnailMetadata.setWidth(THUMBNAIL_PATTERN_WIDTH);
      thumbnailMetadata.setHeight(THUMBNAIL_PATTERN_HEIGHT);
      metadata.setThumbnailMetadata(thumbnailMetadata);
    }
    store.storeMetadata(attachmentId, metadata);
    return metadata;
  }
View Full Code Here


  private AttachmentMetadata metadata;
  private Status status = Status.NOT_UPLOADING;

  public AttachmentImpl() {
    metadata = new AttachmentMetadataImpl();
  }
View Full Code Here

TOP

Related Classes of org.waveprotocol.box.attachment.impl.AttachmentMetadataImpl

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.