info.magnolia.cms.core.version
Class BaseVersionManager

java.lang.Object
  extended by info.magnolia.cms.core.version.BaseVersionManager
Direct Known Subclasses:
VersionManager

public abstract class BaseVersionManager
extends Object

This version manager uses an extra workspace to manage the versions. The workspace maintains a flat hierarchy. The content is then finally versioned using JCR versioning which also copies the sub-nodes. The mix:versionable is only added on the top level nodes.

Version:
$Id$

Field Summary
static String PROPERTY_RULE
          Property name for collection rule.
protected static String ROOT_VERSION
          JCR version store root.
protected static String SYSTEM_NODE
          Sub-node containing the data used for the version/restore process.
static String TMP_REFERENCED_NODES
          Node which contains stubs for referenced nodes.
static String VERSION_WORKSPACE
          Name of the workspace.
 
Constructor Summary
BaseVersionManager()
           
 
Method Summary
 javax.jcr.version.Version addVersion(javax.jcr.Node node)
          Add version of the specified node and all child nodes while ignoring the same node type.
 javax.jcr.version.Version addVersion(javax.jcr.Node node, Rule rule)
          Add version of the specified node and all child nodes while ignoring the same node type.
protected  void checkAndAddMixin(javax.jcr.Node node)
          Verifies the existence of the mix:versionable and adds it if not.
protected  void createInitialStructure()
          Create structure needed for version store workspace.
protected  javax.jcr.version.Version createVersion(Content node, Rule rule)
          Deprecated. since 4.5 use #createVersion(Node, Rule) instead
protected  javax.jcr.version.Version createVersion(javax.jcr.Node node, Rule rule, String userName)
          Create version of the specified node and all child nodes based on the given Rule.
 javax.jcr.version.VersionIterator getAllVersions(javax.jcr.Node node)
          Get all versions.
 javax.jcr.version.Version getBaseVersion(javax.jcr.Node node)
          Returns the current base version of given node.
protected  javax.jcr.Session getSession()
          Get version store hierarchy manager.
protected  javax.jcr.Node getSystemNode(javax.jcr.Node node)
          Get the Magnolia system node created under the given node.
protected  Rule getUsedFilter(javax.jcr.Node versionedNode)
          Get Rule used for this version.
 javax.jcr.version.Version getVersion(javax.jcr.Node node, String name)
          Get named version.
 javax.jcr.Node getVersionedNode(javax.jcr.Node node)
          Get node from version store.
protected  javax.jcr.Node getVersionedNode(String uuid)
          Get node from version store.
 javax.jcr.version.VersionHistory getVersionHistory(javax.jcr.Node node)
          Get history of this node as recorded in the version store.
abstract  boolean isInvalidMaxVersions()
          Check if version index is set to negative number.
 void removeVersionHistory(javax.jcr.Node node)
          Removes all versions of the node associated with given UUID.
 void restore(Content node, javax.jcr.version.Version version, boolean removeExisting)
          Deprecated. since 4.5 use restore(Node, Version, boolean) instead
 void restore(javax.jcr.Node node, javax.jcr.version.Version version, boolean removeExisting)
          Restore specified version.
abstract  void setMaxVersionHistory(javax.jcr.Node node)
          Set version history to max version possible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_WORKSPACE

public static final String VERSION_WORKSPACE
Name of the workspace.

See Also:
Constant Field Values

TMP_REFERENCED_NODES

public static final String TMP_REFERENCED_NODES
Node which contains stubs for referenced nodes. We have to copy them to the workspace as well.

See Also:
Constant Field Values

SYSTEM_NODE

protected static final String SYSTEM_NODE
Sub-node containing the data used for the version/restore process.

See Also:
Constant Field Values

PROPERTY_RULE

public static final String PROPERTY_RULE
Property name for collection rule. The rule defines which sub-nodes belong to a node: page and paragraphs.

See Also:
Constant Field Values

ROOT_VERSION

protected static final String ROOT_VERSION
JCR version store root.

See Also:
Constant Field Values
Constructor Detail

BaseVersionManager

public BaseVersionManager()
Method Detail

createInitialStructure

protected void createInitialStructure()
                               throws javax.jcr.RepositoryException
Create structure needed for version store workspace.

Throws:
javax.jcr.RepositoryException - if unable to create magnolia system structure

addVersion

public javax.jcr.version.Version addVersion(javax.jcr.Node node)
                                     throws javax.jcr.UnsupportedRepositoryOperationException,
                                            javax.jcr.RepositoryException
Add version of the specified node and all child nodes while ignoring the same node type.

Parameters:
node - to be versioned
Returns:
newly created version node
Throws:
UnsupportedOperationException - if repository implementation does not support Versions API
javax.jcr.RepositoryException - if any repository error occurs
javax.jcr.UnsupportedRepositoryOperationException

addVersion

public javax.jcr.version.Version addVersion(javax.jcr.Node node,
                                            Rule rule)
                                     throws javax.jcr.UnsupportedRepositoryOperationException,
                                            javax.jcr.RepositoryException
Add version of the specified node and all child nodes while ignoring the same node type.

Parameters:
node - to be versioned
Returns:
newly created version node
Throws:
UnsupportedOperationException - if repository implementation does not support Versions API
javax.jcr.RepositoryException - if any repository error occurs
javax.jcr.UnsupportedRepositoryOperationException

createVersion

@Deprecated
protected javax.jcr.version.Version createVersion(Content node,
                                                             Rule rule)
                                           throws javax.jcr.UnsupportedRepositoryOperationException,
                                                  javax.jcr.RepositoryException
Deprecated. since 4.5 use #createVersion(Node, Rule) instead

Create version of the specified node and all child nodes based on the given Rule.

Parameters:
node - to be versioned
rule -
Returns:
newly created version node
Throws:
UnsupportedOperationException - if repository implementation does not support Versions API
javax.jcr.RepositoryException - if any repository error occurs
javax.jcr.UnsupportedRepositoryOperationException

createVersion

protected javax.jcr.version.Version createVersion(javax.jcr.Node node,
                                                  Rule rule,
                                                  String userName)
                                           throws javax.jcr.UnsupportedRepositoryOperationException,
                                                  javax.jcr.RepositoryException
Create version of the specified node and all child nodes based on the given Rule.

Parameters:
node - to be versioned
rule -
userName -
Returns:
newly created version node
Throws:
UnsupportedOperationException - if repository implementation does not support Versions API
javax.jcr.RepositoryException - if any repository error occurs
javax.jcr.UnsupportedRepositoryOperationException

isInvalidMaxVersions

public abstract boolean isInvalidMaxVersions()
Check if version index is set to negative number.


getVersionedNode

public javax.jcr.Node getVersionedNode(javax.jcr.Node node)
                                throws javax.jcr.RepositoryException
Get node from version store.

Throws:
javax.jcr.RepositoryException

getVersionedNode

protected javax.jcr.Node getVersionedNode(String uuid)
                                   throws javax.jcr.RepositoryException
Get node from version store.

Throws:
javax.jcr.RepositoryException

setMaxVersionHistory

public abstract void setMaxVersionHistory(javax.jcr.Node node)
                                   throws javax.jcr.RepositoryException
Set version history to max version possible.

Throws:
javax.jcr.RepositoryException - if failed to get VersionHistory or fail to remove

getVersionHistory

public javax.jcr.version.VersionHistory getVersionHistory(javax.jcr.Node node)
                                                   throws javax.jcr.UnsupportedRepositoryOperationException,
                                                          javax.jcr.RepositoryException
Get history of this node as recorded in the version store.

Parameters:
node -
Returns:
version history of the given node
Throws:
UnsupportedOperationException - if repository implementation does not support Versions API
javax.jcr.RepositoryException - if any repository error occurs
javax.jcr.UnsupportedRepositoryOperationException

getVersion

public javax.jcr.version.Version getVersion(javax.jcr.Node node,
                                            String name)
                                     throws javax.jcr.UnsupportedRepositoryOperationException,
                                            javax.jcr.RepositoryException
Get named version.

Throws:
UnsupportedOperationException - if repository implementation does not support Versions API
javax.jcr.RepositoryException - if any repository error occurs
javax.jcr.UnsupportedRepositoryOperationException

getBaseVersion

public javax.jcr.version.Version getBaseVersion(javax.jcr.Node node)
                                         throws UnsupportedOperationException,
                                                javax.jcr.RepositoryException
Returns the current base version of given node.

Throws:
javax.jcr.UnsupportedRepositoryOperationException
javax.jcr.RepositoryException
UnsupportedOperationException

getAllVersions

public javax.jcr.version.VersionIterator getAllVersions(javax.jcr.Node node)
                                                 throws javax.jcr.UnsupportedRepositoryOperationException,
                                                        javax.jcr.RepositoryException
Get all versions.

Parameters:
node -
Returns:
Version iterator retrieved from version history
Throws:
UnsupportedOperationException - if repository implementation does not support Versions API
javax.jcr.RepositoryException - if any repository error occurs
javax.jcr.UnsupportedRepositoryOperationException

restore

@Deprecated
public void restore(Content node,
                               javax.jcr.version.Version version,
                               boolean removeExisting)
             throws javax.jcr.version.VersionException,
                    javax.jcr.UnsupportedRepositoryOperationException,
                    javax.jcr.RepositoryException
Deprecated. since 4.5 use restore(Node, Version, boolean) instead

Restore specified version.

Parameters:
node - to be restored
version - to be used
removeExisting -
Throws:
javax.jcr.version.VersionException - if the specified versionName does not exist in this node's version history
javax.jcr.RepositoryException - if an error occurs
javax.jcr.version.VersionException
javax.jcr.UnsupportedRepositoryOperationException

restore

public void restore(javax.jcr.Node node,
                    javax.jcr.version.Version version,
                    boolean removeExisting)
             throws javax.jcr.version.VersionException,
                    javax.jcr.UnsupportedRepositoryOperationException,
                    javax.jcr.RepositoryException
Restore specified version.

Parameters:
node - to be restored
version - to be used
removeExisting -
Throws:
javax.jcr.version.VersionException - if the specified versionName does not exist in this node's version history
javax.jcr.RepositoryException - if an error occurs
javax.jcr.version.VersionException
javax.jcr.UnsupportedRepositoryOperationException

removeVersionHistory

public void removeVersionHistory(javax.jcr.Node node)
                          throws javax.jcr.RepositoryException
Removes all versions of the node associated with given UUID.

Throws:
javax.jcr.RepositoryException - if fails to remove versioned node from the version store

checkAndAddMixin

protected void checkAndAddMixin(javax.jcr.Node node)
                         throws javax.jcr.RepositoryException
Verifies the existence of the mix:versionable and adds it if not.

Throws:
javax.jcr.RepositoryException

getUsedFilter

protected Rule getUsedFilter(javax.jcr.Node versionedNode)
                      throws IOException,
                             ClassNotFoundException,
                             javax.jcr.RepositoryException
Get Rule used for this version.

Parameters:
versionedNode -
Throws:
IOException
ClassNotFoundException
javax.jcr.RepositoryException

getSystemNode

protected javax.jcr.Node getSystemNode(javax.jcr.Node node)
                                throws javax.jcr.RepositoryException
Get the Magnolia system node created under the given node.

Parameters:
node -
Throws:
javax.jcr.RepositoryException - if failed to create system node

getSession

protected javax.jcr.Session getSession()
                                throws javax.jcr.LoginException,
                                       javax.jcr.RepositoryException
Get version store hierarchy manager.

Throws:
javax.jcr.RepositoryException
javax.jcr.LoginException


Copyright © 2003-2012 Magnolia International Ltd.. All Rights Reserved.