com.xpn.xwiki.api
Class DeletedAttachment

java.lang.Object
  extended by com.xpn.xwiki.api.Api
      extended by com.xpn.xwiki.api.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

Field Summary
 
Fields inherited from class com.xpn.xwiki.api.Api
context
 
Constructor Summary
DeletedAttachment(DeletedAttachment deletedAttachment, XWikiContext context)
          Simple constructor, initializes a new API object with the current context and the specified protected deleted attachment object.
 
Method Summary
 boolean canDelete()
          Check if the current user has the right to permanently delete the attachment from the trash.
 boolean canRestore()
          Check if the current user has the right to restore the attachment.
 void delete()
          Permanently delete this attachment from the trash.
 Attachment getAttachment()
          Access to the real attachment object.
 Date getDate()
          Retrieve the date and time this attachment has been deleted.
 DeletedAttachment getDeletedAttachment()
          Privileged access to the internal object wrapped by this API.
 String getDeleter()
          Retrieve the name of the user who deleted this attachment.
 String getDocName()
          Retrieve the name of the document this attachment belonged to.
 String getFilename()
          Retrieve the original name of this attachment.
 long getId()
          Retrieve the internal entry index, used to uniquely identify this entity in the trash.
 
Methods inherited from class com.xpn.xwiki.api.Api
convert, convert, getXWikiContext, hasAccessLevel, hasAdminRights, hasProgrammingRights, hasWikiAdminRights
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

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