Package javax.jcr.nodetype

Examples of javax.jcr.nodetype.NodeTypeTemplate


    public void testInvalidJCRNames() throws Exception {
        String invalidName = ":ab[2]";

        // invalid name(s) passed to NT-template methods
        NodeTypeTemplate ntt = ntm.createNodeTypeTemplate();
        try {
            ntt.setName(invalidName);
            fail("ConstraintViolationException expected. Nt-name is invalid");
        } catch (ConstraintViolationException e) {
            // success
        }
        try {
            ntt.setDeclaredSuperTypeNames(new String[] {"{" + NS_MIX_URI + "}" + "littlemixin", invalidName});
            fail("ConstraintViolationException expected. One of the super type names is invalid");
        } catch (ConstraintViolationException e) {
            // success
        }
        try {
            ntt.setPrimaryItemName(invalidName);
            fail("ConstraintViolationException expected. Primary item name is invalid");
        } catch (ConstraintViolationException e) {
            // success
        }
View Full Code Here


            // success
        }
    }

    public void testRegisterNodeType() throws Exception {
        NodeTypeTemplate ntt = ntm.createNodeTypeTemplate();

        ntt.setName("mix:foo");
        ntt.setAbstract(false);
        ntt.setMixin(true);
        ntt.setOrderableChildNodes(false);
        ntt.setQueryable(false);

        PropertyDefinitionTemplate pdt = ntm.createPropertyDefinitionTemplate();
        pdt.setAutoCreated(false);
        pdt.setName("foo");
        pdt.setMultiple(false);
        pdt.setRequiredType(PropertyType.STRING);
        List pdefs = ntt.getPropertyDefinitionTemplates();
        pdefs.add(pdt);

        ntm.registerNodeType(ntt, true);

        try {
View Full Code Here

    }

    public void testRegisterNodeTypes() throws Exception {
        NodeTypeDefinition[] defs = new NodeTypeDefinition[5];
        for (int i = 0; i < defs.length; i++) {
            NodeTypeTemplate ntt = ntm.createNodeTypeTemplate();
            ntt.setName("mix:foo" + i);
            ntt.setAbstract(false);
            ntt.setMixin(true);
            ntt.setOrderableChildNodes(false);
            ntt.setQueryable(false);

            PropertyDefinitionTemplate pdt = ntm.createPropertyDefinitionTemplate();
            pdt.setAutoCreated(false);
            pdt.setName("foo" + i);
            pdt.setMultiple(false);
            pdt.setRequiredType(PropertyType.STRING);
            List pdefs = ntt.getPropertyDefinitionTemplates();
            pdefs.add(pdt);

            defs[i] = ntt;
        }
        ntm.registerNodeTypes(defs, true);
View Full Code Here

        ntMgr = superuser.getWorkspace().getNodeTypeManager();
    }

    public void testRegisterNodeTypes() throws RepositoryException {
        NodeTypeTemplate test = ntMgr.createNodeTypeTemplate();
        test.setName("testNodeType");

        ntMgr.registerNodeType(test, true);

        NodeType nt = ntMgr.getNodeType("testNodeType");
        assertNotNull(nt);
        assertEquals("testNodeType", nt.getName());

        test.setOrderableChildNodes(true);

        ntMgr.registerNodeType(test, true);

        nt = ntMgr.getNodeType("testNodeType");
        assertNotNull(nt);
        assertEquals("testNodeType", nt.getName());
        assertEquals(test.hasOrderableChildNodes(), nt.hasOrderableChildNodes());

        test.setDeclaredSuperTypeNames(new String[] {"nt:unstructured"});

        try {
            ntMgr.registerNodeType(test, false);
            fail("NodeTypeExistsException expected");
        } catch (NodeTypeExistsException e) {
View Full Code Here

            // success
        }
    }
   
    public void testUnregisterNodeTypes() throws RepositoryException {
        NodeTypeTemplate test = ntMgr.createNodeTypeTemplate();
        test.setName("testNodeType2");

        ntMgr.registerNodeType(test, true);

        NodeType nt = ntMgr.getNodeType("testNodeType2");
        assertNotNull(nt);
        assertEquals("testNodeType2", nt.getName());

        boolean supported = false;
        try {
            ntMgr.unregisterNodeType(test.getName());
            supported = true;
        } catch (UnsupportedRepositoryOperationException e) {
            // ok
        } catch (RepositoryException e) {
            // TODO improve
View Full Code Here

    }

    public void testAddItemsDefinedByMixin() throws NotExecutableException, RepositoryException {
        // register mixin
        NodeTypeManager ntm = superuser.getWorkspace().getNodeTypeManager();
        NodeTypeTemplate ntd = ntm.createNodeTypeTemplate();
        ntd.setName("testMixin");
        ntd.setMixin(true);
        NodeDefinitionTemplate nodeDef = ntm.createNodeDefinitionTemplate();
        nodeDef.setName("child");
        nodeDef.setRequiredPrimaryTypeNames(new String[] {"nt:folder"});
        ntd.getNodeDefinitionTemplates().add(nodeDef);
        ntm.registerNodeType(ntd, true);

        // create node and add mixin
        Node node = testRootNode.addNode(nodeName1, "nt:resource");
        node.setProperty("jcr:data", "abc");
View Full Code Here


    public void testAddItemsDefinedByMixin2() throws NotExecutableException, RepositoryException {
        // register mixin
        NodeTypeManager ntm = superuser.getWorkspace().getNodeTypeManager();
        NodeTypeTemplate ntd = ntm.createNodeTypeTemplate();
        ntd.setName("testMixin");
        ntd.setMixin(true);
        NodeDefinitionTemplate nodeDef = ntm.createNodeDefinitionTemplate();
        nodeDef.setName("child");
        nodeDef.setRequiredPrimaryTypeNames(new String[] {"nt:folder"});
        ntd.getNodeDefinitionTemplates().add(nodeDef);
        ntm.registerNodeType(ntd, true);

        // create node and add mixin
        Node node = testRootNode.addNode(nodeName1, "nt:resource");
        node.setProperty("jcr:data", "abc");
View Full Code Here

    }

    public void testAddItemsDefinedByMixin3() throws NotExecutableException, RepositoryException {
        // register mixin
        NodeTypeManager ntm = superuser.getWorkspace().getNodeTypeManager();
        NodeTypeTemplate ntd = ntm.createNodeTypeTemplate();
        ntd.setName("testMixin");
        ntd.setMixin(true);
        NodeDefinitionTemplate nodeDef = ntm.createNodeDefinitionTemplate();
        nodeDef.setName("child");
        nodeDef.setRequiredPrimaryTypeNames(new String[] {"nt:folder"});
        nodeDef.setDefaultPrimaryTypeName("nt:folder");
        ntd.getNodeDefinitionTemplates().add(nodeDef);
        ntm.registerNodeType(ntd, true);

        // create node and add mixin
        Node node = testRootNode.addNode(nodeName1, "nt:resource");
        node.setProperty("jcr:data", "abc");
View Full Code Here

        assertDefaultPrivileges(NameConstants.JCR_NODE_TYPE_DEFINITION_MANAGEMENT);
        assertPermission(Permission.NODE_TYPE_DEF_MNGMT, false);

        Workspace testWsp = getTestWorkspace();
        NodeTypeManager ntm = testWsp.getNodeTypeManager();
        NodeTypeTemplate ntd = ntm.createNodeTypeTemplate();
        ntd.setName("testNodeType");
        ntd.setMixin(true);

        try {
            ntm.registerNodeType(ntd, true);
            fail("Node type registration should be denied.");
        } catch (AccessDeniedException e) {
View Full Code Here

        assertPermission(Permission.NODE_TYPE_DEF_MNGMT, true);

        try {
            Workspace testWsp = getTestWorkspace();
            NodeTypeManager ntm = testWsp.getNodeTypeManager();
            NodeTypeTemplate ntd = ntm.createNodeTypeTemplate();
            ntd.setName("testNodeType");
            ntd.setMixin(true);
            ntm.registerNodeType(ntd, true);

            NodeTypeTemplate[] ntds = new NodeTypeTemplate[2];
            ntds[0] = ntd;
            ntds[1] = ntm.createNodeTypeTemplate();
View Full Code Here

TOP

Related Classes of javax.jcr.nodetype.NodeTypeTemplate

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.