noisebelt
noisebelt

Reputation: 1030

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

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.

Upvotes: 0

Views: 958

Answers (1)

Vlad Andronache
Vlad Andronache

Reputation: 333

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

Upvotes: 2

Related Questions