Trying to find a great-uncle node

We have a directory hierarchy something like:

/
±- Market News/
±- Broadband/
±- Credit Cards/
±- Credit Cards navon
±- Credit Cards RSS feed XML
±- 2007 Q1/
| ±- Article 1
| ±- Article 2
|
±- 2007 Q2/
±- Article 3
etc.

From the Global Template, in the context of any of the articles, I’m trying to get to the RSS feed, so I can add an autodiscovery <link rel=“alternate”/> tag to the header.

I have a macro:

#macro(GetRssFeeds $node)
#set ($parentNode = $node.getParent())
#set ($parentAxis = $parentNode.getProperty(“nav:axis”).String)
#set ($parentDepth = $parentNode.getDepth())

#if (($parentAxis == “ANCESTOR” || $parentAxis == “PARENT”) && $parentDepth == 2)
#set ($rssNode = $parentNode.getNode(“RSS”))

  #if ($rssNode)
     &lt;p&gt;[$rssNode]&lt;/p&gt;
  #else
     &lt;p&gt;Could not find RSS node&lt;/p&gt;
  #end
  ## &lt;link rel="alternate" type="text/xml" title="RSS 2.0" src="$rx.location.generate(...)" /&gt;

#else
#GetRssFeeds($parentNode)
#end
#end

Now I’d expect this either to tell me that it can’t find the node or to put some sort of debugging information in from <p>[$rssNode]</p>.

Instead, however, I’m getting a deeply unhelpful error message:

Problem assembling output for item: 1-101-5045 with template: uswGtUKMarketNews exception: com.percussion.utils.jsr170.PSNodeIterator see log for stack trace

With no stack trace to be found anywhere.

Firstly, can anyone divine from this what’s actually going on? Secondly, how do I get it to work? :confused:

All suggestions gratefully received!

Owen

Owen,

I believe that you can only use the nav:axis in a navigation template (that is, one found by the Nav Slot Content Finder) not on a Global Template.

As for the log, look at

/Rhythmyx/AppServer/server/rx/log/server.log.

This file should contain all of your error trace information.

Dave

I don’t believe that’s the problem, as it’s entering the #if condition, it’s erroring on the Node.getNode call (it wasn’t erroring before I added that line). I just can’t work out how to get the Node: it should be coming straight back from Node.getNode(String), which returns type Node, but isn’t.

[QUOTE=dbenua;470]As for the log, look at

/Rhythmyx/AppServer/server/rx/log/server.log.

This file should contain all of your error trace information.[/QUOTE]

Forget that part of my query — it is in the console.log, I was looking on the wrong machine :blush:

Fwiw, the stack trace begins:

2007-09-11 09:08:41,900 ERROR [PSVelocityAssembler] Problem assembling output for item: 1-101-5045 with template: uswGtUKMarketNews
java.lang.ClassCastException: com.percussion.utils.jsr170.PSNodeIterator
at $Proxy112.getNode(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:267)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:197)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:175)
at org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:327)
at org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:51)
at org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:95)
at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:55)
at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:70)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230)
at org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:172)
at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:114)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:230)
at org.apache.velocity.Template.merge(Template.java:256)
at com.percussion.services.assembly.impl.plugin.PSVelocityAssembler.assembleSingle(Unknown Source)

I’m still having some problems with this. I’ve had some help from Percussion, which have led me to an all-new problem.

My macro now reads:

#macro(GetRssFeeds $node)
#if ($node.getParent())
#set ($parent = $node.getParent())
#if ($parent.getParent())
#set ($grandparent = $parent.getParent())
#set ($counter = 0)
#foreach($n in $grandparent.getNodes())
#set ($counter = $counter + 1)
#if ($n.getProperty(“rx:displaytitle”).String.indexOf(“RSS”) > 0)
<!-- [[COLOR=“red”]$n] -->[/COLOR]
#else
<!-- Node [[COLOR=“red”]$n] has displaytitle of
[$n.getProperty([COLOR=“Sienna”]“rx:displaytitle”).String[/COLOR]] -->[/COLOR]
#end
#end
<!-- Processed [COLOR=“red”]$counter nodes;
GP has nodes? [$grandparent.hasNodes()];
count: [$grandparent.getNodes().getSize()] -->[/COLOR]
#else
<!-- No grandparent node -->
#end
#else
<!-- No parent node -->
#end
#end

, which is all well and good, except that apparently $grandparent has no nodes; I only ever get that comment written to the page, reading:

<!-- Processed 0 nodes; GP has nodes? [false]; count: [0] -->

I can’t see how this can be the case, given my calling page is a grandchild of the node I’m inspecting!

Any ideas, anyone?

One thing you need to understand is that the managed nav implementation is a facade on an underlying real content node. A limited set of methods on Node were overridden to create the new behaviors, including adding properties and children. The actual underlying node does not have children itself. It is likely that this is why things aren’t working as expected.

But the reason that your approach isn’t working is that you can only walk the navon children, not all content. So unless the RSS feed is a navon, this won’t work as shown.

If the RSS feed is a distinct content type you might do this with an autoindex, providing you can calculate the grandparent’s path and use that path as part of the JCR query, comparing the pseudo property jcr:path with it.