Package org.apache.jackrabbit.jcr2spi.state

Examples of org.apache.jackrabbit.jcr2spi.state.ItemState


    /**
     * @inheritDoc
     * @see HierarchyEntry#getStatus()
     */
    public int getStatus() {
        ItemState state = internalGetItemState();
        if (state == null) {
            return Status._UNDEFINED_;
        } else {
            return state.getStatus();
        }
    }
View Full Code Here


    /**
     * {@inheritDoc}<br>
     * @see HierarchyEntry#getItemState()
     */
    public ItemState getItemState() throws ItemNotFoundException, RepositoryException {
        ItemState state = resolve();
        return state;
    }
View Full Code Here

    /**
     * {@inheritDoc}<br>
     * @see HierarchyEntry#invalidate(boolean)
     */
    public void invalidate(boolean recursive) {
        ItemState state = internalGetItemState();
        if (state != null) {
            // session-state TODO: only invalidate if existing?
            if (state.getStatus() == Status.EXISTING) {
                state.setStatus(Status.INVALIDATED);
            }
        }
    }
View Full Code Here

    /**
     * {@inheritDoc}
     * @see HierarchyEntry#revert()
     */
    public void revert() throws RepositoryException {
        ItemState state = internalGetItemState();
        if (state == null) {
            // nothing to do
            return;
        }

        int oldStatus = state.getStatus();
        switch (oldStatus) {
            case Status.EXISTING_MODIFIED:
            case Status.STALE_MODIFIED:
                // revert state from overlayed
                state.revert();
                state.setStatus(Status.EXISTING);
                break;
            case Status.EXISTING_REMOVED:
                // revert state from overlayed
                state.revert();
                state.setStatus(Status.EXISTING);
                if (!denotesNode()) {
                    parent.revertPropertyRemoval((PropertyEntry) this);
                }
                break;
            case Status.NEW:
View Full Code Here

     /**
     * {@inheritDoc}
     * @see HierarchyEntry#reload(boolean, boolean)
     */
    public void reload(boolean keepChanges, boolean recursive) {
        ItemState state = internalGetItemState();
        if (state == null) {
            // nothing to do. entry will be validated upon resolution.
            return;
        }
        /*
        if keepChanges is true only existing or invalidated states must be
        updated. otherwise the state gets updated and might be marked 'Stale'
        if transient changes are present and the workspace-state is modified.
        */
        // TODO: check again if 'reload' is not possible for transiently-modified state
        if (!keepChanges || state.getStatus() == Status.EXISTING
            || state.getStatus() == Status.INVALIDATED) {
            // reload the workspace state from the persistent layer
            state.reload(keepChanges);
        }
    }
View Full Code Here

    /**
     * {@inheritDoc}
     * @see HierarchyEntry#transientRemove()
     */
    public void transientRemove() throws InvalidItemStateException, RepositoryException {
        ItemState state = internalGetItemState();
        if (state == null) {
            // nothing to do -> correct status must be set upon resolution.
            return;
        }
        // if during recursive removal an invalidated entry is found, reload
        // it in order to determine the current status.
        if (state.getStatus() == Status.INVALIDATED) {
            reload(false, false);
            // check if upon reload the item has been removed -> nothing to do
            if (Status.isTerminal(state.getStatus())) {
                return;
            }
        }

        switch (state.getStatus()) {
            case Status.NEW:
                remove();
                break;
            case Status.EXISTING:
            case Status.EXISTING_MODIFIED:
                state.setStatus(Status.EXISTING_REMOVED);
                // NOTE: parent does not need to be informed. an transiently
                // removed propertyEntry is automatically moved to the 'attic'
                // if a conflict with a new entry occurs.
                break;
            case Status.REMOVED:
            case Status.STALE_DESTROYED:
                throw new InvalidItemStateException("Item has already been removed by someone else. Status = " + Status.getName(state.getStatus()));
            default:
                throw new RepositoryException("Cannot transiently remove an ItemState with status " + Status.getName(state.getStatus()));
        }
    }
View Full Code Here

    /**
     * {@inheritDoc}
     * @see HierarchyEntry#collectStates(ChangeLog, boolean)
     */
    public void collectStates(ChangeLog changeLog, boolean throwOnStale) throws InvalidItemStateException {
        ItemState state = internalGetItemState();
        if (state == null) {
            // nothing to do
            return;
        }

        if (throwOnStale && Status.isStale(state.getStatus())) {
            String msg = "Cannot save changes: " + state + " has been modified externally.";
            log.debug(msg);
            throw new InvalidItemStateException(msg);
        }
        // only interested in transient modifications or stale states
        switch (state.getStatus()) {
            case Status.NEW:
                changeLog.added(state);
                break;
            case Status.EXISTING_MODIFIED:
            case Status.STALE_MODIFIED:
            case Status.STALE_DESTROYED:
                changeLog.modified(state);
                break;
            case Status.EXISTING_REMOVED:
                changeLog.deleted(state);
                break;
            default:
                log.debug("Collecting states: Ignored ItemState with status " + Status.getName(state.getStatus()));
        }
    }
View Full Code Here

     * @return
     * @throws PathNotFoundException
     * @throws RepositoryException
     */
    protected static NodeState getNodeState(Path nodePath, HierarchyManager hierMgr, PathResolver resolver) throws PathNotFoundException, RepositoryException {
        ItemState itemState = hierMgr.getItemState(nodePath);
        if (!itemState.isNode()) {
            throw new PathNotFoundException(LogUtil.safeGetJCRPath(nodePath, resolver));
        }
        return (NodeState) itemState;
    }
View Full Code Here

        }

        // if this entry has not yet been resolved or if it is 'invalidated'
        // all property entries, that are not contained within the specified
        // collection of property names are removed from this NodeEntry.
        ItemState state = internalGetItemState();
        if (containsExtra && (state == null || state.getStatus() == Status.INVALIDATED)) {
            for (Iterator it = diff.iterator(); it.hasNext();) {
                Name propName = (Name) it.next();
                PropertyEntry pEntry = properties.get(propName);
                if (pEntry != null) {
                    pEntry.remove();
View Full Code Here

            // now restore moved entry with the old name and index and re-add
            // it to its original parent (unless it got destroyed)
            parent = revertInfo.oldParent;
            name = revertInfo.oldName;
            ItemState state = internalGetItemState();
            if (state != null && !Status.isTerminal(state.getStatus())) {
                parent.childNodeEntries().add(this, revertInfo.oldIndex);
            }
        }
        // revert reordering of child-node-entries
        revertInfo.revertReordering();
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.jcr2spi.state.ItemState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.