Improve ACR.
[lgpl/argeo-commons.git] / jcr / org.argeo.cms.jcr / src / org / argeo / cms / jcr / acr / JcrContentProvider.java
index 198a2a3ed4480054cc87e738d770c818489d2774..235e27d1a922139558d8e8c42da322199340dda5 100644 (file)
@@ -12,6 +12,7 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.xml.namespace.NamespaceContext;
 
+import org.argeo.api.acr.Content;
 import org.argeo.api.acr.spi.ContentProvider;
 import org.argeo.api.acr.spi.ProvidedContent;
 import org.argeo.api.acr.spi.ProvidedSession;
@@ -47,12 +48,19 @@ public class JcrContentProvider implements ContentProvider, NamespaceContext {
        }
 
        @Override
-       public ProvidedContent get(ProvidedSession contentSession, String mountPath, String relativePath) {
+       public ProvidedContent get(ProvidedSession contentSession, String relativePath) {
                String jcrWorkspace = ContentUtils.getParentPath(mountPath)[1];
                String jcrPath = "/" + relativePath;
                return new JcrContent(contentSession, this, jcrWorkspace, jcrPath);
        }
 
+       @Override
+       public boolean exists(ProvidedSession contentSession, String relativePath) {
+               String jcrWorkspace = ContentUtils.getParentPath(mountPath)[1];
+               String jcrPath = "/" + relativePath;
+               return new JcrContent(contentSession, this, jcrWorkspace, jcrPath).exists();
+       }
+
        public Session getJcrSession(ProvidedSession contentSession, String jcrWorkspace) {
                JcrSessionAdapter sessionAdapter = sessionAdapters.get(contentSession);
                if (sessionAdapter == null) {
@@ -67,6 +75,10 @@ public class JcrContentProvider implements ContentProvider, NamespaceContext {
                return jcrSession;
        }
 
+       public Session getJcrSession(Content content, String jcrWorkspace) {
+               return getJcrSession(((ProvidedContent) content).getSession(), jcrWorkspace);
+       }
+
        @Override
        public String getMountPath() {
                return mountPath;