Search in sources :

Example 16 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class VersionableState method restoreVersionedChild.

/**
     * Restore an nt:versionedChild node.
     */
private void restoreVersionedChild(NodeBuilder versionedChild, NodeBuilder dest, VersionSelector selector) throws RepositoryException, CommitFailedException {
    // 15.7.5 Chained Versions on Restore
    PropertyState id = versionedChild.getProperty(JCR_CHILDVERSIONHISTORY);
    if (id == null) {
        throw new RepositoryException("Mandatory property " + JCR_CHILDVERSIONHISTORY + " is missing.");
    }
    vMgr.restore(id.getValue(Type.REFERENCE), selector, dest);
}
Also used : RepositoryException(javax.jcr.RepositoryException) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

Example 17 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class ReadOnlyNodeTypeManager method getEffectiveNodeType.

@Override
public EffectiveNodeType getEffectiveNodeType(Tree tree) throws RepositoryException {
    NodeTypeImpl primaryType;
    PropertyState jcrPrimaryType = tree.getProperty(JCR_PRIMARYTYPE);
    if (jcrPrimaryType != null) {
        String ntName = jcrPrimaryType.getValue(STRING);
        primaryType = internalGetNodeType(ntName);
    } else {
        throw new RepositoryException("Node at " + tree.getPath() + " has no primary type.");
    }
    PropertyState jcrMixinType = tree.getProperty(JCR_MIXINTYPES);
    if (jcrMixinType == null) {
        return new EffectiveNodeType(primaryType, this);
    } else {
        NodeTypeImpl[] mixinTypes = new NodeTypeImpl[jcrMixinType.count()];
        for (int i = 0; i < mixinTypes.length; i++) {
            mixinTypes[i] = internalGetNodeType(jcrMixinType.getValue(Type.NAME, i));
        }
        return new EffectiveNodeType(primaryType, mixinTypes, this);
    }
}
Also used : RepositoryException(javax.jcr.RepositoryException) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

Example 18 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class ReadOnlyNodeTypeManager method isa.

private static boolean isa(Tree types, String typeName, String superName) {
    if (typeName.equals(superName)) {
        return true;
    }
    Tree type = types.getChild(typeName);
    if (!type.exists()) {
        return false;
    }
    PropertyState supertypes = type.getProperty(REP_SUPERTYPES);
    return supertypes != null && contains(supertypes.getValue(Type.NAMES), superName);
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

Example 19 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class ReadOnlyNodeTypeManager method isNodeType.

//------------------------------------------< EffectiveNodeTypeProvider >---
@Override
public boolean isNodeType(Tree tree, String oakNtName) {
    // shortcuts for common cases
    if (JcrConstants.NT_BASE.equals(oakNtName)) {
        return true;
    } else if (JcrConstants.MIX_REFERENCEABLE.equals(oakNtName) && !tree.hasProperty(JcrConstants.JCR_UUID)) {
        return false;
    } else if (JcrConstants.MIX_VERSIONABLE.equals(oakNtName) && !tree.hasProperty(JcrConstants.JCR_ISCHECKEDOUT)) {
        return false;
    }
    Tree types = getTypes();
    PropertyState primary = tree.getProperty(JcrConstants.JCR_PRIMARYTYPE);
    if (primary != null && primary.getType() == Type.NAME) {
        String name = primary.getValue(Type.NAME);
        if (isa(types, name, oakNtName)) {
            return true;
        }
    }
    PropertyState mixins = tree.getProperty(JcrConstants.JCR_MIXINTYPES);
    if (mixins != null && mixins.getType() == Type.NAMES) {
        for (String name : mixins.getValue(Type.NAMES)) {
            if (isa(types, name, oakNtName)) {
                return true;
            }
        }
    }
    return false;
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

Example 20 with PropertyState

use of org.apache.jackrabbit.oak.api.PropertyState in project jackrabbit-oak by apache.

the class AbstractTree method getChildNames.

/**
     * Returns the list of child names considering its ordering
     * when the {@link TreeConstants#OAK_CHILD_ORDER} property is set.
     *
     * @return the list of child names.
     */
@Nonnull
protected Iterable<String> getChildNames() {
    NodeBuilder nodeBuilder = getNodeBuilder();
    PropertyState order = nodeBuilder.getProperty(OAK_CHILD_ORDER);
    if (order != null && order.getType() == NAMES) {
        Set<String> names = newLinkedHashSet(nodeBuilder.getChildNodeNames());
        List<String> ordered = newArrayListWithCapacity(names.size());
        for (String name : order.getValue(NAMES)) {
            // only include names of child nodes that actually exist
            if (names.remove(name)) {
                ordered.add(name);
            }
        }
        // add names of child nodes that are not explicitly ordered
        ordered.addAll(names);
        return ordered;
    } else {
        return nodeBuilder.getChildNodeNames();
    }
}
Also used : NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Nonnull(javax.annotation.Nonnull)

Aggregations

PropertyState (org.apache.jackrabbit.oak.api.PropertyState)404 Test (org.junit.Test)189 Tree (org.apache.jackrabbit.oak.api.Tree)138 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)49 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)45 Nonnull (javax.annotation.Nonnull)31 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)29 RemoteTree (org.apache.jackrabbit.oak.remote.RemoteTree)28 RemoteValue (org.apache.jackrabbit.oak.remote.RemoteValue)28 Blob (org.apache.jackrabbit.oak.api.Blob)21 ArrayList (java.util.ArrayList)20 LongPropertyState (org.apache.jackrabbit.oak.plugins.memory.LongPropertyState)17 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)16 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)14 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)13 CheckForNull (javax.annotation.CheckForNull)12 RepositoryException (javax.jcr.RepositoryException)10 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)10 Map (java.util.Map)9 Value (javax.jcr.Value)9