/** * Retrieve the date and time this attachment has been deleted. * * @return the date of the deletion */ public Date getDate() { return this.deletedAttachment.getDate(); }
@Override public boolean storeEntity(DeletedAttachment entity) { if (entity == null) { return true; } try { XWikiAttachment attachment = entity.restoreAttachment(null, this.context.get()); this.store.saveToRecycleBin(attachment, entity.getDeleter(), entity.getDate(), this.context.get(), false); this.logger.debug("Imported deleted attachment [{}@{}#{}] into the filesystem trash store", entity.getDocName(), entity.getFilename(), entity.getId()); return true; } catch (XWikiException ex) { this.logger.error("Failed to store deleted attachment into the filesystem store: {}", ex.getMessage(), ex); return false; } } }
@Override public boolean storeEntity(DeletedAttachment entity) { if (entity == null) { return true; } try { XWikiAttachment attachment = entity.restoreAttachment(null, this.context.get()); this.store.saveToRecycleBin(attachment, entity.getDeleter(), entity.getDate(), this.context.get(), false); this.logger.debug("Imported deleted attachment [{}@{}#{}] into the filesystem trash store", entity.getDocName(), entity.getFilename(), entity.getId()); return true; } catch (XWikiException ex) { this.logger.error("Failed to store deleted attachment into the filesystem store: {}", ex.getMessage(), ex); return false; } } }
public long findDeletedAttachmentForDocRevision(XWikiDocument doc, String docRevision, String filename, XWikiContext context) throws XWikiException { XWikiAttachment attachment = null; XWikiDocument rdoc = context.getWiki().getDocument(doc, docRevision, context); if (context.getWiki().hasAttachmentRecycleBin(context) && filename != null) { attachment = rdoc.getAttachment(filename); if (attachment != null) { List<DeletedAttachment> deleted = context.getWiki().getAttachmentRecycleBinStore() .getAllDeletedAttachments(attachment, context, true); Collections.reverse(deleted); for (DeletedAttachment entry : deleted) { if (entry.getDate().after(rdoc.getDate())) { return entry.getId(); } } } } return -1; } }
DeletedAttachment correctVariant = null; for (DeletedAttachment variant : deletedVariants) { // Reverse chronological order if (variant.getDate().before(rolledbackDoc.getDate())) { break;