From 82046539dc06f6b13ddfe2fa1d87051445471477 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Tue, 23 Aug 2022 11:44:07 +0200 Subject: [PATCH] Get content path from JCR --- .../src/org/argeo/cms/jcr/acr/JcrContent.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/jcr/org.argeo.cms.jcr/src/org/argeo/cms/jcr/acr/JcrContent.java b/jcr/org.argeo.cms.jcr/src/org/argeo/cms/jcr/acr/JcrContent.java index ad90b2df7..b0326f48b 100644 --- a/jcr/org.argeo.cms.jcr/src/org/argeo/cms/jcr/acr/JcrContent.java +++ b/jcr/org.argeo.cms.jcr/src/org/argeo/cms/jcr/acr/JcrContent.java @@ -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 @@ -353,7 +373,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); } -- 2.30.2