<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Available templates problem found in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/available-templates-problem-found/m-p/322252#M9253</link>
    <description>&lt;P&gt;Hi team,&lt;/P&gt;
&lt;P&gt;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 &lt;STRONG&gt;templates = documentManager.getChildren(tl.get(0).getRef(), targetTypeName);&lt;/STRONG&gt; with tl.get(0) is not correct.&lt;/P&gt;
&lt;P&gt;Regards,
VS!&lt;/P&gt;
&lt;P&gt;The source code still on master branch:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/nuxeo/nuxeo/blob/master/nuxeo-dm/nuxeo-platform-webapp-core/src/main/java/org/nuxeo/ecm/webapp/documenttemplates/DocumentTemplatesActionsBean.java" target="test_blank"&gt;https://github.com/nuxeo/nuxeo/blob/master/nuxeo-dm/nuxeo-platform-webapp-core/src/main/java/org/nuxeo/ecm/webapp/documenttemplates/DocumentTemplatesActionsBean.java&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;@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&amp;lt;DocumentModel&amp;gt; deleted = new ArrayList&amp;lt;&amp;gt;();
      for (DocumentModel current : templates) {
         if (current.isTrashed()) {
            deleted.add(current);
         }
      }
      templates.removeAll(deleted);
   }
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 03 May 2018 14:09:29 GMT</pubDate>
    <dc:creator>Victor_Sánchez</dc:creator>
    <dc:date>2018-05-03T14:09:29Z</dc:date>
    <item>
      <title>Available templates problem found</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/available-templates-problem-found/m-p/322252#M9253</link>
      <description>&lt;P&gt;Hi team,&lt;/P&gt;
&lt;P&gt;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 &lt;STRONG&gt;templates = documentManager.getChildren(tl.get(0).getRef(), targetTypeName);&lt;/STRONG&gt; with tl.get(0) is not correct.&lt;/P&gt;
&lt;P&gt;Regards,
VS!&lt;/P&gt;
&lt;P&gt;The source code still on master branch:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/nuxeo/nuxeo/blob/master/nuxeo-dm/nuxeo-platform-webapp-core/src/main/java/org/nuxeo/ecm/webapp/documenttemplates/DocumentTemplatesActionsBean.java" target="test_blank"&gt;https://github.com/nuxeo/nuxeo/blob/master/nuxeo-dm/nuxeo-platform-webapp-core/src/main/java/org/nuxeo/ecm/webapp/documenttemplates/DocumentTemplatesActionsBean.java&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;@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&amp;lt;DocumentModel&amp;gt; deleted = new ArrayList&amp;lt;&amp;gt;();
      for (DocumentModel current : templates) {
         if (current.isTrashed()) {
            deleted.add(current);
         }
      }
      templates.removeAll(deleted);
   }
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 03 May 2018 14:09:29 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/available-templates-problem-found/m-p/322252#M9253</guid>
      <dc:creator>Victor_Sánchez</dc:creator>
      <dc:date>2018-05-03T14:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: Available templates problem found</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/available-templates-problem-found/m-p/322253#M9254</link>
      <description>&lt;P&gt;Thanks for the report, &lt;A href="https://jira.nuxeo.com/browse/NXP-24971"&gt;NXP-24971&lt;/A&gt; will track this issue.&lt;/P&gt;</description>
      <pubDate>Mon, 07 May 2018 14:26:12 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/available-templates-problem-found/m-p/322253#M9254</guid>
      <dc:creator>Florent_Guillau</dc:creator>
      <dc:date>2018-05-07T14:26:12Z</dc:date>
    </item>
  </channel>
</rss>

