use of org.apache.jackrabbit.oak.namepath.NamePathMapper in project jackrabbit-oak by apache.
the class AbstractAccessControlListTest method testGetPath.
@Test
public void testGetPath() {
NameMapper nameMapper = new GlobalNameMapper(Collections.singletonMap("jr", "http://jackrabbit.apache.org"));
NamePathMapper npMapper = new NamePathMapperImpl(nameMapper);
// map of jcr-path to standard jcr-path
Map<String, String> paths = new HashMap<String, String>();
paths.put(null, null);
paths.put(getTestPath(), getTestPath());
paths.put("/", "/");
paths.put("/jr:testPath", "/jr:testPath");
paths.put("/{http://jackrabbit.apache.org}testPath", "/jr:testPath");
for (String path : paths.keySet()) {
AbstractAccessControlList acl = createACL(path, Collections.<JackrabbitAccessControlEntry>emptyList(), npMapper);
assertEquals(paths.get(path), acl.getPath());
}
}
use of org.apache.jackrabbit.oak.namepath.NamePathMapper in project jackrabbit-oak by apache.
the class AbstractAccessControlManagerTest method testGetOakPathInvalid.
@Test(expected = RepositoryException.class)
public void testGetOakPathInvalid() throws Exception {
NamePathMapper np = new NamePathMapper.Default() {
@Override
public String getOakPath(String jcrPath) {
// mock failing conversion from jcr to oak path
return null;
}
};
createAccessControlManager(root, np).getOakPath("/any/abs/path");
}
use of org.apache.jackrabbit.oak.namepath.NamePathMapper in project jackrabbit-oak by apache.
the class NodeObserver method contentChanged.
@Override
public void contentChanged(@Nonnull NodeState root, @Nonnull CommitInfo info) {
if (previousRoot != null) {
try {
long start = PERF_LOGGER.start();
NamePathMapper namePathMapper = new NamePathMapperImpl(new GlobalNameMapper(RootFactory.createReadOnlyRoot(root)));
Set<String> oakPropertyNames = Sets.newHashSet();
for (String name : propertyNames) {
String oakName = namePathMapper.getOakNameOrNull(name);
if (oakName == null) {
LOG.warn("Ignoring invalid property name: {}", name);
} else {
oakPropertyNames.add(oakName);
}
}
NodeState before = previousRoot;
NodeState after = root;
EventHandler handler = new FilteredHandler(VISIBLE_FILTER, new NodeEventHandler("/", info, namePathMapper, oakPropertyNames));
String oakPath = namePathMapper.getOakPath(path);
if (oakPath == null) {
LOG.warn("Cannot listen for changes on invalid path: {}", path);
return;
}
for (String oakName : PathUtils.elements(oakPath)) {
before = before.getChildNode(oakName);
after = after.getChildNode(oakName);
handler = handler.getChildHandler(oakName, before, after);
}
EventGenerator generator = new EventGenerator(before, after, handler);
while (!generator.isDone()) {
generator.generate();
}
PERF_LOGGER.end(start, 100, "Generated events (before: {}, after: {})", previousRoot, root);
} catch (Exception e) {
LOG.warn("Error while dispatching observation events", e);
}
}
previousRoot = root;
}
use of org.apache.jackrabbit.oak.namepath.NamePathMapper in project jackrabbit-oak by apache.
the class ReadOnlyNodeTypeManager method getAllNodeTypes.
@Override
public NodeTypeIterator getAllNodeTypes() throws RepositoryException {
List<NodeType> list = Lists.newArrayList();
Tree types = getTypes();
if (types != null) {
NamePathMapper mapper = getNamePathMapper();
for (Tree type : types.getChildren()) {
list.add(new NodeTypeImpl(type, mapper));
}
}
return new NodeTypeIteratorAdapter(list);
}
use of org.apache.jackrabbit.oak.namepath.NamePathMapper in project jackrabbit-oak by apache.
the class UserImpl method getPrincipal.
@Override
public Principal getPrincipal() throws RepositoryException {
Tree userTree = getTree();
String principalName = getPrincipalName();
NamePathMapper npMapper = getUserManager().getNamePathMapper();
if (isAdmin()) {
return new AdminPrincipalImpl(principalName, userTree, npMapper);
} else {
return new TreeBasedPrincipal(principalName, userTree, npMapper);
}
}
Aggregations