org.apache.jackrabbit.core.state
Class SessionItemStateManager

java.lang.Object
  extended byorg.apache.jackrabbit.core.state.SessionItemStateManager
All Implemented Interfaces:
Dumpable, ItemStateManager, UpdatableItemStateManager

public class SessionItemStateManager
extends Object
implements UpdatableItemStateManager, Dumpable

SessionItemStateManager ...


Constructor Summary
SessionItemStateManager(NodeId rootNodeId, UpdatableItemStateManager persistentStateMgr, NamespaceResolver nsResolver)
          Creates a new SessionItemStateManager instance.
 
Method Summary
 void cancel()
          Cancel an update operation. This will undo all changes made to objects inside this item state manager.
 NodeState createNew(NodeId id, QName nodeTypeName, NodeId parentId)
          Creates a 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.
 NodeState createNew(NodeState transientState)
          Customized variant of createNew(NodeId, QName, NodeId) that connects the newly created persistent state with the transient state.
 PropertyState createNew(PropertyState transientState)
          Customized variant of createNew(QName, NodeId) that connects the newly created persistent state with the transient state.
 PropertyState createNew(QName propName, NodeId parentId)
          Creates a 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.
 NodeState createTransientNodeState(NodeId id, QName nodeTypeName, NodeId parentId, int initialStatus)
           
 NodeState createTransientNodeState(NodeState overlayedState, int initialStatus)
           
 PropertyState createTransientPropertyState(NodeId parentId, QName 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 dump(PrintStream ps)
          Dumps the state of this instance in a human readable format for diagnostic purposes.
 void edit()
          Start an edit operation on items inside this manager. This allows calling the operations defined below. At the end of this operation, either UpdatableItemStateManager.update() or UpdatableItemStateManager.cancel() must be invoked.
 Iterator getDescendantTransientItemStates(NodeId parentId)
          Returns an iterator over those transient item state instances that are direct or indirect descendents of the item state with the given parentId.
 Iterator getDescendantTransientItemStatesInAttic(NodeId parentId)
          Same as getDescendantTransientItemStates(NodeId) except that item state instances in the attic are returned.
 HierarchyManager getHierarchyMgr()
          Returns the hierarchy manager
 ItemState getItemState(ItemId id)
          Return an item state, given its item id.
 NodeReferences getNodeReferences(NodeReferencesId 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(NodeReferencesId id)
          Return a flag indicating whether a node references object for a given target id exists.
 boolean inEditMode()
          Returns true if this manager is in edit mode i.e. if an edit operation has been started by invoking UpdatableItemStateManager.edit(), otherwise returns false.
 boolean isItemStateInAttic(ItemId id)
          Return a flag indicating whether the specified item is in the transient item state manager's attic space.
 void moveTransientItemStateToAttic(ItemState state)
          Transfers the specified transient item state instance from the 'active' cache to the attic.
 void store(ItemState state)
          Store an item state.
 void update()
          End 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SessionItemStateManager

public SessionItemStateManager(NodeId rootNodeId,
                               UpdatableItemStateManager persistentStateMgr,
                               NamespaceResolver nsResolver)
Creates a new SessionItemStateManager instance.

Parameters:
rootNodeId -
persistentStateMgr -
nsResolver -
Method Detail

getHierarchyMgr

public HierarchyManager getHierarchyMgr()
Returns the hierarchy manager

Returns:
the hierarchy manager

dump

public void dump(PrintStream ps)
Dumps the state of this instance in a human readable format for diagnostic purposes.

Specified by:
dump in interface Dumpable
Parameters:
ps - stream to dump state to

getItemState

public ItemState getItemState(ItemId id)
                       throws NoSuchItemStateException,
                              ItemStateException
Return an item state, given its item id.

Specified by:
getItemState in interface ItemStateManager
Parameters:
id - item id
Returns:
item state
Throws:
NoSuchItemStateException - if the item does not exist
ItemStateException - if an error occurs

hasItemState

public boolean hasItemState(ItemId id)
Return a flag indicating whether an item state for a given item id exists.

Specified by:
hasItemState in interface ItemStateManager
Parameters:
id - item id
Returns:
true if an item state exists, otherwise false

getNodeReferences

public NodeReferences getNodeReferences(NodeReferencesId id)
                                 throws NoSuchItemStateException,
                                        ItemStateException
Return a node references object, given its target id

Specified by:
getNodeReferences in interface ItemStateManager
Parameters:
id - target id
Returns:
node references object
Throws:
ItemStateException - if an error occurs
NoSuchItemStateException - if the item does not exist

hasNodeReferences

public boolean hasNodeReferences(NodeReferencesId id)
Return a flag indicating whether a node references object for a given target id exists.

Specified by:
hasNodeReferences in interface ItemStateManager
Parameters:
id - target id
Returns:
true if a node reference object exists for the given id, otherwise false.

edit

public void edit()
          throws IllegalStateException
Start an edit operation on items inside this manager. This allows calling the operations defined below. At the end of this operation, either UpdatableItemStateManager.update() or UpdatableItemStateManager.cancel() must be invoked.

Specified by:
edit in interface UpdatableItemStateManager
Throws:
IllegalStateException - if the manager is already in edit mode.

inEditMode

public boolean inEditMode()
Returns true if this manager is in edit mode i.e. if an edit operation has been started by invoking UpdatableItemStateManager.edit(), otherwise returns false.

Specified by:
inEditMode in interface UpdatableItemStateManager
Returns:
true if this manager is in edit mode, otherwise false

createNew

public NodeState createNew(NodeId id,
                           QName nodeTypeName,
                           NodeId parentId)
                    throws IllegalStateException
Creates a 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.

Specified by:
createNew in interface UpdatableItemStateManager
Parameters:
id - the id of the node
nodeTypeName - qualified node type name
parentId - parent node's id
Returns:
a node state
Throws:
IllegalStateException - if the manager is not in edit mode.

createNew

public NodeState createNew(NodeState transientState)
                    throws IllegalStateException
Customized variant of createNew(NodeId, QName, NodeId) that connects the newly created persistent state with the transient state.

Throws:
IllegalStateException

createNew

public PropertyState createNew(QName propName,
                               NodeId parentId)
                        throws IllegalStateException
Creates a 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.

Specified by:
createNew in interface UpdatableItemStateManager
Parameters:
propName - qualified property name
parentId - parent node Id
Returns:
a property state
Throws:
IllegalStateException - if the manager is not in edit mode.

createNew

public PropertyState createNew(PropertyState transientState)
                        throws IllegalStateException
Customized variant of createNew(QName, NodeId) that connects the newly created persistent state with the transient state.

Throws:
IllegalStateException

store

public void store(ItemState state)
           throws IllegalStateException
Store an item state.

Specified by:
store in interface UpdatableItemStateManager
Parameters:
state - item state that should be stored
Throws:
IllegalStateException - if the manager is not in edit mode.

destroy

public void destroy(ItemState state)
             throws IllegalStateException
Destroy an item state.

Specified by:
destroy in interface UpdatableItemStateManager
Parameters:
state - item state that should be destroyed
Throws:
IllegalStateException - if the manager is not in edit mode.

cancel

public void cancel()
            throws IllegalStateException
Cancel an update operation. This will undo all changes made to objects inside this item state manager.

Specified by:
cancel in interface UpdatableItemStateManager
Throws:
IllegalStateException - if the manager is not in edit mode.

update

public void update()
            throws ReferentialIntegrityException,
                   StaleItemStateException,
                   ItemStateException,
                   IllegalStateException
End 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:
update in interface UpdatableItemStateManager
Throws:
StaleItemStateException - if at least one of the affected items has become stale in the meantime
IllegalStateException - if the manager is not in edit mode.
ReferentialIntegrityException - if a new or modified REFERENCE property refers to a non-existent target or if a removed node is still being referenced
ItemStateException - if the operation failed for another reason

dispose

public void dispose()
Disposes this UpdatableItemStateManager and frees resources.

Specified by:
dispose in interface UpdatableItemStateManager

getTransientItemState

public ItemState getTransientItemState(ItemId id)
                                throws NoSuchItemStateException,
                                       ItemStateException
Parameters:
id -
Returns:
Throws:
NoSuchItemStateException
ItemStateException

hasAnyTransientItemStates

public boolean hasAnyTransientItemStates()
Returns:
true if this manager has any transient state; false otherwise.

getDescendantTransientItemStates

public Iterator getDescendantTransientItemStates(NodeId parentId)
                                          throws InvalidItemStateException,
                                                 RepositoryException
Returns an iterator over those transient item state instances that are direct or indirect descendents of the item state with the given parentId. The transient item state instance with the given parentId itself (if there is such) will not be included.

The instances are returned in depth-first tree traversal order.

Parameters:
parentId - the id of the common parent of the transient item state instances to be returned.
Returns:
an iterator over descendant transient item state instances
Throws:
InvalidItemStateException - if any descendant item state has been deleted externally
RepositoryException - if another error occurs

getDescendantTransientItemStatesInAttic

public Iterator getDescendantTransientItemStatesInAttic(NodeId parentId)
Same as getDescendantTransientItemStates(NodeId) except that item state instances in the attic are returned.

Parameters:
parentId - the id of the common parent of the transient item state instances to be returned.
Returns:
an iterator over descendant transient item state instances in the attic

isItemStateInAttic

public 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:
true if the item state is in the attic space; false otherwise

createTransientNodeState

public NodeState createTransientNodeState(NodeId id,
                                          QName nodeTypeName,
                                          NodeId parentId,
                                          int initialStatus)
                                   throws ItemStateException
Parameters:
id -
nodeTypeName -
parentId -
initialStatus -
Returns:
Throws:
ItemStateException

createTransientNodeState

public NodeState createTransientNodeState(NodeState overlayedState,
                                          int initialStatus)
                                   throws ItemStateException
Parameters:
overlayedState -
initialStatus -
Returns:
Throws:
ItemStateException

createTransientPropertyState

public PropertyState createTransientPropertyState(NodeId parentId,
                                                  QName propName,
                                                  int initialStatus)
                                           throws ItemStateException
Parameters:
parentId -
propName -
initialStatus -
Returns:
Throws:
ItemStateException

createTransientPropertyState

public PropertyState createTransientPropertyState(PropertyState overlayedState,
                                                  int initialStatus)
                                           throws ItemStateException
Parameters:
overlayedState -
initialStatus -
Returns:
Throws:
ItemStateException

disconnectTransientItemState

public void disconnectTransientItemState(ItemState state)
Disconnect a transient item state from its underlying persistent state. Notifies the HierarchyManager about the changed identity.

Parameters:
state - the transient ItemState instance that should be disconnected

disposeTransientItemState

public void disposeTransientItemState(ItemState state)
Disposes the specified transient item state instance, i.e. discards it and clears it from cache.

Parameters:
state - the transient ItemState instance that should be disposed
See Also:
ItemState.discard()

moveTransientItemStateToAttic

public void moveTransientItemStateToAttic(ItemState state)
Transfers the specified transient item state instance from the 'active' cache to the attic.

Parameters:
state - the transient ItemState instance that should be moved to the attic

disposeTransientItemStateInAttic

public 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 ItemState instance that should be disposed @see ItemState#discard()

disposeAllTransientItemStates

public void disposeAllTransientItemStates()
Disposes all transient item states in the cache and in the attic.



Copyright © 2004-2006 The Apache Software Foundation. All Rights Reserved.