如何从 AEM 中的节点获取 "damFolderPath"?
How to get "damFolderPath" from a Node in AEM?
我正在使用 AEM 6.2 并尝试从节点的 "jcr:content" 获取 "damFolderPath" 值。
我试过这些:
//resourcePath = "/content/projects/newyear-1"
Resource resource = resourceResolver.getResource(resourcePath);
Node tNode = resource.adaptTo(Node.class);
Property prop = tNode.getProperty("jcr:content/damFolderPath");
log.info("\n...Output 1:"+tNode.hasProperty("damFolderPath"));
log.info("\n...Output 2:"+prop.toString());
输出 1:假
输出 2:属性[属性Delegate{parent=/content/projects/newyear-1/kms/jcr:content: { jcr:primaryType = nt:unstructured, detailsHref = /projects/details.html, jcr:title = kms, active = true, cq:template = /apps/swa/projects/templates/default, damFolderPath = /content/dam/projects/newyear-1/kms, coverUrl = /content/dam/projects/newyear-1/kms/cover, sling:resourceType = cq/gui/components/projects/admin/card/projectcontent, links = { ... }, dashboard = { ... }}, 属性= damFolderPath = /content/dam/projects/newyear-1/kms}]
我可以看到它在那里,但我如何从 output2 得到它?
您无需达到 JCR API 级别即可读取该值。
从 Sling 的角度来看,jcr:content
是一个可解析的资源。
String resourcePath = "/content/projects/newyear-1/jcr:content"
Resource jcrContentResource = resourceResolver.getResource(resourcePath);
ValueMap valueMap = jcrContentResource.getValueMap();
String damFolderPath = valueMap.get("damFolderPath", String.class);
如果出于某种原因,您坚持使用 JCR API,您在 输出 2 中看到的内容是 String
的默认表示Property
实现(由 toString()
返回)。
Property
接口允许您使用多个 type-specific 吸气剂之一获取 属性 的值。
prop.getString()
将为您找到路径 /content/dam/projects/newyear-1
另请参阅:getValue
、getDouble
、getBoolean
、getDate
等
我正在使用 AEM 6.2 并尝试从节点的 "jcr:content" 获取 "damFolderPath" 值。
我试过这些:
//resourcePath = "/content/projects/newyear-1"
Resource resource = resourceResolver.getResource(resourcePath);
Node tNode = resource.adaptTo(Node.class);
Property prop = tNode.getProperty("jcr:content/damFolderPath");
log.info("\n...Output 1:"+tNode.hasProperty("damFolderPath"));
log.info("\n...Output 2:"+prop.toString());
输出 1:假
输出 2:属性[属性Delegate{parent=/content/projects/newyear-1/kms/jcr:content: { jcr:primaryType = nt:unstructured, detailsHref = /projects/details.html, jcr:title = kms, active = true, cq:template = /apps/swa/projects/templates/default, damFolderPath = /content/dam/projects/newyear-1/kms, coverUrl = /content/dam/projects/newyear-1/kms/cover, sling:resourceType = cq/gui/components/projects/admin/card/projectcontent, links = { ... }, dashboard = { ... }}, 属性= damFolderPath = /content/dam/projects/newyear-1/kms}]
我可以看到它在那里,但我如何从 output2 得到它?
您无需达到 JCR API 级别即可读取该值。
从 Sling 的角度来看,jcr:content
是一个可解析的资源。
String resourcePath = "/content/projects/newyear-1/jcr:content"
Resource jcrContentResource = resourceResolver.getResource(resourcePath);
ValueMap valueMap = jcrContentResource.getValueMap();
String damFolderPath = valueMap.get("damFolderPath", String.class);
如果出于某种原因,您坚持使用 JCR API,您在 输出 2 中看到的内容是 String
的默认表示Property
实现(由 toString()
返回)。
Property
接口允许您使用多个 type-specific 吸气剂之一获取 属性 的值。
prop.getString()
将为您找到路径 /content/dam/projects/newyear-1
另请参阅:getValue
、getDouble
、getBoolean
、getDate
等