Error when creating usage dropdown

Hi

I’ve created a usage dropdown as I have multiple default templates. The user then only sees the template that I’ve give ACL permissions to depending on which community they are logged into. This all works fine apart from the fact that since i’ve added this control the following error appears in the console log file:

com.percussion.cms.PSCmsException: An error occurred while making an internal request in the CMS layer to location: "psx_cebsContentPage/bsContentPage". The text of the exception is: An exception occurred while processing the internal request handler call: [1] S1000: Incorrect syntax near the keyword 'and'. [2] S1000: Preparing the statement failed: Incorrect syntax near the keyword 'and'. 
	at com.percussion.cms.objectstore.server.PSServerItem.o00000(Unknown Source)
	at com.percussion.cms.objectstore.server.PSServerItem.o00000(Unknown Source)
	at com.percussion.cms.objectstore.server.PSServerItem.load(Unknown Source)
	at com.percussion.cms.objectstore.server.PSServerItem.load(Unknown Source)
	at com.percussion.cms.objectstore.server.PSServerItem.<init>(Unknown Source)
	at com.percussion.cms.objectstore.server.PSServerItem.loadItem(Unknown Source)
	at com.percussion.search.i.o00000(Unknown Source)
	at com.percussion.search.i.o00000(Unknown Source)
	at com.percussion.search.i.o00000(Unknown Source)
	at com.percussion.search.i$1.run(Unknown Source)

Now I know why i’m getting the error as the search will not be logged into any community and :PSXUserContext/User/SessionObject/sys_community will not be known. But why is it effectly opening the content editor?

select DISTINCT psx_template.name, psx_template.label from psx_template
inner join psx_contenttype_template on psx_template.template_id = psx_contenttype_template.template_id
inner join psx_acls on psx_template.template_id = psx_acls.objectid
inner join psx_aclentries on psx_acls.id = psx_aclentries.aclid
inner join psx_aclentrypermissions on psx_aclentries.id = psx_aclentrypermissions.entryid
left join rxcommunity on psx_aclentries.name = rxcommunity.name
where psx_contenttype_template.contenttypeid = :PSXParam/sys_contenttypeid
and psx_template.publishwhen = 'n'
and psx_template.outputformat = 1
and ((rxcommunity.communityid = :PSXUserContext/User/SessionObject/sys_community and psx_aclentrypermissions.permission = 40) 
	or 
	(psx_aclentries.name = 'AnyCommunity' and psx_aclentrypermissions.permission = 40))
order by label

How do I get around this issue and only show templates in the content editor (similar to the default_variantid) that apply to certain communities?

The implementation is using Rhythmyx 6.5.2

Cheers
James

Well, one way is to use Java Services rather than a SQL Statement.

Call IPSAssemblyService.findTemplatesByContentType and then call
IPSSecurityWs.filterByRuntimeVisibility.

Hi Dave

So there isn’t an out of the box way of doing this then?

If not then can you explain in more detail how I populate the dropdown control with the values of the java services?

Cheers
James

There isn’t a direct way to do what you’re asking.

What you need is to build an XML in the format specified in sys_Lookup.dtd. Your approach was to use a SQL statement.

One other approach is to use a Java Extension. This has to be “post-exit” (IPSResultDocumentProcessor), and it calls the 2 functions I mentioned in my last post.

The Java exit will use the XML DOM methods to create a new node for each template you find. Every node has both a “value” (that is, the “code” stored in the database) and a “label” (which is what is shown to the user in the dropdown). The name of the template becomes the value, and the label of the template becomes the label (this is what your query resource does today).

Look at PSAddChildInfo.java (in the /Rhythmyx/Exits/Java/src folder on your Rhythmyx server. It shows an example of how to implement this interface, and how to add XML nodes using the PSXmlTreeWalker.

Another approach that doesn’t require coding is to create a 2nd resource. The 2nd resource is identical to the first in all but 2 properties:

  1. In the 2nd sql statement, remove the WHERE clause containing the community check.
  2. The request selector is the opposite of the one specified of the 1st resource: i.e. the community is null.

The easiest way to do this is to add the conditional to the first resource (community not null.) Then copy it and fixup the 2nd resource as noted above.

Paul,

I was going to suggest that as well, but you beat me to it.

We were testing some things out here the other day, and it’s possible that the community is set to some other value (e.g. -1) instead of being null, so the conditional on the second resource might have to be different.

I’m sure that this can be easily determined through trial and error, as I haven’t had time to research it fully.

Dave