use of com.xpn.xwiki.doc.DeletedAttachmentContent in project xwiki-platform by xwiki.
the class HibernateAttachmentRecycleBinStore method createDeletedAttachment.
private DeletedAttachment createDeletedAttachment(XWikiAttachment attachment, String deleter, Date date, AttachmentRecycleBinContentStore contentStore) throws XWikiException {
DeletedAttachment trashdoc;
String storeType = null;
DeletedAttachmentContent deletedDocumentContent = null;
if (contentStore != null) {
storeType = contentStore.getHint();
} else {
deletedDocumentContent = new HibernateDeletedAttachmentContent(attachment);
}
trashdoc = new DeletedAttachment(attachment.getDocId(), attachment.getDoc().getFullName(), attachment.getFilename(), storeType, deleter, date, deletedDocumentContent);
return trashdoc;
}
use of com.xpn.xwiki.doc.DeletedAttachmentContent 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