NodeStoreBinaryResourceProvider implements BinaryResourceProvider { public FluentIterable<BinaryResource> getBinaries(String path) { return new OakTreeTraverser() .preOrderTraversal(createReadOnlyTree(getNode(nodeStore.getRoot(), path))) .transform(new TreeToBinarySource()) .filter(notNull()); } NodeStoreBinaryResourceProvider(NodeStore nodeStore, BlobStore blobStore); FluentIterable<BinaryResource> getBinaries(String path);  }
@Test public void countBinaries() throws Exception { NodeBuilder builder = EMPTY_NODE.builder(); createFileNode(builder, "a", new IdBlob("hello", null), "text/plain"); createFileNode(builder, "b", new IdBlob("hello", "id1"), "text/plain"); createFileNode(builder.child("a2"), "c", new IdBlob("hello", "id2"), "text/foo") .setProperty(JcrConstants.JCR_ENCODING, "bar"); NodeStore store = new MemoryNodeStore(builder.getNodeState()); BlobStore blobStore = new MemoryBlobStore(); NodeStoreBinaryResourceProvider extractor = new NodeStoreBinaryResourceProvider(store, blobStore); assertEquals(2, extractor.getBinaries("/").size()); assertEquals(1, extractor.getBinaries("/a2").size()); BinaryResource bs = extractor.getBinaries("/a2").first().get(); assertEquals("text/foo", bs.getMimeType()); assertEquals("bar", bs.getEncoding()); assertEquals("id2", bs.getBlobId()); }
@Test public void csvGenerator() throws Exception { File csv = new File(temporaryFolder.getRoot(), "test.csv"); BlobStore blobStore = new MemoryBlobStore(); NodeBuilder builder = EMPTY_NODE.builder(); createFileNode(builder, "a", blobOf("foo", blobStore), "text/plain"); createFileNode(builder, "b", blobOf("hello", blobStore), "text/plain"); NodeStore store = new MemoryNodeStore(builder.getNodeState()); NodeStoreBinaryResourceProvider extractor = new NodeStoreBinaryResourceProvider(store, blobStore); CSVFileGenerator generator = new CSVFileGenerator(csv); generator.generate(extractor.getBinaries("/")); CSVFileBinaryResourceProvider csvbrp = new CSVFileBinaryResourceProvider(csv, blobStore); assertEquals(2, csvbrp.getBinaries("/").size()); csvbrp.close(); }