Workspace Versioning Methods

The Workspace object provides the "group restore" method.



restore(Version[] versions,
boolean removeExisting)

Restores a set of versions at once. Used in cases where a "chicken and egg" problem of mutually referring REFERENCE properties would prevent the restore in any serial order.

If the restore succeeds, the changes made are persisted immediately, there is no need to call save.

This method will work regardless of whether the nodes corresponding to the specified versions are checked-in or not.

The following restrictions apply to the set of versions specified:

If S is the set of versions being restored simultaneously,

  • For every version V in S that corresponds to a missing node in the workspace, there must also be a parent of V in S.

  • S must contain at least one version that corresponds to an existing node in the workspace.

  • No V in S can be a root version (jcr:rootVersion).

If any of these restrictions does not hold, the restore will fail because the system will be unable to determine the path locations to which one or more versions are to be restored. In this case a VersionException is thrown.

The versionable nodes in this workspace that correspond to the versions being restored define a set of (one or more) subtrees. A UUID collision occurs when this workspace contains a node outside these subtrees that has the same UUID as one of the nodes that would be introduced by the restore operation into one of these subtrees. The result in such a case is governed by the removeExisting flag. If removeExisting is true then the incoming node takes precedence, and the existing node (and its subtree) is removed. If removeExisting is false then a ItemExistsException is thrown and no changes are made. Note that this applies not only to cases where the restored node itself conflicts with an existing node but also to cases where a conflict occurs with any node that would be introduced into the workspace by the restore operation. In particular conflicts involving subnodes of the restored node that have OnParentVersion settings of COPY or VERSION (see 8.2.11 OnParentVersion Attribute) are also governed by the removeExisting flag.

An UnsupportedRepositoryOperationException is thrown if versioning is not supported.

A LockException is thrown if a lock prevents the restore.

An InvalidItemStateException is thrown if this Session (not necessarily this Node) has pending unsaved changes.

Throws a RepositoryException if another error occurs.