@Test public void testGetBlobsPropertiesBlobList() throws Exception { DocumentModel doc = new DocumentModelImpl("/", "doc", "BlobInListDocument"); Map<String, Object> map1 = new HashMap<>(); map1.put("file", createBlob("test1.pdf")); Map<String, Object> map2 = new HashMap<>(); map2.put("file", createBlob("test2.pdf")); doc.setPropertyValue("bil:files", (Serializable) Arrays.asList(map1, map2)); List<Property> blobs; blobs = new BlobsExtractor().getBlobsProperties(doc); assertEquals(2, blobs.size()); assertEquals("test1.pdf", ((Blob) blobs.get(0).getValue()).getFilename()); assertEquals("test2.pdf", ((Blob) blobs.get(1).getValue()).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);  }