com.xpn.xwiki.doc
Class XWikiDocumentArchive

java.lang.Object
  extended by com.xpn.xwiki.doc.XWikiDocumentArchive

public class XWikiDocumentArchive
extends Object

Contains document history. Allows to load any version of document.

Version:
$Id: 96307a38124fe233246e970949bb175ed126a1be $

Constructor Summary
XWikiDocumentArchive()
          default constructor.
XWikiDocumentArchive(long id)
           
 
Method Summary
 XWikiDocumentArchive clone(long docId, XWikiContext context)
           
protected  org.suigeneris.jrcs.rcs.Version createNextVersion(org.suigeneris.jrcs.rcs.Version cur, boolean isMinor)
           
 String getArchive(XWikiContext context)
           
 Set<XWikiRCSNodeInfo> getDeletedNodeInfo()
           
 long getId()
           
 XWikiRCSNodeInfo getLatestNode()
           
 org.suigeneris.jrcs.rcs.Version getLatestVersion()
           
 org.suigeneris.jrcs.rcs.Version getNearestFullVersion(org.suigeneris.jrcs.rcs.Version ver)
           
 org.suigeneris.jrcs.rcs.Version getNextVersion(org.suigeneris.jrcs.rcs.Version ver)
           
 XWikiRCSNodeInfo getNode(org.suigeneris.jrcs.rcs.Version version)
           
 Collection<XWikiRCSNodeInfo> getNodes()
           
 Collection<XWikiRCSNodeInfo> getNodes(org.suigeneris.jrcs.rcs.Version vfrom, org.suigeneris.jrcs.rcs.Version vto)
           
 org.suigeneris.jrcs.rcs.Version getPrevVersion(org.suigeneris.jrcs.rcs.Version ver)
           
 Set<XWikiRCSNodeContent> getUpdatedNodeContents()
           
 Set<XWikiRCSNodeInfo> getUpdatedNodeInfos()
           
 String getVersionXml(org.suigeneris.jrcs.rcs.Version version, XWikiContext context)
          Return the XML corresponding to a version.
 XWikiDocument loadDocument(org.suigeneris.jrcs.rcs.Version version, XWikiContext context)
           
protected  XWikiRCSNodeContent makePatch(XWikiRCSNodeInfo newnode, XWikiDocument doc, XWikiContext context)
          Make a patch.
 void removeVersions(org.suigeneris.jrcs.rcs.Version newerVersion, org.suigeneris.jrcs.rcs.Version olderVersion, XWikiContext context)
          Remove document versions from vfrom to vto, inclusive.
 void resetArchive()
          reset history.
 void setArchive(String text)
          Deserialize class.
 void setId(long id)
           
 void setNodes(Collection<XWikiRCSNodeInfo> versions)
           
 void updateArchive(XWikiDocument doc, String author, Date date, String comment, org.suigeneris.jrcs.rcs.Version version, XWikiContext context)
          Update history with new document version.
protected  void updateNode(XWikiRCSNodeInfo node)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XWikiDocumentArchive

public XWikiDocumentArchive(long id)
Parameters:
id - = XWikiDocument.getId()

XWikiDocumentArchive

public XWikiDocumentArchive()
default constructor.

Method Detail

createNextVersion

protected org.suigeneris.jrcs.rcs.Version createNextVersion(org.suigeneris.jrcs.rcs.Version cur,
                                                            boolean isMinor)
Parameters:
cur - - current version
isMinor - - is modification is minor
Returns:
next version

updateNode

protected void updateNode(XWikiRCSNodeInfo node)
Parameters:
node - - node added to versionToNode and fullNodes

makePatch

protected XWikiRCSNodeContent makePatch(XWikiRCSNodeInfo newnode,
                                        XWikiDocument doc,
                                        XWikiContext context)
                                 throws XWikiException
Make a patch. It is store only modified nodes(latest). New nodes need be saved after.

Parameters:
newnode - - new node information
doc - - document for that patch created
context - - used for loading node contents and generating xml
Returns:
node content for newnode
Throws:
XWikiException - if exception while loading content

getId

public long getId()
Returns:
XWikiDocument.getId() - primary key

setId

public void setId(long id)
Parameters:
id - = XWikiDocument.getId()

getNodes

public Collection<XWikiRCSNodeInfo> getNodes()
Returns:
collection of XWikiRCSNodeInfo order by version desc

getNodes

public Collection<XWikiRCSNodeInfo> getNodes(org.suigeneris.jrcs.rcs.Version vfrom,
                                             org.suigeneris.jrcs.rcs.Version vto)
Parameters:
vfrom - - start version
vto - - end version
Returns:
collection of XWikiRCSNodeInfo where vfrom>=version>=vto order by version desc

setNodes

public void setNodes(Collection<XWikiRCSNodeInfo> versions)
Parameters:
versions - - collection of XWikiRCSNodeInfo

getArchive

public String getArchive(XWikiContext context)
                  throws XWikiException
Parameters:
context - - used for load nodes content
Returns:
serialization of class used in PackagePlugin.
Throws:
XWikiException - if any error

setArchive

public void setArchive(String text)
                throws XWikiException
Deserialize class. Used in PackagePlugin.

Parameters:
text - - archive in JRCS format
Throws:
XWikiException - if parse error

updateArchive

public void updateArchive(XWikiDocument doc,
                          String author,
                          Date date,
                          String comment,
                          org.suigeneris.jrcs.rcs.Version version,
                          XWikiContext context)
                   throws XWikiException
Update history with new document version.

Parameters:
doc - - document for this version
author - - author of version
date - - date of version
comment - - version comment
version - - preferably document version in history
context - - used for loading nodes content
Throws:
XWikiException - in any error

removeVersions

public void removeVersions(org.suigeneris.jrcs.rcs.Version newerVersion,
                           org.suigeneris.jrcs.rcs.Version olderVersion,
                           XWikiContext context)
                    throws XWikiException
Remove document versions from vfrom to vto, inclusive.

Parameters:
newerVersion - - start version
olderVersion - - end version
context - - used for loading nodes content
Throws:
XWikiException - if any error

loadDocument

public XWikiDocument loadDocument(org.suigeneris.jrcs.rcs.Version version,
                                  XWikiContext context)
                           throws XWikiException
Parameters:
version - - which version to load
context - - used for loading
Returns:
selected version of document, null if version is not found.
Throws:
XWikiException - if any error

getVersionXml

public String getVersionXml(org.suigeneris.jrcs.rcs.Version version,
                            XWikiContext context)
                     throws XWikiException
Return the XML corresponding to a version. If the version node contains just a diff, then restore the complete XML by applying all patches from the nearest full version to the requested version.

Parameters:
version - The version to retrieve.
context - The context.
Returns:
The XML corresponding to the version.
Throws:
XWikiException - If any exception occured.

getNode

public XWikiRCSNodeInfo getNode(org.suigeneris.jrcs.rcs.Version version)
Parameters:
version - which version to get
Returns:
XWikiRCSNodeInfo by version. null if none.

getLatestVersion

public org.suigeneris.jrcs.rcs.Version getLatestVersion()
Returns:
latest version in history for document. null if none.

getLatestNode

public XWikiRCSNodeInfo getLatestNode()
Returns:
latest node in history for document. null if none.

getNextVersion

public org.suigeneris.jrcs.rcs.Version getNextVersion(org.suigeneris.jrcs.rcs.Version ver)
Parameters:
ver - - current version
Returns:
next version in history. null if none

getPrevVersion

public org.suigeneris.jrcs.rcs.Version getPrevVersion(org.suigeneris.jrcs.rcs.Version ver)
Parameters:
ver - - current version
Returns:
previous version in history. null if none

getNearestFullVersion

public org.suigeneris.jrcs.rcs.Version getNearestFullVersion(org.suigeneris.jrcs.rcs.Version ver)
Parameters:
ver - - for what version find nearest
Returns:
nearest version which contain full information (not patch)

resetArchive

public void resetArchive()
reset history. history becomes empty.


getDeletedNodeInfo

public Set<XWikiRCSNodeInfo> getDeletedNodeInfo()
Returns:
mutable Set of XWikiRCSNodeInfo which are need for delete

getUpdatedNodeInfos

public Set<XWikiRCSNodeInfo> getUpdatedNodeInfos()
Returns:
mutable Set of XWikiRCSNodeInfo which are need for saveOrUpdate

getUpdatedNodeContents

public Set<XWikiRCSNodeContent> getUpdatedNodeContents()
Returns:
mutable Set of XWikiRCSNodeContent which are need for update

clone

public XWikiDocumentArchive clone(long docId,
                                  XWikiContext context)
                           throws XWikiException
Parameters:
docId - - new getId()
context - - used for loading content
Returns:
full copy of this archive with specified docId
Throws:
XWikiException - if any error


Copyright © 2004–2014 XWiki. All rights reserved.