Search in sources :

Example 31 with QNodeTypeDefinition

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

the class LostFromCacheIssueTest method setUp.

public void setUp() throws Exception {
    super.setUp();
    Workspace workspace = superuser.getWorkspace();
    NamespaceRegistry namespaceRegistry = workspace.getNamespaceRegistry();
    NodeTypeManager ntmgr = workspace.getNodeTypeManager();
    NodeTypeRegistry nodetypeRegistry = ((NodeTypeManagerImpl) ntmgr).getNodeTypeRegistry();
    try {
        namespaceRegistry.registerNamespace(NAMESPACE_PREFIX, NAMESPACE_URI);
    } catch (NamespaceException ignore) {
    //already exists
    }
    QNodeTypeDefinition nodeTypeDefinition = new QNodeTypeDefinitionImpl(((SessionImpl) superuser).getQName(NODETYPE_1), Name.EMPTY_ARRAY, Name.EMPTY_ARRAY, true, false, true, false, null, QPropertyDefinition.EMPTY_ARRAY, QNodeDefinition.EMPTY_ARRAY);
    try {
        nodetypeRegistry.registerNodeType(nodeTypeDefinition);
    } catch (InvalidNodeTypeDefException ignore) {
    //already exists
    }
    nodeTypeDefinition = new QNodeTypeDefinitionImpl(((SessionImpl) superuser).getQName(NODETYPE_2), Name.EMPTY_ARRAY, Name.EMPTY_ARRAY, true, false, true, false, null, QPropertyDefinition.EMPTY_ARRAY, QNodeDefinition.EMPTY_ARRAY);
    try {
        nodetypeRegistry.registerNodeType(nodeTypeDefinition);
    } catch (InvalidNodeTypeDefException ignore) {
    //already exists
    }
    getOrCreate(superuser.getRootNode(), TESTNODE_PATH);
    superuser.save();
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition) InvalidNodeTypeDefException(org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException) NodeTypeManager(javax.jcr.nodetype.NodeTypeManager) NamespaceRegistry(javax.jcr.NamespaceRegistry) NamespaceException(javax.jcr.NamespaceException) NodeTypeRegistry(org.apache.jackrabbit.core.nodetype.NodeTypeRegistry) NodeTypeManagerImpl(org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl) Workspace(javax.jcr.Workspace) QNodeTypeDefinitionImpl(org.apache.jackrabbit.spi.commons.QNodeTypeDefinitionImpl)

Example 32 with QNodeTypeDefinition

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

the class TestAll method testMixinNodeType.

/** Test for the <code>mixin</code> node type attribute. */
public void testMixinNodeType() {
    QNodeTypeDefinition def = getNodeType("mixinNodeType");
    assertEquals("mixinNodeType mixin", true, def.isMixin());
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition)

Example 33 with QNodeTypeDefinition

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

the class TestAll method getPropDef.

/**
     * Returns the named property definition from the named node type
     * definition. If either of the definitions do not exist, an assertion
     * failure is generated.
     * <p>
     * If the given property name is <code>null</code>, then the residual
     * property definition (if one exists) is returned.
     *
     * @param typeName node type name
     * @param propertyName property name, or <code>null</code>
     * @return property definition
     */
private QPropertyDefinition getPropDef(String typeName, String propertyName) {
    Name name;
    if (propertyName != null) {
        name = FACTORY.create(TEST_NAMESPACE, propertyName);
    } else {
        name = NameConstants.ANY_NAME;
    }
    QNodeTypeDefinition def = getNodeType(typeName);
    QPropertyDefinition[] defs = def.getPropertyDefs();
    for (int i = 0; i < defs.length; i++) {
        if (name.equals(defs[i].getName())) {
            return defs[i];
        }
    }
    throw new AssertionFailedError("Property " + propertyName + " does not exist");
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition) QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition) AssertionFailedError(junit.framework.AssertionFailedError) Name(org.apache.jackrabbit.spi.Name)

Example 34 with QNodeTypeDefinition

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

the class TestAll method testEmptyNodeType.

/** Test for the empty node type. */
public void testEmptyNodeType() {
    QNodeTypeDefinition def = getNodeType("emptyNodeType");
    assertNotNull("emptyNodeType exists", def);
    assertEquals("emptyNodeType mixin", false, def.isMixin());
    assertEquals("emptyNodeType hasOrderableChildNodes", false, def.hasOrderableChildNodes());
    assertEquals("emptyNodeType primaryItemName", null, def.getPrimaryItemName());
    assertEquals("emptyNodeType childNodeDefs", 0, def.getChildNodeDefs().length);
    assertEquals("emptyNodeType propertyDefs", 0, def.getPropertyDefs().length);
}
Also used : QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition)

Example 35 with QNodeTypeDefinition

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

the class TestAll method testChildNodeType.

/** Test for node type child node definitions. */
public void testChildNodeType() {
    QNodeTypeDefinition def = getNodeType("childNodeType");
    assertEquals("childNodeType childNodeDefs", 4, def.getChildNodeDefs().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