mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-8968 - De-Lucene DeleteUser, Users and AddUsers JSF dialogs, which now use the person service finder
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28368 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -31,14 +31,13 @@ import javax.faces.model.SelectItem;
|
|||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.search.impl.lucene.AbstractLuceneQueryParser;
|
import org.alfresco.query.PagingRequest;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.search.ResultSet;
|
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
|
||||||
import org.alfresco.service.cmr.security.AuthorityService;
|
import org.alfresco.service.cmr.security.AuthorityService;
|
||||||
|
import org.alfresco.service.cmr.security.PagingPersonResults;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
import org.alfresco.web.app.Application;
|
import org.alfresco.web.app.Application;
|
||||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||||
@@ -203,25 +202,17 @@ public class AddUsersDialog extends BaseDialogBean
|
|||||||
{
|
{
|
||||||
SelectItem[] items = new SelectItem[0];
|
SelectItem[] items = new SelectItem[0];
|
||||||
|
|
||||||
// Use lucene search to retrieve user details
|
// Use the Person Service to retrieve user details
|
||||||
String term = AbstractLuceneQueryParser.escape(contains.trim());
|
String term = contains.trim();
|
||||||
if (term.length() != 0)
|
if (term.length() != 0)
|
||||||
{
|
{
|
||||||
StringBuilder query = new StringBuilder(128);
|
PagingPersonResults people = getPersonService().getPeople(
|
||||||
Utils.generatePersonSearch(query, term);
|
Utils.generatePersonFilter(contains.trim()),
|
||||||
List<NodeRef> nodes;
|
true,
|
||||||
ResultSet resultSet = Repository.getServiceRegistry(context).getSearchService().query(
|
Utils.generatePersonSort(),
|
||||||
Repository.getStoreRef(),
|
new PagingRequest(Utils.getPersonMaxResults(), null)
|
||||||
SearchService.LANGUAGE_LUCENE,
|
);
|
||||||
query.toString());
|
List<NodeRef> nodes = people.getPage();
|
||||||
try
|
|
||||||
{
|
|
||||||
nodes = resultSet.getNodeRefs();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
resultSet.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<SelectItem> itemList = new ArrayList<SelectItem>(nodes.size());
|
ArrayList<SelectItem> itemList = new ArrayList<SelectItem>(nodes.size());
|
||||||
for (NodeRef personRef : nodes)
|
for (NodeRef personRef : nodes)
|
||||||
|
@@ -28,14 +28,16 @@ import javax.faces.context.FacesContext;
|
|||||||
import javax.faces.event.ActionEvent;
|
import javax.faces.event.ActionEvent;
|
||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
|
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.query.PagingRequest;
|
||||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
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.AuthenticationService;
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||||
|
import org.alfresco.service.cmr.security.PagingPersonResults;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.ISO9075;
|
import org.alfresco.util.ISO9075;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
import org.alfresco.web.app.Application;
|
import org.alfresco.web.app.Application;
|
||||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||||
import org.alfresco.web.bean.repository.MapNode;
|
import org.alfresco.web.bean.repository.MapNode;
|
||||||
@@ -122,36 +124,28 @@ public class DeleteUserDialog extends BaseDialogBean
|
|||||||
|
|
||||||
// define the query to find people by their first or last name
|
// define the query to find people by their first or last name
|
||||||
String search = ISO9075.encode(this.searchCriteria);
|
String search = ISO9075.encode(this.searchCriteria);
|
||||||
String query = "( TYPE:\"{http://www.alfresco.org/model/content/1.0}person\") AND " + "((@\\{http\\://www.alfresco.org/model/content/1.0\\}firstName:" + search
|
List<Pair<QName,String>> filter = new ArrayList<Pair<QName,String>>();
|
||||||
+ "*) OR (@\\{http\\://www.alfresco.org/model/content/1.0\\}lastName:" + search + "*) OR (@\\{http\\://www.alfresco.org/model/content/1.0\\}userName:" + search
|
filter.add(new Pair<QName, String>(ContentModel.PROP_FIRSTNAME, search));
|
||||||
+ "*)))";
|
filter.add(new Pair<QName, String>(ContentModel.PROP_LASTNAME, search));
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
logger.debug("Query: " + query);
|
|
||||||
|
|
||||||
// define the search parameters
|
|
||||||
SearchParameters params = new SearchParameters();
|
|
||||||
params.setLanguage(SearchService.LANGUAGE_LUCENE);
|
|
||||||
params.addStore(Repository.getStoreRef());
|
|
||||||
params.setQuery(query);
|
|
||||||
|
|
||||||
ResultSet results = this.getSearchService().query(params);
|
|
||||||
List<NodeRef> people;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
people = results.getNodeRefs();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
results.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("Found " + people.size() + " users");
|
logger.debug("Query filter: " + filter);
|
||||||
|
|
||||||
this.users = new ArrayList<Node>(people.size());
|
// Perform the search
|
||||||
|
PagingPersonResults people = getPersonService().getPeople(
|
||||||
|
filter,
|
||||||
|
true,
|
||||||
|
Utils.generatePersonSort(),
|
||||||
|
new PagingRequest(Utils.getPersonMaxResults(), null)
|
||||||
|
);
|
||||||
|
List<NodeRef> nodes = people.getPage();
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("Found " + nodes.size() + " users");
|
||||||
|
|
||||||
for (NodeRef nodeRef : people)
|
this.users = new ArrayList<Node>(nodes.size());
|
||||||
|
|
||||||
|
for (NodeRef nodeRef : nodes)
|
||||||
{
|
{
|
||||||
// create our Node representation
|
// create our Node representation
|
||||||
MapNode node = new MapNode(nodeRef);
|
MapNode node = new MapNode(nodeRef);
|
||||||
|
@@ -30,11 +30,10 @@ import javax.faces.event.ActionEvent;
|
|||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.query.PagingRequest;
|
||||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.search.ResultSet;
|
import org.alfresco.service.cmr.security.PagingPersonResults;
|
||||||
import org.alfresco.service.cmr.search.SearchParameters;
|
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.web.app.Application;
|
import org.alfresco.web.app.Application;
|
||||||
import org.alfresco.web.app.context.IContextListener;
|
import org.alfresco.web.app.context.IContextListener;
|
||||||
@@ -296,35 +295,23 @@ public class UsersDialog extends BaseDialogBean implements IContextListener, Cha
|
|||||||
|
|
||||||
// define the query to find people by their first or last name
|
// define the query to find people by their first or last name
|
||||||
String search = properties.getSearchCriteria();
|
String search = properties.getSearchCriteria();
|
||||||
StringBuilder query = new StringBuilder(128);
|
|
||||||
Utils.generatePersonSearch(query, search);
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("Query: " + query.toString());
|
logger.debug("Query term: " + search);
|
||||||
|
|
||||||
// define the search parameters
|
PagingPersonResults people = properties.getPersonService().getPeople(
|
||||||
SearchParameters params = new SearchParameters();
|
Utils.generatePersonFilter(search),
|
||||||
params.setLanguage(SearchService.LANGUAGE_LUCENE);
|
true,
|
||||||
params.addStore(Repository.getStoreRef());
|
Utils.generatePersonSort(),
|
||||||
params.setQuery(query.toString());
|
new PagingRequest(Utils.getPersonMaxResults(), null)
|
||||||
|
);
|
||||||
ResultSet results = properties.getSearchService().query(params);
|
List<NodeRef> nodes = people.getPage();
|
||||||
List<NodeRef> people;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
people = results.getNodeRefs();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
results.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("Found " + people.size() + " users");
|
logger.debug("Found " + nodes.size() + " users");
|
||||||
|
|
||||||
this.users = new ArrayList<Node>(people.size());
|
this.users = new ArrayList<Node>(nodes.size());
|
||||||
|
|
||||||
for (NodeRef nodeRef : people)
|
for (NodeRef nodeRef : nodes)
|
||||||
{
|
{
|
||||||
// create our Node representation
|
// create our Node representation
|
||||||
MapNode node = new MapNode(nodeRef);
|
MapNode node = new MapNode(nodeRef);
|
||||||
|
@@ -21,6 +21,7 @@ package org.alfresco.web.ui.common;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
@@ -61,7 +62,10 @@ import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
|||||||
import org.alfresco.service.cmr.repository.NoTransformerException;
|
import org.alfresco.service.cmr.repository.NoTransformerException;
|
||||||
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.security.PersonService;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
import org.alfresco.web.app.Application;
|
import org.alfresco.web.app.Application;
|
||||||
import org.alfresco.web.app.servlet.DownloadContentServlet;
|
import org.alfresco.web.app.servlet.DownloadContentServlet;
|
||||||
import org.alfresco.web.app.servlet.ExternalAccessServlet;
|
import org.alfresco.web.app.servlet.ExternalAccessServlet;
|
||||||
@@ -1046,12 +1050,53 @@ public final class Utils extends StringUtils
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the QName sort for a standard Person lookup. The filter is
|
||||||
|
* standardised across multiple JSF components and beans, and used with
|
||||||
|
* {@link PersonService#getPeople(List, boolean, List, org.alfresco.query.PagingRequest)}
|
||||||
|
*/
|
||||||
|
public static List<Pair<QName,Boolean>> generatePersonSort()
|
||||||
|
{
|
||||||
|
List<Pair<QName,Boolean>> sort = new ArrayList<Pair<QName,Boolean>>();
|
||||||
|
sort.add(new Pair<QName, Boolean>(ContentModel.PROP_FIRSTNAME, true));
|
||||||
|
sort.add(new Pair<QName, Boolean>(ContentModel.PROP_LASTNAME, true));
|
||||||
|
sort.add(new Pair<QName, Boolean>(ContentModel.PROP_USERNAME, true));
|
||||||
|
return sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the QName filter for a standard Person lookup. The filter is
|
||||||
|
* standardised across multiple JSF components and beans, and used with
|
||||||
|
* {@link PersonService#getPeople(List, boolean, List, org.alfresco.query.PagingRequest)}
|
||||||
|
*
|
||||||
|
* @param term Search term
|
||||||
|
*/
|
||||||
|
public static List<Pair<QName,String>> generatePersonFilter(String term)
|
||||||
|
{
|
||||||
|
List<Pair<QName,String>> filter = new ArrayList<Pair<QName,String>>();
|
||||||
|
filter.add(new Pair<QName, String>(ContentModel.PROP_FIRSTNAME, term));
|
||||||
|
filter.add(new Pair<QName, String>(ContentModel.PROP_LASTNAME, term));
|
||||||
|
filter.add(new Pair<QName, String>(ContentModel.PROP_USERNAME, term));
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many results should a person search return up to? This is needed
|
||||||
|
* because the JSF components do paging differently.
|
||||||
|
* For now, hard coded at 1000, may be configurable later
|
||||||
|
*/
|
||||||
|
public static int getPersonMaxResults()
|
||||||
|
{
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the Lucene query for a standard Person search. The query used is standardised
|
* Generate the Lucene query for a standard Person search. The query used is standardised
|
||||||
* across multiple JSF components and beans.
|
* across multiple JSF components and beans.
|
||||||
*
|
*
|
||||||
* @param query Buffer for the query
|
* @param query Buffer for the query
|
||||||
* @param term Search term
|
* @param term Search term
|
||||||
|
* @deprecated Use {@link #generatePersonFilter(String)} and {@link PersonService#getPeople(List, boolean, List, org.alfresco.query.PagingRequest)} instead
|
||||||
*/
|
*/
|
||||||
public static void generatePersonSearch(StringBuilder query, String term)
|
public static void generatePersonSearch(StringBuilder query, String term)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user