public class SessionItemStateManager extends Object implements UpdatableItemStateManager, NodeStateListener
| Constructor and Description |
|---|
SessionItemStateManager(NodeId rootNodeId,
LocalItemStateManager stateMgr)
Creates a new
SessionItemStateManager instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(ItemStateListener listener)
Add an
ItemStateListener |
void |
cancel()
Cancel an update operation.
|
PropertyState |
createNew(Name propName,
NodeId parentId)
Creates a
PropertyState instance representing new,
i.e. |
NodeState |
createNew(NodeId id,
Name nodeTypeName,
NodeId parentId)
Creates a
NodeState instance representing new,
i.e. |
PropertyState |
createNew(PropertyState transientState)
Customized variant of
createNew(Name, NodeId) that
connects the newly created persistent state with the transient state. |
NodeState |
createTransientNodeState(NodeId id,
Name nodeTypeName,
NodeId parentId,
int initialStatus) |
NodeState |
createTransientNodeState(NodeState overlayedState,
int initialStatus) |
PropertyState |
createTransientPropertyState(NodeId parentId,
Name propName,
int initialStatus) |
PropertyState |
createTransientPropertyState(PropertyState overlayedState,
int initialStatus) |
void |
destroy(ItemState state)
Destroy an item state.
|
void |
disconnectTransientItemState(ItemState state)
Disconnect a transient item state from its underlying persistent state.
|
void |
dispose()
Disposes this
UpdatableItemStateManager and frees resources. |
void |
disposeAllTransientItemStates()
Disposes all transient item states in the cache and in the attic.
|
void |
disposeTransientItemState(ItemState state)
Disposes the specified transient item state instance, i.e.
|
void |
disposeTransientItemStateInAttic(ItemState state)
Disposes the specified transient item state instance in the attic, i.e.
|
void |
edit()
Start an edit operation on items inside this manager.
|
ItemStateManager |
getAttic()
Return the attic item state provider that holds all items
moved into the attic.
|
HierarchyManager |
getAtticAwareHierarchyMgr()
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 as
except that item state instances in the attic are returned. |
HierarchyManager |
getHierarchyMgr()
Returns the hierarchy manager
|
NodeId |
getIdOfRootTransientNodeState()
Returns the id of the root of the minimal subtree including all
transient states.
|
ItemState |
getItemState(ItemId id)
Return an item state, given its item id.
|
NodeReferences |
getNodeReferences(NodeId id)
Return a node references object, given its target id
|
ItemState |
getTransientItemState(ItemId id) |
boolean |
hasAnyTransientItemStates() |
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.
|
boolean |
hasTransientItemState(ItemId id) |
boolean |
hasTransientItemStateInAttic(ItemId id) |
boolean |
inEditMode()
Returns
true if this manager is in edit mode i.e. |
boolean |
isItemStateInAttic(ItemId id)
Return a flag indicating whether the specified item is in the transient
item state manager's attic space.
|
NodeState |
makePersistent(NodeState transientState)
Pushes the given transient state to the change log so it'll be
persisted when the change log is committed.
|
void |
moveTransientItemStateToAttic(ItemState state)
Transfers the specified transient item state instance from the 'active'
cache to the attic.
|
void |
nodeAdded(NodeState state,
Name name,
int index,
NodeId id)
Called when a child node has been added
|
void |
nodeModified(NodeState state)
Called when a node has been modified, typically as a result of removal
or addition of a child node.
|
void |
nodeRemoved(NodeState state,
Name name,
int index,
NodeId id)
Called when a child node has been removed
|
void |
nodesReplaced(NodeState state)
Called when the children nodes were replaced by other nodes, typically
as result of a reorder operation.
|
void |
removeListener(ItemStateListener listener)
Remove an
ItemStateListener |
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. |
void |
store(ItemState state)
Store an item state.
|
String |
toString() |
void |
update()
End an update operation.
|
public SessionItemStateManager(NodeId rootNodeId, LocalItemStateManager stateMgr)
SessionItemStateManager instance.rootNodeId - the root node idstateMgr - the local item state managerpublic HierarchyManager getHierarchyMgr()
public HierarchyManager getAtticAwareHierarchyMgr()
public ItemState getItemState(ItemId id) throws NoSuchItemStateException, ItemStateException
getItemState in interface ItemStateManagerid - item idNoSuchItemStateException - if the item does not existItemStateException - if an error occurspublic boolean hasItemState(ItemId id)
hasItemState in interface ItemStateManagerid - item idtrue if an item state exists,
otherwise falsepublic NodeReferences getNodeReferences(NodeId id) throws NoSuchItemStateException, ItemStateException
getNodeReferences in interface ItemStateManagerid - target idNoSuchItemStateException - if the item does not existItemStateException - if an error occurspublic boolean hasNodeReferences(NodeId id)
hasNodeReferences in interface ItemStateManagerid - target idtrue if a node reference object exists for the given
id, otherwise false.public void edit()
throws IllegalStateException
UpdatableItemStateManager.update() or UpdatableItemStateManager.cancel()
must be invoked.edit in interface UpdatableItemStateManagerIllegalStateException - if the manager is already in edit mode.public boolean inEditMode()
true if this manager is in edit mode i.e.
if an edit operation has been started by invoking UpdatableItemStateManager.edit(),
otherwise returns false.inEditMode in interface UpdatableItemStateManagertrue if this manager is in edit mode, otherwise
falsepublic NodeState createNew(NodeId id, Name nodeTypeName, NodeId parentId) throws RepositoryException
NodeState instance representing new,
i.e. not yet existing state. Call UpdatableItemStateManager.store(org.apache.jackrabbit.core.state.ItemState)
on the returned object to make it persistent.createNew in interface UpdatableItemStateManagerid - the id of the node, or null for a new node idnodeTypeName - The node type nameparentId - parent node's idRepositoryException - if the node state can not be createdpublic PropertyState createNew(Name propName, NodeId parentId) throws IllegalStateException
PropertyState instance representing new,
i.e. not yet existing state. Call UpdatableItemStateManager.store(org.apache.jackrabbit.core.state.ItemState)
on the returned object to make it persistent.createNew in interface UpdatableItemStateManagerpropName - property nameparentId - parent node IdIllegalStateException - if the manager is not in edit mode.public PropertyState createNew(PropertyState transientState) throws ItemStateException
createNew(Name, NodeId) that
connects the newly created persistent state with the transient state.ItemStateExceptionpublic void store(ItemState state) throws IllegalStateException
store in interface UpdatableItemStateManagerstate - item state that should be storedIllegalStateException - if the manager is not in edit mode.public void destroy(ItemState state) throws IllegalStateException
destroy in interface UpdatableItemStateManagerstate - item state that should be destroyedIllegalStateException - if the manager is not in edit mode.public void cancel()
throws IllegalStateException
cancel in interface UpdatableItemStateManagerIllegalStateException - if the manager is not in edit mode.public void update()
throws ReferentialIntegrityException,
StaleItemStateException,
ItemStateException,
IllegalStateException
update in interface UpdatableItemStateManagerReferentialIntegrityException - if a new or modified REFERENCE
property refers to a non-existent
target or if a removed node is still
being referencedStaleItemStateException - if at least one of the affected items
has become stale in the meantimeItemStateException - if the operation failed for another reasonIllegalStateException - if the manager is not in edit mode.public void dispose()
UpdatableItemStateManager and frees resources.dispose in interface UpdatableItemStateManagerpublic ItemState getTransientItemState(ItemId id) throws NoSuchItemStateException, ItemStateException
id - NoSuchItemStateExceptionItemStateExceptionpublic boolean hasTransientItemState(ItemId id)
id - public boolean hasTransientItemStateInAttic(ItemId id)
id - public boolean hasAnyTransientItemStates()
true if this manager has any transient state;
false otherwise.public Collection<ItemState> getDescendantTransientItemStates(ItemId id) throws InvalidItemStateException, RepositoryException
The instances are returned in depth-first tree traversal order.
id - identifier of the common parent of the transient item state
instances to be returnedInvalidItemStateException - if any descendant item state has been
deleted externallyRepositoryException - if another error occurspublic Iterable<ItemState> getDescendantTransientItemStatesInAttic(ItemId id) throws RepositoryException
getDescendantTransientItemStates(ItemId)
except that item state instances in the attic are returned.id - identifier of the common parent of the transient item state
instances to be returnedRepositoryExceptionpublic NodeId getIdOfRootTransientNodeState() throws RepositoryException
RepositoryException - if an error occurspublic boolean isItemStateInAttic(ItemId id)
id - item idtrue if the item state is in the attic space;
false otherwisepublic NodeState createTransientNodeState(NodeId id, Name nodeTypeName, NodeId parentId, int initialStatus) throws RepositoryException
id - nodeTypeName - parentId - initialStatus - RepositoryExceptionpublic NodeState createTransientNodeState(NodeState overlayedState, int initialStatus) throws ItemStateException
overlayedState - initialStatus - ItemStateExceptionpublic PropertyState createTransientPropertyState(NodeId parentId, Name propName, int initialStatus) throws ItemStateException
parentId - propName - initialStatus - ItemStateExceptionpublic PropertyState createTransientPropertyState(PropertyState overlayedState, int initialStatus) throws ItemStateException
overlayedState - initialStatus - ItemStateExceptionpublic void disconnectTransientItemState(ItemState state)
HierarchyManager about the changed identity.state - the transient ItemState instance that should
be disconnectedpublic void disposeTransientItemState(ItemState state)
state - the transient ItemState instance that should
be disposedItemState.discard()public void moveTransientItemStateToAttic(ItemState state)
state - the transient ItemState instance that should
be moved to the atticpublic void disposeTransientItemStateInAttic(ItemState state)
state - the transient ItemState instance that should
be disposed @see ItemState#discard()public void disposeAllTransientItemStates()
public void addListener(ItemStateListener listener)
ItemStateListenerlistener - the new listener to be informed on modificationspublic void removeListener(ItemStateListener listener)
ItemStateListenerlistener - an existing listenerpublic ItemStateManager getAttic()
public void stateCreated(ItemState created)
ItemState has 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.
stateCreated in interface ItemStateListenercreated - the ItemState that has been 'created'public void stateModified(ItemState modified)
ItemState has 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.
stateModified in interface ItemStateListenermodified - 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).
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.
stateDestroyed in interface ItemStateListenerdestroyed - the ItemState that has been 'destroyed'public void stateDiscarded(ItemState discarded)
ItemState has 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.
stateDiscarded in interface ItemStateListenerdiscarded - the ItemState that has been discardedItemState.discard()public void nodeAdded(NodeState state, Name name, int index, NodeId id)
Pass notification to listeners if a transient state was modified or if the local state is not overlayed.
nodeAdded in interface NodeStateListenerstate - node state that changedname - name of node that was addedindex - index of new nodeid - id of new nodepublic void nodesReplaced(NodeState state)
Pass notification to listeners if a transient state was modified or if the local state is not overlayed.
nodesReplaced in interface NodeStateListenerstate - node state that changedpublic void nodeModified(NodeState state)
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.
nodeModified in interface NodeStateListenerstate - node state that changedpublic void nodeRemoved(NodeState state, Name name, int index, NodeId id)
Pass notification to listeners if a transient state was modified or if the local state is not overlayed.
nodeRemoved in interface NodeStateListenerstate - node state that changedname - name of node that was removedindex - index of removed nodeid - id of removed nodepublic NodeState makePersistent(NodeState transientState) throws RepositoryException
transientState - transient stateRepositoryException - if the transiet state can not be persistedCopyright © 2004–2022 The Apache Software Foundation. All rights reserved.