Class InternalXAVersionManager
- java.lang.Object
-
- org.apache.jackrabbit.core.version.InternalXAVersionManager
-
- All Implemented Interfaces:
EventStateCollectionFactory,ItemStateManager,InternalVersionManager,VirtualItemStateProvider,InternalXAResource
public class InternalXAVersionManager extends Object implements EventStateCollectionFactory, VirtualItemStateProvider, InternalXAResource
Implementation of aInternalVersionManagerthat works in an XA environment. Works as a filter between a version manager client and the global version manager.
-
-
Field Summary
Fields Modifier and Type Field Description protected NodeIdactivitiesIdprotected NodeIdhistoriesIdprotected NodeTypeRegistryntRegNode type registry.protected LocalItemStateManagerstateMgrState manager for the version storage.
-
Constructor Summary
Constructors Constructor Description InternalXAVersionManager(InternalVersionManagerImpl vMgr, NodeTypeRegistry ntReg, SessionImpl session, ItemStateCacheFactory cacheFactory)Creates a new instance of this class.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description VersioningLock.ReadLockacquireReadLock()acquires the read lock on this version manager.protected VersioningLock.WriteLockacquireWriteLock()Acquires the write lock on this version manager.voidaddListener(ItemStateListener listener)Add anItemStateListenervoidafterOperation(TransactionContext tx)voidassociate(TransactionContext tx)Associate this resource with a transaction.voidbeforeOperation(TransactionContext tx)protected StringcalculateCheckinVersionName(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history, NodeStateEx node, boolean simple)Calculates the name of the new version that will be created by a checkin call.NodeIdcanCheckout(NodeStateEx state, NodeId activityId)invokes the checkout() on the persistent version manager.InternalVersioncheckin(Session session, NodeStateEx node, Calendar created)invokes the checkin() on the persistent version manager and remaps the newly created version objects.protected InternalVersioncheckin(NodeStateEx node, Calendar created)Creates a new version of the given node using the given version creation time.voidclose()Close this version manager.voidcommit(TransactionContext tx)Commit transaction.NodeIdcreateActivity(Session session, String title)Creates a new activityEventStateCollectioncreateEventStateCollection()Creates anEventStateCollection.protected InternalVersionItemcreateInternalVersionItem(NodeId id)VirtualNodeStatecreateNodeState(VirtualNodeState parent, Name name, NodeId id, Name nodeTypeName)Creates a new virtual node stateVirtualPropertyStatecreatePropertyState(VirtualNodeState parent, Name name, int type, boolean multiValued)Creats a new virtual property stateprotected VersionHistoryInfocreateVersionHistory(Session session, NodeState node, NodeId copiedFrom)Creates a new version history.protected NodeStateExgetActivitiesRoot()returns the id of the activities root nodeInternalActivitygetActivity(NodeId id)Returns the activity with the given idInternalBaselinegetBaseline(NodeId id)Returns the baseline with the given idInternalVersiongetHeadVersionOfNode(NodeId id)Returns the head version of the node with the given id.protected NodeStateExgetHistoryRoot()returns the id of the version history root nodeprotected InternalVersionItemgetItem(NodeId id)Returns the item with the given persistent id.ItemStategetItemState(ItemId id)Return an item state, given its item id.protected static NamegetName(String name)Utility method that returns the given string as a name in the default namespace.NodeIdFactorygetNodeIdFactory()NodeReferencesgetNodeReferences(NodeId id)Return a node references object, given its target idprotected NodeStateExgetNodeStateEx(NodeId parentNodeId)Returns the node with the given persistent id.protected static NodeStateExgetParentNode(NodeStateEx parent, String uuid, Name interNT)Utility method that returns the parent node under which the version history of the identified versionable node is or will be stored.InternalVersiongetVersion(NodeId id)Returns the version with the given idVersionHistoryInfogetVersionHistory(Session session, NodeState node, NodeId copiedFrom)Returns information about the version history of the specified node.InternalVersionHistorygetVersionHistory(NodeId id)Returns the version history with the given idVersionHistoryInfogetVersionHistoryInfoForNode(NodeState node)Returns information about the version history of the specified node ornullwhen unavailable.InternalVersionHistorygetVersionHistoryOfNode(NodeId id)Returns the version history for the versionable node with the given id.VirtualItemStateProvidergetVirtualItemStateProvider()returns the virtual item state provider that exposes the internal versions as items.NodeIdgetVirtualRootId()Returns the id of the root node of the virtual tree.NodeId[]getVirtualRootIds()Returns the ids of the root nodes of the virtual tree.InternalXAResourcegetXAResourceBegin()Returns anInternalXAResourcethat acquires a write lock on the version manager inInternalXAResource.prepare(TransactionContext).InternalXAResourcegetXAResourceEnd()Returns anInternalXAResourcethat releases the write lock on the version manager inInternalXAResource.commit(TransactionContext)orInternalXAResource.rollback(TransactionContext).protected booleanhasItem(NodeId id)Return a flag indicating if the item specified exists.protected booleanhasItemReferences(NodeId id)Checks if there are item references (from outside the version storage) that reference the given node.booleanhasItemState(ItemId id)Return a flag indicating whether an item state for a given item id exists.booleanhasNodeReferences(NodeId id)Return a flag indicating whether a node references object for a given target id exists.protected InternalVersioninternalCheckin(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history, NodeStateEx node, boolean simple, Calendar created)Checks in a nodeprotected voidinternalRemoveActivity(org.apache.jackrabbit.core.version.InternalActivityImpl activity)Removes the specified activityprotected voidinternalRemoveVersion(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history, Name name)Removes the specified version from the historyvoidinternalRemoveVersionHistory(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history)Removes the specified history from the storagebooleanisVirtualRoot(ItemId id)Checks if the id refers to the root of a virtual tree.protected voiditemDiscarded(InternalVersionItem item)Invoked by the internal version item itself, when it's underlying persistence state was discarded.voidprepare(TransactionContext tx)Prepare transaction.voidremoveActivity(Session session, NodeId nodeId)Removes an activity and allvoidremoveListener(ItemStateListener listener)Remove anItemStateListenervoidremoveVersion(Session session, InternalVersionHistory history, Name versionName)Removes the specified version from the given version history.voidremoveVersionHistory(Session session, InternalVersionHistory history)Removes the specified version history from storage.voidrollback(TransactionContext tx)Rollback transaction.booleansetNodeReferences(ChangeLog references)Informs this provider that the node references to some of its states have changed.InternalVersionsetVersionLabel(Session session, InternalVersionHistory history, Name version, Name label, boolean move)Sets the versionlabelto the givenversion.protected InternalVersionsetVersionLabel(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history, Name version, Name label, boolean move)Set version label on the specified version.protected voidversionCreated(InternalVersion version)Invoked when a new internal item has been created.protected voidversionDestroyed(InternalVersion version)Invoked when a new internal item has been destroyed.
-
-
-
Field Detail
-
stateMgr
protected LocalItemStateManager stateMgr
State manager for the version storage.
-
ntReg
protected final NodeTypeRegistry ntReg
Node type registry.
-
historiesId
protected final NodeId historiesId
-
activitiesId
protected final NodeId activitiesId
-
-
Constructor Detail
-
InternalXAVersionManager
public InternalXAVersionManager(InternalVersionManagerImpl vMgr, NodeTypeRegistry ntReg, SessionImpl session, ItemStateCacheFactory cacheFactory) throws RepositoryException
Creates a new instance of this class.- Parameters:
vMgr- the underlying version managerntReg- node type registrysession- the sessioncacheFactory- cache factory- Throws:
RepositoryException- if a an error occurs
-
-
Method Detail
-
createEventStateCollection
public EventStateCollection createEventStateCollection() throws RepositoryException
Creates anEventStateCollection.- Specified by:
createEventStateCollectionin interfaceEventStateCollectionFactory- Returns:
- a new
EventStateCollection - Throws:
RepositoryException- if creation fails for some reason
-
getVirtualItemStateProvider
public VirtualItemStateProvider getVirtualItemStateProvider()
returns the virtual item state provider that exposes the internal versions as items.- Specified by:
getVirtualItemStateProviderin interfaceInternalVersionManager- Returns:
- the virtual item state provider.
-
createVersionHistory
protected VersionHistoryInfo createVersionHistory(Session session, NodeState node, NodeId copiedFrom) throws RepositoryException
Creates a new version history. This action is needed either when creating a new 'mix:versionable' node or when adding the 'mix:versionable' mixin to a node.- Parameters:
session- repository sessionnode- versionable node statecopiedFrom- node id for the jcr:copiedFrom property- Returns:
- identifier of the new version history node
- Throws:
RepositoryException- if an error occurs- See Also:
InternalVersionManager.getVersionHistory(Session, NodeState, NodeId)
-
createActivity
public NodeId createActivity(Session session, String title) throws RepositoryException
Creates a new activity- Specified by:
createActivityin interfaceInternalVersionManager- Parameters:
session- the current sessiontitle- title of the new activity- Returns:
- the nodeid of the new activity
- Throws:
RepositoryException- if an error occurs
-
removeActivity
public void removeActivity(Session session, NodeId nodeId) throws RepositoryException
Removes an activity and all- Specified by:
removeActivityin interfaceInternalVersionManager- Parameters:
session- the current sessionnodeId- id of the activity to remove- Throws:
RepositoryException- if an error occurs
-
internalRemoveActivity
protected void internalRemoveActivity(org.apache.jackrabbit.core.version.InternalActivityImpl activity) throws VersionException, RepositoryExceptionRemoves the specified activityBefore modifying activity, make a local copy of it.
- Parameters:
activity- the activity to remove- Throws:
RepositoryException- if any other error occurs.VersionException
-
canCheckout
public NodeId canCheckout(NodeStateEx state, NodeId activityId) throws RepositoryException
invokes the checkout() on the persistent version manager.- Specified by:
canCheckoutin interfaceInternalVersionManager- Parameters:
state- node to checkoutactivityId- node id if the current activity- Returns:
- the base version id
- Throws:
RepositoryException- if an error occurs
-
checkin
public InternalVersion checkin(Session session, NodeStateEx node, Calendar created) throws RepositoryException
invokes the checkin() on the persistent version manager and remaps the newly created version objects.- Specified by:
checkinin interfaceInternalVersionManager- Parameters:
session- session that invokes the checkinnode- node to checkincreated- create time of the new version, ornullfor the current time- Returns:
- the newly created version
- Throws:
RepositoryException- if an error occurs
-
removeVersion
public void removeVersion(Session session, InternalVersionHistory history, Name versionName) throws RepositoryException
Removes the specified version from the given version history.- Specified by:
removeVersionin interfaceInternalVersionManager- Parameters:
session- the session that performs the removehistory- version history to remove the version fromversionName- name of the version- Throws:
RepositoryException- if an error occurs
-
removeVersionHistory
public void removeVersionHistory(Session session, InternalVersionHistory history) throws RepositoryException
Removes the specified version history from storage.- Specified by:
removeVersionHistoryin interfaceInternalVersionManager- Parameters:
session- the session that performs the removehistory- the version history to remove- Throws:
RepositoryException- if an error occurs
-
setVersionLabel
public InternalVersion setVersionLabel(Session session, InternalVersionHistory history, Name version, Name label, boolean move) throws RepositoryException
Sets the versionlabelto the givenversion. If the label is already assigned to another version, a VersionException is thrown unlessmoveistrue. Ifversionisnull, the label is removed from the respective version. In either case, the version the label was previously assigned is returned, ornullof the label was not moved.- Specified by:
setVersionLabelin interfaceInternalVersionManager- Parameters:
session- the session that performs the operationhistory- version historyversion- name of the versionlabel- new labelmove- iftruelabel will be moved- Returns:
- the version that had the label or
null - Throws:
RepositoryException- if an error occurs
-
close
public void close() throws ExceptionClose this version manager. After having closed a persistence manager, further operations on this object are treated as illegal and throw- Specified by:
closein interfaceInternalVersionManager- Throws:
Exception- if an error occurs
-
isVirtualRoot
public boolean isVirtualRoot(ItemId id)
Checks if the id refers to the root of a virtual tree.- Specified by:
isVirtualRootin interfaceVirtualItemStateProvider- Returns:
trueif it is the root
-
getVirtualRootId
public NodeId getVirtualRootId()
Returns the id of the root node of the virtual tree.- Specified by:
getVirtualRootIdin interfaceVirtualItemStateProvider- Returns:
- the id of the root node of the virtual tree.
-
getVirtualRootIds
public NodeId[] getVirtualRootIds()
Description copied from interface:VirtualItemStateProviderReturns the ids of the root nodes of the virtual tree.- Specified by:
getVirtualRootIdsin interfaceVirtualItemStateProvider- Returns:
- the ids of the roots node of the virtual tree.
-
createPropertyState
public VirtualPropertyState createPropertyState(VirtualNodeState parent, Name name, int type, boolean multiValued) throws RepositoryException
Creats a new virtual property state- Specified by:
createPropertyStatein interfaceVirtualItemStateProvider- Returns:
- Throws:
RepositoryException
-
createNodeState
public VirtualNodeState createNodeState(VirtualNodeState parent, Name name, NodeId id, Name nodeTypeName) throws RepositoryException
Creates a new virtual node state- Specified by:
createNodeStatein interfaceVirtualItemStateProviderid- (must not be null)- Returns:
- Throws:
RepositoryException
-
setNodeReferences
public boolean setNodeReferences(ChangeLog references)
Informs this provider that the node references to some of its states have changed.- Specified by:
setNodeReferencesin interfaceVirtualItemStateProvider- Parameters:
references- collection ofNodeReferencesinstances- Returns:
trueif the reference target is one of its items.
-
getItemState
public ItemState getItemState(ItemId id) throws NoSuchItemStateException, ItemStateException
Return an item state, given its item id.Return item states for changes only. Global version manager will return other items.
- Specified by:
getItemStatein interfaceItemStateManager- Parameters:
id- item id- Returns:
- item state
- Throws:
NoSuchItemStateException- if the item does not existItemStateException- if an error occurs
-
hasItemState
public boolean hasItemState(ItemId id)
Return a flag indicating whether an item state for a given item id exists.- Specified by:
hasItemStatein interfaceItemStateManager- Parameters:
id- item id- Returns:
trueif an item state exists, otherwisefalse
-
getNodeReferences
public NodeReferences getNodeReferences(NodeId id) throws NoSuchItemStateException, ItemStateException
Return a node references object, given its target id- Specified by:
getNodeReferencesin interfaceItemStateManager- Parameters:
id- target id- Returns:
- node references object
- Throws:
NoSuchItemStateException- if the item does not existItemStateException- if an error occurs
-
hasNodeReferences
public boolean hasNodeReferences(NodeId id)
Return a flag indicating whether a node references object for a given target id exists.- Specified by:
hasNodeReferencesin interfaceItemStateManager- Parameters:
id- target id- Returns:
trueif a node reference object exists for the given id, otherwisefalse.
-
addListener
public void addListener(ItemStateListener listener)
Add anItemStateListenerNot needed.
- Specified by:
addListenerin interfaceVirtualItemStateProvider- Parameters:
listener- the new listener to be informed on modifications
-
removeListener
public void removeListener(ItemStateListener listener)
Remove anItemStateListenerNot needed.
- Specified by:
removeListenerin interfaceVirtualItemStateProvider- Parameters:
listener- an existing listener
-
getHistoryRoot
protected NodeStateEx getHistoryRoot()
returns the id of the version history root node- Returns:
- the id of the version history root node
-
getActivitiesRoot
protected NodeStateEx getActivitiesRoot()
returns the id of the activities root node- Returns:
- the id of the activities root node
-
getItem
protected InternalVersionItem getItem(NodeId id) throws RepositoryException
Returns the item with the given persistent id. Subclass responsibility.Please note, that the overridden method must acquire the readlock before reading the state manager.
- Parameters:
id- the id of the item- Returns:
- version item
- Throws:
RepositoryException- if an error occurs
-
hasItem
protected boolean hasItem(NodeId id)
Return a flag indicating if the item specified exists. Subclass responsibility.- Parameters:
id- the id of the item- Returns:
trueif the item exists;falseotherwise
-
hasItemReferences
protected boolean hasItemReferences(NodeId id) throws RepositoryException
Checks if there are item references (from outside the version storage) that reference the given node. Subclass responsibility.Please note, that the overridden method must acquire the readlock before reading the state manager.
- Parameters:
id- the id of the node- Returns:
trueif there are item references from outside the version storage;falseotherwise.- Throws:
RepositoryException- if an error occurs while reading from the repository.
-
getNodeStateEx
protected NodeStateEx getNodeStateEx(NodeId parentNodeId) throws RepositoryException
Returns the node with the given persistent id. Subclass responsibility.Please note, that the overridden method must acquire the readlock before reading the state manager.
- Parameters:
parentNodeId- the id of the node- Returns:
- the nodestate for the given id.
- Throws:
RepositoryException- if an error occurs while reading from the repository.
-
internalCheckin
protected InternalVersion internalCheckin(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history, NodeStateEx node, boolean simple, Calendar created) throws RepositoryException
Checks in a nodeBefore modifying version history given, make a local copy of it.
- Parameters:
history- the version historynode- node to checkinsimple- flag indicates simple versioningcreated- optional created date.- Returns:
- internal version
- Throws:
RepositoryException- if an error occurs- See Also:
Node.checkin()
-
internalRemoveVersion
protected void internalRemoveVersion(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history, Name name) throws VersionException, RepositoryExceptionRemoves the specified version from the historyBefore modifying version history given, make a local copy of it.
- Parameters:
history- the version history from where to remove the version.name- the name of the version to remove.- Throws:
VersionException- if the versionhistorydoes not have a version withname.RepositoryException- if any other error occurs.
-
setVersionLabel
protected InternalVersion setVersionLabel(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history, Name version, Name label, boolean move) throws RepositoryException
Set version label on the specified version.Before modifying version history given, make a local copy of it.
- Parameters:
history- version historyversion- version namelabel- version labelmove-trueto move from existing version;falseotherwise.- Returns:
- The internal version.
- Throws:
RepositoryException- if an error occurs
-
versionCreated
protected void versionCreated(InternalVersion version)
Invoked when a new internal item has been created.Put the version object into our cache.
- Parameters:
version- internal version item
-
versionDestroyed
protected void versionDestroyed(InternalVersion version)
Invoked when a new internal item has been destroyed.Remove the version object from our cache.
- Parameters:
version- internal version item
-
associate
public void associate(TransactionContext tx)
Associate this resource with a transaction. All further operations on the object should be interpreted as part of this transaction and changes recorded in some attribute of the transaction context.- Specified by:
associatein interfaceInternalXAResource- Parameters:
tx- transaction context, ifnulldisassociate
-
beforeOperation
public void beforeOperation(TransactionContext tx)
Invoked before one of theInternalXAResource.prepare(org.apache.jackrabbit.data.core.TransactionContext),InternalXAResource.commit(org.apache.jackrabbit.data.core.TransactionContext)orInternalXAResource.rollback(org.apache.jackrabbit.data.core.TransactionContext)method is called.Delegate the call to our XA item state manager.
- Specified by:
beforeOperationin interfaceInternalXAResource- Parameters:
tx- transaction context
-
prepare
public void prepare(TransactionContext tx) throws TransactionException
Prepare transaction. The transaction is identified by a transaction context.Delegate the call to our XA item state manager.
- Specified by:
preparein interfaceInternalXAResource- Parameters:
tx- transaction context- Throws:
TransactionException- if an error occurs
-
commit
public void commit(TransactionContext tx) throws TransactionException
Commit transaction. The transaction is identified by a transaction context. If the method throws, other resources get their changes rolled back.Delegate the call to our XA item state manager. If successful, inform global repository manager to update its caches.
- Specified by:
commitin interfaceInternalXAResource- Parameters:
tx- transaction context- Throws:
TransactionException- if an error occurs
-
rollback
public void rollback(TransactionContext tx)
Rollback transaction. The transaction is identified by a transaction context.Delegate the call to our XA item state manager.
- Specified by:
rollbackin interfaceInternalXAResource- Parameters:
tx- transaction context.
-
afterOperation
public void afterOperation(TransactionContext tx)
Invoked after one of theInternalXAResource.prepare(org.apache.jackrabbit.data.core.TransactionContext),InternalXAResource.commit(org.apache.jackrabbit.data.core.TransactionContext)orInternalXAResource.rollback(org.apache.jackrabbit.data.core.TransactionContext)method has been called.Delegate the call to our XA item state manager.
- Specified by:
afterOperationin interfaceInternalXAResource- Parameters:
tx- transaction context
-
getXAResourceBegin
public InternalXAResource getXAResourceBegin()
Returns anInternalXAResourcethat acquires a write lock on the version manager inInternalXAResource.prepare(TransactionContext).- Returns:
- an internal XA resource.
-
getXAResourceEnd
public InternalXAResource getXAResourceEnd()
Returns anInternalXAResourcethat releases the write lock on the version manager inInternalXAResource.commit(TransactionContext)orInternalXAResource.rollback(TransactionContext).- Returns:
- an internal XA resource.
-
getVersion
public InternalVersion getVersion(NodeId id) throws RepositoryException
Returns the version with the given id- Specified by:
getVersionin interfaceInternalVersionManager- Parameters:
id- id of the version to retrieve- Returns:
- the version or
null - Throws:
RepositoryException- if an error occurs
-
getBaseline
public InternalBaseline getBaseline(NodeId id) throws RepositoryException
Returns the baseline with the given id- Specified by:
getBaselinein interfaceInternalVersionManager- Parameters:
id- id of the baseline version to retrieve- Returns:
- the baseline or
nullif not found - Throws:
RepositoryException- if an error occurs
-
getActivity
public InternalActivity getActivity(NodeId id) throws RepositoryException
Returns the activity with the given id- Specified by:
getActivityin interfaceInternalVersionManager- Parameters:
id- id of the activity to retrieve- Returns:
- the activity.
- Throws:
RepositoryException- if an error occurs
-
getVersionHistory
public InternalVersionHistory getVersionHistory(NodeId id) throws RepositoryException
Returns the version history with the given id- Specified by:
getVersionHistoryin interfaceInternalVersionManager- Parameters:
id- id of the version history- Returns:
- the version history.
- Throws:
RepositoryException- if an error occurs
-
getVersionHistoryOfNode
public InternalVersionHistory getVersionHistoryOfNode(NodeId id) throws RepositoryException
Returns the version history for the versionable node with the given id.- Specified by:
getVersionHistoryOfNodein interfaceInternalVersionManager- Parameters:
id- id of the node to retrieve the version history for- Returns:
- the version history
- Throws:
RepositoryException- if an error occurs or the history does not exit
-
getHeadVersionOfNode
public InternalVersion getHeadVersionOfNode(NodeId id) throws RepositoryException
Returns the head version of the node with the given id. this is always the last of all versions. this only works correctly for liner version graphs (i.e. simple versioning) Assumes that all versions are stored chronologically below the version history and just returns the last one. i.e. currently only works for simple versioning.- Specified by:
getHeadVersionOfNodein interfaceInternalVersionManager- Parameters:
id- id of the node to retrieve the version for- Returns:
- the version.
- Throws:
RepositoryException- if an error occurs
-
acquireWriteLock
protected VersioningLock.WriteLock acquireWriteLock()
Acquires the write lock on this version manager.- Returns:
- returns the write lock
-
acquireReadLock
public VersioningLock.ReadLock acquireReadLock()
acquires the read lock on this version manager.- Returns:
- returns the read lock
-
getVersionHistoryInfoForNode
public VersionHistoryInfo getVersionHistoryInfoForNode(NodeState node) throws RepositoryException
Returns information about the version history of the specified node ornullwhen unavailable.- Parameters:
node- node whose version history should be returned- Returns:
- identifiers of the version history and root version nodes
- Throws:
RepositoryException- if an error occurs
-
getVersionHistory
public VersionHistoryInfo getVersionHistory(Session session, NodeState node, NodeId copiedFrom) throws RepositoryException
Returns information about the version history of the specified node. If the given node does not already have an associated version history, then an empty history is automatically created. This method should only be called by code that already knows that the specified node is versionable.- Specified by:
getVersionHistoryin interfaceInternalVersionManager- Parameters:
session- workspace sessionnode- node whose version history should be returnedcopiedFrom- the node id for the jcr:copiedFrom property use for copied nodes- Returns:
- identifiers of the version history and root version nodes
- Throws:
RepositoryException- if an error occurs
-
getName
protected static Name getName(String name)
Utility method that returns the given string as a name in the default namespace.- Parameters:
name- string name- Returns:
- A
Nameobject.
-
getParentNode
protected static NodeStateEx getParentNode(NodeStateEx parent, String uuid, Name interNT) throws RepositoryException
Utility method that returns the parent node under which the version history of the identified versionable node is or will be stored. If theinterNTis notnullthen the returned parent node and any ancestor nodes are automatically created if they do not already exist. Otherwisenullis returned if the parent node does not exist.- Parameters:
parent- the parent nodeuuid- UUID of a versionable nodeinterNT- intermediate nodetype.- Returns:
- parent node of the version history, or
null - Throws:
RepositoryException- if an error occurs
-
checkin
protected InternalVersion checkin(NodeStateEx node, Calendar created) throws RepositoryException
Creates a new version of the given node using the given version creation time.- Parameters:
node- the node to be checked increated- version creation time- Returns:
- the new version
- Throws:
RepositoryException- if an error occurs
-
calculateCheckinVersionName
protected String calculateCheckinVersionName(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history, NodeStateEx node, boolean simple) throws RepositoryException
Calculates the name of the new version that will be created by a checkin call. The name is determined as follows:- first the predecessor version with the shortest name is searched.
- if that predecessor version is the root version, the new version gets the name "{number of successors}+1" + ".0"
- if that predecessor version has no successor, the last digit of it's version number is incremented.
- if that predecessor version has successors but the incremented name does not exist, that name is used.
- otherwise a ".0" is added to the name until a non conflicting name is found.
jcr:rootVersion | | 1.0 2.0 | 1.1 | 1.2 ---\ ------\ | \ \ 1.3 1.2.0 1.2.0.0 | | 1.4 1.2.1 ----\ | | \ 1.5 1.2.2 1.2.1.0 | | | 1.6 | 1.2.1.1 |-----/ 1.7
- Parameters:
history- the version historynode- the node to checkinsimple- iftrueindicates simple versioning- Returns:
- the new version name
- Throws:
RepositoryException- if an error occurs.
-
internalRemoveVersionHistory
public void internalRemoveVersionHistory(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history) throws VersionException, RepositoryExceptionRemoves the specified history from the storage- Parameters:
history- the version history to remove- Throws:
VersionExceptionRepositoryException
-
itemDiscarded
protected void itemDiscarded(InternalVersionItem item)
Invoked by the internal version item itself, when it's underlying persistence state was discarded.- Parameters:
item- item that was discarded
-
createInternalVersionItem
protected InternalVersionItem createInternalVersionItem(NodeId id) throws RepositoryException
- Parameters:
id- the node id of the version item.- Returns:
- the version item or
nullif there is no node state with the givenid. - Throws:
RepositoryException- if an error occurs while reading from the version storage.
-
getNodeIdFactory
public NodeIdFactory getNodeIdFactory()
-
-