Available templates problem found

Hi team,

I found a problem with the available templates for a new Workspace creation. The problem is if you delete several TemplateRoot (and create others TemplateRoot) in your Domain and it (or them) keeps in the trash (TAB) the query to select available templates has a problem. It does not filter deleted document and the line templates = documentManager.getChildren(tl.get(0).getRef(), targetTypeName); with tl.get(0) is not correct.

Regards, VS!

The source code still on master branch:

https://github.com/nuxeo/nuxeo/blob/master/nuxeo-dm/nuxeo-platform-webapp-core/src/main/java/org/nuxeo/ecm/webapp/documenttemplates/DocumentTemplatesActionsBean.java

@Override
public DocumentModelList getTemplates(String targetTypeName) {
   ...
   String query = "SELECT * FROM Document where ecm:primaryType = '%s' AND ecm:path STARTSWITH %s";
   DocumentModelList tl = documentManager.query(String.format(query, TemplateRoot,
                NXQL.escapeString(navigationContext.getCurrentDomainPath())));
   if (tl.isEmpty()) {
      templates = tl;
   } else {
      templates = documentManager.getChildren(tl.get(0).getRef(), targetTypeName);
      List<DocumentModel> deleted = new ArrayList<>();
      for (DocumentModel current : templates) {
         if (current.isTrashed()) {
            deleted.add(current);
         }
      }
      templates.removeAll(deleted);
   }
}
0 votes

1 answers

1686 views

ANSWER



Thanks for the report, NXP-24971 will track this issue.

1 votes