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;
}