API to get the template of a container (Product/Library)
Background: I’m working on a requirement to filter all Product and Library containers in an Organization based on the template they were created from. So I need to read the template associated with each container.
Has anyone successfully retrieved template information for Product or Library containers without hitting this recursion issue or any recommended API for this job?
What I’ve tried so far:
-
ContainerTemplateService.getContainerTemplate(...) I attempted calling the getContainerTemplate API using both the container’s own reference and the OrgContainer reference. In all cases, the method consistently returns null, even for containers that I know were created from a template.
- WTContainer.getContainerTemplateReference().getName() This API does return a template name when called once, but any further processing (such as checking startsWith(...)) triggers a runtime failure:
java.lang.StackOverflowError
at wt.method.RemoteMethodServer.invoke
at wt.fc.CachedObjectReference.inflate
at wt.inf.container.WTContainerTemplateRef.getName
at wt.inf.container.WTContainerTemplateRef.initialize
at wt.inf.container.WTContainerTemplateRef.inflate
It appears that inflating the WTContainerTemplateRef causes recursive error.

