@Override public void update(Supplier<NodeBuilder> index, String path, String indexName, NodeBuilder indexMeta, Set<String> beforeKeys, Set<String> afterKeys) throws CommitFailedException { if (filter.apply(path)) { if (readOnly) { throw new CommitFailedException( CommitFailedException.UNSUPPORTED, 0, "Unsupported commit to a read-only store!", new Throwable("Commit path: " + path)); } strategy.update(index, path, indexName, indexMeta, beforeKeys, afterKeys); } }
@Override public void update(Supplier<NodeBuilder> index, String path, String indexName, NodeBuilder indexMeta, Set<String> beforeKeys, Set<String> afterKeys) throws CommitFailedException { if (filter.apply(path)) { if (readOnly) { throw new CommitFailedException( CommitFailedException.UNSUPPORTED, 0, "Unsupported commit to a read-only store!", new Throwable("Commit path: " + path)); } strategy.update(index, path, indexName, indexMeta, beforeKeys, afterKeys); } }
@Override public void update(Supplier<NodeBuilder> index, String path, String indexName, NodeBuilder indexMeta, Set<String> beforeKeys, Set<String> afterKeys) throws CommitFailedException { if (filter.apply(path)) { if (readOnly) { throw new CommitFailedException( CommitFailedException.UNSUPPORTED, 0, "Unsupported commit to a read-only store!", new Throwable("Commit path: " + path)); } strategy.update(index, path, indexName, indexMeta, beforeKeys, afterKeys); } }
private void update(Set<IndexStoreStrategy> refStores, NodeBuilder definition, String name, String key, Set<String> add, Set<String> rm) throws CommitFailedException { for (IndexStoreStrategy store : refStores) { Set<String> empty = of(); for (String p : rm) { Supplier<NodeBuilder> index = memoize(() -> definition.child(store.getIndexNodeName())); store.update(index, p, name, definition, of(key), empty); } for (String p : add) { // TODO do we still need to encode the values? Supplier<NodeBuilder> index = memoize(() -> definition.child(store.getIndexNodeName())); store.update(index, p, name, definition, empty, of(key)); } } }
private void update(Set<IndexStoreStrategy> refStores, NodeBuilder definition, String name, String key, Set<String> add, Set<String> rm) throws CommitFailedException { for (IndexStoreStrategy store : refStores) { Set<String> empty = of(); for (String p : rm) { Supplier<NodeBuilder> index = memoize(() -> definition.child(store.getIndexNodeName())); store.update(index, p, name, definition, of(key), empty); } for (String p : add) { // TODO do we still need to encode the values? Supplier<NodeBuilder> index = memoize(() -> definition.child(store.getIndexNodeName())); store.update(index, p, name, definition, empty, of(key)); } } }
private void update(Set<IndexStoreStrategy> refStores, NodeBuilder definition, String name, String key, Set<String> add, Set<String> rm) throws CommitFailedException { for (IndexStoreStrategy store : refStores) { Set<String> empty = of(); for (String p : rm) { Supplier<NodeBuilder> index = memoize(() -> definition.child(store.getIndexNodeName())); store.update(index, p, name, definition, of(key), empty); } for (String p : add) { // TODO do we still need to encode the values? Supplier<NodeBuilder> index = memoize(() -> definition.child(store.getIndexNodeName())); store.update(index, p, name, definition, empty, of(key)); } } }
afterKeys, roBuilder, strategy)); strategy.update(index, getPath(), properties, definition, beforeKeys, afterKeys);
afterKeys, roBuilder, strategy)); strategy.update(index, getPath(), properties, definition, beforeKeys, afterKeys);
afterKeys, roBuilder, strategy)); strategy.update(index, getPath(), properties, definition, beforeKeys, afterKeys);
@Test public void testUnique() throws CommitFailedException { IndexStoreStrategy store = new ContentMirrorStoreStrategy(); NodeState root = EMPTY_NODE; NodeBuilder indexMeta = root.builder(); Supplier<NodeBuilder> index = memoize(() -> indexMeta.child(INDEX_CONTENT_NODE_NAME)); store.update(index, "a", null, null, EMPTY, KEY); store.update(index, "b", null, null, EMPTY, KEY); Assert.assertTrue( "ContentMirrorStoreStrategy should guarantee uniqueness on insert", store.count(root, indexMeta.getNodeState(), Collections.singleton("key"), 2) > 1); }
store.update(index, path, null, null, EMPTY, KEY); store.update(index, "/", null, null, KEY, EMPTY); checkPath(builder, "key", "d/e/f", true); store.update(index, "d/e", null, null, KEY, EMPTY); checkPath(builder, "key", "d/e/f", true); store.update(index, "d/e/f", null, null, KEY, EMPTY); checkNotPath(builder, "key", "d"); store.update(index, "a/b/d", null, null, KEY, EMPTY); store.update(index, "a/b", null, null, KEY, EMPTY); checkPath(builder, "key", "a/b/c", true); store.update(index, "", null, null, EMPTY, KEY); store.update(index, "d/e/f", null, null, KEY, EMPTY); store.update(index, "b", null, null, KEY, EMPTY); store.update(index, "a/b/c", null, null, KEY, EMPTY); store.update(index, "", null, null, KEY, EMPTY); Assert.assertEquals(0, builder.getChildNodeCount(1));
@Test public void nonRootStorage() throws Exception{ IndexStoreStrategy store = new ContentMirrorStoreStrategy(INDEX_CONTENT_NODE_NAME, "/content", false); NodeState root = EMPTY_NODE; NodeBuilder builder = root.builder(); Supplier<NodeBuilder> index = () -> builder; for (String path : asList("a", "a/c", "b")) { store.update(index, path, null, null, EMPTY, KEY); } FilterImpl filter = FilterImpl.newTestInstance(); filter.restrictPath("/content", Filter.PathRestriction.ALL_CHILDREN); NodeBuilder indexMeta = EMPTY_NODE.builder(); indexMeta.setChildNode(INDEX_CONTENT_NODE_NAME, builder.getNodeState()); Iterable<String> paths = store.query(filter, null, indexMeta.getNodeState(), KEY); assertThat(copyOf(paths), containsInAnyOrder("a", "a/c", "b")); FilterImpl filter2 = FilterImpl.newTestInstance(); filter2.restrictPath("/content/a", Filter.PathRestriction.ALL_CHILDREN); paths = store.query(filter2, null, indexMeta.getNodeState(), KEY); assertThat(copyOf(paths), containsInAnyOrder("a", "a/c")); store = new ContentMirrorStoreStrategy(INDEX_CONTENT_NODE_NAME, "/content", true); paths = store.query(filter, null, indexMeta.getNodeState(), KEY); assertThat(copyOf(paths), containsInAnyOrder("/content/a", "/content/a/c", "/content/b")); paths = store.query(filter2, null, indexMeta.getNodeState(), KEY); assertThat(copyOf(paths), containsInAnyOrder("/content/a", "/content/a/c")); }