Search in sources :

Example 1 with PropertyState

use of org.apache.jackrabbit.jcr2spi.state.PropertyState in project jackrabbit by apache.

the class NodeEntryImpl method complete.

private void complete(SetMixin operation) throws RepositoryException {
    if (operation.getNodeState().getHierarchyEntry() != this) {
        throw new IllegalArgumentException();
    }
    PropertyEntry pe = getPropertyEntry(NameConstants.JCR_MIXINTYPES);
    if (pe != null) {
        PropertyState pState = pe.getPropertyState();
        switch(operation.getStatus()) {
            case Operation.STATUS_PERSISTED:
                Name[] mixins = StateUtility.getMixinNames(pState);
                getNodeState().setMixinTypeNames(mixins);
                if (pState.getStatus() == Status.NEW || pState.getStatus() == Status.EXISTING_MODIFIED) {
                    pState.setStatus(Status.EXISTING);
                }
                break;
            case Operation.STATUS_UNDO:
                pe.revert();
                break;
            // ignore
            default:
        }
    }
// else: no such prop-Entry (should not occur)
}
Also used : PropertyState(org.apache.jackrabbit.jcr2spi.state.PropertyState) Name(org.apache.jackrabbit.spi.Name)

Example 2 with PropertyState

use of org.apache.jackrabbit.jcr2spi.state.PropertyState in project jackrabbit by apache.

the class ItemManagerImpl method getItem.

/**
     * @see ItemManager#getItem(HierarchyEntry)
     */
public Item getItem(HierarchyEntry hierarchyEntry) throws ItemNotFoundException, RepositoryException {
    session.checkIsAlive();
    ItemState state = hierarchyEntry.getItemState();
    if (!state.isValid()) {
        throw new ItemNotFoundException(LogUtil.safeGetJCRPath(state, session.getPathResolver()));
    }
    // first try to access item from cache
    Item item = itemCache.getItem(state);
    // not yet in cache, need to create instance
    if (item == null) {
        // create instance of item
        if (hierarchyEntry.denotesNode()) {
            item = createNodeInstance((NodeState) state);
        } else {
            item = createPropertyInstance((PropertyState) state);
        }
    }
    return item;
}
Also used : Item(javax.jcr.Item) NodeState(org.apache.jackrabbit.jcr2spi.state.NodeState) ItemState(org.apache.jackrabbit.jcr2spi.state.ItemState) ItemNotFoundException(javax.jcr.ItemNotFoundException) PropertyState(org.apache.jackrabbit.jcr2spi.state.PropertyState)

Example 3 with PropertyState

use of org.apache.jackrabbit.jcr2spi.state.PropertyState in project jackrabbit by apache.

the class VersionManagerImpl method getVersionHistoryEntry.

public NodeEntry getVersionHistoryEntry(NodeState versionableState) throws RepositoryException {
    PropertyState ps = versionableState.getPropertyState(NameConstants.JCR_VERSIONHISTORY);
    String uniqueID = ps.getValue().getString();
    NodeId vhId = workspaceManager.getIdFactory().createNodeId(uniqueID);
    return workspaceManager.getHierarchyManager().getNodeEntry(vhId);
}
Also used : NodeId(org.apache.jackrabbit.spi.NodeId) PropertyState(org.apache.jackrabbit.jcr2spi.state.PropertyState)

Example 4 with PropertyState

use of org.apache.jackrabbit.jcr2spi.state.PropertyState in project jackrabbit by apache.

the class NodeEntryImpl method notifyUUIDorMIXINModified.

/**
     * Deals with modified jcr:uuid and jcr:mixinTypes property.
     * See {@link #notifyUUIDorMIXINRemoved(Name)}
     *
     * @param child
     */
private void notifyUUIDorMIXINModified(PropertyEntry child) {
    try {
        if (NameConstants.JCR_UUID.equals(child.getName())) {
            PropertyState ps = child.getPropertyState();
            setUniqueID(ps.getValue().getString());
        } else if (NameConstants.JCR_MIXINTYPES.equals(child.getName())) {
            NodeState state = (NodeState) internalGetItemState();
            if (state != null) {
                PropertyState ps = child.getPropertyState();
                state.setMixinTypeNames(StateUtility.getMixinNames(ps));
            }
        // nodestate not yet loaded -> ignore change
        }
    } catch (ItemNotFoundException e) {
        log.debug("Property with name " + child.getName() + " does not exist (anymore)");
    } catch (RepositoryException e) {
        log.debug("Unable to access child property " + child.getName(), e.getMessage());
    }
}
Also used : NodeState(org.apache.jackrabbit.jcr2spi.state.NodeState) RepositoryException(javax.jcr.RepositoryException) PropertyState(org.apache.jackrabbit.jcr2spi.state.PropertyState) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Example 5 with PropertyState

use of org.apache.jackrabbit.jcr2spi.state.PropertyState in project jackrabbit by apache.

the class NodeEntryImpl method complete.

private void complete(AddProperty operation) throws RepositoryException {
    if (operation.getParentState().getHierarchyEntry() != this) {
        throw new IllegalArgumentException();
    }
    PropertyEntry pe = getPropertyEntry(operation.getPropertyName());
    if (pe != null && pe.getStatus() == Status.NEW) {
        switch(operation.getStatus()) {
            case Operation.STATUS_PERSISTED:
                // for autocreated/protected props, mark to be reloaded
                // upon next access.
                PropertyState addedState = (PropertyState) ((PropertyEntryImpl) pe).internalGetItemState();
                addedState.setStatus(Status.EXISTING);
                QPropertyDefinition pd = addedState.getDefinition();
                if (pd.isAutoCreated() || pd.isProtected()) {
                    pe.invalidate(true);
                }
                // else: assume added property is up to date.
                break;
            case Operation.STATUS_UNDO:
                pe.revert();
                break;
            // ignore
            default:
        }
    }
// else: no such prop entry or entry has already been persisted
//       e.g due to external modifications merged into this NodeEntry.
}
Also used : QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition) PropertyState(org.apache.jackrabbit.jcr2spi.state.PropertyState)

Aggregations

PropertyState (org.apache.jackrabbit.jcr2spi.state.PropertyState)12 ItemNotFoundException (javax.jcr.ItemNotFoundException)5 NodeState (org.apache.jackrabbit.jcr2spi.state.NodeState)5 Operation (org.apache.jackrabbit.jcr2spi.operation.Operation)3 Name (org.apache.jackrabbit.spi.Name)3 NodeId (org.apache.jackrabbit.spi.NodeId)3 QPropertyDefinition (org.apache.jackrabbit.spi.QPropertyDefinition)3 ItemExistsException (javax.jcr.ItemExistsException)2 RepositoryException (javax.jcr.RepositoryException)2 NodeEntry (org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry)2 QValue (org.apache.jackrabbit.spi.QValue)2 Item (javax.jcr.Item)1 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)1 PropertyEntry (org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry)1 AddNode (org.apache.jackrabbit.jcr2spi.operation.AddNode)1 Checkpoint (org.apache.jackrabbit.jcr2spi.operation.Checkpoint)1 ItemState (org.apache.jackrabbit.jcr2spi.state.ItemState)1 Path (org.apache.jackrabbit.spi.Path)1 QNodeDefinition (org.apache.jackrabbit.spi.QNodeDefinition)1