private NodeBuilder getConflictMarker(ConflictType conflictType) { final String conflictName = conflictType.getName(); if (target.hasChildNode(CONFLICT)) { NodeBuilder conflict = target.child(CONFLICT); if (conflict.hasChildNode(conflictName)) { return conflict.child(conflictName); } } return null; }
public static void setupNamespaces(NodeBuilder system) { if (!system.hasChildNode(REP_NAMESPACES)) { NodeBuilder namespaces = createStandardMappings(system); buildIndexNode(namespaces); // index node for faster lookup } }
public static void setupNamespaces(NodeBuilder system) { if (!system.hasChildNode(REP_NAMESPACES)) { NodeBuilder namespaces = createStandardMappings(system); buildIndexNode(namespaces); // index node for faster lookup } }
@Override public boolean childNodeChanged(String name, NodeState before, NodeState after) { if (builder.hasChildNode(name)) { after.compareAgainstBaseState(before, createDiff(builder, name)); } else if (after.equals(before)) { return false; } else { changeDeletedNode(builder, name, after, before); } return true; }
public static NodeBuilder getOrCreateOakIndex(NodeBuilder root) { NodeBuilder index; if (!root.hasChildNode(INDEX_DEFINITIONS_NAME)) { index = root.child(INDEX_DEFINITIONS_NAME); // TODO: use property node type name index.setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, NAME); } else { index = root.child(INDEX_DEFINITIONS_NAME); } return index; }
public static NodeBuilder getOrCreateOakIndex(NodeBuilder root) { NodeBuilder index; if (!root.hasChildNode(INDEX_DEFINITIONS_NAME)) { index = root.child(INDEX_DEFINITIONS_NAME); // TODO: use property node type name index.setProperty(JCR_PRIMARYTYPE, NT_UNSTRUCTURED, NAME); } else { index = root.child(INDEX_DEFINITIONS_NAME); } return index; }
@Override public boolean childNodeAdded(String name, NodeState after) { if (builder.hasChildNode(name)) { after.compareAgainstBaseState(EMPTY_NODE, createDiff(builder, name)); } else { builder.setChildNode(name, after); } return true; }
@Test public void testConnectOnAddNode() { NodeBuilder root = base.builder(); NodeBuilder childA = root.child("x"); NodeBuilder childB = root.child("x"); assertFalse(childA.hasChildNode("test")); assertFalse(childB.hasChildNode("test")); childB.child("test"); assertTrue(childA.hasChildNode("test")); assertTrue(childB.hasChildNode("test")); }
@Test public void testReset() { NodeBuilder root = base.builder(); NodeBuilder child = root.child("x"); child.child("new"); assertTrue(child.hasChildNode("new")); assertTrue(root.child("x").hasChildNode("new")); ((MemoryNodeBuilder) root).reset(base); assertFalse(child.hasChildNode("new")); assertFalse(root.child("x").hasChildNode("new")); }
@Override public boolean hasChildNode(String name) { String childPath = simpleConcat(getPath(), name); MountedNodeStore mountedStore = ctx.getOwningStore(childPath); return nodeBuilders.get(mountedStore).hasChildNode(name); }
@Override public boolean childNodeDeleted(String name, NodeState before) { if (!builder.hasChildNode(name)) { deleteDeletedNode(builder, name, before); } else if (before.equals(builder.child(name).getNodeState())) { builder.getChildNode(name).remove(); } else { deleteChangedNode(builder, name, before); } return true; }
@Override public void enter(NodeState before, NodeState after) { NodeBuilder stuff = builder.child(parentName); for (int i = 0; i < numChanges; i++) { String name = "n-" + i; assertFalse(stuff.hasChildNode(name)); stuff.child(name); } } }
@Test public void builderHasPropertyNameInRootStore() { assertFalse("Node 'nope' does not exist", store.getRoot().builder().hasChildNode("nope")); assertTrue("Node 'tmp' should exist (contributed by mount)", store.getRoot().builder().hasChildNode("tmp")); assertTrue("Node 'libs' should exist (contributed by root)", store.getRoot().builder().hasChildNode("libs")); }
@Test public void rename() { NodeBuilder test = store.getRoot().builder().getChildNode("test"); NodeBuilder x = test.getChildNode("x"); assertTrue(x.moveTo(test, "xx")); assertFalse(x.exists()); assertFalse(test.hasChildNode("x")); assertTrue(test.hasChildNode("xx")); }
@Test public void builderStateIsUpdatedBeforeMergeinMountedStore() throws Exception { NodeBuilder builder = store.getRoot().getChildNode("tmp").builder(); builder.child("newChild"); assertTrue("Newly created node should be visible in the builder's node state", builder.hasChildNode("newChild")); }
@Test public void resetOnGlobalStore() { NodeBuilder builder = store.getRoot().builder(); builder.child("newChild"); store.reset(builder); assertFalse("Newly added child should no longer be visible after reset", builder.hasChildNode("newChild")); }
@Test public void nestedBuilderFromState() throws Exception { NodeState rootState = store.getRoot(); NodeBuilder rootBuilder = rootState.builder(); rootBuilder.child("newNode"); NodeState baseState = rootBuilder.getNodeState(); NodeBuilder builderFromState = baseState.builder(); assertTrue(builderFromState.hasChildNode("newNode")); }
@Test public void move() { NodeBuilder test = store.getRoot().builder().getChildNode("test"); NodeBuilder x = test.getChildNode("x"); NodeBuilder y = test.getChildNode("y"); assertTrue(x.moveTo(y, "xx")); assertFalse(x.exists()); assertTrue(y.exists()); assertFalse(test.hasChildNode("x")); assertTrue(y.hasChildNode("xx")); }
@Test public void renameNonExisting() { NodeBuilder test = store.getRoot().builder().getChildNode("test"); NodeBuilder any = test.getChildNode("any"); assertFalse(any.moveTo(test, "xx")); assertFalse(any.exists()); assertFalse(test.hasChildNode("xx")); }
@Test public void moveToSelf() { NodeBuilder test = store.getRoot().builder().getChildNode("test"); NodeBuilder x = test.getChildNode("x"); assertFalse(x.moveTo(test, "x")); assertTrue(x.exists()); assertTrue(test.hasChildNode("x")); }