Class AbstractVISProvider
- java.lang.Object
-
- org.apache.jackrabbit.core.virtual.AbstractVISProvider
-
- All Implemented Interfaces:
ItemStateListener
,ItemStateManager
,VirtualItemStateProvider
- Direct Known Subclasses:
VirtualNodeTypeStateProvider
public abstract class AbstractVISProvider extends Object implements VirtualItemStateProvider, ItemStateListener
This Class implements a virtual item state provider, in order to expose the versions to the version storage.
-
-
Field Summary
Fields Modifier and Type Field Description protected NodeTypeRegistry
ntReg
the node type registryprotected NodeId
rootNodeId
the root node id
-
Constructor Summary
Constructors Constructor Description AbstractVISProvider(NodeTypeRegistry ntReg, NodeId rootNodeId)
Creates an abstract virtual item state provider
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addListener(ItemStateListener listener)
Add anItemStateListener
protected NodeState
cache(NodeState state)
adds the node state to the cacheVirtualNodeState
createNodeState(VirtualNodeState parent, Name name, NodeId id, Name nodeTypeName)
Creates a new virtual node stateVirtualPropertyState
createPropertyState(VirtualNodeState parent, Name name, int type, boolean multiValued)
Creats a new virtual property stateprotected abstract VirtualNodeState
createRootNodeState()
Creates the root node state.protected void
discardAll()
Discards all virtual item states and prepares for the root state to be recreated when next accessed.protected void
evict(NodeId id)
removes the node state from the cacheprotected QNodeDefinition
getApplicableChildNodeDef(NodeState parent, Name nodeName, Name nodeTypeName)
Retrieves the node definition for the given constraints.protected QPropertyDefinition
getApplicablePropertyDef(NodeState parent, Name propertyName, int type, boolean multiValued)
retrieves the property definition for the given constraintsprotected EffectiveNodeType
getEffectiveNodeType(NodeState parent)
Returns the effective (i.e.ItemState
getItemState(ItemId id)
Return an item state, given its item id.NodeReferences
getNodeReferences(NodeId id)
Return a node references object, given its target idprotected NodeTypeRegistry
getNodeTypeRegistry()
returns the node type managerNodeState
getRootState()
Returns the root stateNodeId
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.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 abstract VirtualNodeState
internalGetNodeState(NodeId id)
Retrieves the node state with the given node idprotected VirtualPropertyState
internalGetPropertyState(PropertyId id)
Retrieves the property state for the given idprotected abstract boolean
internalHasNodeState(NodeId id)
Checks if this provide has the node state of the given node idprotected boolean
internalHasPropertyState(PropertyId id)
Checks if this provider has the property state of the given id.void
invalidateItem(ItemId id, boolean recursive)
invalidates the itemboolean
isVirtualRoot(ItemId id)
Checks if the id refers to the root of a virtual tree.void
removeListener(ItemStateListener listener)
Remove anItemStateListener
void
stateCreated(ItemState created)
Called when anItemState
has successfully been created (i.e.void
stateDestroyed(ItemState destroyed)
Called when anItemState
has successfully been removed (i.e.void
stateDiscarded(ItemState discarded)
Called when anItemState
has been discarded (i.e.void
stateModified(ItemState modified)
Called when anItemState
has successfully been modified (i.e.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.jackrabbit.core.virtual.VirtualItemStateProvider
setNodeReferences
-
-
-
-
Field Detail
-
rootNodeId
protected final NodeId rootNodeId
the root node id
-
ntReg
protected final NodeTypeRegistry ntReg
the node type registry
-
-
Constructor Detail
-
AbstractVISProvider
public AbstractVISProvider(NodeTypeRegistry ntReg, NodeId rootNodeId)
Creates an abstract virtual item state provider- Parameters:
ntReg
-rootNodeId
-
-
-
Method Detail
-
createRootNodeState
protected abstract VirtualNodeState createRootNodeState() throws RepositoryException
Creates the root node state.- Returns:
- The virtual root node state.
- Throws:
RepositoryException
-
hasItemState
public boolean hasItemState(ItemId id)
Return a flag indicating whether an item state for a given item id exists.- Specified by:
hasItemState
in interfaceItemStateManager
- Parameters:
id
- item id- Returns:
true
if an item state exists, otherwisefalse
-
getItemState
public ItemState getItemState(ItemId id) throws NoSuchItemStateException, ItemStateException
Return an item state, given its item id.- Specified by:
getItemState
in interfaceItemStateManager
- Parameters:
id
- item id- Returns:
- item state
- Throws:
NoSuchItemStateException
- if the item does not existItemStateException
- if an error occurs
-
getNodeReferences
public NodeReferences getNodeReferences(NodeId id) throws NoSuchItemStateException, ItemStateException
Return a node references object, given its target id- Specified by:
getNodeReferences
in 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:
hasNodeReferences
in interfaceItemStateManager
- Parameters:
id
- target id- Returns:
true
if a node reference object exists for the given id, otherwisefalse
.
-
isVirtualRoot
public boolean isVirtualRoot(ItemId id)
Checks if the id refers to the root of a virtual tree.- Specified by:
isVirtualRoot
in interfaceVirtualItemStateProvider
- Returns:
true
if it is the root
-
getVirtualRootId
public NodeId getVirtualRootId()
Returns the id of the root node of the virtual tree.- Specified by:
getVirtualRootId
in interfaceVirtualItemStateProvider
- Returns:
- the id of the root node of the virtual tree.
-
getVirtualRootIds
public NodeId[] getVirtualRootIds()
Returns the ids of the root nodes of the virtual tree.- Specified by:
getVirtualRootIds
in interfaceVirtualItemStateProvider
- Returns:
- the ids of the roots node of the virtual tree.
-
getRootState
public NodeState getRootState() throws ItemStateException
Returns the root state- Returns:
- the root state
- Throws:
ItemStateException
- If the root node state does not exist and its creation fails.
-
discardAll
protected void discardAll()
Discards all virtual item states and prepares for the root state to be recreated when next accessed.- See Also:
- JCR-2617
-
internalHasNodeState
protected abstract boolean internalHasNodeState(NodeId id)
Checks if this provide has the node state of the given node id- Parameters:
id
-- Returns:
true
if it has the node state
-
internalGetNodeState
protected abstract VirtualNodeState internalGetNodeState(NodeId id) throws NoSuchItemStateException, ItemStateException
Retrieves the node state with the given node id- Parameters:
id
-- Returns:
- Throws:
NoSuchItemStateException
ItemStateException
-
internalHasPropertyState
protected boolean internalHasPropertyState(PropertyId id)
Checks if this provider has the property state of the given id.- Parameters:
id
-- Returns:
true
if it has the property state
-
internalGetPropertyState
protected VirtualPropertyState internalGetPropertyState(PropertyId id) throws NoSuchItemStateException, ItemStateException
Retrieves the property state for the given id- Parameters:
id
-- Returns:
- Throws:
NoSuchItemStateException
ItemStateException
-
createPropertyState
public VirtualPropertyState createPropertyState(VirtualNodeState parent, Name name, int type, boolean multiValued) throws RepositoryException
Creats a new virtual property state- Specified by:
createPropertyState
in 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:
createNodeState
in interfaceVirtualItemStateProvider
id
- (must not be null)- Returns:
- Throws:
RepositoryException
-
addListener
public void addListener(ItemStateListener listener)
Add anItemStateListener
- Specified by:
addListener
in interfaceVirtualItemStateProvider
- Parameters:
listener
- the new listener to be informed on modifications
-
removeListener
public void removeListener(ItemStateListener listener)
Remove anItemStateListener
- Specified by:
removeListener
in interfaceVirtualItemStateProvider
- Parameters:
listener
- an existing listener
-
getNodeTypeRegistry
protected NodeTypeRegistry getNodeTypeRegistry()
returns the node type manager- Returns:
- the node type manager
-
cache
protected NodeState cache(NodeState state)
adds the node state to the cache- Parameters:
state
-- Returns:
- The same state.
-
evict
protected void evict(NodeId id)
removes the node state from the cache- Parameters:
id
-
-
invalidateItem
public void invalidateItem(ItemId id, boolean recursive)
invalidates the item- Parameters:
id
-recursive
-
-
getApplicablePropertyDef
protected QPropertyDefinition getApplicablePropertyDef(NodeState parent, Name propertyName, int type, boolean multiValued) throws RepositoryException
retrieves the property definition for the given constraints- Parameters:
parent
- The parent node state.propertyName
- The name of the property.type
-multiValued
-- Returns:
- Throws:
RepositoryException
-
getApplicableChildNodeDef
protected QNodeDefinition getApplicableChildNodeDef(NodeState parent, Name nodeName, Name nodeTypeName) throws RepositoryException
Retrieves the node definition for the given constraints.- Parameters:
parent
- The parent state.nodeName
-nodeTypeName
-- Returns:
- Throws:
RepositoryException
-
getEffectiveNodeType
protected EffectiveNodeType getEffectiveNodeType(NodeState parent) throws RepositoryException
Returns the effective (i.e. merged and resolved) node type representation of this node's primary and mixin node types.- Returns:
- the effective node type
- Throws:
RepositoryException
-
stateCreated
public void stateCreated(ItemState created)
Called when anItemState
has successfully been created (i.e. its underlying persistent state was created).- Specified by:
stateCreated
in interfaceItemStateListener
- Parameters:
created
- theItemState
that has been 'created'
-
stateModified
public void stateModified(ItemState modified)
Called when anItemState
has successfully been modified (i.e. its underlying persistent state has changed).- Specified by:
stateModified
in interfaceItemStateListener
- Parameters:
modified
- theItemState
that has been 'modified'
-
stateDestroyed
public void stateDestroyed(ItemState destroyed)
Called when anItemState
has successfully been removed (i.e. its underlying persistent state has been destroyed).- Specified by:
stateDestroyed
in interfaceItemStateListener
- Parameters:
destroyed
- theItemState
that has been 'destroyed'
-
stateDiscarded
public void stateDiscarded(ItemState discarded)
Called when anItemState
has been discarded (i.e. it has been rendered 'invalid').- Specified by:
stateDiscarded
in interfaceItemStateListener
- Parameters:
discarded
- theItemState
that has been discarded- See Also:
ItemState.discard()
-
-