Refine search
public void orderBefore(String source, String target) throws ItemNotFoundException, InvalidItemStateException { Tree tree = getTree(); if (!tree.getChild(source).exists()) { throw new ItemNotFoundException("Not a child: " + source); } else if (target != null && !tree.getChild(target).exists()) { throw new ItemNotFoundException("Not a child: " + target); } else { tree.getChild(source).orderBefore(target); } }
public boolean canAddMixin(String typeName) throws RepositoryException { Tree type = sessionDelegate.getRoot().getTree(NODE_TYPES_PATH).getChild(typeName); if (type.exists()) { return !TreeUtil.getBoolean(type, JCR_IS_ABSTRACT) && TreeUtil.getBoolean(type, JCR_ISMIXIN); } else { throw new NoSuchNodeTypeException( "Node type " + typeName + " does not exist"); } }
@Test public void noTransitiveModifiedStatus() throws CommitFailedException { Tree tree = root.getTree("/"); tree.addChild("one").addChild("two"); root.commit(); tree.getChild("one").getChild("two").addChild("three"); assertEquals(Tree.Status.UNCHANGED, tree.getChild("one").getStatus()); assertEquals(Tree.Status.MODIFIED, tree.getChild("one").getChild("two").getStatus()); }
@Test public void testGetAggregatedPrivilegeNamesNonExistingTree() { ImmutableSet<String> names = ImmutableSet.of(JCR_LOCK_MANAGEMENT, JCR_READ_ACCESS_CONTROL); when(pTree.getProperty(REP_AGGREGATES)).thenReturn(PropertyStates.createProperty(REP_AGGREGATES, names, Type.NAMES)); when(privTree.getChild(KNOWN_PRIV_NAME)).thenReturn(pTree); Iterable<String> result = bitsProvider.getAggregatedPrivilegeNames(KNOWN_PRIV_NAME); assertTrue(Iterables.isEmpty(result)); }
@Test public void testGetAggregatedPrivilegeNamesMissingAggProperty() { when(pTree.exists()).thenReturn(true); when(privTree.getChild(KNOWN_PRIV_NAME)).thenReturn(pTree); Iterable<String> result = bitsProvider.getAggregatedPrivilegeNames(KNOWN_PRIV_NAME); assertTrue(Iterables.elementsEqual(ImmutableList.of(KNOWN_PRIV_NAME), result)); }
@Test public void getChildrenCount() { Tree tree = root.getTree("/"); assertEquals(3, tree.getChildrenCount(4)); tree.getChild("x").remove(); assertEquals(2, tree.getChildrenCount(3)); tree.addChild("a"); assertEquals(3, tree.getChildrenCount(3)); tree.addChild("x"); assertEquals(4, tree.getChildrenCount(5)); }
@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()); }
static void assertMemberList(@NotNull Tree groupTree, int cntRefTrees, int cnt) { Tree list = groupTree.getChild(REP_MEMBERS_LIST); assertTrue(list.exists()); assertEquals(cntRefTrees, list.getChildrenCount(5)); for (Tree c : list.getChildren()) { PropertyState repMembers = c.getProperty(REP_MEMBERS); assertNotNull(repMembers); assertTrue(SIZE_TH == repMembers.count() || cnt == repMembers.count()); } }
@Test public void testVersionableWithUnsupportedType() throws Exception { Tree versionable = root.getTree("/content"); Tree vh = checkNotNull(versionManager.getVersionHistory(versionable)); Tree frozen = vh.getChild("1.0").getChild(JCR_FROZENNODE).getChild("a").getChild("b").getChild("c"); Tree invalidFrozen = frozen.addChild(REP_CUG_POLICY); invalidFrozen.setProperty(JCR_PRIMARYTYPE, NT_REP_CUG_POLICY); CugPermissionProvider pp = createCugPermissionProvider(ImmutableSet.of(SUPPORTED_PATH, SUPPORTED_PATH2)); TreePermission tp = getTreePermission(root, PathUtils.concat(vh.getPath(), "1.0", JCR_FROZENNODE, "a/b/c"), pp); TreePermission tpForUnsupportedType = pp.getTreePermission(invalidFrozen, TreeType.VERSION, tp); assertEquals(TreePermission.NO_RECOURSE, tpForUnsupportedType); }
@Test public void testGetChild() throws Exception { Tree rootTree = testRoot.getTree("/"); assertTrue(rootTree.exists()); Tree a = rootTree.getChild("a"); assertTrue(a.exists()); Tree b = a.getChild("b"); assertTrue(b.exists()); assertTrue(b.getChild("c").exists()); assertFalse(a.getChild("bb").exists()); }
@Test public void testGetAggregatedPrivilegeNamesNested() { ImmutableSet<String> values = ImmutableSet.of(JCR_READ, JCR_ADD_CHILD_NODES); when(pTree.getProperty(REP_AGGREGATES)).thenReturn(PropertyStates.createProperty(REP_AGGREGATES, values, Type.NAMES)); when(pTree.exists()).thenReturn(true); when(privTree.getChild(KNOWN_PRIV_NAME)).thenReturn(pTree); Iterable<String> result = bitsProvider.getAggregatedPrivilegeNames(KNOWN_PRIV_NAME); ImmutableSet<String> expected = ImmutableSet.of(REP_READ_NODES, REP_READ_PROPERTIES, JCR_ADD_CHILD_NODES); assertEquals(expected, ImmutableSet.copyOf(result)); }
public void orderBefore(String source, String target) throws ItemNotFoundException, InvalidItemStateException { Tree tree = getTree(); if (!tree.getChild(source).exists()) { throw new ItemNotFoundException("Not a child: " + source); } else if (target != null && !tree.getChild(target).exists()) { throw new ItemNotFoundException("Not a child: " + target); } else { tree.getChild(source).orderBefore(target); } }
public boolean canAddMixin(String typeName) throws RepositoryException { if (!LockDeprecation.isLockingSupported() && JcrConstants.MIX_LOCKABLE.equals(typeName)) { return false; } Tree type = sessionDelegate.getRoot().getTree(NODE_TYPES_PATH).getChild(typeName); if (type.exists()) { return !TreeUtil.getBoolean(type, JCR_IS_ABSTRACT) && TreeUtil.getBoolean(type, JCR_ISMIXIN); } else { throw new NoSuchNodeTypeException( "Node type " + typeName + " does not exist"); } }
@Test(expected = IllegalStateException.class) public void throwOnClosedTree() throws LoginException, NoSuchWorkspaceException, IOException { ContentSession session = repository.login(null, null); Root root = session.getLatestRoot(); Tree tree = root.getTree("/"); session.close(); tree.getChild("any"); } }
@Test public void testPrincipalNamesIndexDefinition() { Tree oakIndex = root.getTree('/' + IndexConstants.INDEX_DEFINITIONS_NAME); assertTrue(oakIndex.exists()); Tree externalPrincipalNames = oakIndex.getChild("externalPrincipalNames"); assertIndexDefinition(externalPrincipalNames, ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES, false); }