@Test public void testGetBlobsFromTwoSchemas() throws Exception { DocumentModel doc = new DocumentModelImpl("/", "doc", "BlobWithTwoSchemasContainingBlob"); doc.setPropertyValue("simpleblob:blob", (Serializable) createBlob("test1.pdf")); doc.setPropertyValue("simpleblob2:blob", (Serializable) createBlob("test2.pdf")); List<Property> blobs = new BlobsExtractor().getBlobsProperties(doc); assertEquals(2, blobs.size()); Blob blob = (Blob) blobs.get(0).getValue(); Blob blob2 = (Blob) blobs.get(1).getValue(); assertEquals(new HashSet<>(Arrays.asList("test1.pdf", "test2.pdf")), new HashSet<>(Arrays.asList(blob.getFilename(), blob2.getFilename()))); }
public List<Property> getBlobsProperties(DocumentModel doc) { List<Property> properties = new ArrayList<>(); for (String path : getBlobPaths(doc.getDocumentType())) { if (!isInterestingPath(path)) { continue; } List<String> split = Arrays.asList(path.split("/[*]/")); if (split.isEmpty()) { throw new IllegalStateException("Path detected not well-formed: " + path); } Property property = doc.getProperty(split.get(0)); List<String> subPath = split.subList(1, split.size()); findBlobsProperties(property, subPath, properties); } return properties; }
BlobsExtractor { public List<Property> getBlobsProperties(DocumentModel doc) { List<Property> properties = new ArrayList<>(); for (String path : getBlobPaths(doc.getDocumentType())) { if (!isInterestingPath(path)) { continue; } List<String> split = Arrays.asList(path.split("/[*]/")); if (split.isEmpty()) { throw new IllegalStateException("Path detected not well-formed: " + path); } Property property = doc.getProperty(split.get(0)); List<String> subPath = split.subList(1, split.size()); findBlobsProperties(property, subPath, properties); } return properties; } }
BlobsExtractor { public List<Property> getBlobsProperties(DocumentModel doc) { List<Property> properties = new ArrayList<>(); for (String path : getBlobPaths(doc.getDocumentType())) { if (!isInterestingPath(path)) { continue; } List<String> split = Arrays.asList(path.split("/[*]/")); if (split.isEmpty()) { throw new IllegalStateException("Path detected not well-formed: " + path); } Property property = doc.getProperty(split.get(0)); List<String> subPath = split.subList(1, split.size()); findBlobsProperties(property, subPath, properties); } return properties; }  }
BlobsExtractor { public List<Property> getBlobsProperties(DocumentModel doc) { List<Property> properties = new ArrayList<>(); for (String path : getBlobPaths(doc.getDocumentType())) { if (!isInterestingPath(path)) { continue; } List<String> split = Arrays.asList(path.split("/[*]/")); if (split.isEmpty()) { throw new IllegalStateException("Path detected not well-formed: " + path); } Property property = doc.getProperty(split.get(0)); List<String> subPath = split.subList(1, split.size()); findBlobsProperties(property, subPath, properties); } return properties; }  void setExtractorProperties(Set<String> includedPaths, Set<String> excludedPaths, boolean allBlobs); List<Blob> getBlobs(DocumentModel doc); List<Property> getBlobsProperties(DocumentModel doc); List<String> getBlobPaths(DocumentType documentType); }
BlobsExtractor { public List<Property> getBlobsProperties(DocumentModel doc) { List<Property> properties = new ArrayList<>(); for (String path : getBlobPaths(doc.getDocumentType())) { if (!isInterestingPath(path)) { continue; } List<String> split = Arrays.asList(path.split("/[*]/")); if (split.isEmpty()) { throw new IllegalStateException("Path detected not well-formed: " + path); } Property property = doc.getProperty(split.get(0)); List<String> subPath = split.subList(1, split.size()); findBlobsProperties(property, subPath, properties); } return properties; }  void setExtractorProperties(Set<String> includedPaths, Set<String> excludedPaths, boolean allBlobs); List<Blob> getBlobs(DocumentModel doc); List<Property> getBlobsProperties(DocumentModel doc); List<String> getBlobPaths(DocumentType documentType);  }