Fixed issues found as a result of ALF-9636: SVC 67: Lucene removal: Sanity test Share UI with Lucene turned off

Fixed ALF-9686: It's impossible to find any group at the Manage Space Users page

Fixed ALF-9673: It's impossible to find any site

Fixed ALF-9669: Site invite fails using SOLR while building email - need to remove query use in invite.

NOTE: Searches from the UI are now consistent in that by default a canned query based search (consistent results) are performed by default for people, group, user & site searches, to force a lucene based search that support the "contains" type query users must prefix their search with *, this is no longer added by default by the UI.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29628 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2011-08-09 11:35:51 +00:00
parent 5c4f984dd2
commit 6dbe542032
7 changed files with 108 additions and 52 deletions

View File

@@ -202,6 +202,8 @@
<property name="dictionaryService" ref="dictionaryService"/> <property name="dictionaryService" ref="dictionaryService"/>
<property name="searchService" ref="searchService"/> <property name="searchService" ref="searchService"/>
<property name="nodeService" ref="nodeService"/> <property name="nodeService" ref="nodeService"/>
<property name="namespaceService" ref="namespaceService" />
<property name="repository" ref="repositoryHelper" />
<property name="searchPath" value="/app:company_home/app:dictionary/app:email_templates/app:notify_email_templates"/> <property name="searchPath" value="/app:company_home/app:dictionary/app:email_templates/app:notify_email_templates"/>
<property name="cacheAllowableValues" value="false" /> <property name="cacheAllowableValues" value="false" />
<property name="nodeInclusionFilter"> <property name="nodeInclusionFilter">
@@ -215,6 +217,8 @@
<property name="dictionaryService" ref="dictionaryService"/> <property name="dictionaryService" ref="dictionaryService"/>
<property name="searchService" ref="searchService"/> <property name="searchService" ref="searchService"/>
<property name="nodeService" ref="nodeService"/> <property name="nodeService" ref="nodeService"/>
<property name="namespaceService" ref="namespaceService" />
<property name="repository" ref="repositoryHelper" />
<property name="searchPath" value="/app:company_home/app:dictionary/app:scripts"/> <property name="searchPath" value="/app:company_home/app:dictionary/app:scripts"/>
<property name="cacheAllowableValues" value="false" /> <property name="cacheAllowableValues" value="false" />
<property name="nodeInclusionFilter"> <property name="nodeInclusionFilter">

View File

@@ -27,13 +27,13 @@ import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.model.Repository;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.namespace.RegexQNamePattern;
@@ -50,6 +50,10 @@ public class FolderContentsParameterConstraint extends BaseParameterConstraint
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
private NamespaceService namespaceService;
private Repository repository;
private String searchPath; private String searchPath;
private List<String> nodeInclusionFilter = Collections.emptyList(); private List<String> nodeInclusionFilter = Collections.emptyList();
@@ -74,6 +78,16 @@ public class FolderContentsParameterConstraint extends BaseParameterConstraint
this.dictionaryService = dictionaryService; this.dictionaryService = dictionaryService;
} }
public void setNamespaceService(NamespaceService namespaceService)
{
this.namespaceService = namespaceService;
}
public void setRepository(Repository repository)
{
this.repository = repository;
}
/** /**
* This optional property defines a list of file extensions which should be included in the result set from * This optional property defines a list of file extensions which should be included in the result set from
* this class. By implication, all other file extensions will be excluded. (The dot should not be specified * this class. By implication, all other file extensions will be excluded. (The dot should not be specified
@@ -102,19 +116,18 @@ public class FolderContentsParameterConstraint extends BaseParameterConstraint
* @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues() * @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues()
*/ */
protected Map<String, String> getAllowableValuesImpl() protected Map<String, String> getAllowableValuesImpl()
{ {
ResultSet resultSet = searchService.query( List<NodeRef> nodeRefs = searchService.selectNodes(repository.getRootHome(),
StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, this.searchPath, null, this.namespaceService, false);
SearchService.LANGUAGE_LUCENE,
"PATH:\"" + searchPath + "\"");
NodeRef rootFolder = null; NodeRef rootFolder = null;
if (resultSet.length() == 0) if (nodeRefs.size() == 0)
{ {
throw new AlfrescoRuntimeException("The path '" + searchPath + "' did not return any results."); throw new AlfrescoRuntimeException("The path '" + searchPath + "' did not return any results.");
} }
else else
{ {
rootFolder = resultSet.getNodeRef(0); rootFolder = nodeRefs.get(0);
} }
Map<String, String> result = new HashMap<String, String>(23); Map<String, String> result = new HashMap<String, String>(23);

View File

@@ -42,7 +42,6 @@ import org.alfresco.repo.action.executer.MailActionExecuter;
import org.alfresco.repo.admin.SysAdminParams; import org.alfresco.repo.admin.SysAdminParams;
import org.alfresco.repo.i18n.MessageService; import org.alfresco.repo.i18n.MessageService;
import org.alfresco.repo.model.Repository; import org.alfresco.repo.model.Repository;
import org.alfresco.repo.search.SearcherException;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService; import org.alfresco.service.cmr.action.ActionService;
@@ -51,16 +50,13 @@ import org.alfresco.service.cmr.invitation.InvitationException;
import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.TemplateService; import org.alfresco.service.cmr.repository.TemplateService;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.site.SiteInfo; import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService; import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.util.ModelUtil; import org.alfresco.util.ModelUtil;
import org.alfresco.util.UrlUtil;
import org.springframework.extensions.surf.util.ParameterCheck; import org.springframework.extensions.surf.util.ParameterCheck;
import org.springframework.extensions.surf.util.URLEncoder; import org.springframework.extensions.surf.util.URLEncoder;
@@ -98,6 +94,7 @@ public class InviteSender
private final FileFolderService fileFolderService; private final FileFolderService fileFolderService;
private final SysAdminParams sysAdminParams; private final SysAdminParams sysAdminParams;
private final RepoAdminService repoAdminService; private final RepoAdminService repoAdminService;
private final NamespaceService namespaceService;
public InviteSender(ServiceRegistry services, Repository repository, MessageService messageService) public InviteSender(ServiceRegistry services, Repository repository, MessageService messageService)
{ {
@@ -109,6 +106,7 @@ public class InviteSender
this.fileFolderService = services.getFileFolderService(); this.fileFolderService = services.getFileFolderService();
this.sysAdminParams = services.getSysAdminParams(); this.sysAdminParams = services.getSysAdminParams();
this.repoAdminService = services.getRepoAdminService(); this.repoAdminService = services.getRepoAdminService();
this.namespaceService = services.getNamespaceService();
this.repository = repository; this.repository = repository;
this.messageService = messageService; this.messageService = messageService;
} }
@@ -216,36 +214,20 @@ public class InviteSender
private NodeRef getEmailTemplateNodeRef() private NodeRef getEmailTemplateNodeRef()
{ {
StoreRef spacesStore = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); List<NodeRef> nodeRefs = searchService.selectNodes(repository.getRootHome(),
String query = " PATH:\"app:company_home/app:dictionary/app:email_templates/cm:invite/cm:invite-email.html.ftl\""; "app:company_home/app:dictionary/app:email_templates/cm:invite/cm:invite-email.html.ftl", null,
this.namespaceService, false);
SearchParameters searchParams = new SearchParameters();
searchParams.addStore(spacesStore); if (nodeRefs.size() == 1)
searchParams.setLanguage(SearchService.LANGUAGE_LUCENE);
searchParams.setQuery(query);
ResultSet results = null;
try
{ {
results = searchService.query(searchParams); // Now localise this
List<NodeRef> nodeRefs = results.getNodeRefs(); NodeRef base = nodeRefs.get(0);
if (nodeRefs.size() == 1) { NodeRef local = fileFolderService.getLocalizedSibling(base);
// Now localise this return local;
NodeRef base = nodeRefs.get(0);
NodeRef local = fileFolderService.getLocalizedSibling(base);
return local;
}
else
throw new InvitationException("Cannot find the email template!");
} }
catch (SearcherException e) else
{ {
throw new InvitationException("Cannot find the email template!", e); throw new InvitationException("Cannot find the email template!");
}
finally
{
if (results != null)
results.close();
} }
} }

View File

@@ -59,12 +59,14 @@ import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.QueryParameterDefinition;
import org.alfresco.service.cmr.search.ResultSet; import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchParameters; import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.PersonService; import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.site.SiteInfo; import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService; import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.namespace.NamespacePrefixResolver;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock; import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
@@ -349,6 +351,9 @@ public class InviteSenderTest extends TestCase
List<NodeRef> nodeRefs = Arrays.asList(template); List<NodeRef> nodeRefs = Arrays.asList(template);
when(results.getNodeRefs()).thenReturn(nodeRefs); when(results.getNodeRefs()).thenReturn(nodeRefs);
when(searchService.query((SearchParameters) any())).thenReturn(results); when(searchService.query((SearchParameters) any())).thenReturn(results);
when(searchService.selectNodes(any(NodeRef.class), any(String.class),
any(QueryParameterDefinition[].class), any(NamespacePrefixResolver.class), eq(false)))
.thenReturn(nodeRefs);
return searchService; return searchService;
} }

View File

@@ -154,6 +154,43 @@ public class ScriptSiteService extends BaseScopableProcessorExtension
return (SiteServiceImpl.SITE_MANAGER.equals(role)); return (SiteServiceImpl.SITE_MANAGER.equals(role));
} }
/**
* Retrieves the sites available in the repository. The returned list can optionally be filtered by name and site
* preset. If no filters are specified then all the available sites are returned.
*
* NOTE: If the filter starts with a * a Lucene based search will be performed, this may discover a wider range
* of results i.e. those sites that contain the search term as opposed to those that start with the search term,
* but newly created sites may not be found until the underlying search indexes are updated.
*
* @param filter inclusion filter for returned sites. Only sites whose cm:name OR cm:title
* OR cm:description start with the filter string will be returned.
* @param sitePresetFilter site preset filter
* @param size max results size crop if >0
* @return Site[] a list of the site filtered as appropriate
*/
public Site[] getSites(String filter, String sitePresetFilter, int size)
{
// reset filter if necessary
if (filter != null && (filter.length() == 0 || filter.equals("*")))
{
filter = null;
}
if (filter != null && (filter.startsWith("*")))
{
// findSites will add the wildcard so remove here
filter = filter.substring(1, filter.length());
// use findSites to do a "contains" search
return findSites(filter, sitePresetFilter, size);
}
else
{
// use listSites to do a canned query (will provide consistent results)
return listSites(filter, sitePresetFilter, size);
}
}
/** /**
* List the sites available in the repository. The returned list can optionally be filtered by name and site * List the sites available in the repository. The returned list can optionally be filtered by name and site
* preset. * preset.

View File

@@ -75,6 +75,28 @@ function testFindSites()
test.assertEquals(1, sites.length); test.assertEquals(1, sites.length);
} }
function testGetSites()
{
// get all the sites
var sites = siteService.getSites(null, null, -1);
test.assertEquals(preexistingSiteCount + 2, sites.length);
sites = siteService.getSites("*", null, -1);
test.assertEquals(preexistingSiteCount + 2, sites.length);
// get all sites whose name starts with "site"
sites = siteService.getSites("site", null, -1);
test.assertEquals(2, sites.length);
// get all sites whose name starts with "short"
sites = siteService.getSites("short", null, -1);
test.assertEquals(0, sites.length);
// get all sites with "short" in the name
sites = siteService.getSites("*short", null, -1);
test.assertEquals(2, sites.length);
}
function testMembership() function testMembership()
{ {
var site = siteService.getSite("siteShortName"); var site = siteService.getSite("siteShortName");
@@ -226,6 +248,7 @@ function testSiteCustomProperties()
testCRUD(); testCRUD();
testListSites(); testListSites();
testFindSites(); testFindSites();
testGetSites();
testMembership(); testMembership();
testContainer(); testContainer();
testPermissions(); testPermissions();

View File

@@ -18,10 +18,8 @@
*/ */
package org.alfresco.repo.template; package org.alfresco.repo.template;
import java.util.List;
import org.alfresco.repo.search.impl.lucene.AbstractLuceneQueryParser;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
/** /**
* Provides functionality to execute a Lucene search for a single node by NodeRef. * Provides functionality to execute a Lucene search for a single node by NodeRef.
@@ -49,14 +47,8 @@ public class NodeSearchResultsMap extends BaseSearchResultsMap
TemplateNode result = null; TemplateNode result = null;
if (key != null) if (key != null)
{ {
String ref = "ID:" + AbstractLuceneQueryParser.escape(key.toString()); NodeRef nodeRef = new NodeRef((String)key);
result = new TemplateNode(nodeRef, services, this.parent.getImageResolver());
List<TemplateNode> results = query(ref);
if (results.size() != 0)
{
result = results.get(0);
}
} }
return result; return result;
} }