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);
}
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();
}
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);
}
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
}
}
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);
}
Aggregations