Search in sources :

Example 56 with Workspace

use of javax.jcr.Workspace in project jackrabbit by apache.

the class QueryImpl method columnForName.

/**
     * Returns a column for the given property name and the default selector
     * name.
     *
     * @param propertyName the name of the property as well as the column.
     * @return a column.
     * @throws RepositoryException if an error occurs while creating the column.
     */
protected ColumnImpl columnForName(Name propertyName) throws RepositoryException {
    Workspace workspace = sessionContext.getSessionImpl().getWorkspace();
    QueryObjectModelFactory qomFactory = workspace.getQueryManager().getQOMFactory();
    String name = sessionContext.getJCRName(propertyName);
    return (ColumnImpl) qomFactory.column(sessionContext.getJCRName(DEFAULT_SELECTOR_NAME), name, name);
}
Also used : QueryObjectModelFactory(javax.jcr.query.qom.QueryObjectModelFactory) ColumnImpl(org.apache.jackrabbit.spi.commons.query.qom.ColumnImpl) Workspace(javax.jcr.Workspace)

Example 57 with Workspace

use of javax.jcr.Workspace 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 58 with Workspace

use of javax.jcr.Workspace in project jackrabbit by apache.

the class AbstractRepositoryOperationTest method testRegisterPrivilegeWithPrivilege.

public void testRegisterPrivilegeWithPrivilege() throws Exception {
    assertDefaultPrivileges(PrivilegeRegistry.REP_PRIVILEGE_MANAGEMENT_NAME);
    assertPermission(Permission.PRIVILEGE_MNGMT, false);
    modifyPrivileges(null, PrivilegeRegistry.REP_PRIVILEGE_MANAGEMENT_NAME.toString(), true);
    assertPrivilege(PrivilegeRegistry.REP_PRIVILEGE_MANAGEMENT_NAME, true);
    assertPermission(Permission.PRIVILEGE_MNGMT, true);
    try {
        Workspace testWsp = getTestWorkspace();
        ((JackrabbitWorkspace) testWsp).getPrivilegeManager().registerPrivilege(getNewPrivilegeName(testWsp), false, new String[0]);
    } finally {
        modifyPrivileges(null, PrivilegeRegistry.REP_PRIVILEGE_MANAGEMENT_NAME.toString(), false);
    }
    assertPrivilege(PrivilegeRegistry.REP_PRIVILEGE_MANAGEMENT_NAME, false);
    assertPermission(Permission.PRIVILEGE_MNGMT, false);
}
Also used : JackrabbitWorkspace(org.apache.jackrabbit.api.JackrabbitWorkspace) Workspace(javax.jcr.Workspace)

Example 59 with Workspace

use of javax.jcr.Workspace in project jackrabbit by apache.

the class AbstractRepositoryOperationTest method testRegisterPrivilege.

public void testRegisterPrivilege() throws Exception {
    assertDefaultPrivileges(PrivilegeRegistry.REP_PRIVILEGE_MANAGEMENT_NAME);
    assertPermission(Permission.PRIVILEGE_MNGMT, false);
    try {
        Workspace testWsp = getTestWorkspace();
        ((JackrabbitWorkspace) testWsp).getPrivilegeManager().registerPrivilege(getNewPrivilegeName(testWsp), false, new String[0]);
        fail("Privilege registration should be denied.");
    } catch (AccessDeniedException e) {
    // success
    }
}
Also used : AccessDeniedException(javax.jcr.AccessDeniedException) JackrabbitWorkspace(org.apache.jackrabbit.api.JackrabbitWorkspace) Workspace(javax.jcr.Workspace)

Example 60 with Workspace

use of javax.jcr.Workspace in project jackrabbit by apache.

the class AbstractRepositoryOperationTest method testRegisterNodeTypeWithPrivilege.

public void testRegisterNodeTypeWithPrivilege() throws Exception {
    assertDefaultPrivileges(NameConstants.JCR_NODE_TYPE_DEFINITION_MANAGEMENT);
    assertPermission(Permission.NODE_TYPE_DEF_MNGMT, false);
    modifyPrivileges(null, NameConstants.JCR_NODE_TYPE_DEFINITION_MANAGEMENT.toString(), true);
    assertPrivilege(NameConstants.JCR_NODE_TYPE_DEFINITION_MANAGEMENT, true);
    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();
        ntds[1].setName("anotherNodeType");
        ntds[1].setDeclaredSuperTypeNames(new String[] { "nt:file" });
        ntm.registerNodeTypes(ntds, true);
    } finally {
        modifyPrivileges(null, NameConstants.JCR_NODE_TYPE_DEFINITION_MANAGEMENT.toString(), false);
    }
    assertPrivilege(NameConstants.JCR_NODE_TYPE_DEFINITION_MANAGEMENT, false);
    assertPermission(Permission.NODE_TYPE_DEF_MNGMT, false);
}
Also used : NodeTypeManager(javax.jcr.nodetype.NodeTypeManager) NodeTypeTemplate(javax.jcr.nodetype.NodeTypeTemplate) JackrabbitWorkspace(org.apache.jackrabbit.api.JackrabbitWorkspace) Workspace(javax.jcr.Workspace)

Aggregations

Workspace (javax.jcr.Workspace)105 Node (javax.jcr.Node)51 Session (javax.jcr.Session)25 AccessDeniedException (javax.jcr.AccessDeniedException)18 Test (org.junit.Test)18 RepositoryException (javax.jcr.RepositoryException)16 JackrabbitWorkspace (org.apache.jackrabbit.api.JackrabbitWorkspace)16 NodeTypeManager (javax.jcr.nodetype.NodeTypeManager)10 UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)8 NodeTypeTemplate (javax.jcr.nodetype.NodeTypeTemplate)7 File (java.io.File)6 FileInputStream (java.io.FileInputStream)6 IOException (java.io.IOException)6 InputStream (java.io.InputStream)6 OutputStream (java.io.OutputStream)6 ObservationManager (javax.jcr.observation.ObservationManager)6 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)6 FileOutputStream (java.io.FileOutputStream)5 NodeIterator (javax.jcr.NodeIterator)4 Version (javax.jcr.version.Version)4