BlobCollector { public void collect(NodeDocument doc, Collection<ReferencedBlob> blobs) { for (String key : doc.keySet()) { if (!Utils.isPropertyName(key)) { continue; } Map<Revision, String> valueMap = doc.getLocalMap(key); for (String v : valueMap.values()) { if (v != null) { loadValue(v, blobs, doc.getPath().toString()); } } } } BlobCollector(DocumentNodeStore nodeStore); void collect(NodeDocument doc, Collection<ReferencedBlob> blobs);  }
@Test public void testCollect() throws Exception { NodeBuilder b1 = store.getRoot().builder(); List<ReferencedBlob> blobs = Lists.newArrayList(); b1.child("x").child("y"); store.merge(b1, EmptyHook.INSTANCE, CommitInfo.EMPTY); for(int i = 0; i < 2; i++){ b1 = store.getRoot().builder(); Blob b = store.createBlob(randomStream(i, 4096)); b1.child("x").child("y").setProperty("b" + i, b); blobs.add(new ReferencedBlob(b, "/x/y")); store.merge(b1, EmptyHook.INSTANCE, CommitInfo.EMPTY); } PropertyBuilder<Blob> p1 = PropertyBuilder.array(Type.BINARY) .setName("barr"); for(int i = 0; i < 2; i++){ Blob b = store.createBlob(randomStream(i, 4096)); p1.addValue(b); blobs.add(new ReferencedBlob(b, "/x/y")); } b1 = store.getRoot().builder(); b1.child("x").child("y").setProperty(p1.getPropertyState()); store.merge(b1, EmptyHook.INSTANCE, CommitInfo.EMPTY); for(int i = 0; i < 2; i++){ b1 = store.getRoot().builder(); Blob b = store.createBlob(randomStream(i+1, 4096)); b1.child("x").child("y").setProperty("b" + i, b); blobs.add(new ReferencedBlob(b, "/x/y")); store.merge(b1, EmptyHook.INSTANCE, CommitInfo.EMPTY); } NodeDocument doc = store.getDocumentStore().find(Collection.NODES, Utils.getIdFromPath("/x/y")); List<ReferencedBlob> collectedBlobs = Lists.newArrayList(); blobCollector.collect(doc, collectedBlobs); assertEquals(blobs.size(), collectedBlobs.size()); assertEquals(new HashSet<ReferencedBlob>(blobs), new HashSet<ReferencedBlob>(collectedBlobs)); }