Improve ACR
[lgpl/argeo-commons.git] / jcr / org.argeo.cms.jcr / src / org / argeo / cms / jcr / acr / JcrContent.java
index 41672a0e9e24b68ca9ca0a49f64776330d2948d7..a4af35bc671437ad6b3d9d587817181a9ab7a480 100644 (file)
@@ -178,6 +178,26 @@ public class JcrContent extends AbstractContent {
 
        }
 
+       @Override
+       public String getPath() {
+               try {
+                       // Note: it is important to to use the default way (recursing through parents),
+                       // since the session may not have access to parent nodes
+                       return ContentUtils.ROOT_SLASH + jcrWorkspace + getJcrNode().getPath();
+               } catch (RepositoryException e) {
+                       throw new JcrException("Cannot get depth of " + getJcrNode(), e);
+               }
+       }
+
+       @Override
+       public int getDepth() {
+               try {
+                       return getJcrNode().getDepth() + 1;
+               } catch (RepositoryException e) {
+                       throw new JcrException("Cannot get depth of " + getJcrNode(), e);
+               }
+       }
+
        @Override
        public Content getParent() {
                if (Jcr.isRoot(getJcrNode())) // root
@@ -291,7 +311,7 @@ public class JcrContent extends AbstractContent {
         * TYPING
         */
        @Override
-       public List<QName> getTypes() {
+       public List<QName> getContentClasses() {
                try {
 //                     Node node = getJcrNode();
 //                     List<QName> res = new ArrayList<>();
@@ -341,6 +361,11 @@ public class JcrContent extends AbstractContent {
                return QName.valueOf(name);
        }
 
+       @Override
+       public int getSiblingIndex() {
+               return Jcr.getIndex(getJcrNode());
+       }
+
        /*
         * STATIC UTLITIES
         */
@@ -353,7 +378,7 @@ public class JcrContent extends AbstractContent {
                        if (contentSession == null)
                                throw new IllegalArgumentException(
                                                "Cannot adapt " + node + " to content, because it was not loaded from a content session");
-                       return contentSession.get(CmsConstants.SYS_WORKSPACE + node.getPath());
+                       return contentSession.get(ContentUtils.SLASH + CmsConstants.SYS_WORKSPACE + node.getPath());
                } catch (RepositoryException e) {
                        throw new JcrException("Cannot adapt " + node + " to a content", e);
                }