Class SessionItemStateManager
- java.lang.Object
- 
- org.apache.jackrabbit.core.state.SessionItemStateManager
 
- 
- All Implemented Interfaces:
- ItemStateListener,- ItemStateManager,- NodeStateListener,- UpdatableItemStateManager
 
 public class SessionItemStateManager extends Object implements UpdatableItemStateManager, NodeStateListener Item state manager that handles both transient and persistent items.
- 
- 
Constructor SummaryConstructors Constructor Description SessionItemStateManager(NodeId rootNodeId, LocalItemStateManager stateMgr)Creates a newSessionItemStateManagerinstance.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(ItemStateListener listener)Add anItemStateListenervoidcancel()Cancel an update operation.NodeStatecreateNew(NodeId id, Name nodeTypeName, NodeId parentId)Creates aNodeStateinstance representing new, i.e.PropertyStatecreateNew(PropertyState transientState)Customized variant ofcreateNew(Name, NodeId)that connects the newly created persistent state with the transient state.PropertyStatecreateNew(Name propName, NodeId parentId)Creates aPropertyStateinstance representing new, i.e.NodeStatecreateTransientNodeState(NodeId id, Name nodeTypeName, NodeId parentId, int initialStatus)NodeStatecreateTransientNodeState(NodeState overlayedState, int initialStatus)PropertyStatecreateTransientPropertyState(NodeId parentId, Name propName, int initialStatus)PropertyStatecreateTransientPropertyState(PropertyState overlayedState, int initialStatus)voiddestroy(ItemState state)Destroy an item state.voiddisconnectTransientItemState(ItemState state)Disconnect a transient item state from its underlying persistent state.voiddispose()Disposes thisUpdatableItemStateManagerand frees resources.voiddisposeAllTransientItemStates()Disposes all transient item states in the cache and in the attic.voiddisposeTransientItemState(ItemState state)Disposes the specified transient item state instance, i.e.voiddisposeTransientItemStateInAttic(ItemState state)Disposes the specified transient item state instance in the attic, i.e.voidedit()Start an edit operation on items inside this manager.ItemStateManagergetAttic()Return the attic item state provider that holds all items moved into the attic.HierarchyManagergetAtticAwareHierarchyMgr()Returns an attic-aware hierarchy manager, i.e.Collection<ItemState>getDescendantTransientItemStates(ItemId id)Returns a collection of those transient item state instances that are direct or indirect descendants of the item state with the given parent.Iterable<ItemState>getDescendantTransientItemStatesInAttic(ItemId id)Same asgetDescendantTransientItemStates(ItemId)HierarchyManagergetHierarchyMgr()Returns the hierarchy managerNodeIdgetIdOfRootTransientNodeState()Returns the id of the root of the minimal subtree including all transient states.ItemStategetItemState(ItemId id)Return an item state, given its item id.NodeReferencesgetNodeReferences(NodeId id)Return a node references object, given its target idItemStategetTransientItemState(ItemId id)booleanhasAnyTransientItemStates()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.booleanhasTransientItemState(ItemId id)booleanhasTransientItemStateInAttic(ItemId id)booleaninEditMode()Returnstrueif this manager is in edit mode i.e.booleanisItemStateInAttic(ItemId id)Return a flag indicating whether the specified item is in the transient item state manager's attic space.NodeStatemakePersistent(NodeState transientState)Pushes the given transient state to the change log so it'll be persisted when the change log is committed.voidmoveTransientItemStateToAttic(ItemState state)Transfers the specified transient item state instance from the 'active' cache to the attic.voidnodeAdded(NodeState state, Name name, int index, NodeId id)Called when a child node has been addedvoidnodeModified(NodeState state)Called when a node has been modified, typically as a result of removal or addition of a child node.voidnodeRemoved(NodeState state, Name name, int index, NodeId id)Called when a child node has been removedvoidnodesReplaced(NodeState state)Called when the children nodes were replaced by other nodes, typically as result of a reorder operation.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.voidstore(ItemState state)Store an item state.StringtoString()voidupdate()End an update operation.
 
- 
- 
- 
Constructor Detail- 
SessionItemStateManagerpublic SessionItemStateManager(NodeId rootNodeId, LocalItemStateManager stateMgr) Creates a newSessionItemStateManagerinstance.- Parameters:
- rootNodeId- the root node id
- stateMgr- the local item state manager
 
 
- 
 - 
Method Detail- 
getHierarchyMgrpublic HierarchyManager getHierarchyMgr() Returns the hierarchy manager- Returns:
- the hierarchy manager
 
 - 
getAtticAwareHierarchyMgrpublic HierarchyManager getAtticAwareHierarchyMgr() Returns an attic-aware hierarchy manager, i.e. an hierarchy manager that is also able to build/resolve paths of those items that have been moved or removed (i.e. moved to the attic).- Returns:
- an attic-aware hierarchy manager
 
 - 
getItemStatepublic ItemState getItemState(ItemId id) throws NoSuchItemStateException, ItemStateException Return an item state, given its item id.- Specified by:
- getItemStatein interface- ItemStateManager
- Parameters:
- id- item id
- Returns:
- item state
- Throws:
- NoSuchItemStateException- if the item does not exist
- ItemStateException- if an error occurs
 
 - 
hasItemStatepublic boolean hasItemState(ItemId id) Return a flag indicating whether an item state for a given item id exists.- Specified by:
- hasItemStatein interface- ItemStateManager
- Parameters:
- id- item id
- Returns:
- trueif an item state exists, otherwise- false
 
 - 
getNodeReferencespublic NodeReferences getNodeReferences(NodeId id) throws NoSuchItemStateException, ItemStateException Return a node references object, given its target id- Specified by:
- getNodeReferencesin interface- ItemStateManager
- Parameters:
- id- target id
- Returns:
- node references object
- Throws:
- NoSuchItemStateException- if the item does not exist
- ItemStateException- if an error occurs
 
 - 
hasNodeReferencespublic boolean hasNodeReferences(NodeId id) Return a flag indicating whether a node references object for a given target id exists.- Specified by:
- hasNodeReferencesin interface- ItemStateManager
- Parameters:
- id- target id
- Returns:
- trueif a node reference object exists for the given id, otherwise- false.
 
 - 
editpublic void edit() throws IllegalStateExceptionStart an edit operation on items inside this manager. This allows calling the operations defined below. At the end of this operation, eitherUpdatableItemStateManager.update()orUpdatableItemStateManager.cancel()must be invoked.- Specified by:
- editin interface- UpdatableItemStateManager
- Throws:
- IllegalStateException- if the manager is already in edit mode.
 
 - 
inEditModepublic boolean inEditMode() Returnstrueif this manager is in edit mode i.e. if an edit operation has been started by invokingUpdatableItemStateManager.edit(), otherwise returnsfalse.- Specified by:
- inEditModein interface- UpdatableItemStateManager
- Returns:
- trueif this manager is in edit mode, otherwise- false
 
 - 
createNewpublic NodeState createNew(NodeId id, Name nodeTypeName, NodeId parentId) throws RepositoryException Creates aNodeStateinstance representing new, i.e. not yet existing state. CallUpdatableItemStateManager.store(org.apache.jackrabbit.core.state.ItemState)on the returned object to make it persistent.- Specified by:
- createNewin interface- UpdatableItemStateManager
- Parameters:
- id- the id of the node, or- nullfor a new node id
- nodeTypeName- The node type name
- parentId- parent node's id
- Returns:
- a node state
- Throws:
- RepositoryException- if the node state can not be created
 
 - 
createNewpublic PropertyState createNew(Name propName, NodeId parentId) throws IllegalStateException Creates aPropertyStateinstance representing new, i.e. not yet existing state. CallUpdatableItemStateManager.store(org.apache.jackrabbit.core.state.ItemState)on the returned object to make it persistent.- Specified by:
- createNewin interface- UpdatableItemStateManager
- Parameters:
- propName- property name
- parentId- parent node Id
- Returns:
- a property state
- Throws:
- IllegalStateException- if the manager is not in edit mode.
 
 - 
createNewpublic PropertyState createNew(PropertyState transientState) throws ItemStateException Customized variant ofcreateNew(Name, NodeId)that connects the newly created persistent state with the transient state.- Throws:
- ItemStateException
 
 - 
storepublic void store(ItemState state) throws IllegalStateException Store an item state.- Specified by:
- storein interface- UpdatableItemStateManager
- Parameters:
- state- item state that should be stored
- Throws:
- IllegalStateException- if the manager is not in edit mode.
 
 - 
destroypublic void destroy(ItemState state) throws IllegalStateException Destroy an item state.- Specified by:
- destroyin interface- UpdatableItemStateManager
- Parameters:
- state- item state that should be destroyed
- Throws:
- IllegalStateException- if the manager is not in edit mode.
 
 - 
cancelpublic void cancel() throws IllegalStateExceptionCancel an update operation. This will undo all changes made to objects inside this item state manager.- Specified by:
- cancelin interface- UpdatableItemStateManager
- Throws:
- IllegalStateException- if the manager is not in edit mode.
 
 - 
updatepublic void update() throws ReferentialIntegrityException, StaleItemStateException, ItemStateException, IllegalStateExceptionEnd an update operation. This will save all items added to this update operation in a single step. If this operation fails, no item will have been saved.- Specified by:
- updatein interface- UpdatableItemStateManager
- Throws:
- ReferentialIntegrityException- if a new or modified REFERENCE property refers to a non-existent target or if a removed node is still being referenced
- StaleItemStateException- if at least one of the affected items has become stale in the meantime
- ItemStateException- if the operation failed for another reason
- IllegalStateException- if the manager is not in edit mode.
 
 - 
disposepublic void dispose() Disposes thisUpdatableItemStateManagerand frees resources.- Specified by:
- disposein interface- UpdatableItemStateManager
 
 - 
getTransientItemStatepublic ItemState getTransientItemState(ItemId id) throws NoSuchItemStateException, ItemStateException - Parameters:
- id-
- Returns:
- Throws:
- NoSuchItemStateException
- ItemStateException
 
 - 
hasTransientItemStatepublic boolean hasTransientItemState(ItemId id) - Parameters:
- id-
- Returns:
 
 - 
hasTransientItemStateInAtticpublic boolean hasTransientItemStateInAttic(ItemId id) - Parameters:
- id-
- Returns:
 
 - 
hasAnyTransientItemStatespublic boolean hasAnyTransientItemStates() - Returns:
- trueif this manager has any transient state;- falseotherwise.
 
 - 
getDescendantTransientItemStatespublic Collection<ItemState> getDescendantTransientItemStates(ItemId id) throws InvalidItemStateException, RepositoryException Returns a collection of those transient item state instances that are direct or indirect descendants of the item state with the given parent. The transient item state instance with the given identifier itself (if there is such) will not be included.The instances are returned in depth-first tree traversal order. - Parameters:
- id- identifier of the common parent of the transient item state instances to be returned
- Returns:
- collection of descendant transient item state instances
- Throws:
- InvalidItemStateException- if any descendant item state has been deleted externally
- RepositoryException- if another error occurs
 
 - 
getDescendantTransientItemStatesInAtticpublic Iterable<ItemState> getDescendantTransientItemStatesInAttic(ItemId id) throws RepositoryException Same asgetDescendantTransientItemStates(ItemId)- Parameters:
- id- identifier of the common parent of the transient item state instances to be returned
- Returns:
- collection of descendant transient item state instances in the attic
- Throws:
- RepositoryException
 
 - 
getIdOfRootTransientNodeStatepublic NodeId getIdOfRootTransientNodeState() throws RepositoryException Returns the id of the root of the minimal subtree including all transient states.- Returns:
- id of nearest common ancestor of all transient states or null if there's no transient state.
- Throws:
- RepositoryException- if an error occurs
 
 - 
isItemStateInAtticpublic boolean isItemStateInAttic(ItemId id) Return a flag indicating whether the specified item is in the transient item state manager's attic space.- Parameters:
- id- item id
- Returns:
- trueif the item state is in the attic space;- falseotherwise
 
 - 
createTransientNodeStatepublic NodeState createTransientNodeState(NodeId id, Name nodeTypeName, NodeId parentId, int initialStatus) throws RepositoryException - Parameters:
- id-
- nodeTypeName-
- parentId-
- initialStatus-
- Returns:
- Throws:
- RepositoryException
 
 - 
createTransientNodeStatepublic NodeState createTransientNodeState(NodeState overlayedState, int initialStatus) throws ItemStateException - Parameters:
- overlayedState-
- initialStatus-
- Returns:
- Throws:
- ItemStateException
 
 - 
createTransientPropertyStatepublic PropertyState createTransientPropertyState(NodeId parentId, Name propName, int initialStatus) throws ItemStateException - Parameters:
- parentId-
- propName-
- initialStatus-
- Returns:
- Throws:
- ItemStateException
 
 - 
createTransientPropertyStatepublic PropertyState createTransientPropertyState(PropertyState overlayedState, int initialStatus) throws ItemStateException - Parameters:
- overlayedState-
- initialStatus-
- Returns:
- Throws:
- ItemStateException
 
 - 
disconnectTransientItemStatepublic void disconnectTransientItemState(ItemState state) Disconnect a transient item state from its underlying persistent state. Notifies theHierarchyManagerabout the changed identity.- Parameters:
- state- the transient- ItemStateinstance that should be disconnected
 
 - 
disposeTransientItemStatepublic void disposeTransientItemState(ItemState state) Disposes the specified transient item state instance, i.e. discards it and clears it from cache.- Parameters:
- state- the transient- ItemStateinstance that should be disposed
- See Also:
- ItemState.discard()
 
 - 
moveTransientItemStateToAtticpublic void moveTransientItemStateToAttic(ItemState state) Transfers the specified transient item state instance from the 'active' cache to the attic.- Parameters:
- state- the transient- ItemStateinstance that should be moved to the attic
 
 - 
disposeTransientItemStateInAtticpublic void disposeTransientItemStateInAttic(ItemState state) Disposes the specified transient item state instance in the attic, i.e. discards it and removes it from the attic.- Parameters:
- state- the transient- ItemStateinstance that should be disposed @see ItemState#discard()
 
 - 
disposeAllTransientItemStatespublic void disposeAllTransientItemStates() Disposes all transient item states in the cache and in the attic.
 - 
addListenerpublic void addListener(ItemStateListener listener) Add anItemStateListener- Parameters:
- listener- the new listener to be informed on modifications
 
 - 
removeListenerpublic void removeListener(ItemStateListener listener) Remove anItemStateListener- Parameters:
- listener- an existing listener
 
 - 
getAtticpublic ItemStateManager getAttic() Return the attic item state provider that holds all items moved into the attic.- Returns:
- attic
 
 - 
stateCreatedpublic void stateCreated(ItemState created) Called when anItemStatehas successfully been created (i.e. its underlying persistent state was created).Notification handler gets called for both transient states that this state manager has created, as well as states that were created by the local state manager we're listening to. - Specified by:
- stateCreatedin interface- ItemStateListener
- Parameters:
- created- the- ItemStatethat has been 'created'
 
 - 
stateModifiedpublic void stateModified(ItemState modified) Called when anItemStatehas successfully been modified (i.e. its underlying persistent state has changed).Notification handler gets called for both transient states that this state manager has created, as well as states that were created by the local state manager we're listening to. - Specified by:
- stateModifiedin interface- ItemStateListener
- Parameters:
- modified- the- ItemStatethat has been 'modified'
 
 - 
stateDestroyedpublic void stateDestroyed(ItemState destroyed) Called when anItemStatehas successfully been removed (i.e. its underlying persistent state has been destroyed).Notification handler gets called for both transient states that this state manager has created, as well as states that were created by the local state manager we're listening to. - Specified by:
- stateDestroyedin interface- ItemStateListener
- Parameters:
- destroyed- the- ItemStatethat has been 'destroyed'
 
 - 
stateDiscardedpublic void stateDiscarded(ItemState discarded) Called when anItemStatehas been discarded (i.e. it has been rendered 'invalid').Notification handler gets called for both transient states that this state manager has created, as well as states that were created by the local state manager we're listening to. - Specified by:
- stateDiscardedin interface- ItemStateListener
- Parameters:
- discarded- the- ItemStatethat has been discarded
- See Also:
- ItemState.discard()
 
 - 
nodeAddedpublic void nodeAdded(NodeState state, Name name, int index, NodeId id) Called when a child node has been addedPass notification to listeners if a transient state was modified or if the local state is not overlayed. - Specified by:
- nodeAddedin interface- NodeStateListener
- Parameters:
- state- node state that changed
- name- name of node that was added
- index- index of new node
- id- id of new node
 
 - 
nodesReplacedpublic void nodesReplaced(NodeState state) Called when the children nodes were replaced by other nodes, typically as result of a reorder operation.Pass notification to listeners if a transient state was modified or if the local state is not overlayed. - Specified by:
- nodesReplacedin interface- NodeStateListener
- Parameters:
- state- node state that changed
 
 - 
nodeModifiedpublic void nodeModified(NodeState state) Called when a node has been modified, typically as a result of removal or addition of a child node.Please note, that this method is not called if ItemStateListener.stateModified(ItemState)was called.Pass notification to listeners if a transient state was modified or if the local state is not overlayed. - Specified by:
- nodeModifiedin interface- NodeStateListener
- Parameters:
- state- node state that changed
 
 - 
nodeRemovedpublic void nodeRemoved(NodeState state, Name name, int index, NodeId id) Called when a child node has been removedPass notification to listeners if a transient state was modified or if the local state is not overlayed. - Specified by:
- nodeRemovedin interface- NodeStateListener
- Parameters:
- state- node state that changed
- name- name of node that was removed
- index- index of removed node
- id- id of removed node
 
 - 
makePersistentpublic NodeState makePersistent(NodeState transientState) throws RepositoryException Pushes the given transient state to the change log so it'll be persisted when the change log is committed. The transient state is replaced with the local state that has been pushed to the change log.- Parameters:
- transientState- transient state
- Returns:
- the local state to be persisted
- Throws:
- RepositoryException- if the transiet state can not be persisted
 
 
- 
 
-