com.xpn.xwiki.doc
Class DeletedAttachment

java.lang.Object
  extended by com.xpn.xwiki.util.AbstractSimpleClass
      extended by com.xpn.xwiki.doc.DeletedAttachment

public class DeletedAttachment
extends AbstractSimpleClass

Archive of deleted attachment, stored in AttachmentRecycleBinStore. Immutable, because deleted attachments should not be modified.

Since:
1.4M1
Version:
$Id: 0aa035ec17e93361b643c81af72b24384f1c7ca8 $

Constructor Summary
protected DeletedAttachment()
          Default constructor.
  DeletedAttachment(XWikiAttachment attachment, String deleter, Date deleteDate, XWikiContext context)
          A constructor with all the information about the deleted attachment.
 
Method Summary
 Date getDate()
          Getter for date.
 String getDeleter()
          Getter for deleter.
 long getDocId()
          Getter for docId.
 String getDocName()
          Getter for docName.
 String getFilename()
          Getter for filename.
 long getId()
          Getter for id.
 String getXml()
          Getter for xml.
 XWikiAttachment restoreAttachment(XWikiAttachment attachment, XWikiContext context)
          Restore a XWikiAttachment from a DeletedAttachment.
protected  void setAttachment(XWikiAttachment attachment, XWikiContext context)
          Export XWikiAttachment to DeletedAttachment.
protected  void setDate(Date date)
          Setter for date.
protected  void setDeleter(String deleter)
          Setter for deleter.
protected  void setDocId(long docId)
          Setter for docId.
protected  void setDocName(String docName)
          Setter for docName.
protected  void setFilename(String filename)
          Setter for filename.
protected  void setId(long id)
          Setter for id.
protected  void setXml(String xml)
          Setter for xml.
 
Methods inherited from class com.xpn.xwiki.util.AbstractSimpleClass
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DeletedAttachment

protected DeletedAttachment()
Default constructor. Used only by hibernate when restoring objects from the database.


DeletedAttachment

public DeletedAttachment(XWikiAttachment attachment,
                         String deleter,
                         Date deleteDate,
                         XWikiContext context)
                  throws XWikiException
A constructor with all the information about the deleted attachment.

Parameters:
attachment - Deleted attachment.
deleter - User which deleted the attachment.
deleteDate - Date of delete action.
context - The current context. Used for determining the encoding.
Throws:
XWikiException - If the attachment cannot be exported to XML.
Method Detail

getId

public long getId()
Getter for id.

Returns:
The synthetic id of this deleted attachment. Uniquely identifies an entry in the recycle bin.

setId

protected void setId(long id)
Setter for id.

Parameters:
id - The synthetic id to set. Used only by hibernate.

getDocId

public long getDocId()
Getter for docId.

Returns:
The id of the document this attachment belonged to.

setDocId

protected void setDocId(long docId)
Setter for docId.

Parameters:
docId - The id of the document to set. Used only by hibernate.

getDocName

public String getDocName()
Getter for docName.

Returns:
The name of the document this attachment belonged to.

setDocName

protected void setDocName(String docName)
Setter for docName.

Parameters:
docName - The document name to set. Used only by hibernate.

getFilename

public String getFilename()
Getter for filename.

Returns:
The name of the attachment.

setFilename

protected void setFilename(String filename)
Setter for filename.

Parameters:
filename - The attachment filename to set. Used only by hibernate.

getDate

public Date getDate()
Getter for date.

Returns:
The date of the delete action.

setDate

protected void setDate(Date date)
Setter for date.

Parameters:
date - The date of the delete action to set. Used only by Hibernate.

getDeleter

public String getDeleter()
Getter for deleter.

Returns:
the user who deleted the attachment, as its document name (e.g. XWiki.Admin)

setDeleter

protected void setDeleter(String deleter)
Setter for deleter.

Parameters:
deleter - The user which has removed the document to set. Used only by Hibernate.

getXml

public String getXml()
Getter for xml.

Returns:
XML serialization of XWikiAttachment

setXml

protected void setXml(String xml)
Setter for xml.

Parameters:
xml - XML serialization of XWikiAttachment. Used only by Hibernate.

setAttachment

protected void setAttachment(XWikiAttachment attachment,
                             XWikiContext context)
                      throws XWikiException
Export XWikiAttachment to DeletedAttachment.

Parameters:
attachment - the deleted attachment
context - the current context, used in the XML export
Throws:
XWikiException - if an exception occurs during the XML export

restoreAttachment

public XWikiAttachment restoreAttachment(XWikiAttachment attachment,
                                         XWikiContext context)
                                  throws XWikiException
Restore a XWikiAttachment from a DeletedAttachment. Note that this method does not actually restore the attachment to its owner document, it simply recomposes an XWikiAttachment object from the saved data.

Parameters:
attachment - optional object where to put the attachment data, if not null
context - the current context
Returns:
restored attachment
Throws:
XWikiException - If an exception occurs while the Attachment is restored from the XML. See XWikiAttachment.fromXML(String).


Copyright © 2004–2014 XWiki. All rights reserved.