@Override @CheckForNull public Status getStatus() { return tree.getStatus(); }
@Override @Nullable public Status getStatus() { return tree.getStatus(); }
@Override @Nullable public Status getStatus() { return tree.getStatus(); }
@NotNull private Iterator<String> getMixinTypeNames(@NotNull Tree tree) throws RepositoryException { Iterator<String> mixinNames = Collections.emptyIterator(); if (tree.hasProperty(JcrConstants.JCR_MIXINTYPES) || canReadMixinTypes(tree)) { mixinNames = TreeUtil.getNames(tree, JcrConstants.JCR_MIXINTYPES).iterator(); } else if (tree.getStatus() != Status.NEW) { // OAK-2441: for backwards compatibility with Jackrabbit 2.x try to // read the primary type from the underlying node state. mixinNames = TreeUtil.getNames( RootFactory.createReadOnlyRoot(sessionDelegate.getRoot()).getTree(tree.getPath()), JcrConstants.JCR_MIXINTYPES).iterator(); } return mixinNames; }
@Nonnull private Iterator<String> getMixinTypeNames(@Nonnull Tree tree) throws RepositoryException { Iterator<String> mixinNames = Collections.emptyIterator(); if (tree.hasProperty(JcrConstants.JCR_MIXINTYPES) || canReadProperty(tree, JcrConstants.JCR_MIXINTYPES)) { mixinNames = TreeUtil.getNames(tree, JcrConstants.JCR_MIXINTYPES).iterator(); } else if (tree.getStatus() != Status.NEW) { // OAK-2441: for backwards compatibility with Jackrabbit 2.x try to // read the primary type from the underlying node state. mixinNames = TreeUtil.getNames( RootFactory.createReadOnlyRoot(sessionDelegate.getRoot()).getTree(tree.getPath()), JcrConstants.JCR_MIXINTYPES).iterator(); } return mixinNames; }
@NotNull private Iterator<String> getMixinTypeNames(@NotNull Tree tree) throws RepositoryException { Iterator<String> mixinNames = Collections.emptyIterator(); if (tree.hasProperty(JcrConstants.JCR_MIXINTYPES) || canReadMixinTypes(tree)) { mixinNames = TreeUtil.getNames(tree, JcrConstants.JCR_MIXINTYPES).iterator(); } else if (tree.getStatus() != Status.NEW) { // OAK-2441: for backwards compatibility with Jackrabbit 2.x try to // read the primary type from the underlying node state. mixinNames = TreeUtil.getNames( RootFactory.createReadOnlyRoot(sessionDelegate.getRoot()).getTree(tree.getPath()), JcrConstants.JCR_MIXINTYPES).iterator(); } return mixinNames; }
@Nullable private String getPrimaryTypeName(@NotNull Tree tree) { String primaryTypeName = null; if (tree.hasProperty(JcrConstants.JCR_PRIMARYTYPE)) { primaryTypeName = TreeUtil.getPrimaryTypeName(tree); } else if (tree.getStatus() != Status.NEW) { // OAK-2441: for backwards compatibility with Jackrabbit 2.x try to // read the primary type from the underlying node state. primaryTypeName = TreeUtil.getPrimaryTypeName(RootFactory.createReadOnlyRoot(sessionDelegate.getRoot()).getTree(tree.getPath())); } return primaryTypeName; }
@Nullable private String getPrimaryTypeName(@NotNull Tree tree) { String primaryTypeName = null; if (tree.hasProperty(JcrConstants.JCR_PRIMARYTYPE)) { primaryTypeName = TreeUtil.getPrimaryTypeName(tree); } else if (tree.getStatus() != Status.NEW) { // OAK-2441: for backwards compatibility with Jackrabbit 2.x try to // read the primary type from the underlying node state. primaryTypeName = TreeUtil.getPrimaryTypeName(RootFactory.createReadOnlyRoot(sessionDelegate.getRoot()).getTree(tree.getPath())); } return primaryTypeName; }
@CheckForNull private String getPrimaryTypeName(@Nonnull Tree tree) { String primaryTypeName = null; if (tree.hasProperty(JcrConstants.JCR_PRIMARYTYPE)) { primaryTypeName = TreeUtil.getPrimaryTypeName(tree); } else if (tree.getStatus() != Status.NEW) { // OAK-2441: for backwards compatibility with Jackrabbit 2.x try to // read the primary type from the underlying node state. primaryTypeName = TreeUtil.getPrimaryTypeName(RootFactory.createReadOnlyRoot(sessionDelegate.getRoot()).getTree(tree.getPath())); } return primaryTypeName; }
if (protectedParent.getStatus() == Tree.Status.NEW) { if (a.isGroup()) { userManager.onCreate((Group) a);
@Test public void testDisconnectAfterRefresh() { Tree x = root.getTree("/x"); x.setProperty("p", "any"); Tree xx = x.addChild("xx"); xx.setProperty("q", "any"); assertEquals(Status.MODIFIED, x.getStatus()); assertEquals(Status.NEW, x.getPropertyStatus("p")); assertEquals(Status.NEW, xx.getStatus()); assertEquals(Status.NEW, xx.getPropertyStatus("q")); root.refresh(); assertEquals(Status.UNCHANGED, x.getStatus()); assertNull(x.getPropertyStatus("p")); assertFalse(xx.exists()); }
@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 purgePreservesStatus() throws CommitFailedException { Tree x = session.getLatestRoot().getTree("/x"); Tree added = x.addChild("added"); for (int k = 0; k < 10000; k++) { assertEquals("k=" + k, NEW, x.getChild("added").getStatus()); x.addChild("k" + k); } }
@Test public void moveExistingParent() throws CommitFailedException { Root root = session.getLatestRoot(); root.getTree("/").addChild("parent").addChild("new"); root.commit(); Tree parent = root.getTree("/parent"); Tree n = root.getTree("/parent/new"); root.move("/parent", "/moved"); assertEquals(Status.NEW, parent.getStatus()); assertEquals(Status.NEW, n.getStatus()); assertEquals("/moved", parent.getPath()); assertEquals("/moved/new", n.getPath()); }
@Test public void isNew() throws CommitFailedException { Tree tree = root.getTree("/"); tree.addChild("c"); root.commit(); tree.getChild("c").remove(); Tree c = tree.addChild("c"); assertEquals(Status.NEW, c.getStatus()); }
@Test public void nodeStatus() throws CommitFailedException { Tree tree = root.getTree("/"); tree.addChild("new"); assertEquals(Tree.Status.NEW, tree.getChild("new").getStatus()); root.commit(); assertEquals(Tree.Status.UNCHANGED, tree.getChild("new").getStatus()); Tree added = tree.getChild("new"); added.addChild("another"); assertEquals(Tree.Status.MODIFIED, tree.getChild("new").getStatus()); root.commit(); assertEquals(Tree.Status.UNCHANGED, tree.getChild("new").getStatus()); tree.getChild("new").getChild("another").remove(); assertEquals(Tree.Status.MODIFIED, tree.getChild("new").getStatus()); root.commit(); assertEquals(Tree.Status.UNCHANGED, tree.getChild("new").getStatus()); assertFalse(tree.getChild("new").getChild("another").exists()); Tree x = root.getTree("/x"); Tree y = x.addChild("y"); x.remove(); assertFalse(x.exists()); assertFalse(y.exists()); }
@Test public void rebasePreservesStatus() throws CommitFailedException { Root root1 = session.getLatestRoot(); Root root2 = session.getLatestRoot(); Tree x = root1.getTree("/x"); Tree added = x.addChild("added"); assertEquals(NEW, added.getStatus()); root2.getTree("/x").addChild("bar"); root2.commit(); root1.rebase(); assertTrue(x.hasChild("added")); assertEquals(NEW, x.getChild("added").getStatus()); assertTrue(x.hasChild("bar")); }
@Test public void testDisconnectAfterRemove() { Tree x = root.getTree("/x"); x.setProperty("p", "any"); Tree xx = x.addChild("xx"); xx.setProperty("q", "any"); assertEquals(Status.MODIFIED, x.getStatus()); assertEquals(Status.NEW, x.getPropertyStatus("p")); assertEquals(Status.NEW, xx.getStatus()); assertEquals(Status.NEW, xx.getPropertyStatus("q")); root.getTree("/x").remove(); assertFalse(x.exists()); assertFalse(xx.exists()); }
@Test public void moveRemoveAdd() { Root root = session.getLatestRoot(); Tree x = root.getTree("/x"); Tree z = root.getTree("/z"); z.setProperty("p", "1"); root.move("/z", "/x/z"); root.getTree("/x/z").remove(); assertFalse(z.exists()); x.addChild("z"); assertEquals(Status.NEW, z.getStatus()); x.getChild("z").setProperty("p", "2"); PropertyState p = z.getProperty("p"); assertNotNull(p); assertEquals("2", p.getValue(Type.STRING)); }