public static void copyFiles(Node folder, Content collection, String... additionalCollectionTypes) {
try {
+ log.debug("Copy collection " + collection);
nodes: for (NodeIterator it = folder.getNodes(); it.hasNext();) {
Node node = it.nextNode();
String name = node.getName();
}
QName qName = NamespaceUtils.parsePrefixedName(name);
- if (NamespaceUtils.hasNamespace(qName)) {
- if (node.getIndex() > 1) {
- log.warn("Same name siblings not supported, skipping " + node);
- continue nodes;
- }
- Content content = collection.add(qName, qName);
- Source source = toSource(node);
- ((ProvidedContent) content).getSession().edit((s) -> {
- ((ProvidedSession) s).notifyModification((ProvidedContent) content);
- content.write(Source.class).complete(source);
-// ContentUtils.traverse(content,
-// (c, depth) -> ContentUtils.print(c, System.out, depth, false));
- }).toCompletableFuture().join();
-
- } else {
- // ignore
- log.debug(() -> "Ignored " + node);
+// if (NamespaceUtils.hasNamespace(qName)) {
+ if (node.getIndex() > 1) {
+ log.warn("Same name siblings not supported, skipping " + node);
continue nodes;
}
+ Content content = collection.add(qName, qName);
+ Source source = toSource(node);
+ ((ProvidedContent) content).getSession().edit((s) -> {
+ ((ProvidedSession) s).notifyModification((ProvidedContent) content);
+ content.write(Source.class).complete(source);
+ }).toCompletableFuture().join();
+
+// } else {
+// // ignore
+// log.debug(() -> "Ignored " + node);
+// continue nodes;
+// }
}
}
} catch (RepositoryException e) {
}
}
- private static Source toSource(Node node) {
+ private static Source toSource(Node node) throws RepositoryException {
+
+// try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
+// node.getSession().exportDocumentView(node.getPath(), out, true, false);
+// DocumentBuilder documentBuilder = DocumentBuilderFactory.newNSInstance().newDocumentBuilder();
+// Document document;
+// try (ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray())) {
+// document = documentBuilder.parse(in);
+// }
+// cleanJcrDom(document);
+// return new DOMSource(document);
+// } catch (IOException | SAXException | ParserConfigurationException e) {
+// throw new RuntimeException(e);
+// }
+
try (PipedInputStream in = new PipedInputStream();) {
CompletableFuture<Document> toDo = CompletableFuture.supplyAsync(() -> {