public class InternalXAVersionManager extends Object implements EventStateCollectionFactory, VirtualItemStateProvider, InternalXAResource
InternalVersionManager
that works in an XA environment.
Works as a filter between a version manager client and the global version
manager.Modifier and Type | Field and Description |
---|---|
protected NodeId |
activitiesId |
protected NodeId |
historiesId |
protected NodeTypeRegistry |
ntReg
Node type registry.
|
protected LocalItemStateManager |
stateMgr
State manager for the version storage.
|
Constructor and Description |
---|
InternalXAVersionManager(InternalVersionManagerImpl vMgr,
NodeTypeRegistry ntReg,
SessionImpl session,
ItemStateCacheFactory cacheFactory)
Creates a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
VersioningLock.ReadLock |
acquireReadLock()
acquires the read lock on this version manager.
|
protected VersioningLock.WriteLock |
acquireWriteLock()
Acquires the write lock on this version manager.
|
void |
addListener(ItemStateListener listener)
Add an
ItemStateListener |
void |
afterOperation(TransactionContext tx)
|
void |
associate(TransactionContext tx)
Associate this resource with a transaction.
|
void |
beforeOperation(TransactionContext tx)
|
protected String |
calculateCheckinVersionName(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.
|
NodeId |
canCheckout(NodeStateEx state,
NodeId activityId)
invokes the checkout() on the persistent version manager.
|
protected InternalVersion |
checkin(NodeStateEx node,
Calendar created)
Creates a new version of the given node using the given version
creation time.
|
InternalVersion |
checkin(Session session,
NodeStateEx node,
Calendar created)
invokes the checkin() on the persistent version manager and remaps the
newly created version objects.
|
void |
close()
Close this version manager.
|
void |
commit(TransactionContext tx)
Commit transaction.
|
NodeId |
createActivity(Session session,
String title)
Creates a new activity
|
EventStateCollection |
createEventStateCollection()
Creates an
EventStateCollection . |
protected InternalVersionItem |
createInternalVersionItem(NodeId id)
|
VirtualNodeState |
createNodeState(VirtualNodeState parent,
Name name,
NodeId id,
Name nodeTypeName)
Creates a new virtual node state
|
VirtualPropertyState |
createPropertyState(VirtualNodeState parent,
Name name,
int type,
boolean multiValued)
Creats a new virtual property state
|
protected VersionHistoryInfo |
createVersionHistory(Session session,
NodeState node,
NodeId copiedFrom)
Creates a new version history.
|
protected NodeStateEx |
getActivitiesRoot()
returns the id of the activities root node
|
InternalActivity |
getActivity(NodeId id)
Returns the activity with the given id
|
InternalBaseline |
getBaseline(NodeId id)
Returns the baseline with the given id
|
InternalVersion |
getHeadVersionOfNode(NodeId id)
Returns the head version of the node with the given id.
|
protected NodeStateEx |
getHistoryRoot()
returns the id of the version history root node
|
protected InternalVersionItem |
getItem(NodeId id)
Returns the item with the given persistent id.
|
ItemState |
getItemState(ItemId id)
Return an item state, given its item id.
|
protected static Name |
getName(String name)
Utility method that returns the given string as a name in the default
namespace.
|
NodeIdFactory |
getNodeIdFactory() |
NodeReferences |
getNodeReferences(NodeId id)
Return a node references object, given its target id
|
protected NodeStateEx |
getNodeStateEx(NodeId parentNodeId)
Returns the node with the given persistent id.
|
protected static NodeStateEx |
getParentNode(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.
|
InternalVersion |
getVersion(NodeId id)
Returns the version with the given id
|
InternalVersionHistory |
getVersionHistory(NodeId id)
Returns the version history with the given id
|
VersionHistoryInfo |
getVersionHistory(Session session,
NodeState node,
NodeId copiedFrom)
Returns information about the version history of the specified node.
|
VersionHistoryInfo |
getVersionHistoryInfoForNode(NodeState node)
Returns information about the version history of the specified node
or
null when unavailable. |
InternalVersionHistory |
getVersionHistoryOfNode(NodeId id)
Returns the version history for the versionable node with the given id.
|
VirtualItemStateProvider |
getVirtualItemStateProvider()
returns the virtual item state provider that exposes the internal versions
as items.
|
NodeId |
getVirtualRootId()
Returns the id of the root node of the virtual tree.
|
NodeId[] |
getVirtualRootIds()
Returns the ids of the root nodes of the virtual tree.
|
InternalXAResource |
getXAResourceBegin()
Returns an
InternalXAResource that acquires a write lock on the
version manager in InternalXAResource.prepare(TransactionContext) . |
InternalXAResource |
getXAResourceEnd()
Returns an
InternalXAResource that releases the write lock on the
version manager in InternalXAResource.commit(TransactionContext)
or InternalXAResource.rollback(TransactionContext) . |
protected boolean |
hasItem(NodeId id)
Return a flag indicating if the item specified exists.
|
protected boolean |
hasItemReferences(NodeId id)
Checks if there are item references (from outside the version storage)
that reference the given node.
|
boolean |
hasItemState(ItemId id)
Return a flag indicating whether an item state for a given
item id exists.
|
boolean |
hasNodeReferences(NodeId id)
Return a flag indicating whether a node references object
for a given target id exists.
|
protected InternalVersion |
internalCheckin(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history,
NodeStateEx node,
boolean simple,
Calendar created)
Checks in a node
|
protected void |
internalRemoveActivity(org.apache.jackrabbit.core.version.InternalActivityImpl activity)
Removes the specified activity
|
protected void |
internalRemoveVersion(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history,
Name name)
Removes the specified version from the history
|
void |
internalRemoveVersionHistory(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history)
Removes the specified history from the storage
|
boolean |
isVirtualRoot(ItemId id)
Checks if the id refers to the root of a virtual tree.
|
protected void |
itemDiscarded(InternalVersionItem item)
Invoked by the internal version item itself, when it's underlying
persistence state was discarded.
|
void |
prepare(TransactionContext tx)
Prepare transaction.
|
void |
removeActivity(Session session,
NodeId nodeId)
Removes an activity and all
|
void |
removeListener(ItemStateListener listener)
Remove an
ItemStateListener |
void |
removeVersion(Session session,
InternalVersionHistory history,
Name versionName)
Removes the specified version from the given version history.
|
void |
removeVersionHistory(Session session,
InternalVersionHistory history)
Removes the specified version history from storage.
|
void |
rollback(TransactionContext tx)
Rollback transaction.
|
boolean |
setNodeReferences(ChangeLog references)
Informs this provider that the node references to some of its states
have changed.
|
protected InternalVersion |
setVersionLabel(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history,
Name version,
Name label,
boolean move)
Set version label on the specified version.
|
InternalVersion |
setVersionLabel(Session session,
InternalVersionHistory history,
Name version,
Name label,
boolean move)
Sets the version
label to the given version . |
protected void |
versionCreated(InternalVersion version)
Invoked when a new internal item has been created.
|
protected void |
versionDestroyed(InternalVersion version)
Invoked when a new internal item has been destroyed.
|
protected LocalItemStateManager stateMgr
protected final NodeTypeRegistry ntReg
protected final NodeId historiesId
protected final NodeId activitiesId
public InternalXAVersionManager(InternalVersionManagerImpl vMgr, NodeTypeRegistry ntReg, SessionImpl session, ItemStateCacheFactory cacheFactory) throws RepositoryException
vMgr
- the underlying version managerntReg
- node type registrysession
- the sessioncacheFactory
- cache factoryRepositoryException
- if a an error occurspublic EventStateCollection createEventStateCollection() throws RepositoryException
EventStateCollection
.createEventStateCollection
in interface EventStateCollectionFactory
EventStateCollection
RepositoryException
- if creation fails for some reasonpublic VirtualItemStateProvider getVirtualItemStateProvider()
getVirtualItemStateProvider
in interface InternalVersionManager
protected VersionHistoryInfo createVersionHistory(Session session, NodeState node, NodeId copiedFrom) throws RepositoryException
session
- repository sessionnode
- versionable node statecopiedFrom
- node id for the jcr:copiedFrom propertyRepositoryException
- if an error occursgetVersionHistory(Session, NodeState, NodeId)
public NodeId createActivity(Session session, String title) throws RepositoryException
createActivity
in interface InternalVersionManager
session
- the current sessiontitle
- title of the new activityRepositoryException
- if an error occurspublic void removeActivity(Session session, NodeId nodeId) throws RepositoryException
removeActivity
in interface InternalVersionManager
session
- the current sessionnodeId
- id of the activity to removeRepositoryException
- if an error occursprotected void internalRemoveActivity(org.apache.jackrabbit.core.version.InternalActivityImpl activity) throws VersionException, RepositoryException
Before modifying activity, make a local copy of it.
activity
- the activity to removeRepositoryException
- if any other error occurs.VersionException
public NodeId canCheckout(NodeStateEx state, NodeId activityId) throws RepositoryException
canCheckout
in interface InternalVersionManager
state
- node to checkoutactivityId
- node id if the current activityRepositoryException
- if an error occurspublic InternalVersion checkin(Session session, NodeStateEx node, Calendar created) throws RepositoryException
checkin
in interface InternalVersionManager
session
- session that invokes the checkinnode
- node to checkincreated
- create time of the new version,
or null
for the current timeRepositoryException
- if an error occurspublic void removeVersion(Session session, InternalVersionHistory history, Name versionName) throws RepositoryException
removeVersion
in interface InternalVersionManager
session
- the session that performs the removehistory
- version history to remove the version fromversionName
- name of the versionRepositoryException
- if an error occurspublic void removeVersionHistory(Session session, InternalVersionHistory history) throws RepositoryException
removeVersionHistory
in interface InternalVersionManager
session
- the session that performs the removehistory
- the version history to removeRepositoryException
- if an error occurspublic InternalVersion setVersionLabel(Session session, InternalVersionHistory history, Name version, Name label, boolean move) throws RepositoryException
label
to the given version
.
If the label is already assigned to another version, a VersionException is
thrown unless move
is true
. If version
is null
, the label is removed from the respective version.
In either case, the version the label was previously assigned is returned,
or null
of the label was not moved.setVersionLabel
in interface InternalVersionManager
session
- the session that performs the operationhistory
- version historyversion
- name of the versionlabel
- new labelmove
- if true
label will be movednull
RepositoryException
- if an error occurspublic void close() throws Exception
close
in interface InternalVersionManager
Exception
- if an error occurspublic boolean isVirtualRoot(ItemId id)
isVirtualRoot
in interface VirtualItemStateProvider
true
if it is the rootpublic NodeId getVirtualRootId()
getVirtualRootId
in interface VirtualItemStateProvider
public NodeId[] getVirtualRootIds()
VirtualItemStateProvider
getVirtualRootIds
in interface VirtualItemStateProvider
public VirtualPropertyState createPropertyState(VirtualNodeState parent, Name name, int type, boolean multiValued) throws RepositoryException
createPropertyState
in interface VirtualItemStateProvider
RepositoryException
public VirtualNodeState createNodeState(VirtualNodeState parent, Name name, NodeId id, Name nodeTypeName) throws RepositoryException
createNodeState
in interface VirtualItemStateProvider
id
- (must not be null)RepositoryException
public boolean setNodeReferences(ChangeLog references)
setNodeReferences
in interface VirtualItemStateProvider
references
- collection of NodeReferences
instancestrue
if the reference target is one of its items.public ItemState getItemState(ItemId id) throws NoSuchItemStateException, ItemStateException
Return item states for changes only. Global version manager will return other items.
getItemState
in interface ItemStateManager
id
- item idNoSuchItemStateException
- if the item does not existItemStateException
- if an error occurspublic boolean hasItemState(ItemId id)
hasItemState
in interface ItemStateManager
id
- item idtrue
if an item state exists,
otherwise false
public NodeReferences getNodeReferences(NodeId id) throws NoSuchItemStateException, ItemStateException
getNodeReferences
in interface ItemStateManager
id
- target idNoSuchItemStateException
- if the item does not existItemStateException
- if an error occurspublic boolean hasNodeReferences(NodeId id)
hasNodeReferences
in interface ItemStateManager
id
- target idtrue
if a node reference object exists for the given
id, otherwise false
.public void addListener(ItemStateListener listener)
ItemStateListener
Not needed.
addListener
in interface VirtualItemStateProvider
listener
- the new listener to be informed on modificationspublic void removeListener(ItemStateListener listener)
ItemStateListener
Not needed.
removeListener
in interface VirtualItemStateProvider
listener
- an existing listenerprotected NodeStateEx getHistoryRoot()
protected NodeStateEx getActivitiesRoot()
protected InternalVersionItem getItem(NodeId id) throws RepositoryException
Please note, that the overridden method must acquire the readlock before reading the state manager.
id
- the id of the itemRepositoryException
- if an error occursprotected boolean hasItem(NodeId id)
id
- the id of the itemtrue
if the item exists;
false
otherwiseprotected boolean hasItemReferences(NodeId id) throws RepositoryException
Please note, that the overridden method must acquire the readlock before reading the state manager.
id
- the id of the nodetrue
if there are item references from outside the
version storage; false
otherwise.RepositoryException
- if an error occurs while reading from the
repository.protected NodeStateEx getNodeStateEx(NodeId parentNodeId) throws RepositoryException
Please note, that the overridden method must acquire the readlock before reading the state manager.
parentNodeId
- the id of the nodeRepositoryException
- if an error occurs while reading from the
repository.protected InternalVersion internalCheckin(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history, NodeStateEx node, boolean simple, Calendar created) throws RepositoryException
Before modifying version history given, make a local copy of it.
history
- the version historynode
- node to checkinsimple
- flag indicates simple versioningcreated
- optional created date.RepositoryException
- if an error occursNode.checkin()
protected void internalRemoveVersion(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history, Name name) throws VersionException, RepositoryException
Before modifying version history given, make a local copy of it.
history
- the version history from where to remove the version.name
- the name of the version to remove.VersionException
- if the version history
does
not have a version with name
.RepositoryException
- if any other error occurs.protected InternalVersion setVersionLabel(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history, Name version, Name label, boolean move) throws RepositoryException
Before modifying version history given, make a local copy of it.
history
- version historyversion
- version namelabel
- version labelmove
- true
to move from existing version;
false
otherwise.RepositoryException
- if an error occursprotected void versionCreated(InternalVersion version)
Put the version object into our cache.
version
- internal version itemprotected void versionDestroyed(InternalVersion version)
Remove the version object from our cache.
version
- internal version itempublic void associate(TransactionContext tx)
associate
in interface InternalXAResource
tx
- transaction context, if null
disassociatepublic void beforeOperation(TransactionContext tx)
InternalXAResource.prepare(org.apache.jackrabbit.data.core.TransactionContext)
, InternalXAResource.commit(org.apache.jackrabbit.data.core.TransactionContext)
or
InternalXAResource.rollback(org.apache.jackrabbit.data.core.TransactionContext)
method is called.
Delegate the call to our XA item state manager.
beforeOperation
in interface InternalXAResource
tx
- transaction contextpublic void prepare(TransactionContext tx) throws TransactionException
Delegate the call to our XA item state manager.
prepare
in interface InternalXAResource
tx
- transaction contextTransactionException
- if an error occurspublic void commit(TransactionContext tx) throws TransactionException
Delegate the call to our XA item state manager. If successful, inform global repository manager to update its caches.
commit
in interface InternalXAResource
tx
- transaction contextTransactionException
- if an error occurspublic void rollback(TransactionContext tx)
Delegate the call to our XA item state manager.
rollback
in interface InternalXAResource
tx
- transaction context.public void afterOperation(TransactionContext tx)
InternalXAResource.prepare(org.apache.jackrabbit.data.core.TransactionContext)
, InternalXAResource.commit(org.apache.jackrabbit.data.core.TransactionContext)
or
InternalXAResource.rollback(org.apache.jackrabbit.data.core.TransactionContext)
method has been called.
Delegate the call to our XA item state manager.
afterOperation
in interface InternalXAResource
tx
- transaction contextpublic InternalXAResource getXAResourceBegin()
InternalXAResource
that acquires a write lock on the
version manager in InternalXAResource.prepare(TransactionContext)
.public InternalXAResource getXAResourceEnd()
InternalXAResource
that releases the write lock on the
version manager in InternalXAResource.commit(TransactionContext)
or InternalXAResource.rollback(TransactionContext)
.public InternalVersion getVersion(NodeId id) throws RepositoryException
getVersion
in interface InternalVersionManager
id
- id of the version to retrievenull
RepositoryException
- if an error occurspublic InternalBaseline getBaseline(NodeId id) throws RepositoryException
getBaseline
in interface InternalVersionManager
id
- id of the baseline version to retrievenull
if not foundRepositoryException
- if an error occurspublic InternalActivity getActivity(NodeId id) throws RepositoryException
getActivity
in interface InternalVersionManager
id
- id of the activity to retrieveRepositoryException
- if an error occurspublic InternalVersionHistory getVersionHistory(NodeId id) throws RepositoryException
getVersionHistory
in interface InternalVersionManager
id
- id of the version historyRepositoryException
- if an error occurspublic InternalVersionHistory getVersionHistoryOfNode(NodeId id) throws RepositoryException
getVersionHistoryOfNode
in interface InternalVersionManager
id
- id of the node to retrieve the version history forRepositoryException
- if an error occurs or the history does not exitpublic InternalVersion getHeadVersionOfNode(NodeId id) throws RepositoryException
getHeadVersionOfNode
in interface InternalVersionManager
id
- id of the node to retrieve the version forRepositoryException
- if an error occursprotected VersioningLock.WriteLock acquireWriteLock()
public VersioningLock.ReadLock acquireReadLock()
public VersionHistoryInfo getVersionHistoryInfoForNode(NodeState node) throws RepositoryException
null
when unavailable.node
- node whose version history should be returnedRepositoryException
- if an error occurspublic VersionHistoryInfo getVersionHistory(Session session, NodeState node, NodeId copiedFrom) throws RepositoryException
getVersionHistory
in interface InternalVersionManager
session
- workspace sessionnode
- node whose version history should be returnedcopiedFrom
- the node id for the jcr:copiedFrom property use for copied nodesRepositoryException
- if an error occursprotected static Name getName(String name)
name
- string nameName
object.protected static NodeStateEx getParentNode(NodeStateEx parent, String uuid, Name interNT) throws RepositoryException
interNT
is not null
then the returned
parent node and any ancestor nodes are automatically created if they do
not already exist. Otherwise
null
is returned if the parent node does not exist.parent
- the parent nodeuuid
- UUID of a versionable nodeinterNT
- intermediate nodetype.null
RepositoryException
- if an error occursprotected InternalVersion checkin(NodeStateEx node, Calendar created) throws RepositoryException
node
- the node to be checked increated
- version creation timeRepositoryException
- if an error occursprotected String calculateCheckinVersionName(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history, NodeStateEx node, boolean simple) throws RepositoryException
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
history
- the version historynode
- the node to checkinsimple
- if true
indicates simple versioningRepositoryException
- if an error occurs.public void internalRemoveVersionHistory(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history) throws VersionException, RepositoryException
history
- the version history to removeVersionException
RepositoryException
protected void itemDiscarded(InternalVersionItem item)
item
- item that was discardedprotected InternalVersionItem createInternalVersionItem(NodeId id) throws RepositoryException
id
- the node id of the version item.null
if there is no node state
with the given id
.RepositoryException
- if an error occurs while reading from the
version storage.public NodeIdFactory getNodeIdFactory()
Copyright © 2004–2021 The Apache Software Foundation. All rights reserved.