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.

Author:
Sameer Charles

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(Content node)
          Add version of the specified node and all child nodes while ignoring the same node type.
 javax.jcr.version.Version addVersion(Content node, Rule rule)
          Add version of the specified node and all child nodes while ignoring the same node type.
protected  void checkAndAddMixin(Content 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)
          Create version of the specified node and all child nodes based on the given Rule.
protected  List getAccessManagerPermissions()
          Get access manager permission list.
 javax.jcr.version.VersionIterator getAllVersions(Content node)
          Get all versions.
 javax.jcr.version.Version getBaseVersion(Content node)
          Returns the current base version of given node.
protected  HierarchyManager getHierarchyManager()
          Get version store hierarchy manager.
protected  Content getSystemNode(Content node)
          Get the Magnolia system node created under the given node.
protected  Rule getUsedFilter(Content versionedNode)
          Get Rule used for this version.
 javax.jcr.version.Version getVersion(Content node, String name)
          Get named version.
 Content getVersionedNode(Content node)
          Get node from version store.
protected  Content getVersionedNode(String uuid)
          Get node from version store.
 javax.jcr.version.VersionHistory getVersionHistory(Content node)
          Get history of this node as recorded in the version store.
protected  void impersonateAccessManager(List permissions)
          Impersonate to be access manager with system rights.
abstract  boolean isInvalidMaxVersions()
          Check if version index is set to negative number.
 void removeVersionHistory(String uuid)
          Removes all versions of the node associated with given UUID.
 void restore(Content node, javax.jcr.version.Version version, boolean removeExisting)
          Restore specified version.
protected  void revertAccessManager(List permissions)
          Revert access manager permissions.
abstract  void setMaxVersionHistory(Content 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(Content 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(Content 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

protected javax.jcr.version.Version createVersion(Content node,
                                                  Rule rule)
                                           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 -
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 Content getVersionedNode(Content node)
                         throws javax.jcr.RepositoryException
Get node from version store.

Throws:
javax.jcr.RepositoryException

getVersionedNode

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

Throws:
javax.jcr.RepositoryException

setMaxVersionHistory

public abstract void setMaxVersionHistory(Content 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(Content 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(Content 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(Content 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(Content 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

public void restore(Content 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(String uuid)
                          throws javax.jcr.RepositoryException
Removes all versions of the node associated with given UUID.

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

checkAndAddMixin

protected void checkAndAddMixin(Content 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(Content versionedNode)
                      throws IOException,
                             ClassNotFoundException,
                             javax.jcr.RepositoryException
Get Rule used for this version.

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

getSystemNode

protected Content getSystemNode(Content 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

impersonateAccessManager

protected void impersonateAccessManager(List permissions)
Impersonate to be access manager with system rights.

Parameters:
permissions -

revertAccessManager

protected void revertAccessManager(List permissions)
Revert access manager permissions.

Parameters:
permissions -

getAccessManagerPermissions

protected List getAccessManagerPermissions()
Get access manager permission list.


getHierarchyManager

protected HierarchyManager getHierarchyManager()
Get version store hierarchy manager.



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