mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.1 to HEAD
13700: ETHREEOH-1724 - Site finder does not search site names git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13708 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -572,19 +572,35 @@ public class SiteServiceImpl implements SiteService, SiteModel
|
||||
NodeRef siteRoot = getSiteRoot();
|
||||
if (nameFilter != null && nameFilter.length() != 0)
|
||||
{
|
||||
// Perform a Lucene search under the Site parent node using *name* search query
|
||||
QueryParameterDefinition[] params = new QueryParameterDefinition[1];
|
||||
// Perform a Lucene search under the Site parent node using *name*, *title* and *description* search query
|
||||
QueryParameterDefinition[] params = new QueryParameterDefinition[3];
|
||||
params[0] = new QueryParameterDefImpl(
|
||||
ContentModel.PROP_NAME,
|
||||
dictionaryService.getDataType(
|
||||
DataTypeDefinition.TEXT),
|
||||
true,
|
||||
LuceneQueryParser.escape(nameFilter.replace('"', ' ')));
|
||||
|
||||
|
||||
params[1] = new QueryParameterDefImpl(
|
||||
ContentModel.PROP_TITLE,
|
||||
dictionaryService.getDataType(
|
||||
DataTypeDefinition.TEXT),
|
||||
true,
|
||||
QueryParser.escape(nameFilter.replace('"', ' ')));
|
||||
|
||||
params[2] = new QueryParameterDefImpl(
|
||||
ContentModel.PROP_DESCRIPTION,
|
||||
dictionaryService.getDataType(
|
||||
DataTypeDefinition.TEXT),
|
||||
true,
|
||||
QueryParser.escape(nameFilter.replace('"', ' ')));
|
||||
|
||||
// get the sites that match the specified names
|
||||
StringBuilder query = new StringBuilder(128);
|
||||
query.append("+PARENT:\"").append(siteRoot.toString())
|
||||
.append("\" +@cm\\:name:\"*${cm:name}*\"");
|
||||
.append("\" +(@cm\\:name:\"*${cm:name}*\"")
|
||||
.append(" @cm\\:title:\"*${cm:title}*\"")
|
||||
.append(" @cm\\:description:\"*${cm:description}*\")");
|
||||
ResultSet results = this.searchService.query(
|
||||
siteRoot.getStoreRef(),
|
||||
SearchService.LANGUAGE_LUCENE,
|
||||
|
@@ -237,6 +237,22 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest
|
||||
sites = this.siteService.listSites(null, null);
|
||||
assertNotNull(sites);
|
||||
assertEquals(4, sites.size());
|
||||
|
||||
// Get sites by matching name
|
||||
sites = this.siteService.listSites("One", null);
|
||||
assertNotNull(sites);
|
||||
assertEquals(1, sites.size());
|
||||
|
||||
// Get sites by matching title
|
||||
sites = this.siteService.listSites("title", null);
|
||||
assertNotNull(sites);
|
||||
assertEquals(4, sites.size());
|
||||
|
||||
// Get sites by matching description
|
||||
sites = this.siteService.listSites("description", null);
|
||||
assertNotNull(sites);
|
||||
assertEquals(4, sites.size());
|
||||
|
||||
// Do detailed check of the site info objects
|
||||
for (SiteInfo site : sites)
|
||||
{
|
||||
|
@@ -483,6 +483,18 @@ public abstract class BaseContentNode implements TemplateContent
|
||||
return (o instanceof TemplateContentData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to return true if the supplied property value is a TemplateNodeRef object
|
||||
*
|
||||
* @param o Object to test
|
||||
*
|
||||
* @return true if instanceof isTemplateNodeRef, false otherwise
|
||||
*/
|
||||
public boolean isTemplateNodeRef(Object o)
|
||||
{
|
||||
return (o instanceof TemplateNodeRef);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Inner classes
|
||||
|
Reference in New Issue
Block a user