Magnolia HierarchyManager and Content are depreciated. How do I replicate functionality using Session and jcrNode?

StackOverflow https://stackoverflow.com/questions/14506605

문제

I'm trying to do some logic in my Spring controller where I route to a website node based on the template used in another website node.

I can use LifeTimeJCRSessionUtil.getHierarchyManager("website").getContent("mynodepath").getTemplate() to do this, but I see that the HierarchyManager and Content classes are depreciated.

I looked at the Session class, but I have thus far been unable to figure out how to get the Template id based on the jcrNode.

도움이 되었습니까?

해결책

You can use instead:

javax.jcr.Session jcrSession = LifeTimeJCRSessionUtil.getSession("website");
Node mynode = jcrSession.getNode("/my/node/path");
info.magnolia.cms.core.MetaData metaData = info.magnolia.jcr.util.MetaDataUtil.getMetaData(mynode);
String template = metaData.getTemplate();

Basically, instead of getHierarchyManager("website").getContent("mynodepath") you should use getSession("website").getNode("/my/node/path").

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top