Package javax.jcr.nodetype

Examples of javax.jcr.nodetype.NodeDefinition


     * <code>childNodeName</code> with a default primary type.
     */
    public void testDefinedWithDefault()
            throws NotExecutableException, RepositoryException {

        NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, true, true, false);

        if (nodeDef == null) {
            throw new NotExecutableException("No child node def with " +
                    "defaultPrimaryType found");
        }

        NodeType nodeType = nodeDef.getDeclaringNodeType();

        assertTrue("NodeType.canAddChildNode(String childNodeName) must return " +
                "true if child node def 'childNodeName' defines a defaultPrimaryType.",
                nodeType.canAddChildNode(nodeDef.getName()));
    }
View Full Code Here


     * <code>childNodeName</code> without a default primary type.
     */
    public void testDefinedWithoutDefault()
            throws NotExecutableException, RepositoryException {

        NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, true, false, false);

        if (nodeDef == null) {
            throw new NotExecutableException("No child node def without " +
                    "defaultPrimaryType found");
        }

        NodeType nodeType = nodeDef.getDeclaringNodeType();

        assertFalse("NodeType.canAddChildNode(String childNodeName) must return false " +
                "if child node def 'childNodeName' does not define a defaultPrimaryType.",
                nodeType.canAddChildNode(nodeDef.getName()));
    }
View Full Code Here

     * <code>childNodeName</code> nor a residual definition.
     */
    public void testUndefined()
            throws NotExecutableException, RepositoryException {

        NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, false, true, false);

        if (nodeDef == null) {
            throw new NotExecutableException("No testable node type found.");
        }

        NodeType nodeType = nodeDef.getDeclaringNodeType();
        String undefinedName = NodeTypeUtil.getUndefinedChildNodeName(nodeType);

        assertFalse("NodeType.canAddChildNode(String childNodeName) must return " +
                "false if 'childNodeName' is a undefined child node def",
                nodeType.canAddChildNode(undefinedName));
View Full Code Here

     * with a default primary type.
     */
    public void testResidualWithDefault()
            throws NotExecutableException, RepositoryException {

        NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, true, true, true);

        if (nodeDef == null) {
            throw new NotExecutableException("No residual child node def " +
                    "without a defaultPrimaryType found.");
        }

        NodeType nodeType = nodeDef.getDeclaringNodeType();
        String undefinedName = NodeTypeUtil.getUndefinedChildNodeName(nodeType);

        assertTrue("NodeType.canAddChildNode(String childNodeName) must return " +
                "true for a not defined childNodeName if NodeType has a residual child node " +
                "definition with a defaultPrimaryType",
View Full Code Here

     * without a default primary type.
     */
    public void testResidualWithoutDefault()
            throws NotExecutableException, RepositoryException {

        NodeDefinition nodeDef = NodeTypeUtil.locateChildNodeDef(session, true, false, true);

        if (nodeDef == null) {
            throw new NotExecutableException("No residual child node def " +
                    "with a defaultPrimaryType found.");
        }

        NodeType nodeType = nodeDef.getDeclaringNodeType();
        String undefinedName = NodeTypeUtil.getUndefinedChildNodeName(nodeType);

        assertFalse("NodeType.canAddChildNode(String childNodeName) must return " +
                "false for a not defiend childNodeName if NodeType has a " +
                "residual child node definition without a defaultPrimaryType",
View Full Code Here

        NodeTypeIterator types = manager.getAllNodeTypes();
        // loop all node types
        while (types.hasNext()) {
            NodeType currentType = types.nextNodeType();
            NodeDefinition defsOfCurrentType[] =
                    currentType.getChildNodeDefinitions();

            // loop all child node defs of each node type
            for (int i = 0; i < defsOfCurrentType.length; i++) {
                NodeDefinition def = defsOfCurrentType[i];
                NodeType type = def.getDeclaringNodeType();

                // check if def is part of the child node defs of the
                // declaring node type
                NodeDefinition defs[] = type.getChildNodeDefinitions();
                boolean hasType = false;
                for (int j = 0; j < defs.length; j++) {
                    if (defs[j].getName().equals(def.getName())) {
                        hasType = true;
                        break;
View Full Code Here

        NodeTypeIterator types = manager.getAllNodeTypes();
        // loop all node types
        while (types.hasNext()) {
            NodeType type = types.nextNodeType();
            NodeDefinition defs[] = type.getChildNodeDefinitions();
            for (int i = 0; i < defs.length; i++) {
                if (defs[i].isAutoCreated()) {
                    assertFalse("An auto create node must not be a " +
                            "residual set definition.",
                            defs[i].getName().equals("*"));
 
View Full Code Here

        NodeTypeIterator types = manager.getAllNodeTypes();
        // loop all node types
        while (types.hasNext()) {
            NodeType type = types.nextNodeType();
            NodeDefinition defs[] = type.getChildNodeDefinitions();

            for (int i = 0; i < defs.length; i++) {
                assertTrue("getRequiredPrimaryTypes() must never return an " +
                        "empty array.",
                        defs[i].getRequiredPrimaryTypes().length > 0);
View Full Code Here

        NodeTypeIterator types = manager.getAllNodeTypes();
        // loop all node types
        while (types.hasNext()) {
            NodeType type = types.nextNodeType();
            NodeDefinition defs[] = type.getChildNodeDefinitions();

            for (int i = 0; i < defs.length; i++) {

                NodeDefinition def = defs[i];
                NodeType defaultType = def.getDefaultPrimaryType();
                if (defaultType != null) {

                    NodeType requiredTypes[] =
                            def.getRequiredPrimaryTypes();

                    for (int j = 0; j < requiredTypes.length; j++) {
                        NodeType requiredType = requiredTypes[j];

                        boolean isSubType = false;
View Full Code Here

     */
    private void checkMandatoryConstraint(Node node, NodeType type)
            throws RepositoryException {

        // test if node contains all mandatory nodes of current type
        NodeDefinition nodeDefs[] = type.getChildNodeDefinitions();
        for (int i = 0; i < nodeDefs.length; i++) {
            NodeDefinition nodeDef = nodeDefs[i];
            if (nodeDef.isMandatory()) {
                foundMandatoryNode = true;
                try {
                    node.getNode(nodeDef.getName());
                } catch (PathNotFoundException e) {
                    fail("Mandatory child " + nodeDef.getName() + " for " +
                            node.getPath() + " does not exist.");
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of javax.jcr.nodetype.NodeDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.