Class DeletedAttachment


  • public class DeletedAttachment
    extends Api
    Information about a deleted attachment in the recycle bin. Note that this does not hold much information about the real attachment, but only meta-information relevant to the trash: original document and filename, deleter, deletion date. The attachment can be accessed using getAttachment().

    This object is immutable, since entries in the trash can not be modified.

    Since:
    2.2M1
    Version:
    $Id: d0afc8480748439d155003c3f1f1f292cdfa1695 $
    • Constructor Detail

      • DeletedAttachment

        public DeletedAttachment​(DeletedAttachment deletedAttachment,
                                 XWikiContext context)
        Simple constructor, initializes a new API object with the current context and the specified protected deleted attachment object.
        Parameters:
        deletedAttachment - the internal object wrapped by this API
        context - the current request context
    • Method Detail

      • getId

        public long getId()
        Retrieve the internal entry index, used to uniquely identify this entity in the trash. This is needed because a file can be attached and deleted multiple times, so the document name and filename are not enough to uniquely identify a deleted attachment.
        Returns:
        internal identifier of the corresponding trash entry
      • getFilename

        public String getFilename()
        Retrieve the original name of this attachment.
        Returns:
        the original filename, for example MyPhoto.png
      • getDocName

        public String getDocName()
        Retrieve the name of the document this attachment belonged to.
        Returns:
        the name of the owner document, in the Space.Document format
      • getDeleter

        public String getDeleter()
        Retrieve the name of the user who deleted this attachment.
        Returns:
        the user who deleted the attachment, as its document name (e.g. XWiki.Admin)
      • getDate

        public Date getDate()
        Retrieve the date and time this attachment has been deleted.
        Returns:
        the date of the deletion
      • getAttachment

        public Attachment getAttachment()
        Access to the real attachment object.
        Returns:
        the attachment as it was before being deleted, and as it currently is in the recycle bin
      • getDeletedAttachment

        @Programming
        public DeletedAttachment getDeletedAttachment()
        Privileged access to the internal object wrapped by this API.
        Returns:
        original deleted attachment if the current user has programming rights, else null.
      • canRestore

        public boolean canRestore()
        Check if the current user has the right to restore the attachment.
        Returns:
        true if the current user can restore this document, false otherwise
      • canDelete

        public boolean canDelete()
        Check if the current user has the right to permanently delete the attachment from the trash.
        Returns:
        true if the current user can purge this document, false otherwise
        xwiki.cfg configuration:
        xwiki.store.recyclebin.adminWaitDays How many days should an administrator wait before being able to permanently delete this document from the recycle bin. 0 by default., xwiki.store.recyclebin.waitDays How many days should a normal user with "delete" right wait before being able to permanently delete this document from the recycle bin. 7 by default.
      • delete

        public void delete()
                    throws XWikiException
        Permanently delete this attachment from the trash. Throws an access denied exception if the user does not have the right to perform this action, which will trigger the generic Access Denied message. Any other failures will be silently ignored.
        Throws:
        XWikiException - if the user does not have the right to perform this action