Search in sources :

Example 16 with PropertyEntry

use of org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry in project jackrabbit by apache.

the class SessionItemStateManager method visit.

/**
     * @see OperationVisitor#visit(SetMixin)
     */
public void visit(SetMixin operation) throws ConstraintViolationException, AccessDeniedException, NoSuchNodeTypeException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
    // NOTE: nodestate is only modified upon save of the changes!
    Name[] mixinNames = operation.getMixinNames();
    NodeState nState = operation.getNodeState();
    NodeEntry nEntry = nState.getNodeEntry();
    // assert the existence of the property entry and set the array of
    // mixinNames to be set on the corresponding property state
    PropertyEntry mixinEntry = nEntry.getPropertyEntry(NameConstants.JCR_MIXINTYPES);
    if (mixinNames.length > 0) {
        // update/create corresponding property state
        if (mixinEntry != null) {
            // execute value of existing property
            PropertyState pState = mixinEntry.getPropertyState();
            setPropertyStateValue(pState, getQValues(mixinNames, qValueFactory), PropertyType.NAME, operation.getOptions());
        } else {
            // create new jcr:mixinTypes property
            ItemDefinitionProvider defProvider = mgrProvider.getItemDefinitionProvider();
            QPropertyDefinition pd = defProvider.getQPropertyDefinition(nState.getAllNodeTypeNames(), NameConstants.JCR_MIXINTYPES, PropertyType.NAME, true);
            QValue[] mixinValue = getQValues(mixinNames, qValueFactory);
            addPropertyState(nState, pd.getName(), pd.getRequiredType(), mixinValue, pd, operation.getOptions());
        }
        nState.markModified();
        transientStateMgr.addOperation(operation);
    } else if (mixinEntry != null) {
        // remove the jcr:mixinTypes property state if already present
        PropertyState pState = mixinEntry.getPropertyState();
        removeItemState(pState, operation.getOptions());
        nState.markModified();
        transientStateMgr.addOperation(operation);
    }
// else: empty Name array and no mixin-prop-entry (should not occur)
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry) QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition) ItemDefinitionProvider(org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider) Name(org.apache.jackrabbit.spi.Name)

Example 17 with PropertyEntry

use of org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry in project jackrabbit by apache.

the class NodeImpl method hasProperty.

/**
     * @see Node#hasProperty(String)
     */
public boolean hasProperty(String relPath) throws RepositoryException {
    checkStatus();
    PropertyEntry childEntry = resolveRelativePropertyPath(relPath);
    return (childEntry != null) && getItemManager().itemExists(childEntry);
}
Also used : PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry)

Example 18 with PropertyEntry

use of org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry in project jackrabbit by apache.

the class RemoveVersion method persisted.

/**
     * Invalidates the <code>NodeState</code> that has been updated and all
     * its descendants. Second, the parent state gets invalidated.
     *
     * @see Operation#persisted()
     */
public void persisted() {
    assert status == STATUS_PENDING;
    status = STATUS_PERSISTED;
    // Invalidate the versionable node as well (version related properties)
    if (versionableEntry != null) {
        Iterator<PropertyEntry> propEntries = versionableEntry.getPropertyEntries();
        while (propEntries.hasNext()) {
            PropertyEntry pe = propEntries.next();
            pe.invalidate(false);
        }
        versionableEntry.invalidate(false);
    }
    // invalidate the versionhistory entry and all its children
    // in order to have the v-graph recalculated
    parent.getNodeEntry().invalidate(true);
}
Also used : PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry)

Example 19 with PropertyEntry

use of org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry in project jackrabbit by apache.

the class ItemStateValidator method checkCollision.

/**
     *
     * @param parentState
     * @param propertyName
     * @throws ItemExistsException
     * @throws RepositoryException
     */
private void checkCollision(NodeState parentState, Name propertyName) throws ItemExistsException, RepositoryException {
    NodeEntry parentEntry = (NodeEntry) parentState.getHierarchyEntry();
    // NOTE: check for name collisions with existing child node has been
    // removed as with JSR 283 having same-named node and property can be
    // allowed. thus delegate the corresponding validation to the underlying
    // SPI implementation.
    // check for name collisions with an existing property
    PropertyEntry pe = parentEntry.getPropertyEntry(propertyName);
    if (pe != null) {
        try {
            pe.getPropertyState();
            throw new ItemExistsException("Property '" + pe.getName() + "' already exists.");
        } catch (ItemNotFoundException e) {
        // apparently conflicting entry does not exist any more
        // ignore and return
        }
    }
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry) ItemExistsException(javax.jcr.ItemExistsException) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Aggregations

PropertyEntry (org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry)19 NodeEntry (org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry)10 RepositoryException (javax.jcr.RepositoryException)7 Name (org.apache.jackrabbit.spi.Name)7 ItemNotFoundException (javax.jcr.ItemNotFoundException)4 ArrayList (java.util.ArrayList)3 QValue (org.apache.jackrabbit.spi.QValue)3 ItemExistsException (javax.jcr.ItemExistsException)2 PathNotFoundException (javax.jcr.PathNotFoundException)2 Property (javax.jcr.Property)2 QPropertyDefinition (org.apache.jackrabbit.spi.QPropertyDefinition)2 AccessDeniedException (javax.jcr.AccessDeniedException)1 Node (javax.jcr.Node)1 Version (javax.jcr.version.Version)1 VersionException (javax.jcr.version.VersionException)1 EffectiveNodeTypeProvider (org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeTypeProvider)1 ItemDefinitionProvider (org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider)1 AddProperty (org.apache.jackrabbit.jcr2spi.operation.AddProperty)1 Operation (org.apache.jackrabbit.jcr2spi.operation.Operation)1 PropertyState (org.apache.jackrabbit.jcr2spi.state.PropertyState)1