@Override
public AttachmentData getAttachment(WaveletName waveletName, String id) {
String completeAttachmentId = computeCompleteAttachmentId(waveletName, id);
final GridFSDBFile attachment = getAttachmentGrid().findOne(completeAttachmentId);
if (attachment == null) {
return null;
} else {
return new AttachmentData() {
@Override
public void writeDataTo(OutputStream out) throws IOException {
attachment.writeTo(out);
}
@Override
public Date getLastModifiedDate() {
return attachment.getUploadDate();
}
@Override
public long getContentSize() {
return attachment.getLength();
}
@Override
public InputStream getInputStream() {
return attachment.getInputStream();
}
};
}
}