mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
fix a bug where getTempalteType was screwing up and throwin NullPointerExceptions when recieving multiple results for a search query it was expeting only one result from (didn't realize it was tokenizing queries - thought it would be the exact match thing...)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4047 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -141,9 +141,8 @@ public final class TemplatingService implements Serializable
|
||||
final SearchParameters sp = new SearchParameters();
|
||||
sp.addStore(Repository.getStoreRef());
|
||||
sp.setLanguage(SearchService.LANGUAGE_LUCENE);
|
||||
final String q = "ASPECT:\"" + WCMModel.ASPECT_TEMPLATE + "\"";
|
||||
sp.setQuery(q);
|
||||
LOGGER.debug("running query [" + q + "]");
|
||||
sp.setQuery("ASPECT:\"" + WCMModel.ASPECT_TEMPLATE + "\"");
|
||||
LOGGER.debug("running query [" + sp.getQuery() + "]");
|
||||
final ResultSet rs = this.searchService.query(sp);
|
||||
LOGGER.debug("received " + rs.length() + " results");
|
||||
final Collection<TemplateType> result = new LinkedList<TemplateType>();
|
||||
@@ -172,8 +171,21 @@ public final class TemplatingService implements Serializable
|
||||
sp.setQuery("ASPECT:\"" + WCMModel.ASPECT_TEMPLATE +
|
||||
"\" AND @" + Repository.escapeQName(ContentModel.PROP_TITLE) +
|
||||
":\"" + name + "\"");
|
||||
LOGGER.debug("running query [" + sp.getQuery() + "]");
|
||||
final ResultSet rs = this.searchService.query(sp);
|
||||
return (rs.length() == 1 ? this.newTemplateType(rs.getNodeRef(0)) : null);
|
||||
NodeRef result = null;
|
||||
for (ResultSetRow row : rs)
|
||||
{
|
||||
final NodeRef nr = row.getNodeRef();
|
||||
if (this.nodeService.getProperty(nr, ContentModel.PROP_TITLE).equals(name))
|
||||
{
|
||||
result = nr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (result == null && LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("unable to find tempalte type " + name);
|
||||
return result != null ? this.newTemplateType(result) : null;
|
||||
}
|
||||
catch (RuntimeException re)
|
||||
{
|
||||
|
Reference in New Issue
Block a user