Class XWikiDocumentArchive


  • public class XWikiDocumentArchive
    extends Object
    Contains document history. Allows to load any version of document.
    Version:
    $Id: 4d5a37ae8c47dc6b88112bd60645a4be006dca38 $
    • 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
      • getWikiReference

        public WikiReference getWikiReference()
        Returns:
        the wikiReference the wiki of the document
        Since:
        13.10.7, 14.4.1, 14.5
      • 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 with 3.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
      • 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

        @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 to getNextFullVersion(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.