@NotNull @Override public String getName() { return tree.getName(); }
@Override @NotNull public String getName() { return tree.getName(); }
@Override public boolean apply(Tree t) { String s = t.getName(); return s.equals(name) || s.startsWith(name + "["); } }
private static int getIndex(@NotNull Tree tree) { String name = tree.getName(); int i = name.lastIndexOf('['); return (i == -1) ? 1 : Integer.valueOf(name.substring(i+1, name.lastIndexOf(']'))); }
@Override public boolean matches(@NotNull Tree tree, @Nullable PropertyState property) { if (property != null) { return names.contains(property.getName()); } else { return names.contains(tree.getName()); } }
private Collection<PermissionEntry> loadPermissionEntries(@NotNull String path, @NotNull Tree tree) { Collection<PermissionEntry> ret = new TreeSet<>(); for (Tree ace : tree.getChildren()) { if (ace.getName().charAt(0) != 'c') { ret.add(createPermissionEntry(path, ace)); } } return ret; }
@Override public Map<String, RemoteTree> getChildren() { Map<String, RemoteTree> children = new HashMap<String, RemoteTree>(); for (Tree child : getFilteredChildren()) { if (depth < filters.getDepth()) { children.put(child.getName(), new ContentRemoteTree(child, depth + 1, filters, contentRemoteBinaries)); } else { children.put(child.getName(), null); } } return children; }
VersionTreePermission createChildPermission(@NotNull Tree versionTree) { TreePermission delegatee; if (JCR_FROZENNODE.equals(versionTree.getName()) || NT_NAMES.contains(TreeUtil.getPrimaryTypeName(versionTree))) { delegatee = versionablePermission; } else { delegatee = versionablePermission.getChildPermission(versionTree.getName(), treeProvider.asNodeState(versionTree)); } return new VersionTreePermission(versionTree, delegatee, treeProvider); }
@NotNull @Override public NodeDefinition getDefinition( @NotNull Tree parent, @NotNull Tree targetNode) throws RepositoryException { checkNotNull(parent); checkNotNull(targetNode); String name = dropIndexFromName(targetNode.getName()); EffectiveNodeType eff = getEffectiveNodeType(parent); return eff.getNodeDefinition(name, getEffectiveNodeType(targetNode)); }
private TreeType internalGetType(@NotNull Tree tree) { Tree t = tree; while (!t.isRoot()) { TreeType type = internalGetType(t.getName(), t); // stop walking up the hierarchy as soon as a special type is found if (TreeType.DEFAULT != type) { return type; } t = t.getParent(); } return TreeType.DEFAULT; }
@NotNull @Override public TreePermission getTreePermission(@NotNull Tree tree, @NotNull TreePermission parentPermission) { return getTreePermission(tree.getName()); }
public static void assertSequence(Iterable<Tree> trees, String... names) { List<String> expected = Lists.newArrayList(names); List<String> actual = Lists.newArrayList(); for (Tree t : trees) { actual.add(t.getName()); } assertEquals(expected.toString(), actual.toString()); }
private static Tree mockTree(@NotNull String name, @NotNull String ntName) { Tree t = Mockito.mock(Tree.class); when(t.getName()).thenReturn(name); when(t.getProperty(JcrConstants.JCR_PRIMARYTYPE)).thenReturn(PropertyStates.createProperty(JcrConstants.JCR_PRIMARYTYPE, ntName, Type.NAME)); return t; }
private static Tree mockTree(@NotNull String name, @NotNull String ntName) { Tree t = Mockito.mock(Tree.class); when(t.getName()).thenReturn(name); when(t.getProperty(JcrConstants.JCR_PRIMARYTYPE)).thenReturn(PropertyStates.createProperty(JcrConstants.JCR_PRIMARYTYPE, ntName, Type.NAME)); return t; }
@Test public void testGetInstanceFromTreeJcrRead() { Tree readPrivTree = Mockito.mock(Tree.class); when(readPrivTree.getName()).thenReturn(JCR_READ); assertEquals(PrivilegeBits.BUILT_IN.get(JCR_READ), PrivilegeBits.getInstance(readPrivTree)); }
private static TreeLocation createNonExistingTreeLocation(@NotNull String path) { String name = Text.getName(path); Tree nonExistingTree = Mockito.mock(Tree.class); when(nonExistingTree.exists()).thenReturn(false); when(nonExistingTree.getName()).thenReturn(name); when(nonExistingTree.getPath()).thenReturn(path); when(nonExistingTree.getChild(name)).thenReturn(nonExistingTree); return TreeLocation.create(nonExistingTree); }
@Before public void before() { existingTree = Mockito.mock(Tree.class); when(existingTree.exists()).thenReturn(true); when(existingTree.getName()).thenReturn(PathUtils.ROOT_NAME); when(existingTree.getPath()).thenReturn(PathUtils.ROOT_PATH); when(existingTree.hasProperty(JcrConstants.JCR_PRIMARYTYPE)).thenReturn(true); when(existingTree.getProperty(JcrConstants.JCR_PRIMARYTYPE)).thenReturn(PropertyStates.createProperty(JcrConstants.JCR_PRIMARYTYPE, "rep:root")); }
private void assertNodeName(Authorizable authorizable) throws RepositoryException { assertEquals(id, authorizable.getID()); String path = authorizable.getPath(); Tree tree = root.getTree(path); assertFalse(id.equals(tree.getName())); assertEquals(RandomAuthorizableNodeName.DEFAULT_LENGTH, tree.getName().length()); }
@Override public boolean check(MountedNodeStore mountedStore, Tree tree, ErrorHolder errorHolder, Context context) { String name = tree.getName(); String path = tree.getPath(); validate(mountedStore, errorHolder, context, name, path); for ( PropertyState prop : tree.getProperties() ) { String propName = prop.getName(); validate(mountedStore, errorHolder, context, propName, PathUtils.concat(tree.getPath(), propName)); } return true; }
@Test public void ruleOrder() throws Exception{ builder.indexRule("nt:unstructured"); builder.indexRule("nt:base"); Tree tree = TreeFactory.createTree(EMPTY_NODE.builder()); builder.build(tree); //Assert the order Iterator<Tree> children = tree.getChild("indexRules").getChildren().iterator(); assertEquals("nt:unstructured", children.next().getName()); assertEquals("nt:base", children.next().getName()); }