@Override public synchronized void contentChanged(@NotNull NodeState root, @NotNull CommitInfo info) { EditorDiff.process(changeDetector, this.root, root); this.root = root; }
@Override public synchronized void contentChanged(@NotNull NodeState root, @NotNull CommitInfo info) { EditorDiff.process(changeDetector, this.root, root); this.root = root; }
@Override public void run() { EditorDiff.process( new VisibleEditor(TraversingEditor.INSTANCE), before, state); } });
@Override public void run() { EditorDiff.process( new VisibleEditor(TraversingEditor.INSTANCE), before, state); } });
private boolean diff(@Nonnull ImmutableTree source, @Nonnull ImmutableTree dest, @Nonnull MoveAwarePermissionValidator validator) throws CommitFailedException { Validator nextValidator = validator.visibleValidator(source, dest); CommitFailedException e = EditorDiff.process(nextValidator , source.getNodeState(), dest.getNodeState()); if (e != null) { throw e; } return true; }
private boolean diff(@NotNull Tree source, @NotNull Tree dest, @NotNull MoveAwarePermissionValidator validator) throws CommitFailedException { Validator nextValidator = validator.visibleValidator(source, dest); TreeProvider tp = validator.getTreeProvider(); CommitFailedException e = EditorDiff.process(nextValidator , tp.asNodeState(source), tp.asNodeState(dest)); if (e != null) { throw e; } return true; }
private boolean diff(@NotNull Tree source, @NotNull Tree dest, @NotNull MoveAwarePermissionValidator validator) throws CommitFailedException { Validator nextValidator = validator.visibleValidator(source, dest); TreeProvider tp = validator.getTreeProvider(); CommitFailedException e = EditorDiff.process(nextValidator , tp.asNodeState(source), tp.asNodeState(dest)); if (e != null) { throw e; } return true; }
@Override @NotNull public NodeState processCommit( @NotNull NodeState before, @NotNull NodeState after, @NotNull CommitInfo info) throws CommitFailedException { checkNotNull(before); checkNotNull(after); checkNotNull(info); NodeBuilder builder = after.builder(); Editor editor = provider.getRootEditor(before, after, builder, info); CommitFailedException exception = EditorDiff.process(editor, before, after); if (exception == null) { return builder.getNodeState(); } else { throw exception; } }
@Override @Nonnull public NodeState processCommit( @Nonnull NodeState before, @Nonnull NodeState after, @Nonnull CommitInfo info) throws CommitFailedException { checkNotNull(before); checkNotNull(after); checkNotNull(info); NodeBuilder builder = after.builder(); Editor editor = provider.getRootEditor(before, after, builder, info); CommitFailedException exception = EditorDiff.process(editor, before, after); if (exception == null) { return builder.getNodeState(); } else { throw exception; } }
public static Map<String, Set<String>> compare(NodeState before, NodeState after) { final TestValidator validator = new TestValidator(); EditorDiff.process(validator, before, after); return validator.actual; }
@Override public void enter(NodeState before, NodeState after) throws CommitFailedException { rootState.nodeRead(this); collectIndexEditors(builder.getChildNode(INDEX_DEFINITIONS_NAME), before); if (!reindex.isEmpty()) { log.info("Reindexing will be performed for following indexes: {}", reindex.keySet()); rootState.progressReporter.reindexingTraversalStart(getPath()); } // no-op when reindex is empty CommitFailedException exception = process( wrap(wrapProgress(compose(reindex.values()))), MISSING_NODE, after); rootState.progressReporter.reindexingTraversalEnd(); if (exception != null) { throw exception; } for (Editor editor : editors) { editor.enter(before, after); } }
@Override public void enter(NodeState before, NodeState after) throws CommitFailedException { rootState.nodeRead(this); collectIndexEditors(builder.getChildNode(INDEX_DEFINITIONS_NAME), before); if (!reindex.isEmpty()) { log.info("Reindexing will be performed for following indexes: {}", reindex.keySet()); rootState.progressReporter.reindexingTraversalStart(getPath()); } // no-op when reindex is empty CommitFailedException exception = process( wrap(wrapProgress(compose(reindex.values()))), MISSING_NODE, after); rootState.progressReporter.reindexingTraversalEnd(); if (exception != null) { throw exception; } for (Editor editor : editors) { editor.enter(before, after); } }
@Override public void enter(NodeState before, NodeState after) throws CommitFailedException { rootState.nodeRead(this); collectIndexEditors(builder.getChildNode(INDEX_DEFINITIONS_NAME), before); if (!reindex.isEmpty()) { log.info("Reindexing will be performed for following indexes: {}", reindex.keySet()); rootState.progressReporter.reindexingTraversalStart(getPath()); } // no-op when reindex is empty CommitFailedException exception = process( wrap(wrapProgress(compose(reindex.values()))), MISSING_NODE, after); rootState.progressReporter.reindexingTraversalEnd(); if (exception != null) { throw exception; } for (Editor editor : editors) { editor.enter(before, after); } }
EditorDiff.process(editor, MISSING_NODE, root);
/** * Test whether we can detect a single move * @throws CommitFailedException */ @Test public void simpleMove() throws CommitFailedException { NodeState moved1 = move(root.builder(), "/test/x", "/test/y/xx").getNodeState(); MoveExpectation moveExpectation1 = new MoveExpectation( ImmutableMap.of("/test/x", "/test/y/xx")); MoveDetector moveDetector1 = new MoveDetector(moveExpectation1); CommitFailedException exception1 = EditorDiff.process(moveDetector1, root, moved1); if (exception1 != null) { throw exception1; } moveExpectation1.assertAllFound(); // Test whether we can also detect the move back on top of the previous, persisted move NodeState moved2 = move(moved1.builder(), "/test/y/xx", "/test/x").getNodeState(); MoveExpectation moveExpectation2 = new MoveExpectation( ImmutableMap.of("/test/y/xx", "/test/x")); MoveDetector moveDetector2 = new MoveDetector(moveExpectation2); CommitFailedException exception2 = EditorDiff.process(moveDetector2, moved1, moved2); if (exception2 != null) { throw exception2; } moveExpectation2.assertAllFound(); }
/** * Moving a node forth and back again should not generate a move event. * @throws CommitFailedException */ @Test public void moveForthAndBack() throws CommitFailedException { NodeBuilder rootBuilder = root.builder(); move(rootBuilder, "/test/x", "/test/y/xx"); NodeState moved = move(rootBuilder, "/test/y/xx", "/test/x").getNodeState(); MoveExpectation moveExpectation = new MoveExpectation( ImmutableMap.<String, String>of()); MoveDetector moveDetector = new MoveDetector(moveExpectation); CommitFailedException exception = EditorDiff.process(moveDetector, root, moved); if (exception != null) { throw exception; } moveExpectation.assertAllFound(); }
/** * Moving a node from a moved subtree doesn't generate a move event. * @throws CommitFailedException */ @Test public void moveFromMovedSubtree() throws CommitFailedException { NodeBuilder rootBuilder = root.builder(); move(rootBuilder, "/test/z", "/test/y/z"); NodeState moved = move(rootBuilder, "/test/y/z/zz", "/test/x/zz").getNodeState(); MoveExpectation moveExpectation = new MoveExpectation( ImmutableMap.of("/test/z", "/test/y/z", "/test/z/zz", "/test/x/zz")); MoveDetector moveDetector = new MoveDetector(moveExpectation); CommitFailedException exception = EditorDiff.process(moveDetector, root, moved); if (exception != null) { throw exception; } moveExpectation.assertAllFound(); }
/** * Moving a transiently added node doesn't generate a move event * @throws CommitFailedException */ @Test public void moveAddedNode() throws CommitFailedException { NodeBuilder rootBuilder = root.builder(); rootBuilder.getChildNode("test").setChildNode("added"); NodeState moved = move(rootBuilder, "/test/added", "/test/y/added").getNodeState(); MoveExpectation moveExpectation = new MoveExpectation( ImmutableMap.<String, String>of()); MoveDetector moveDetector = new MoveDetector(moveExpectation); CommitFailedException exception = EditorDiff.process(moveDetector, root, moved); if (exception != null) { throw exception; } moveExpectation.assertAllFound(); }
/** * Moving a moved node is reported as a single move from the original source * to the final destination. * @throws CommitFailedException */ @Test public void moveMoved() throws CommitFailedException { NodeBuilder rootBuilder = root.builder(); move(rootBuilder, "/test/x", "/test/y/xx"); NodeState moved = move(rootBuilder, "/test/y/xx", "/test/z/xxx").getNodeState(); MoveExpectation moveExpectation = new MoveExpectation( ImmutableMap.of("/test/x", "/test/z/xxx")); MoveDetector moveDetector = new MoveDetector(moveExpectation); CommitFailedException exception = EditorDiff.process(moveDetector, root, moved); if (exception != null) { throw exception; } moveExpectation.assertAllFound(); }
/** * Moving a transiently added node from a moved subtree doesn't generate a move event. * @throws CommitFailedException */ @Test public void moveAddedFromMovedSubtree() throws CommitFailedException { NodeBuilder rootBuilder = root.builder(); rootBuilder.getChildNode("test").getChildNode("z").setChildNode("added"); move(rootBuilder, "/test/z", "/test/y/z"); NodeState moved = move(rootBuilder, "/test/y/z/added", "/test/x/added").getNodeState(); MoveExpectation moveExpectation = new MoveExpectation( ImmutableMap.of("/test/z", "/test/y/z")); MoveDetector moveDetector = new MoveDetector(moveExpectation); CommitFailedException exception = EditorDiff.process(moveDetector, root, moved); if (exception != null) { throw exception; } moveExpectation.assertAllFound(); }