Search in sources :

Example 1 with MergeResult

use of org.apache.jackrabbit.jcr2spi.state.ItemState.MergeResult in project jackrabbit by apache.

the class HierarchyEntryImpl method setItemState.

/**
     * {@inheritDoc}<br>
     * @see HierarchyEntry#setItemState(ItemState)
     */
public synchronized void setItemState(ItemState state) {
    ItemState currentState = internalGetItemState();
    if (state == null || state == currentState || denotesNode() != state.isNode()) {
        throw new IllegalArgumentException();
    }
    if (currentState == null) {
        // not connected yet to an item state. either a new entry or
        // an unresolved hierarchy entry.
        target = new SoftReference<ItemState>(state);
    } else {
        // was already resolved before -> merge the existing state
        // with the passed state.
        int currentStatus = currentState.getStatus();
        boolean keepChanges = Status.isTransient(currentStatus) || Status.isStale(currentStatus);
        MergeResult mergeResult = currentState.merge(state, keepChanges);
        if (currentStatus == Status.INVALIDATED) {
            currentState.setStatus(Status.EXISTING);
        } else if (mergeResult.modified()) {
            currentState.setStatus(Status.MODIFIED);
        }
        // else: not modified. just leave status as it is.
        mergeResult.dispose();
    }
}
Also used : ItemState(org.apache.jackrabbit.jcr2spi.state.ItemState) MergeResult(org.apache.jackrabbit.jcr2spi.state.ItemState.MergeResult)

Aggregations

ItemState (org.apache.jackrabbit.jcr2spi.state.ItemState)1 MergeResult (org.apache.jackrabbit.jcr2spi.state.ItemState.MergeResult)1