Skip to content
Permalink
Browse files
OAK-9757 : move isNodeNameLong check to addNode api of commitbuilder
  • Loading branch information
Rishabh Kumar committed May 23, 2022
1 parent 73562d8 commit e5074e3846d005fe2cd89c30d78a231e748b3bde
Showing 4 changed files with 10 additions and 16 deletions.
@@ -123,6 +123,11 @@ CommitBuilder addNode(@NotNull DocumentNodeState node)
checkNotNull(node);

Path path = node.getPath();

if (Utils.isNodeNameLong(path, nodeStore.getDocumentStore().getNodeNameLimit())) {
throw new DocumentStoreException("Node name is too long: " + path);
}

UpdateOp op = node.asOperation(revision);
if (operations.containsKey(path)) {
String msg = "Node already added: " + path;
@@ -414,11 +414,6 @@ public String toString() {
* @param revision the revision this node is created.
*/
UpdateOp asOperation(@NotNull Revision revision) {

if (Utils.isNodeNameLong(path, store.getDocumentStore().getNodeNameLimit())) {
throw new DocumentStoreException("Node name is too long: " + path);
}

String id = Utils.getIdFromPath(path);
UpdateOp op = new UpdateOp(id, true);
if (Utils.isIdFromLongPath(id)) {
@@ -155,11 +155,7 @@ public void addLongNameNodeState() {
Path path = Path.fromString(DocumentMK.LONG_PATH);
CommitBuilder builder = new CommitBuilder(ns, null);
builder.addNode(path);
Commit c = builder.build(ns.newRevision());
UpdateOp up = c.getUpdateOperationForNode(path);
UpdateOp.Operation op = up.getChanges().get(
new UpdateOp.Key("_deleted", c.getRevision()));
assertNotNull(op);
fail("should not reach this point");
}

@Test
@@ -20,6 +20,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.util.ArrayList;
import java.util.List;
@@ -249,12 +250,9 @@ public void queryWithNodeNameTooLong() {
DocumentStore docStore = openDocumentStore();
DocumentNodeStore store = builderProvider.newBuilder().setDocumentStore(docStore).setAsyncDelay(0).getNodeStore();
Revision rev = Revision.newRevision(0);
List<UpdateOp> inserts = Lists.newArrayList();
for (int i = 0; i < 2; i++) {
DocumentNodeState n = new DocumentNodeState(store, Path.fromString(DocumentMK.LONG_PATH + i),
new RevisionVector(rev));
inserts.add(n.asOperation(rev));
}
DocumentNodeState n = new DocumentNodeState(store, Path.fromString(DocumentMK.LONG_PATH), new RevisionVector(rev));
n.asOperation(rev);
fail("should not reach this point");
}

@Test

0 comments on commit e5074e3

Please sign in to comment.