@Override public boolean canReadAll() { return versionablePermission.canReadAll(); }
@Override public boolean canReadAll() { return versionablePermission.canReadAll(); }
@Override public boolean canReadAll() { return versionablePermission.canReadAll(); }
@Override public synchronized long getChildNodeCount(long max) { if (getTreePermission().canReadAll()) { return builder.getChildNodeCount(max); } else { return size(getChildNodeNames()); } }
@Override public synchronized long getChildNodeCount(long max) { if (getTreePermission().canReadAll()) { return builder.getChildNodeCount(max); } else { return size(getChildNodeNames()); } }
@Override public synchronized long getChildNodeCount(long max) { if (getTreePermission().canReadAll()) { return builder.getChildNodeCount(max); } else { return size(getChildNodeNames()); } }
@Override @NotNull public Iterable<? extends ChildNodeEntry> getChildNodeEntries() { if (treePermission.canReadAll()) { // everything is readable including ac-content -> no secure wrapper needed return state.getChildNodeEntries(); } else if (treePermission.canRead()) { Iterable<ChildNodeEntry> readable = transform( state.getChildNodeEntries(), new WrapChildEntryFunction()); return filter(readable, new IterableNodePredicate()); } else { return emptyList(); } }
@Override @Nonnull public Iterable<? extends ChildNodeEntry> getChildNodeEntries() { if (treePermission.canReadAll()) { // everything is readable including ac-content -> no secure wrapper needed return state.getChildNodeEntries(); } else if (treePermission.canRead()) { Iterable<ChildNodeEntry> readable = transform( state.getChildNodeEntries(), new WrapChildEntryFunction()); return filter(readable, new IterableNodePredicate()); } else { return emptyList(); } }
@Override public boolean hasChildNode(@NotNull String name) { if (!state.hasChildNode(name)) { return false; } else if (treePermission.canReadAll()) { return true; } else { NodeState child = state.getChildNode(name); return treePermission.getChildPermission(name, child).canRead(); } }
@Override public boolean hasChildNode(@Nonnull String name) { if (!state.hasChildNode(name)) { return false; } else if (treePermission.canReadAll()) { return true; } else { NodeState child = state.getChildNode(name); return treePermission.getChildPermission(name, child).canRead(); } }
@Override public boolean hasChildNode(@NotNull String name) { if (!state.hasChildNode(name)) { return false; } else if (treePermission.canReadAll()) { return true; } else { NodeState child = state.getChildNode(name); return treePermission.getChildPermission(name, child).canRead(); } }
@Test(expected = UnsupportedOperationException.class) public void testCanReadAll() { noRecurse.canReadAll(); }
@NotNull @Override public NodeState getChildNode(@NotNull String name) { NodeState child = state.getChildNode(name); if (child.exists() && !treePermission.canReadAll()) { ChildNodeEntry entry = new MemoryChildNodeEntry(name, child); return new WrapChildEntryFunction().apply(entry).getNodeState(); } else { return child; } }
@NotNull @Override public NodeState getChildNode(@NotNull String name) { NodeState child = state.getChildNode(name); if (child.exists() && !treePermission.canReadAll()) { ChildNodeEntry entry = new MemoryChildNodeEntry(name, child); return new WrapChildEntryFunction().apply(entry).getNodeState(); } else { return child; } }
@Nonnull @Override public NodeState getChildNode(@Nonnull String name) { NodeState child = state.getChildNode(name); if (child.exists() && !treePermission.canReadAll()) { ChildNodeEntry entry = new MemoryChildNodeEntry(name, child); return new WrapChildEntryFunction().apply(entry).getNodeState(); } else { return child; } }
@Test public void testCanReadAll() { assertFalse(empty.canReadAll()); }
@Test public void testCanReadAll() { assertTrue(all.canReadAll()); }
@Test public void testCanReadAll() throws Exception { TreePermission tp = getTreePermission(accessSession, REPO_POLICY_PATH); assertFalse(tp.canReadAll()); }
@Test public void testCanReadAll2() throws Exception { TreePermission tp = getTreePermission(noAccessSession, REPO_POLICY_PATH); assertFalse(tp.canReadAll()); }
private void assertVersionPermission(@NotNull TreePermission tp, @NotNull String expectedPath, boolean canRead) throws Exception { assertTrue(tp instanceof VersionTreePermission); assertEquals(canRead, tp.canRead()); assertEquals(canRead, tp.canRead(PropertyStates.createProperty("any", "Value"))); assertEquals(canRead, tp.isGranted(Permissions.READ)); assertEquals(canRead, tp.isGranted(Permissions.READ, PropertyStates.createProperty("any", "Value"))); assertEquals(canRead, tp.canReadProperties()); assertFalse(tp.canReadAll()); VersionTreePermission vtp = (VersionTreePermission) tp; TreePermission delegatee = (TreePermission) vpField.get(vtp); Tree delegateeTree = (Tree) tpImplTree.get(delegatee); assertEquals(expectedPath, delegateeTree.getPath()); }