Package javax.jcr.nodetype

Examples of javax.jcr.nodetype.NodeTypeIterator


            throws RepositoryException, NotExecutableException {
        testRootNode.addNode(nodeName1, testNodeType);
        testRootNode.save();

        NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
        NodeTypeIterator it = ntMgr.getPrimaryNodeTypes();
        NodeType testNt = ntMgr.getNodeType(testNodeType);
        while (it.hasNext()) {
            NodeType nt = it.nextNodeType();
            if (!testNt.isNodeType(nt.getName())) {
                // perform test
                Query q = qf.createQuery(qf.selector(nt.getName(), "s"),
                        qf.descendantNode("s", testRoot), null, null);
                checkResult(q.execute(), new Node[]{});
View Full Code Here


        Node node = testRootNode.addNode(nodeName1, testNodeType);
        superuser.save();

        // TODO improve. retrieve settable node type name from config.
        NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
        NodeTypeIterator nts = manager.getPrimaryNodeTypes();
        while (nts.hasNext()) {
            NodeType nt = nts.nextNodeType();
            String ntName = nt.getName();
            if (!nt.isAbstract()) {
                try {
                    node.setPrimaryType(ntName);
                    // property value must be adjusted immediately
View Full Code Here

     */
    public void testSetMixinAsPrimaryType() throws RepositoryException {
        Session session = testRootNode.getSession();

        NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
        NodeTypeIterator nts = manager.getMixinNodeTypes();
        while (nts.hasNext()) {
            try {
                Node node = testRootNode.addNode(nodeName1, testNodeType);
                node.setPrimaryType(nts.nextNodeType().getName());
                fail("Node.setPrimaryType(String) must throw ConstraintViolationException if the specified node type name refers to a mixin.");
            } catch (ConstraintViolationException e) {
                // success
            } finally {
                // reset the changes.
View Full Code Here

     */
    public void testSetAbstractAsPrimaryType() throws RepositoryException {
        Session session = testRootNode.getSession();

        NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
        NodeTypeIterator nts = manager.getPrimaryNodeTypes();
        while (nts.hasNext()) {
            NodeType nt = nts.nextNodeType();
            if (nt.isAbstract()) {
                try {
                    Node node = testRootNode.addNode(nodeName1, testNodeType);
                    node.setPrimaryType(nt.getName());
                    fail("Node.setPrimaryType(String) must throw ConstraintViolationException if the specified node type name refers to an abstract node type.");
View Full Code Here

    private static String getPrimaryTypeName(Session session, Node node)
            throws RepositoryException {

        NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
        NodeTypeIterator nts = manager.getPrimaryNodeTypes();

        while (nts.hasNext()) {
            String name = nts.nextNodeType().getName();
            if (!name.equals(node.getPrimaryNodeType().getName())) {
                return name;
            }
        }
        return null;
View Full Code Here

        }

        NodeType nodeType = nodeDef.getDeclaringNodeType();
        String childNodeName = nodeDef.getName();
        String mixinName;
        NodeTypeIterator it = manager.getMixinNodeTypes();
        if (it.hasNext()) {
            mixinName = it.nextNodeType().getName();
        } else {
            throw new NotExecutableException("No mixin type found.");
        }

        assertFalse("NodeType.canAddChildNode(String childNodeName, String nodeTypeName) " +
View Full Code Here

        }

        NodeType nodeType = nodeDef.getDeclaringNodeType();
        String childNodeName = nodeDef.getName();
        String abstractName = null;
        NodeTypeIterator it = manager.getPrimaryNodeTypes();
        while (it.hasNext() && abstractName == null) {
            NodeType nt = it.nextNodeType();
            if (nt.isAbstract()) {
                abstractName = nt.getName();
            }
        }
        if (abstractName == null) {
View Full Code Here

            throws RepositoryException, NotExecutableException {
        testRootNode.addNode(nodeName1, testNodeType);
        testRootNode.save();

        NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
        NodeTypeIterator it = ntMgr.getPrimaryNodeTypes();
        NodeType testNt = ntMgr.getNodeType(testNodeType);
        while (it.hasNext()) {
            NodeType nt = it.nextNodeType();
            if (!testNt.isNodeType(nt.getName())) {
                // perform test
                Query q = qf.createQuery(qf.selector(nt.getName(), "s"),
                        qf.sameNode("s", testRoot + "/" + nodeName1), null, null);
                checkResult(q.execute(), new Node[]{});
View Full Code Here

                                resolver.getJCRName(node.getValue())));
                terms.add(t);
            }

            // now search for all node types that are derived from base
            NodeTypeIterator allTypes = ntMgr.getAllNodeTypes();
            while (allTypes.hasNext()) {
                NodeType nt = allTypes.nextNodeType();
                NodeType[] superTypes = nt.getSupertypes();
                if (Arrays.asList(superTypes).contains(base)) {
                    Name n = session.getQName(nt.getName());
                    String ntName = nsMappings.translateName(n);
                    Term t;
View Full Code Here

     * Tests if addNode() throws a ConstraintViolationException in case
     * of an abstract node type.
     */
    public void testAbstractNodeType() throws RepositoryException {
        NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
        NodeTypeIterator nts = ntMgr.getPrimaryNodeTypes();
        while (nts.hasNext()) {
            NodeType nt = nts.nextNodeType();
            if (nt.isAbstract()) {
                try {
                    testRootNode.addNode(nodeName1, nt.getName());
                    superuser.save();
                    fail("Expected ConstraintViolationException.");
View Full Code Here

TOP

Related Classes of javax.jcr.nodetype.NodeTypeIterator

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.