use of com.xpn.xwiki.store.AttachmentRecycleBinContentStore in project xwiki-platform by xwiki.
the class HibernateAttachmentRecycleBinStore method resolveDeletedAttachmentContent.
private DeletedAttachment resolveDeletedAttachmentContent(DeletedAttachment deletedAttachment, boolean bTransaction, boolean failIfNoContent) throws XWikiException {
AttachmentRecycleBinContentStore contentStore = getAttachmentRecycleBinContentStore(deletedAttachment.getContentStore());
if (contentStore != null) {
AttachmentReference reference = deletedAttachment.getAttachmentReference();
DeletedAttachmentContent content = contentStore.get(reference, deletedAttachment.getDate(), deletedAttachment.getId(), bTransaction);
if (content == null) {
if (failIfNoContent) {
throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_UNKNOWN, "Can't find any content for deleted attachment [" + reference + "] with id [" + deletedAttachment.getId() + "]");
} else {
this.logger.warn("Can't find any content for deleted attachment [{}] with id [{}]", reference, deletedAttachment.getId());
}
}
try {
FieldUtils.writeDeclaredField(deletedAttachment, "content", content, true);
} catch (IllegalAccessException e) {
throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_UNKNOWN, "Failed to set deleted document content", e);
}
}
return deletedAttachment;
}
Aggregations