Package org.apache.jackrabbit.jcr2spi.state

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


    /**
     * @return
     */
    ItemState internalGetItemState() {
        ItemState state = null;
        if (target != null) {
            state = (ItemState) target.get();
        }
        return state;
    }
View Full Code Here


    /**
     * @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#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 WeakReference(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);
            boolean modified = currentState.merge(state, keepChanges);
            if (currentStatus == Status.INVALIDATED) {
                currentState.setStatus(Status.EXISTING);
            } else if (modified) {
                currentState.setStatus(Status.MODIFIED);
            } // else: not modified. just leave status as it is.
        }
    }
View Full Code Here

     * {@inheritDoc}<br>
     * @see HierarchyEntry#invalidate(boolean)
     */
    public void invalidate(boolean recursive) {
        if (getStatus() == Status.EXISTING) {
            ItemState state = internalGetItemState();
            state.setStatus(Status.INVALIDATED);
        } else {
            log.debug("Skip invalidation for HierarchyEntry " + name + " with status " + Status.getName(getStatus()));
        }
    }
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 modifications
                state.revert();
                state.setStatus(Status.EXISTING);
                break;
            case Status.EXISTING_REMOVED:
                // revert state modifications
                state.revert();
                state.setStatus(Status.EXISTING);
                break;
            case Status.NEW:
                // reverting a NEW state is equivalent to its removal.
                // however: no need remove the complete hierarchy as revert is
                // always related to Item#refresh(false) which affects the
                // complete tree (and all add-operations within it) anyway.
                state.setStatus(Status.REMOVED);
                parent.internalRemoveChildEntry(this);
                break;
            case Status.STALE_DESTROYED:
                // overlayed does not exist any more -> reverting of pending
                // transient changes (that lead to the stale status) can be
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

     * does not exist.
     * @throws RepositoryException if an error occurs.
     */
    ItemState resolve() throws ItemNotFoundException, RepositoryException {
        // check if already resolved
        ItemState state = internalGetItemState();
        // not yet resolved. retrieve and keep soft reference to state
        if (state == null) {
            try {
                state = doResolve();
                // set the item state unless 'setItemState' has already been
                // called by the ItemStateFactory (recall internalGetItemState)
                if (internalGetItemState() == null) {
                    setItemState(state);
                }
            } catch (ItemNotFoundException e) {
                remove();
                throw e;
            }
        } else if (state.getStatus() == Status.INVALIDATED) {
            // completely reload this entry, but don't reload recursively
            reload(false);
        }
        return state;
    }
View Full Code Here

    /**
     * @return the item state or <code>null</code> if the entry isn't resolved.
     */
    ItemState internalGetItemState() {
        ItemState state = null;
        if (target != null) {
            state = target.get();
        }
        return state;
    }
View Full Code Here

     * Invalidates the underlying {@link ItemState}. If <code>recursive</code> is
     * true also invalidates the underlying item states of all child entries.
     * @param recursive
     */
    protected void invalidateInternal(boolean recursive) {
        ItemState state = internalGetItemState();
        if (state == null) {
            log.debug("Skip invalidation for unresolved HierarchyEntry " + name);
        } else {
            state.invalidate();
        }
    }
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.