Class SessionItemStateManager

    • Constructor Detail

      • SessionItemStateManager

        public SessionItemStateManager​(NodeId rootNodeId,
                                       LocalItemStateManager stateMgr)
        Creates a new SessionItemStateManager instance.
        Parameters:
        rootNodeId - the root node id
        stateMgr - the local item state manager
    • Method Detail

      • getHierarchyMgr

        public HierarchyManager getHierarchyMgr()
        Returns the hierarchy manager
        Returns:
        the hierarchy manager
      • getAtticAwareHierarchyMgr

        public 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
      • 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
      • 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 interface ItemStateManager
        Parameters:
        id - target id
        Returns:
        true if a node reference object exists for the given id, otherwise false.
      • hasTransientItemState

        public boolean hasTransientItemState​(ItemId id)
        Parameters:
        id -
        Returns:
      • hasTransientItemStateInAttic

        public boolean hasTransientItemStateInAttic​(ItemId id)
        Parameters:
        id -
        Returns:
      • hasAnyTransientItemStates

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

        public 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
      • getIdOfRootTransientNodeState

        public 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
      • 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
      • 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.
      • addListener

        public void addListener​(ItemStateListener listener)
        Add an ItemStateListener
        Parameters:
        listener - the new listener to be informed on modifications
      • removeListener

        public void removeListener​(ItemStateListener listener)
        Remove an ItemStateListener
        Parameters:
        listener - an existing listener
      • getAttic

        public ItemStateManager getAttic()
        Return the attic item state provider that holds all items moved into the attic.
        Returns:
        attic
      • stateCreated

        public void stateCreated​(ItemState created)
        Called when an 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.

        Specified by:
        stateCreated in interface ItemStateListener
        Parameters:
        created - the ItemState that has been 'created'
      • stateModified

        public void stateModified​(ItemState modified)
        Called when an 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.

        Specified by:
        stateModified in interface ItemStateListener
        Parameters:
        modified - the ItemState that has been 'modified'
      • stateDestroyed

        public void stateDestroyed​(ItemState destroyed)
        Called when an 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.

        Specified by:
        stateDestroyed in interface ItemStateListener
        Parameters:
        destroyed - the ItemState that has been 'destroyed'
      • stateDiscarded

        public void stateDiscarded​(ItemState discarded)
        Called when an 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.

        Specified by:
        stateDiscarded in interface ItemStateListener
        Parameters:
        discarded - the ItemState that has been discarded
        See Also:
        ItemState.discard()
      • nodeAdded

        public void nodeAdded​(NodeState state,
                              Name name,
                              int index,
                              NodeId id)
        Called when a child node has been added

        Pass notification to listeners if a transient state was modified or if the local state is not overlayed.

        Specified by:
        nodeAdded in 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
      • nodesReplaced

        public 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:
        nodesReplaced in interface NodeStateListener
        Parameters:
        state - node state that changed
      • nodeModified

        public 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:
        nodeModified in interface NodeStateListener
        Parameters:
        state - node state that changed
      • nodeRemoved

        public void nodeRemoved​(NodeState state,
                                Name name,
                                int index,
                                NodeId id)
        Called when a child node has been removed

        Pass notification to listeners if a transient state was modified or if the local state is not overlayed.

        Specified by:
        nodeRemoved in 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
      • makePersistent

        public 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