Search in sources :

Example 6 with TypePredicate

use of org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate in project jackrabbit-oak by apache.

the class NodeTypePredicateTest method singleNodeTypeMiss.

@Test
public void singleNodeTypeMiss() {
    NodeState node = createNodeOfType(NT_BASE);
    TypePredicate p = new TypePredicate(node, new String[] { NT_FILE });
    assertFalse(p.apply(node));
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) TypePredicate(org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate) Test(org.junit.Test)

Example 7 with TypePredicate

use of org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate in project jackrabbit-oak by apache.

the class NodeTypePredicateTest method singleNodeTypeMatch.

@Test
public void singleNodeTypeMatch() {
    NodeState node = createNodeOfType(NT_BASE);
    TypePredicate p = new TypePredicate(node, new String[] { NT_BASE });
    assertTrue(p.apply(node));
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) TypePredicate(org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate) Test(org.junit.Test)

Example 8 with TypePredicate

use of org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate in project jackrabbit-oak by apache.

the class SameNameSiblingsEditor method parseNamedChildNodeDefs.

private static List<ChildTypeDef> parseNamedChildNodeDefs(NodeState root, NodeState parentType, TypePredicate parentTypePredicate) {
    List<ChildTypeDef> defs = new ArrayList<ChildTypeDef>();
    NodeState namedChildNodeDefinitions = parentType.getChildNode(REP_NAMED_CHILD_NODE_DEFINITIONS);
    for (ChildNodeEntry childName : namedChildNodeDefinitions.getChildNodeEntries()) {
        for (String childType : filterChildren(childName.getNodeState(), NO_SNS_PROPERTY)) {
            TypePredicate childTypePredicate = new TypePredicate(root, childType);
            defs.add(new ChildTypeDef(parentTypePredicate, childName.getName(), childTypePredicate));
        }
    }
    return defs;
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry) ArrayList(java.util.ArrayList) TypePredicate(org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate)

Example 9 with TypePredicate

use of org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate in project jackrabbit-oak by apache.

the class SameNameSiblingsEditor method prepareChildDefsWithoutSns.

/**
     * Prepare a list of node definitions that doesn't allow having SNS children.
     *
     * @param root Repository root
     * @return a list of node definitions denying SNS children
     */
private static List<ChildTypeDef> prepareChildDefsWithoutSns(NodeState root) {
    List<ChildTypeDef> defs = new ArrayList<ChildTypeDef>();
    NodeState types = root.getChildNode(JCR_SYSTEM).getChildNode(JCR_NODE_TYPES);
    for (ChildNodeEntry typeEntry : types.getChildNodeEntries()) {
        NodeState type = typeEntry.getNodeState();
        TypePredicate typePredicate = new TypePredicate(root, typeEntry.getName());
        defs.addAll(parseResidualChildNodeDefs(root, type, typePredicate));
        defs.addAll(parseNamedChildNodeDefs(root, type, typePredicate));
    }
    return defs;
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry) ArrayList(java.util.ArrayList) TypePredicate(org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate)

Example 10 with TypePredicate

use of org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate in project jackrabbit-oak by apache.

the class SameNameSiblingsEditor method parseResidualChildNodeDefs.

private static List<ChildTypeDef> parseResidualChildNodeDefs(NodeState root, NodeState parentType, TypePredicate parentTypePredicate) {
    List<ChildTypeDef> defs = new ArrayList<ChildTypeDef>();
    NodeState resChildNodeDefinitions = parentType.getChildNode(REP_RESIDUAL_CHILD_NODE_DEFINITIONS);
    for (String childType : filterChildren(resChildNodeDefinitions, NO_SNS_PROPERTY)) {
        TypePredicate childTypePredicate = new TypePredicate(root, childType);
        defs.add(new ChildTypeDef(parentTypePredicate, childTypePredicate));
    }
    return defs;
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) ArrayList(java.util.ArrayList) TypePredicate(org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate)

Aggregations

TypePredicate (org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate)10 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)8 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)3 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)2 CheckForNull (javax.annotation.CheckForNull)1 Nonnull (javax.annotation.Nonnull)1 PrivilegeBitsProvider (org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBitsProvider)1 DefaultNodeStateDiff (org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff)1 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1