use of org.apache.jackrabbit.oak.namepath.NamePathMapperImpl in project jackrabbit-oak by apache.
the class AccessControlManagerImplTest method before.
@Override
@Before
public void before() throws Exception {
super.before();
registerNamespace(TEST_PREFIX, TEST_URI);
NameMapper nameMapper = new GlobalNameMapper(root);
npMapper = new NamePathMapperImpl(nameMapper);
acMgr = new AccessControlManagerImpl(root, npMapper, getSecurityProvider());
NodeUtil rootNode = new NodeUtil(root.getTree("/"), getNamePathMapper());
rootNode.addChild(testName, JcrConstants.NT_UNSTRUCTURED);
root.commit();
valueFactory = new ValueFactoryImpl(root, npMapper);
testPrivileges = privilegesFromNames(PrivilegeConstants.JCR_ADD_CHILD_NODES, PrivilegeConstants.JCR_READ);
testPrincipal = getTestUser().getPrincipal();
}
use of org.apache.jackrabbit.oak.namepath.NamePathMapperImpl in project jackrabbit-oak by apache.
the class PrivilegeManagerImplTest method testGetPrivilegeExpandedName.
@Test
public void testGetPrivilegeExpandedName() throws Exception {
Privilege p = create(root, new NamePathMapperImpl(new GlobalNameMapper(root))).getPrivilege(Privilege.JCR_VERSION_MANAGEMENT);
assertNotNull(p);
assertNotEquals(Privilege.JCR_VERSION_MANAGEMENT, p.getName());
assertEquals(PrivilegeConstants.JCR_VERSION_MANAGEMENT, p.getName());
}
use of org.apache.jackrabbit.oak.namepath.NamePathMapperImpl in project jackrabbit-oak by apache.
the class PrivilegeManagerImplTest method testGetPrivilegeRemappedNamespace.
@Test
public void testGetPrivilegeRemappedNamespace() throws Exception {
NamePathMapper mapper = new NamePathMapperImpl(new LocalNameMapper(root, ImmutableMap.of("prefix", NamespaceRegistry.NAMESPACE_JCR)));
Privilege p = create(root, mapper).getPrivilege("prefix:read");
assertNotNull(p);
assertNotEquals(Privilege.JCR_READ, p.getName());
assertNotEquals(PrivilegeConstants.JCR_READ, p.getName());
assertEquals("prefix:read", p.getName());
}
use of org.apache.jackrabbit.oak.namepath.NamePathMapperImpl in project jackrabbit-oak by apache.
the class QueryUtilTest method testEscapeForQuery.
@Test
public void testEscapeForQuery() throws Exception {
NamePathMapper namePathMapper = new NamePathMapperImpl(new LocalNameMapper(ImmutableMap.of(NamespaceRegistry.PREFIX_JCR, NamespaceRegistry.NAMESPACE_JCR), ImmutableMap.of("myPrefix", NamespaceRegistry.NAMESPACE_JCR)));
String value = "'string\\value";
assertEquals(QueryUtils.escapeForQuery("myPrefix:" + value), QueryUtil.escapeForQuery("jcr:" + value, namePathMapper));
}
use of org.apache.jackrabbit.oak.namepath.NamePathMapperImpl in project jackrabbit-oak by apache.
the class AbstractAccessControlListTest method testGetOakPath.
@Test
public void testGetOakPath() {
NamePathMapper npMapper = new NamePathMapperImpl(new LocalNameMapper(singletonMap("oak", "http://jackrabbit.apache.org"), singletonMap("jcr", "http://jackrabbit.apache.org")));
// map of jcr-path to oak path
Map<String, String> paths = new HashMap<String, String>();
paths.put(null, null);
paths.put(getTestPath(), getTestPath());
paths.put("/", "/");
String oakPath = "/oak:testPath";
String jcrPath = "/jcr:testPath";
paths.put(jcrPath, oakPath);
jcrPath = "/{http://jackrabbit.apache.org}testPath";
paths.put(jcrPath, oakPath);
// test if oak-path is properly set.
for (String path : paths.keySet()) {
AbstractAccessControlList acl = createACL(path, Collections.<JackrabbitAccessControlEntry>emptyList(), npMapper);
assertEquals(paths.get(path), acl.getOakPath());
}
}
Aggregations