Package com.xpn.xwiki.doc
Class XWikiDocumentArchive
- java.lang.Object
-
- com.xpn.xwiki.doc.XWikiDocumentArchive
-
public class XWikiDocumentArchive extends Object
Contains document history. Allows to load any version of document.- Version:
- $Id: 4d5a37ae8c47dc6b88112bd60645a4be006dca38 $
-
-
Constructor Summary
Constructors Constructor Description XWikiDocumentArchive()
Deprecated.since 13.10.7, 14.4.1, 14.5, useXWikiDocumentArchive(WikiReference, long)
insteadXWikiDocumentArchive(long id)
Deprecated.since 13.10.7, 14.4.1, 14.5, useXWikiDocumentArchive(WikiReference, long)
insteadXWikiDocumentArchive(WikiReference wikiReference, long id)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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)
Deprecated.This method has been deprecated as its name is error-prone, and it has never done what's documented: it always returned the next full version, and never the nearest one.org.suigeneris.jrcs.rcs.Version
getNextFullVersion(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 upperBound, org.suigeneris.jrcs.rcs.Version lowerBound)
Be careful when using that method: the first argument is the upper bound and the second is the lower bound.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.WikiReference
getWikiReference()
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)
Deprecated.since 13.10.7, 14.4.1, 14.5, useXWikiDocumentArchive(WikiReference, long)
insteadvoid
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)
-
-
-
Constructor Detail
-
XWikiDocumentArchive
public XWikiDocumentArchive(WikiReference wikiReference, long id)
- Parameters:
wikiReference
- the wiki of the documentid
- the local identifier of the document- Since:
- 13.10.7, 14.4.1, 14.5
-
XWikiDocumentArchive
@Deprecated(since="13.10.7") public XWikiDocumentArchive(long id)
Deprecated.since 13.10.7, 14.4.1, 14.5, useXWikiDocumentArchive(WikiReference, long)
instead- Parameters:
id
- the local identifier of the document
-
XWikiDocumentArchive
@Deprecated(since="13.10.7") public XWikiDocumentArchive()
Deprecated.since 13.10.7, 14.4.1, 14.5, useXWikiDocumentArchive(WikiReference, long)
instead
-
-
Method Detail
-
createNextVersion
protected org.suigeneris.jrcs.rcs.Version createNextVersion(org.suigeneris.jrcs.rcs.Version cur, boolean isMinor)
- Parameters:
cur
- - current versionisMinor
- - 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 informationdoc
- - document for that patch createdcontext
- - used for loading node contents and generating xml- Returns:
- node content for newnode
- Throws:
XWikiException
- if exception while loading content
-
getWikiReference
public WikiReference getWikiReference()
- Returns:
- the wikiReference the wiki of the document
- Since:
- 13.10.7, 14.4.1, 14.5
-
getId
public long getId()
- Returns:
XWikiDocument.getId()
- primary key
-
setId
@Deprecated(since="13.10.7") public void setId(long id)
Deprecated.since 13.10.7, 14.4.1, 14.5, useXWikiDocumentArchive(WikiReference, long)
instead- 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 upperBound, org.suigeneris.jrcs.rcs.Version lowerBound)
Be careful when using that method: the first argument is the upper bound and the second is the lower bound. So if you want to get nodes for versions between [2.1,3.4] you need to call it with3.4,2.1
.- Parameters:
upperBound
- - start version (upper bound)lowerBound
- - end version (lower bound)- Returns:
- collection of XWikiRCSNodeInfo where upperBound >= version >= lowerBound 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 inPackagePlugin
.- 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 versionauthor
- - author of versiondate
- - date of versioncomment
- - version commentversion
- - preferably document version in historycontext
- - 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 versionolderVersion
- - end versioncontext
- - 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 loadcontext
- - 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
- Thecontext
.- 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
@Deprecated(since="14.10.12,15.5RC1") public org.suigeneris.jrcs.rcs.Version getNearestFullVersion(org.suigeneris.jrcs.rcs.Version ver)
Deprecated.This method has been deprecated as its name is error-prone, and it has never done what's documented: it always returned the next full version, and never the nearest one. So we renamed it togetNextFullVersion(Version)
.- Parameters:
ver
- - for what version find next full one- Returns:
- next version which contain full information (not patch)
-
getNextFullVersion
@Unstable public org.suigeneris.jrcs.rcs.Version getNextFullVersion(org.suigeneris.jrcs.rcs.Version ver)
- Parameters:
ver
- - for what version find next full one- Returns:
- next version which contain full information (not patch)
- Since:
- 14.10.12, 15.5RC1
-
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
- - newgetId()
context
- - used for loading content- Returns:
- full copy of this archive with specified docId
- Throws:
XWikiException
- if any error
-
-