public class InternalVersionManagerImpl extends Object implements ItemStateListener, UpdateEventListener
Modifier and Type | Class and Description |
---|---|
static class |
InternalVersionManagerImpl.DynamicESCFactory |
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 |
---|
InternalVersionManagerImpl(PersistenceManager pMgr,
FileSystem fs,
NodeTypeRegistry ntReg,
DelegatingObservationDispatcher obsMgr,
NodeId systemId,
NodeId historiesId,
NodeId activitiesId,
ItemStateCacheFactory cacheFactory,
ISMLocking ismLocking,
NodeIdFactory nodeIdFactory)
Creates a new internal version manager
|
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.
|
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(javax.jcr.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.
|
NodeId |
createActivity(javax.jcr.Session session,
String title)
Creates a new activity
|
protected InternalVersionItem |
createInternalVersionItem(NodeId id)
|
protected VersionItemStateManager |
createItemStateManager(PersistenceManager pMgr,
NodeId rootId,
NodeTypeRegistry ntReg,
ItemStateCacheFactory cacheFactory,
ISMLocking ismLocking,
NodeIdFactory nodeIdFactory)
Creates a
VersionItemStateManager or derivative. |
protected VersionHistoryInfo |
createVersionHistory(javax.jcr.Session session,
NodeState node,
NodeId copiedFrom)
Creates a new version history.
|
void |
externalUpdate(ChangeLog changes,
List<EventState> events,
long timestamp,
String userData)
Handle an external update.
|
protected NodeStateEx |
getActivitiesRoot()
returns 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
|
InternalVersionManagerImpl.DynamicESCFactory |
getEscFactory()
Returns the event state collection factory.
|
InternalVersion |
getHeadVersionOfNode(NodeId id)
Returns the head version of the node with the given id.
|
protected NodeStateEx |
getHistoryRoot()
returns the version history root node
|
protected InternalVersionItem |
getItem(NodeId id)
Returns the item with the given persistent id.
|
protected static Name |
getName(String name)
Utility method that returns the given string as a name in the default
namespace.
|
NodeIdFactory |
getNodeIdFactory() |
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.
|
PersistenceManager |
getPersistenceManager()
Return the persistence manager.
|
protected SharedItemStateManager |
getSharedStateMgr()
Returns the shared item state manager.
|
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(javax.jcr.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.
|
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.
|
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
|
protected void |
itemDiscarded(InternalVersionItem item)
Invoked by the internal version item itself, when it's underlying
persistence state was discarded.
|
void |
itemsUpdated(Collection<InternalVersionItem> items)
Invoked by some external source to indicate that some items in the
versions tree were updated.
|
void |
removeActivity(javax.jcr.Session session,
NodeId nodeId)
Removes an activity and all
|
void |
removeVersion(javax.jcr.Session session,
InternalVersionHistory history,
Name name)
Removes the specified version from the given version history.
|
void |
removeVersionHistory(javax.jcr.Session session,
InternalVersionHistory history)
Removes the specified version history from storage.
|
void |
setEventChannel(UpdateEventChannel eventChannel)
Set an event channel to inform about updates.
|
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(javax.jcr.Session session,
InternalVersionHistory history,
Name version,
Name label,
boolean move)
Sets the version
label to the given version . |
void |
stateCreated(ItemState created)
Called when an
ItemState has successfully
been created (i.e. |
void |
stateDestroyed(ItemState destroyed)
Called when an
ItemState has successfully been
removed (i.e. |
void |
stateDiscarded(ItemState discarded)
Called when an
ItemState has been discarded (i.e. |
void |
stateModified(ItemState modified)
Called when an
ItemState has successfully
been modified (i.e. |
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 InternalVersionManagerImpl(PersistenceManager pMgr, FileSystem fs, NodeTypeRegistry ntReg, DelegatingObservationDispatcher obsMgr, NodeId systemId, NodeId historiesId, NodeId activitiesId, ItemStateCacheFactory cacheFactory, ISMLocking ismLocking, NodeIdFactory nodeIdFactory) throws javax.jcr.RepositoryException
pMgr
- underlying persistence managerfs
- workspace file systemntReg
- node type registryobsMgr
- observation managersystemId
- node id of the version storage parent (i.e. jcr:system)historiesId
- node id of the version storage (i.e. jcr:versionStorage)activitiesId
- node id of the activities storage (i.e. jcr:activities)cacheFactory
- item state cache factoryismLocking
- workspace item state lockingjavax.jcr.RepositoryException
- if an error occurspublic VirtualItemStateProvider getVirtualItemStateProvider()
getVirtualItemStateProvider
in interface InternalVersionManager
public PersistenceManager getPersistenceManager()
public void close() throws Exception
close
in interface InternalVersionManager
Exception
- if an error occurspublic InternalVersionManagerImpl.DynamicESCFactory getEscFactory()
protected VersionHistoryInfo createVersionHistory(javax.jcr.Session session, NodeState node, NodeId copiedFrom) throws javax.jcr.RepositoryException
This method must not be synchronized since it could cause deadlocks with item-reading listeners in the observation thread.
session
- repository sessionnode
- versionable node statecopiedFrom
- node id for the jcr:copiedFrom propertyjavax.jcr.RepositoryException
- if an error occursgetVersionHistory(Session, NodeState, NodeId)
public NodeId createActivity(javax.jcr.Session session, String title) throws javax.jcr.RepositoryException
This method must not be synchronized since it could cause deadlocks with item-reading listeners in the observation thread.
createActivity
in interface InternalVersionManager
session
- the current sessiontitle
- title of the new activityjavax.jcr.RepositoryException
- if an error occurspublic void removeActivity(javax.jcr.Session session, NodeId nodeId) throws javax.jcr.RepositoryException
This method must not be synchronized since it could cause deadlocks with item-reading listeners in the observation thread.
removeActivity
in interface InternalVersionManager
session
- the current sessionnodeId
- id of the activity to removejavax.jcr.RepositoryException
- if an error occurspublic boolean hasItem(NodeId id)
id
- the id of the itemtrue
if the item exists;
false
otherwiseprotected InternalVersionItem getItem(NodeId id) throws javax.jcr.RepositoryException
Please note, that the overridden method must acquire the readlock before reading the state manager.
id
- the id of the itemjavax.jcr.RepositoryException
- if an error occurspublic NodeId canCheckout(NodeStateEx state, NodeId activityId) throws javax.jcr.RepositoryException
canCheckout
in interface InternalVersionManager
state
- node to checkoutactivityId
- node id if the current activityjavax.jcr.RepositoryException
- if an error occurspublic InternalVersion checkin(javax.jcr.Session session, NodeStateEx node, Calendar created) throws javax.jcr.RepositoryException
This method must not be synchronized since it could cause deadlocks with item-reading listeners in the observation thread.
checkin
in interface InternalVersionManager
session
- session that invokes the checkinnode
- node to checkincreated
- create time of the new version,
or null
for the current timejavax.jcr.RepositoryException
- if an error occurspublic void removeVersion(javax.jcr.Session session, InternalVersionHistory history, Name name) throws javax.jcr.version.VersionException, javax.jcr.RepositoryException
This method must not be synchronized since it could cause deadlocks with item-reading listeners in the observation thread.
removeVersion
in interface InternalVersionManager
session
- the session that performs the removehistory
- version history to remove the version fromname
- name of the versionjavax.jcr.RepositoryException
- if an error occursjavax.jcr.version.VersionException
public void removeVersionHistory(javax.jcr.Session session, InternalVersionHistory history) throws javax.jcr.RepositoryException
This method must not be synchronized since it could cause deadlocks with item-reading listeners in the observation thread.
removeVersionHistory
in interface InternalVersionManager
session
- the session that performs the removehistory
- the version history to removejavax.jcr.RepositoryException
- if an error occurspublic InternalVersion setVersionLabel(javax.jcr.Session session, InternalVersionHistory history, Name version, Name label, boolean move) throws javax.jcr.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.
This method must not be synchronized since it could cause deadlocks with item-reading listeners in the observation thread.
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
javax.jcr.RepositoryException
- if an error occurspublic void itemsUpdated(Collection<InternalVersionItem> items)
items
- items updatedpublic void setEventChannel(UpdateEventChannel eventChannel)
eventChannel
- event channelprotected void itemDiscarded(InternalVersionItem item)
item
- item that was discardedprotected boolean hasItemReferences(NodeId id) throws javax.jcr.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.javax.jcr.RepositoryException
- if an error occurs while reading from the
repository.protected NodeStateEx getNodeStateEx(NodeId parentNodeId) throws javax.jcr.RepositoryException
Please note, that the overridden method must acquire the readlock before reading the state manager.
parentNodeId
- the id of the nodejavax.jcr.RepositoryException
- if an error occurs while reading from the
repository.protected NodeStateEx getHistoryRoot()
protected NodeStateEx getActivitiesRoot()
protected SharedItemStateManager getSharedStateMgr()
protected VersionItemStateManager createItemStateManager(PersistenceManager pMgr, NodeId rootId, NodeTypeRegistry ntReg, ItemStateCacheFactory cacheFactory, ISMLocking ismLocking, NodeIdFactory nodeIdFactory) throws ItemStateException
VersionItemStateManager
or derivative.pMgr
- persistence managerrootId
- root node idntReg
- node type registrycacheFactory
- cache factoryismLocking
- the ISM locking implementationItemStateException
- if an error occurspublic void stateCreated(ItemState created)
ItemState
has successfully
been created (i.e. its underlying persistent state was created).
Not used.
stateCreated
in interface ItemStateListener
created
- the ItemState
that has been 'created'public void stateModified(ItemState modified)
ItemState
has successfully
been modified (i.e. its underlying persistent state has changed).
Not used.
stateModified
in interface ItemStateListener
modified
- the ItemState
that has been 'modified'public void stateDestroyed(ItemState destroyed)
ItemState
has successfully been
removed (i.e. its underlying persistent state has been destroyed).
Remove item from cache on removal.
stateDestroyed
in interface ItemStateListener
destroyed
- the ItemState
that has been 'destroyed'public void stateDiscarded(ItemState discarded)
ItemState
has been discarded (i.e. it has
been rendered 'invalid').
Not used.
stateDiscarded
in interface ItemStateListener
discarded
- the ItemState
that has been discardedItemState.discard()
public void externalUpdate(ChangeLog changes, List<EventState> events, long timestamp, String userData) throws javax.jcr.RepositoryException
externalUpdate
in interface UpdateEventListener
changes
- external changes containing only node and property ids.events
- events to delivertimestamp
- when the change occurred.userData
- the user data associated with this update.javax.jcr.RepositoryException
- if the update cannot be processedpublic InternalVersion getVersion(NodeId id) throws javax.jcr.RepositoryException
getVersion
in interface InternalVersionManager
id
- id of the version to retrievenull
javax.jcr.RepositoryException
- if an error occurspublic InternalBaseline getBaseline(NodeId id) throws javax.jcr.RepositoryException
getBaseline
in interface InternalVersionManager
id
- id of the baseline version to retrievenull
if not foundjavax.jcr.RepositoryException
- if an error occurspublic InternalActivity getActivity(NodeId id) throws javax.jcr.RepositoryException
getActivity
in interface InternalVersionManager
id
- id of the activity to retrievejavax.jcr.RepositoryException
- if an error occurspublic InternalVersionHistory getVersionHistory(NodeId id) throws javax.jcr.RepositoryException
getVersionHistory
in interface InternalVersionManager
id
- id of the version historyjavax.jcr.RepositoryException
- if an error occurspublic InternalVersionHistory getVersionHistoryOfNode(NodeId id) throws javax.jcr.RepositoryException
getVersionHistoryOfNode
in interface InternalVersionManager
id
- id of the node to retrieve the version history forjavax.jcr.RepositoryException
- if an error occurs or the history does not exitpublic InternalVersion getHeadVersionOfNode(NodeId id) throws javax.jcr.RepositoryException
getHeadVersionOfNode
in interface InternalVersionManager
id
- id of the node to retrieve the version forjavax.jcr.RepositoryException
- if an error occursprotected VersioningLock.WriteLock acquireWriteLock()
public VersioningLock.ReadLock acquireReadLock()
public VersionHistoryInfo getVersionHistoryInfoForNode(NodeState node) throws javax.jcr.RepositoryException
null
when unavailable.node
- node whose version history should be returnedjavax.jcr.RepositoryException
- if an error occurspublic VersionHistoryInfo getVersionHistory(javax.jcr.Session session, NodeState node, NodeId copiedFrom) throws javax.jcr.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 nodesjavax.jcr.RepositoryException
- if an error occursprotected void internalRemoveActivity(org.apache.jackrabbit.core.version.InternalActivityImpl activity) throws javax.jcr.RepositoryException
activity
- the activity to removejavax.jcr.RepositoryException
- if any other error occurs.protected static Name getName(String name)
name
- string nameName
object.protected static NodeStateEx getParentNode(NodeStateEx parent, String uuid, Name interNT) throws javax.jcr.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
javax.jcr.RepositoryException
- if an error occursprotected InternalVersion checkin(NodeStateEx node, Calendar created) throws javax.jcr.RepositoryException
node
- the node to be checked increated
- version creation timejavax.jcr.RepositoryException
- if an error occursprotected InternalVersion internalCheckin(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history, NodeStateEx node, boolean simple, Calendar created) throws javax.jcr.RepositoryException
history
- the version historynode
- node to checkinsimple
- flag indicates simple versioningcreated
- optional created date.javax.jcr.RepositoryException
- if an error occursNode.checkin()
protected String calculateCheckinVersionName(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history, NodeStateEx node, boolean simple) throws javax.jcr.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 versioningjavax.jcr.RepositoryException
- if an error occurs.protected void internalRemoveVersion(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history, Name name) throws javax.jcr.version.VersionException, javax.jcr.RepositoryException
history
- the version history from where to remove the version.name
- the name of the version to remove.javax.jcr.version.VersionException
- if the version history
does
not have a version with name
.javax.jcr.RepositoryException
- if any other error occurs.public void internalRemoveVersionHistory(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history) throws javax.jcr.version.VersionException, javax.jcr.RepositoryException
history
- the version history to removejavax.jcr.version.VersionException
javax.jcr.RepositoryException
protected InternalVersion setVersionLabel(org.apache.jackrabbit.core.version.InternalVersionHistoryImpl history, Name version, Name label, boolean move) throws javax.jcr.RepositoryException
history
- version historyversion
- version namelabel
- version labelmove
- true
to move from existing version;
false
otherwise.javax.jcr.RepositoryException
- if an error occursprotected void versionCreated(InternalVersion version)
version
- internal version itemprotected void versionDestroyed(InternalVersion version)
version
- internal version itemprotected InternalVersionItem createInternalVersionItem(NodeId id) throws javax.jcr.RepositoryException
id
- the node id of the version item.null
if there is no node state
with the given id
.javax.jcr.RepositoryException
- if an error occurs while reading from the
version storage.public NodeIdFactory getNodeIdFactory()
Copyright © 2004-2020 The Apache Software Foundation. All Rights Reserved.