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 NodeTypeRegistryntRegthe node type registryprotected NodeIdrootNodeIdthe 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 voidaddListener(ItemStateListener listener)Add anItemStateListenerprotected NodeStatecache(NodeState state)adds the node state to the cacheVirtualNodeStatecreateNodeState(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 abstract VirtualNodeStatecreateRootNodeState()Creates the root node state.protected voiddiscardAll()Discards all virtual item states and prepares for the root state to be recreated when next accessed.protected voidevict(NodeId id)removes the node state from the cacheprotected QNodeDefinitiongetApplicableChildNodeDef(NodeState parent, Name nodeName, Name nodeTypeName)Retrieves the node definition for the given constraints.protected QPropertyDefinitiongetApplicablePropertyDef(NodeState parent, Name propertyName, int type, boolean multiValued)retrieves the property definition for the given constraintsprotected EffectiveNodeTypegetEffectiveNodeType(NodeState parent)Returns the effective (i.e.ItemStategetItemState(ItemId id)Return an item state, given its item id.NodeReferencesgetNodeReferences(NodeId id)Return a node references object, given its target idprotected NodeTypeRegistrygetNodeTypeRegistry()returns the node type managerNodeStategetRootState()Returns the root stateNodeIdgetVirtualRootId()Returns the id of the root node of the virtual tree.NodeId[]getVirtualRootIds()Returns the ids of the root nodes of the virtual tree.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 abstract VirtualNodeStateinternalGetNodeState(NodeId id)Retrieves the node state with the given node idprotected VirtualPropertyStateinternalGetPropertyState(PropertyId id)Retrieves the property state for the given idprotected abstract booleaninternalHasNodeState(NodeId id)Checks if this provide has the node state of the given node idprotected booleaninternalHasPropertyState(PropertyId id)Checks if this provider has the property state of the given id.voidinvalidateItem(ItemId id, boolean recursive)invalidates the itembooleanisVirtualRoot(ItemId id)Checks if the id refers to the root of a virtual tree.voidremoveListener(ItemStateListener listener)Remove anItemStateListenervoidstateCreated(ItemState created)Called when anItemStatehas successfully been created (i.e.voidstateDestroyed(ItemState destroyed)Called when anItemStatehas successfully been removed (i.e.voidstateDiscarded(ItemState discarded)Called when anItemStatehas been discarded (i.e.voidstateModified(ItemState modified)Called when anItemStatehas 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:
hasItemStatein interfaceItemStateManager- Parameters:
id- item id- Returns:
trueif an item state exists, otherwisefalse
-
getItemState
public ItemState getItemState(ItemId id) throws NoSuchItemStateException, ItemStateException
Return an item state, given its item id.- Specified by:
getItemStatein 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:
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.
-
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()
Returns 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.
-
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:
trueif 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:
NoSuchItemStateExceptionItemStateException
-
internalHasPropertyState
protected boolean internalHasPropertyState(PropertyId id)
Checks if this provider has the property state of the given id.- Parameters:
id-- Returns:
trueif 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:
NoSuchItemStateExceptionItemStateException
-
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
-
addListener
public void addListener(ItemStateListener listener)
Add anItemStateListener- Specified by:
addListenerin interfaceVirtualItemStateProvider- Parameters:
listener- the new listener to be informed on modifications
-
removeListener
public void removeListener(ItemStateListener listener)
Remove anItemStateListener- Specified by:
removeListenerin 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 anItemStatehas successfully been created (i.e. its underlying persistent state was created).- Specified by:
stateCreatedin interfaceItemStateListener- Parameters:
created- theItemStatethat has been 'created'
-
stateModified
public void stateModified(ItemState modified)
Called when anItemStatehas successfully been modified (i.e. its underlying persistent state has changed).- Specified by:
stateModifiedin interfaceItemStateListener- Parameters:
modified- theItemStatethat has been 'modified'
-
stateDestroyed
public void stateDestroyed(ItemState destroyed)
Called when anItemStatehas successfully been removed (i.e. its underlying persistent state has been destroyed).- Specified by:
stateDestroyedin interfaceItemStateListener- Parameters:
destroyed- theItemStatethat has been 'destroyed'
-
stateDiscarded
public void stateDiscarded(ItemState discarded)
Called when anItemStatehas been discarded (i.e. it has been rendered 'invalid').- Specified by:
stateDiscardedin interfaceItemStateListener- Parameters:
discarded- theItemStatethat has been discarded- See Also:
ItemState.discard()
-
-