mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -202,6 +202,8 @@
|
||||
<property name="dictionaryService" ref="dictionaryService"/>
|
||||
<property name="searchService" ref="searchService"/>
|
||||
<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="cacheAllowableValues" value="false" />
|
||||
<property name="nodeInclusionFilter">
|
||||
@@ -215,6 +217,8 @@
|
||||
<property name="dictionaryService" ref="dictionaryService"/>
|
||||
<property name="searchService" ref="searchService"/>
|
||||
<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="cacheAllowableValues" value="false" />
|
||||
<property name="nodeInclusionFilter">
|
||||
|
@@ -27,13 +27,13 @@ import java.util.Map;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.model.Repository;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
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.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
|
||||
@@ -50,6 +50,10 @@ public class FolderContentsParameterConstraint extends BaseParameterConstraint
|
||||
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
private NamespaceService namespaceService;
|
||||
|
||||
private Repository repository;
|
||||
|
||||
private String searchPath;
|
||||
|
||||
private List<String> nodeInclusionFilter = Collections.emptyList();
|
||||
@@ -74,6 +78,16 @@ public class FolderContentsParameterConstraint extends BaseParameterConstraint
|
||||
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 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()
|
||||
*/
|
||||
protected Map<String, String> getAllowableValuesImpl()
|
||||
{
|
||||
ResultSet resultSet = searchService.query(
|
||||
StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,
|
||||
SearchService.LANGUAGE_LUCENE,
|
||||
"PATH:\"" + searchPath + "\"");
|
||||
{
|
||||
List<NodeRef> nodeRefs = searchService.selectNodes(repository.getRootHome(),
|
||||
this.searchPath, null, this.namespaceService, false);
|
||||
|
||||
NodeRef rootFolder = null;
|
||||
if (resultSet.length() == 0)
|
||||
if (nodeRefs.size() == 0)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("The path '" + searchPath + "' did not return any results.");
|
||||
}
|
||||
else
|
||||
{
|
||||
rootFolder = resultSet.getNodeRef(0);
|
||||
rootFolder = nodeRefs.get(0);
|
||||
}
|
||||
|
||||
Map<String, String> result = new HashMap<String, String>(23);
|
||||
|
@@ -42,7 +42,6 @@ import org.alfresco.repo.action.executer.MailActionExecuter;
|
||||
import org.alfresco.repo.admin.SysAdminParams;
|
||||
import org.alfresco.repo.i18n.MessageService;
|
||||
import org.alfresco.repo.model.Repository;
|
||||
import org.alfresco.repo.search.SearcherException;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
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.repository.NodeRef;
|
||||
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.search.ResultSet;
|
||||
import org.alfresco.service.cmr.search.SearchParameters;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.util.ModelUtil;
|
||||
import org.alfresco.util.UrlUtil;
|
||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
import org.springframework.extensions.surf.util.URLEncoder;
|
||||
|
||||
@@ -98,6 +94,7 @@ public class InviteSender
|
||||
private final FileFolderService fileFolderService;
|
||||
private final SysAdminParams sysAdminParams;
|
||||
private final RepoAdminService repoAdminService;
|
||||
private final NamespaceService namespaceService;
|
||||
|
||||
public InviteSender(ServiceRegistry services, Repository repository, MessageService messageService)
|
||||
{
|
||||
@@ -109,6 +106,7 @@ public class InviteSender
|
||||
this.fileFolderService = services.getFileFolderService();
|
||||
this.sysAdminParams = services.getSysAdminParams();
|
||||
this.repoAdminService = services.getRepoAdminService();
|
||||
this.namespaceService = services.getNamespaceService();
|
||||
this.repository = repository;
|
||||
this.messageService = messageService;
|
||||
}
|
||||
@@ -216,36 +214,20 @@ public class InviteSender
|
||||
|
||||
private NodeRef getEmailTemplateNodeRef()
|
||||
{
|
||||
StoreRef spacesStore = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
|
||||
String query = " PATH:\"app:company_home/app:dictionary/app:email_templates/cm:invite/cm:invite-email.html.ftl\"";
|
||||
|
||||
SearchParameters searchParams = new SearchParameters();
|
||||
searchParams.addStore(spacesStore);
|
||||
searchParams.setLanguage(SearchService.LANGUAGE_LUCENE);
|
||||
searchParams.setQuery(query);
|
||||
|
||||
ResultSet results = null;
|
||||
try
|
||||
List<NodeRef> nodeRefs = searchService.selectNodes(repository.getRootHome(),
|
||||
"app:company_home/app:dictionary/app:email_templates/cm:invite/cm:invite-email.html.ftl", null,
|
||||
this.namespaceService, false);
|
||||
|
||||
if (nodeRefs.size() == 1)
|
||||
{
|
||||
results = searchService.query(searchParams);
|
||||
List<NodeRef> nodeRefs = results.getNodeRefs();
|
||||
if (nodeRefs.size() == 1) {
|
||||
// Now localise this
|
||||
NodeRef base = nodeRefs.get(0);
|
||||
NodeRef local = fileFolderService.getLocalizedSibling(base);
|
||||
return local;
|
||||
}
|
||||
else
|
||||
throw new InvitationException("Cannot find the email template!");
|
||||
// Now localise this
|
||||
NodeRef base = nodeRefs.get(0);
|
||||
NodeRef local = fileFolderService.getLocalizedSibling(base);
|
||||
return local;
|
||||
}
|
||||
catch (SearcherException e)
|
||||
else
|
||||
{
|
||||
throw new InvitationException("Cannot find the email template!", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (results != null)
|
||||
results.close();
|
||||
throw new InvitationException("Cannot find the email template!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -59,12 +59,14 @@ import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
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.SearchParameters;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
@@ -349,6 +351,9 @@ public class InviteSenderTest extends TestCase
|
||||
List<NodeRef> nodeRefs = Arrays.asList(template);
|
||||
when(results.getNodeRefs()).thenReturn(nodeRefs);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -154,6 +154,43 @@ public class ScriptSiteService extends BaseScopableProcessorExtension
|
||||
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
|
||||
* preset.
|
||||
|
@@ -75,6 +75,28 @@ function testFindSites()
|
||||
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()
|
||||
{
|
||||
var site = siteService.getSite("siteShortName");
|
||||
@@ -226,6 +248,7 @@ function testSiteCustomProperties()
|
||||
testCRUD();
|
||||
testListSites();
|
||||
testFindSites();
|
||||
testGetSites();
|
||||
testMembership();
|
||||
testContainer();
|
||||
testPermissions();
|
||||
|
@@ -18,10 +18,8 @@
|
||||
*/
|
||||
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.cmr.repository.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;
|
||||
if (key != null)
|
||||
{
|
||||
String ref = "ID:" + AbstractLuceneQueryParser.escape(key.toString());
|
||||
|
||||
List<TemplateNode> results = query(ref);
|
||||
|
||||
if (results.size() != 0)
|
||||
{
|
||||
result = results.get(0);
|
||||
}
|
||||
NodeRef nodeRef = new NodeRef((String)key);
|
||||
result = new TemplateNode(nodeRef, services, this.parent.getImageResolver());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user