Search in sources :

Example 6 with QNodeTypeDefinition

use of org.apache.jackrabbit.spi.QNodeTypeDefinition in project jackrabbit by apache.

the class VirtualNodeTypeStateProvider method createRootNodeState.

/**
     * {@inheritDoc}
     * <p>
     * currently we have no dynamic ones, we just recreate the entire nodetypes tree
     */
protected VirtualNodeState createRootNodeState() throws RepositoryException {
    VirtualNodeState root = new VirtualNodeState(this, parentId, rootNodeId, NameConstants.REP_NODETYPES, null);
    Name[] ntNames = ntReg.getRegisteredNodeTypes();
    for (int i = 0; i < ntNames.length; i++) {
        QNodeTypeDefinition ntDef = ntReg.getNodeTypeDef(ntNames[i]);
        VirtualNodeState ntState = createNodeTypeState(root, ntDef);
        root.addChildNodeEntry(ntNames[i], ntState.getNodeId());
        // add as hard reference
        root.addStateReference(ntState);
    }
    return root;
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition) VirtualNodeState(org.apache.jackrabbit.core.virtual.VirtualNodeState) QValueConstraint(org.apache.jackrabbit.spi.QValueConstraint) Name(org.apache.jackrabbit.spi.Name)

Example 7 with QNodeTypeDefinition

use of org.apache.jackrabbit.spi.QNodeTypeDefinition in project jackrabbit by apache.

the class TestAll method getChildNode.

/**
     * Returns the named child node definition from the named node type
     * definition. If either of the definitions do not exist, an assertion
     * failure is generated.
     *
     * @param typeName node type name
     * @param nodeName child node name
     * @return child node definition
     */
private QNodeDefinition getChildNode(String typeName, String nodeName) {
    Name name = FACTORY.create(TEST_NAMESPACE, nodeName);
    QNodeTypeDefinition def = getNodeType(typeName);
    QNodeDefinition[] defs = def.getChildNodeDefs();
    for (int i = 0; i < defs.length; i++) {
        if (name.equals(defs[i].getName())) {
            return defs[i];
        }
    }
    throw new AssertionFailedError("Child node " + nodeName + " does not exist");
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition) QNodeDefinition(org.apache.jackrabbit.spi.QNodeDefinition) AssertionFailedError(junit.framework.AssertionFailedError) Name(org.apache.jackrabbit.spi.Name)

Example 8 with QNodeTypeDefinition

use of org.apache.jackrabbit.spi.QNodeTypeDefinition in project jackrabbit by apache.

the class NodeTypesInContentTest method setUp.

protected void setUp() throws Exception {
    isReadOnly = true;
    super.setUp();
    InputStream xml = getClass().getClassLoader().getResourceAsStream(TEST_NODETYPES);
    QNodeTypeDefinition[] ntDefs = NodeTypeReader.read(xml);
    NodeTypeRegistry ntReg = ((SessionImpl) superuser).getNodeTypeManager().getNodeTypeRegistry();
    if (!ntReg.isRegistered(ntDefs[0].getName())) {
        ntReg.registerNodeTypes(Arrays.asList(ntDefs));
    }
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition) InputStream(java.io.InputStream)

Example 9 with QNodeTypeDefinition

use of org.apache.jackrabbit.spi.QNodeTypeDefinition in project jackrabbit by apache.

the class TestAll method testItemNodeType.

/** Test for node type item definitions. */
public void testItemNodeType() {
    QNodeTypeDefinition def = getNodeType("itemNodeType");
    assertEquals("itemNodeType primaryItemName", FACTORY.create(TEST_NAMESPACE, "emptyItem"), def.getPrimaryItemName());
    assertEquals("itemNodeType propertyDefs", 10, def.getPropertyDefs().length);
    QPropertyDefinition pdef = getPropDef("itemNodeType", null);
    assertTrue("itemNodeType wildcard property", pdef.definesResidual());
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition) QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition)

Example 10 with QNodeTypeDefinition

use of org.apache.jackrabbit.spi.QNodeTypeDefinition in project jackrabbit by apache.

the class TestAll method testPropertyNodeType.

/** Test for node type property definitions. */
public void testPropertyNodeType() {
    QNodeTypeDefinition def = getNodeType("propertyNodeType");
    assertEquals("propertyNodeType propertyDefs", 13, def.getPropertyDefs().length);
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition)

Aggregations

QNodeTypeDefinition (org.apache.jackrabbit.spi.QNodeTypeDefinition)57 Name (org.apache.jackrabbit.spi.Name)21 ArrayList (java.util.ArrayList)13 RepositoryException (javax.jcr.RepositoryException)11 NoSuchNodeTypeException (javax.jcr.nodetype.NoSuchNodeTypeException)9 NodeType (javax.jcr.nodetype.NodeType)6 QNodeTypeDefinitionImpl (org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl)6 HashMap (java.util.HashMap)5 QPropertyDefinition (org.apache.jackrabbit.spi.QPropertyDefinition)5 NodeTypeDefinition (javax.jcr.nodetype.NodeTypeDefinition)4 NodeTypeManager (javax.jcr.nodetype.NodeTypeManager)4 InvalidNodeTypeDefException (org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException)4 QValueConstraint (org.apache.jackrabbit.spi.QValueConstraint)4 NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)4 QNodeTypeDefinitionBuilder (org.apache.jackrabbit.spi.commons.nodetype.QNodeTypeDefinitionBuilder)4 CompactNodeTypeDefReader (org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader)3 NodeTypeRegistry (org.apache.jackrabbit.core.nodetype.NodeTypeRegistry)3 NamespaceMapping (org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping)3 QDefinitionBuilderFactory (org.apache.jackrabbit.spi.commons.nodetype.QDefinitionBuilderFactory)3 QNodeDefinitionBuilder (org.apache.jackrabbit.spi.commons.nodetype.QNodeDefinitionBuilder)3