-
- /*
- * SESSION
- */
-
- class CmsContentSession implements ProvidedSession {
- private Subject subject;
- private Locale locale;
-
- public CmsContentSession(Subject subject, Locale locale) {
- this.subject = subject;
- this.locale = locale;
- }
-
- @Override
- public Content get(String path) {
- Map.Entry<String, ContentProvider> entry = partitions.floorEntry(path);
- String mountPath = entry.getKey();
- ContentProvider provider = entry.getValue();
- String relativePath = path.substring(mountPath.length());
- return provider.get(CmsContentSession.this, mountPath, relativePath);
- }
-
- @Override
- public Subject getSubject() {
- return subject;
+ public void initRootContentProvider(Path path) {
+ try {
+// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+// factory.setNamespaceAware(true);
+// factory.setXIncludeAware(true);
+// factory.setSchema(contentTypesManager.getSchema());
+//
+ DocumentBuilder dBuilder = typesManager.newDocumentBuilder();
+
+ Document document;
+// if (path != null && Files.exists(path)) {
+// InputSource inputSource = new InputSource(path.toAbsolutePath().toUri().toString());
+// inputSource.setEncoding(StandardCharsets.UTF_8.name());
+// // TODO public id as well?
+// document = dBuilder.parse(inputSource);
+// } else {
+ document = dBuilder.newDocument();
+ Element root = document.createElementNS(CrName.CR_NAMESPACE_URI, CrName.ROOT.get().toPrefixedString());
+
+ for (String prefix : typesManager.getPrefixes().keySet()) {
+// root.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLConstants.XMLNS_ATTRIBUTE + ":" + prefix,
+// contentTypesManager.getPrefixes().get(prefix));
+ DomUtils.addNamespace(root, prefix, typesManager.getPrefixes().get(prefix));
+ }
+
+ document.appendChild(root);
+
+ // write it
+ if (path != null) {
+ try (OutputStream out = Files.newOutputStream(path)) {
+ writeDom(document, out);
+ }
+ }
+// }
+
+ String mountPath = "/";
+ DomContentProvider contentProvider = new DomContentProvider(mountPath, document);
+ addProvider(contentProvider);
+ } catch (DOMException | IOException e) {
+ throw new IllegalStateException("Cannot init ACR root " + path, e);