Package com.xpn.xwiki.api
Class DeletedAttachment
- java.lang.Object
-
- com.xpn.xwiki.api.Api
-
- 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 usinggetAttachment()
.This object is immutable, since entries in the trash can not be modified.
- Since:
- 2.2M1
- Version:
- $Id: d0afc8480748439d155003c3f1f1f292cdfa1695 $
-
-
Constructor Summary
Constructors Constructor Description DeletedAttachment(DeletedAttachment deletedAttachment, XWikiContext context)
Simple constructor, initializes a new API object with the currentcontext
and the specified protecteddeleted attachment
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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, convert, convertAttachments, getAuthorizationManager, getContextualAuthorizationManager, getXWikiContext, hasAccess, hasAccessLevel, hasAdminRights, hasProgrammingRights, hasWikiAdminRights
-
-
-
-
Constructor Detail
-
DeletedAttachment
public DeletedAttachment(DeletedAttachment deletedAttachment, XWikiContext context)
Simple constructor, initializes a new API object with the currentcontext
and the specified protecteddeleted attachment
object.- Parameters:
deletedAttachment
- the internal object wrapped by this APIcontext
- 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
-
-