Passing variables to auto slot query

I am trying to pass the folder path as a variable to an auto slot query. In the auto index template I have used the following binding:

$folderpath = $user.psoFolders.getParentFolderPath($sys.item.guid)

to generate the folder path, which I have then included in the slot:

#slot("$loc_slotName" “” “” “” “” ‘param=$folderpath’)

The slot then uses the following query:

SELECT rx:sys_contentid, rx:sys_folderid FROM rx:NTUPressRelease WHERE jcr:path =’:folderpath’

The error I am getting is:

Error reported
Problem assembling output for item: 1-101-58246 with template: sAutoIndex exception: Path: :folderpath - must start with ‘//’. see log for stack trace

When I check the debug view, the $folderpath variable is displayed correctly, starting ‘//Sites/’ as expected.

Any help would be much appreciated
Thanks

Hi Jerome

You’re assigning the value of $folderpath to your param variable so the query should look this:

SELECT rx:sys_contentid, rx:sys_folderid FROM rx:NTUPressRelease WHERE jcr:path = :param

Cheers
James

Hi James

I’ve tried that, and am still getting the same error:

Error reported
Problem assembling output for item: 1-101-58246 with template: sAutoIndex exception: Path: :param - must start with ‘//’.

You are not passing the parameter correctly. Try the following:

$slotparams.folderpath = $user.psoFolders.getParentFolderPath($sys.item.guid)
$slotparams.template = ... 
$slotparams.max_results = ... 

#slot($loc_slotName "" "" "" "" $slotparams)

Dave

Thanks Dave

I’ve tried as you suggested, but it still returns the same error - here is my full code:

$loc_slotName = $sys.item.getProperty(“rx:loc_slotName”).String
$slotparams.folderpath = $user.psoFolders.getParentFolderPath($sys.item.guid)
$slotparams.template = sPressReleaseSummary
$slotparams.max_results = 10

#slot($loc_slotName “” “” “” “” $slotparams)

With the query string now being:

SELECT rx:sys_contentid, rx:sys_folderid FROM rx:NTUPressRelease WHERE jcr:path =’:slotparams’

Hi Jerome

In this case your query should be:

SELECT rx:sys_contentid, rx:sys_folderid FROM rx:NTUPressRelease WHERE jcr:path = :folderpath

Cheers
James

Sorry - still no luck!

Not sure if the log may offer any more help:

2008-05-14 12:21:53,625 ERROR [PSVelocityAssembler] Problem assembling output for item: 1-101-58246 with template: sAutoIndex
java.lang.IllegalArgumentException: Path: :folderpath - must start with ‘//’.
at com.percussion.cms.objectstore.server.PSRelationshipDbProcessor.getIdByPath(Unknown Source)
at com.percussion.server.webservices.PSServerFolderProcessor.getIdByPath(Unknown Source)
at com.percussion.server.webservices.PSServerFolderProcessor.findMatchingFolders(Unknown Source)
at com.percussion.services.contentmgr.impl.legacy.PSContentRepository$_b.expandPath(Unknown Source)
at com.percussion.services.contentmgr.impl.query.visitors.c.o00000(Unknown Source)
at com.percussion.services.contentmgr.impl.query.nodes.b.o00000(Unknown Source)
at com.percussion.services.contentmgr.impl.legacy.PSContentRepository.executeInternalQuery(Unknown Source)
at sun.reflect.GeneratedMethodAccessor681.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:203)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:162)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:209)
at $Proxy88.executeInternalQuery(Unknown Source)
at com.percussion.services.contentmgr.impl.PSContentMgr.executeQuery(Unknown Source)
at sun.reflect.GeneratedMethodAccessor680.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:203)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:162)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:209)
at $Proxy89.executeQuery(Unknown Source)
at com.percussion.services.assembly.impl.finder.PSAutoSlotContentFinder.getSlotItems(Unknown Source)
at com.percussion.services.assembly.impl.finder.PSBaseSlotContentFinder.find(Unknown Source)
at com.percussion.services.assembly.jexl.PSAssemblerUtils.assemble(Unknown Source)
at sun.reflect.GeneratedMethodAccessor345.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.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)
at com.percussion.services.assembly.impl.plugin.PSAssemblerBase.doAssembleSingle(Unknown Source)
at com.percussion.services.assembly.impl.plugin.PSVelocityAssembler.doAssembleSingle(Unknown Source)
at com.percussion.services.assembly.impl.plugin.PSAssemblerBase$_b.o00000(Unknown Source)
at com.percussion.services.assembly.impl.plugin.PSAssemblerBase$_b.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at com.percussion.services.assembly.impl.plugin.PSAssemblerBase.assemble(Unknown Source)
at com.percussion.services.assembly.impl.PSAssemblyService.assemble(Unknown Source)
at com.percussion.services.assembly.impl.PSAssemblyService.processServletRequest(Unknown Source)
at sun.reflect.GeneratedMethodAccessor414.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
at $Proxy90.processServletRequest(Unknown Source)
at com.percussion.services.assembly.impl.PSAssemblyServlet.service(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.percussion.webdav.PSWebDavRequestFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.percussion.servlets.PSSecurityFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Unknown Source)

Hi Jerome

What happens if you hardcode the folder path eg

$slotparams.folderpath = ‘//Sites/yoursite’

Cheers
James

I’ve used “… WHERE jcr:path like :folderpath …” with no problems. Could it be the = sign that is causing you grief? of course the folder path does need to be something like “//Sites/somefolder”. I’m not exactly sure what $user.psoFolders.getParentFolderPath($sys.item.guid) returns, so you may want to check that result (ie. do you need to do a .trim() or .String on it?).

Jit

Thanks for your help James - after starting with the path hardcoded as you suggested, we managed to get it working:

$loc_slotName = $sys.item.getProperty(“rx:loc_slotName”).String
$params.folderpath = $user.psoFolders.getParentFolderPath($sys.assemblyItem)
$params.template = ‘sPressReleaseSummary’
$params.max_results = 10

#slot($loc_slotName “” “” “” “” $params)

SELECT rx:sys_contentid, rx:sys_folderid FROM rx:NTUPressRelease WHERE jcr:path = :folderpath

The changes made are in bold.

Thanks again