]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - jcr/org.argeo.cms.jcr/src/org/argeo/cms/jcr/acr/JcrContentProvider.java
Clean up and refactor ACR and component register.
[lgpl/argeo-commons.git] / jcr / org.argeo.cms.jcr / src / org / argeo / cms / jcr / acr / JcrContentProvider.java
index f7bfd0949f422b5ce359111347c6e8723de1ca11..198a2a3ed4480054cc87e738d770c818489d2774 100644 (file)
@@ -12,11 +12,11 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.xml.namespace.NamespaceContext;
 
-import org.argeo.api.acr.Content;
-import org.argeo.api.acr.ContentUtils;
 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.argeo.cms.jcr.CmsJcrUtils;
 import org.argeo.jcr.JcrException;
 import org.argeo.jcr.JcrUtils;
@@ -32,6 +32,8 @@ public class JcrContentProvider implements ContentProvider, NamespaceContext {
 
        public void start(Map<String, String> properties) {
                mountPath = properties.get(CmsContentRepository.ACR_MOUNT_PATH_PROPERTY);
+               if ("/".equals(mountPath))
+                       throw new IllegalArgumentException("JCR content provider cannot be root /");
                Objects.requireNonNull(mountPath);
                adminSession = CmsJcrUtils.openDataAdminSession(jcrRepository, null);
        }
@@ -45,7 +47,7 @@ public class JcrContentProvider implements ContentProvider, NamespaceContext {
        }
 
        @Override
-       public Content get(ProvidedSession contentSession, String mountPath, String relativePath) {
+       public ProvidedContent get(ProvidedSession contentSession, String mountPath, String relativePath) {
                String jcrWorkspace = ContentUtils.getParentPath(mountPath)[1];
                String jcrPath = "/" + relativePath;
                return new JcrContent(contentSession, this, jcrWorkspace, jcrPath);
@@ -54,7 +56,7 @@ public class JcrContentProvider implements ContentProvider, NamespaceContext {
        public Session getJcrSession(ProvidedSession contentSession, String jcrWorkspace) {
                JcrSessionAdapter sessionAdapter = sessionAdapters.get(contentSession);
                if (sessionAdapter == null) {
-                       final JcrSessionAdapter newSessionAdapter = new JcrSessionAdapter(jcrRepository,
+                       final JcrSessionAdapter newSessionAdapter = new JcrSessionAdapter(jcrRepository, contentSession,
                                        contentSession.getSubject());
                        sessionAdapters.put(contentSession, newSessionAdapter);
                        contentSession.onClose().thenAccept((s) -> newSessionAdapter.close());