]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/acr/xml/DomContentProvider.java
Improve ACR search and edition
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / acr / xml / DomContentProvider.java
index f76d38ce07a338401452834a3541400892c5cccf..39d9c2a90b56d5a8483c9813fb5637e0b94dc7d3 100644 (file)
@@ -22,6 +22,7 @@ import org.argeo.api.acr.spi.ContentProvider;
 import org.argeo.api.acr.spi.ProvidedContent;
 import org.argeo.api.acr.spi.ProvidedSession;
 import org.argeo.cms.acr.CmsContentRepository;
+import org.argeo.cms.acr.ContentUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
@@ -57,16 +58,6 @@ public class DomContentProvider implements ContentProvider, NamespaceContext {
                };
        }
 
-//     @Override
-//     public Content get() {
-//             return new DomContent(this, document.getDocumentElement());
-//     }
-
-//     public Element createElement(String name) {
-//             return document.createElementNS(null, name);
-//
-//     }
-
        @Override
        public ProvidedContent get(ProvidedSession session, String relativePath) {
                if ("".equals(relativePath))
@@ -76,7 +67,8 @@ public class DomContentProvider implements ContentProvider, NamespaceContext {
                if (nodes.getLength() > 1)
                        throw new IllegalArgumentException("Multiple content found for " + relativePath + " under " + mountPath);
                if (nodes.getLength() == 0)
-                       throw new ContentNotFoundException("Path " + relativePath + " under " + mountPath + " was not found");
+                       throw new ContentNotFoundException(session, mountPath + "/" + relativePath,
+                                       "Path " + relativePath + " under " + mountPath + " was not found");
                Element element = (Element) nodes.item(0);
                return new DomContent(session, this, element);
        }
@@ -85,7 +77,7 @@ public class DomContentProvider implements ContentProvider, NamespaceContext {
                if (relativePath.startsWith("/"))
                        throw new IllegalArgumentException("Relative path cannot start with /");
                String xPathExpression = '/' + relativePath;
-               if ("/".equals(mountPath))
+               if (ContentUtils.SLASH_STRING.equals(mountPath)) // repository root
                        xPathExpression = "/" + CrName.root.qName() + xPathExpression;
                try {
                        NodeList nodes = (NodeList) xPath.get().evaluate(xPathExpression, document, XPathConstants.NODESET);
@@ -104,6 +96,7 @@ public class DomContentProvider implements ContentProvider, NamespaceContext {
                return nodes.getLength() != 0;
        }
 
+       @Override
        public void persist(ProvidedSession session) {
                if (mountPath != null) {
                        Content mountPoint = session.getMountPoint(mountPath);