com.xpn.xwiki.doc
Class XWikiAttachmentArchive

java.lang.Object
  extended by com.xpn.xwiki.doc.XWikiAttachmentArchive
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
VoidAttachmentVersioningStore.VoidAttachmentArchive

public class XWikiAttachmentArchive
extends Object
implements Cloneable

JRCS based implementation of an archive for XWikiAttachment.

Version:
$Id: e99ca7dfac7eb1a0c6f141c408f8aa9342d508f5 $

Constructor Summary
XWikiAttachmentArchive()
           
 
Method Summary
 Object clone()
           
 byte[] getArchive()
          Get the archive if it is currently stored in RAM.
 byte[] getArchive(XWikiContext context)
          Get the archive, loading it from the database if necessary.
 XWikiAttachment getAttachment()
           
 long getId()
           
 org.suigeneris.jrcs.rcs.Archive getRCSArchive()
          Deprecated. since 2.6M1 please do not use this, it is bound to a jrcs based implementation.
 XWikiAttachment getRevision(XWikiAttachment attachment, String rev, XWikiContext context)
          Get an old revision of the attachment which this is an archive of.
 org.suigeneris.jrcs.rcs.Version[] getVersions()
           
 void setArchive(byte[] data)
          Set the archive from a byte array representation of a JRCS archive.
 void setAttachment(XWikiAttachment attachment)
          Set the attachment to associate with this archive.
 void setId(long id)
          This does nothing and is only here to satisfy Hibernate.
 void setRCSArchive(org.suigeneris.jrcs.rcs.Archive archive)
          Deprecated. since 2.6M1 please do not use this, it is bound to a jrcs based implementation.
 void updateArchive(byte[] data, XWikiContext context)
          Update the archive.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XWikiAttachmentArchive

public XWikiAttachmentArchive()
Method Detail

getId

public long getId()
Returns:
the id of the attachment which this archive is associated with.

setId

public void setId(long id)
This does nothing and is only here to satisfy Hibernate.

Parameters:
id - the id of the attachment which this archive is associated with, unused.

clone

public Object clone()
Overrides:
clone in class Object

getRCSArchive

@Deprecated
public org.suigeneris.jrcs.rcs.Archive getRCSArchive()
Deprecated. since 2.6M1 please do not use this, it is bound to a jrcs based implementation.

Returns:
a JRCS archive.

setRCSArchive

@Deprecated
public void setRCSArchive(org.suigeneris.jrcs.rcs.Archive archive)
Deprecated. since 2.6M1 please do not use this, it is bound to a jrcs based implementation.

Parameters:
archive - a JRCS archive.

getArchive

public byte[] getArchive()
                  throws XWikiException
Get the archive if it is currently stored in RAM.

Returns:
a byte array representation of a JRCS archive or an empty array if the archive is not available on the heap.
Throws:
XWikiException - if anything goes wrong.

getArchive

public byte[] getArchive(XWikiContext context)
                  throws XWikiException
Get the archive, loading it from the database if necessary.

Parameters:
context - the XWikiContext for the request used to load the correct attachment archive from the database.
Returns:
a byte array representation of a JRCS archive.
Throws:
XWikiException - if anything goes wrong.

setArchive

public void setArchive(byte[] data)
                throws XWikiException
Set the archive from a byte array representation of a JRCS archive.

Parameters:
data - a byte array representation of a JRCS archive.
Throws:
XWikiException - if anything goes wrong.

updateArchive

public void updateArchive(byte[] data,
                          XWikiContext context)
                   throws XWikiException
Update the archive.

Parameters:
data - not used for anything, the data is loaded from the attachment included with this archive.
context - the XWikiContext for the request used to load the correct attachment content from the database.
Throws:
XWikiException - if anything goes wrong.

getAttachment

public XWikiAttachment getAttachment()
Returns:
the attachment which this is an archive for.

setAttachment

public void setAttachment(XWikiAttachment attachment)
Set the attachment to associate with this archive. This is a dangerous function because it will not change the archive. Using this may cause an attachment to be associated with the wrong history.

Parameters:
attachment - the attachment to set for this archive.

getVersions

public org.suigeneris.jrcs.rcs.Version[] getVersions()
Returns:
an array of versions which are available for this attachment, ordered by version number descending.

getRevision

public XWikiAttachment getRevision(XWikiAttachment attachment,
                                   String rev,
                                   XWikiContext context)
                            throws XWikiException
Get an old revision of the attachment which this is an archive of.

Parameters:
attachment - This attachment will be used to get the document to associate the attachment revision with.
rev - a String representation of the version to load.
context - the context for the request which needed this revision.
Returns:
an XWikiAttachment for the given revision.
Throws:
XWikiException - if any Exception is thrown while getting the revision.


Copyright © 2004–2014 XWiki. All rights reserved.