Search in sources :

Example 6 with NodeTypeManager

use of javax.jcr.nodetype.NodeTypeManager in project jackrabbit-oak by apache.

the class RepositorySidegradeTest method verifyNewBuiltinNodeTypes.

@Test
public void verifyNewBuiltinNodeTypes() throws Exception {
    Session session = createAdminSession();
    try {
        NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
        assertTrue(manager.hasNodeType(UserConstants.NT_REP_MEMBER_REFERENCES));
        assertTrue(manager.hasNodeType(IndexConstants.INDEX_DEFINITIONS_NODE_TYPE));
    } finally {
        session.logout();
    }
}
Also used : NodeTypeManager(javax.jcr.nodetype.NodeTypeManager) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) Test(org.junit.Test)

Example 7 with NodeTypeManager

use of javax.jcr.nodetype.NodeTypeManager in project jackrabbit-oak by apache.

the class RepositorySidegradeTest method verifyReplacedBuiltinNodeTypes.

@Test
public void verifyReplacedBuiltinNodeTypes() throws Exception {
    Session session = createAdminSession();
    try {
        NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
        NodeType nt = manager.getNodeType(UserConstants.NT_REP_GROUP);
        assertTrue("Migrated repository must have new nodetype definitions", nt.isNodeType(UserConstants.NT_REP_MEMBER_REFERENCES));
    } finally {
        session.logout();
    }
}
Also used : NodeTypeManager(javax.jcr.nodetype.NodeTypeManager) NodeType(javax.jcr.nodetype.NodeType) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) Test(org.junit.Test)

Example 8 with NodeTypeManager

use of javax.jcr.nodetype.NodeTypeManager in project jackrabbit-oak by apache.

the class RepositoryUpgradeTest method verifyNewBuiltinNodeTypes.

@Test
public void verifyNewBuiltinNodeTypes() throws Exception {
    Session session = createAdminSession();
    try {
        NodeTypeManager manager = session.getWorkspace().getNodeTypeManager();
        assertTrue(manager.hasNodeType(UserConstants.NT_REP_MEMBER_REFERENCES));
        assertTrue(manager.hasNodeType(IndexConstants.INDEX_DEFINITIONS_NODE_TYPE));
    } finally {
        session.logout();
    }
}
Also used : NodeTypeManager(javax.jcr.nodetype.NodeTypeManager) Session(javax.jcr.Session) Test(org.junit.Test)

Example 9 with NodeTypeManager

use of javax.jcr.nodetype.NodeTypeManager in project jackrabbit-oak by apache.

the class NodeTypeDefinitionManagementTest method testRegisterNodeType.

@Test
public void testRegisterNodeType() throws Exception {
    Workspace testWsp = testSession.getWorkspace();
    NodeTypeManager ntm = testWsp.getNodeTypeManager();
    NodeTypeTemplate ntd = ntm.createNodeTypeTemplate();
    ntd.setName("testRegisterNodeType");
    ntd.setMixin(true);
    try {
        ntm.registerNodeType(ntd, true);
        fail("Node type registration should be denied.");
    } catch (AccessDeniedException e) {
    // success
    }
    try {
        ntm.registerNodeType(ntd, false);
        fail("Node type registration should be denied.");
    } catch (AccessDeniedException e) {
    // success
    }
    NodeTypeTemplate[] ntds = new NodeTypeTemplate[2];
    ntds[0] = ntd;
    ntds[1] = ntm.createNodeTypeTemplate();
    ntds[1].setName("anotherRegisterNodeType");
    ntds[1].setDeclaredSuperTypeNames(new String[] { "nt:file" });
    try {
        ntm.registerNodeTypes(ntds, true);
        fail("Node type registration should be denied.");
    } catch (AccessDeniedException e) {
    // success
    }
    try {
        ntm.registerNodeTypes(ntds, false);
        fail("Node type registration should be denied.");
    } catch (AccessDeniedException e) {
    // success
    }
}
Also used : NodeTypeManager(javax.jcr.nodetype.NodeTypeManager) AccessDeniedException(javax.jcr.AccessDeniedException) NodeTypeTemplate(javax.jcr.nodetype.NodeTypeTemplate) Workspace(javax.jcr.Workspace) Test(org.junit.Test)

Example 10 with NodeTypeManager

use of javax.jcr.nodetype.NodeTypeManager in project jackrabbit-oak by apache.

the class NodeTypeDefinitionManagementTest method testRegisterNodeTypeWithPrivilege.

@Test
public void testRegisterNodeTypeWithPrivilege() throws Exception {
    modify(null, JCR_NODE_TYPE_DEFINITION_MANAGEMENT.toString(), true);
    try {
        Workspace testWsp = testSession.getWorkspace();
        NodeTypeManager ntm = testWsp.getNodeTypeManager();
        NodeTypeTemplate ntd = ntm.createNodeTypeTemplate();
        ntd.setName("testRegisterNodeTypeWithPrivilege");
        ntd.setMixin(true);
        ntm.registerNodeType(ntd, true);
        NodeTypeTemplate[] ntds = new NodeTypeTemplate[2];
        ntds[0] = ntd;
        ntds[1] = ntm.createNodeTypeTemplate();
        ntds[1].setName("anotherRegisterNodeTypeWithPrivilege");
        ntds[1].setDeclaredSuperTypeNames(new String[] { "nt:file" });
        ntm.registerNodeTypes(ntds, true);
    } finally {
        modify(null, JCR_NODE_TYPE_DEFINITION_MANAGEMENT.toString(), false);
    }
}
Also used : NodeTypeManager(javax.jcr.nodetype.NodeTypeManager) NodeTypeTemplate(javax.jcr.nodetype.NodeTypeTemplate) Workspace(javax.jcr.Workspace) Test(org.junit.Test)

Aggregations

NodeTypeManager (javax.jcr.nodetype.NodeTypeManager)103 NodeType (javax.jcr.nodetype.NodeType)47 Node (javax.jcr.Node)38 Session (javax.jcr.Session)35 NodeTypeTemplate (javax.jcr.nodetype.NodeTypeTemplate)31 NodeTypeIterator (javax.jcr.nodetype.NodeTypeIterator)29 Test (org.junit.Test)25 RepositoryException (javax.jcr.RepositoryException)18 ByteArrayInputStream (java.io.ByteArrayInputStream)15 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)15 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)14 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)11 ArrayList (java.util.ArrayList)10 Workspace (javax.jcr.Workspace)10 InputStream (java.io.InputStream)9 NodeDefinition (javax.jcr.nodetype.NodeDefinition)9 PropertyDefinitionTemplate (javax.jcr.nodetype.PropertyDefinitionTemplate)9 InputStreamReader (java.io.InputStreamReader)8 NamespaceRegistry (javax.jcr.NamespaceRegistry)8 Value (javax.jcr.Value)8