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

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

Question

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.

Était-ce utile?

La solution

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").

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top