Merged V3.0 to HEAD

11943: Fix for ETHREEOH-879 & ETHREEOH-783: Multi-valued properties not allowed in Alfresco 3.0 (due to java.lang.UnsupportedOperationException)
   11944: Fix for ETHREEOH-865
   11947: Build fix for site service unit test failures.  This will be reviewed since it works round the issue rather than tackle why runAs is now failing.
   11952: ETHREEOH-845, ETHREEOH-871, ETHREEOH-853, ETHREEOH-839
   11953: ETHREEOH-483 Unable to upload files [with Flash 10 installed] Fixed to fit into yui 2.6.0
   11954: Added missing 'protocolOrder' configuration value.
   11956: Fix for ETHREEOH-895
   11957: Fix for ETHREEOH-891.
   11958: Readded generated source line for RemoteAPI project.
   11959: ETHREEOH-483 Unable to upload files [with Flash 10 installed] Missed to add this image
   11960: Removed JDK6 specific method.
   11962: Fixed missing setup of the share mapper class name when the <class> config tag is used. ALFCOM-2060.
   11964: fix for ETHREEOH-266 - restrict length of webapp to 150 chars.
   11965: Merged 2.2 to 3.0
      11926: Fox for ETHREEOH-725 User doesn't receive email to his box when rule 'Send an Email to specified users' is created 
   11966: ETHREEOH-872: Editing Email-notify-rules fails w/ ClassCastException
   11967: MT - test fixes (post runAs merge)
   11968: Changed Windows x64 NetBIOS warning message to be a debug message. ETHREEOH-897.
   11971: ETHREEOH-829 Case issue when inserting Document Share links into a discussion using richtext editor
   11973: Fix for ETHREEOH-890 - users with apostrophe in their login name can now login to Alfresco Explorer (and Share).

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12490 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2008-12-18 13:58:20 +00:00
parent b387b9b85a
commit c07be19e36
13 changed files with 274 additions and 65 deletions

View File

@@ -25,17 +25,24 @@
package org.alfresco.repo.jscript;
import java.util.Set;
import java.util.StringTokenizer;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.search.impl.lucene.QueryParser;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.repo.security.authentication.PasswordGenerator;
import org.alfresco.repo.security.authentication.UserNameGenerator;
import org.alfresco.repo.security.authority.AuthorityDAO;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
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.AuthorityService;
import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.util.ParameterCheck;
import org.alfresco.util.PropertyMap;
import org.mozilla.javascript.Context;
@@ -56,6 +63,23 @@ public final class People extends BaseScopableProcessorExtension
private MutableAuthenticationDao mutableAuthenticationDao;
private UserNameGenerator usernameGenerator;
private PasswordGenerator passwordGenerator;
private StoreRef storeRef;
/**
* Set the default store reference
*
* @param storeRef the default store reference
*/
public void setStoreUrl(String storeRef)
{
// ensure this is not set again by a script instance
if (this.storeRef != null)
{
throw new IllegalStateException("Default store URL can only be set once.");
}
this.storeRef = new StoreRef(storeRef);
}
/**
* Set the mutable authentication dao
@@ -221,9 +245,12 @@ public final class People extends BaseScopableProcessorExtension
return person;
}
/**
* Get the collection of people stored in the repository.
* An optional filter query may be provided by which to filter the people collection.
* Space separate the query terms i.e. "john bob" will find all users who's first or
* second names contain the strings "john" or "bob".
*
* @param filter filter query string by which to filter the collection of people.
* If <pre>null</pre> then all people stored in the repository are returned
@@ -232,10 +259,78 @@ public final class People extends BaseScopableProcessorExtension
*/
public Scriptable getPeople(String filter)
{
Object[] people = personService.getAllPeople().toArray();
return getPeople(filter, 0);
}
/**
* Get the collection of people stored in the repository.
* An optional filter query may be provided by which to filter the people collection.
* Space separate the query terms i.e. "john bob" will find all users who's first or
* second names contain the strings "john" or "bob".
*
* @param filter filter query string by which to filter the collection of people.
* If <pre>null</pre> then all people stored in the repository are returned
* @param maxResults maximum results to return or all if <= 0
*
* @return people collection as a JavaScript array
*/
public Scriptable getPeople(String filter, int maxResults)
{
Object[] people = null;
// TODO glen.johnson@alfresco.com - if filterQuery parameter provided, then filter the collection
// of people
if (filter == null)
{
people = personService.getAllPeople().toArray();
}
else
{
filter = filter.trim();
if (filter.length() != 0)
{
// define the query to find people by their first or last name
StringBuilder query = new StringBuilder(128);
for (StringTokenizer t = new StringTokenizer(filter, " "); t.hasMoreTokens(); /**/)
{
String term = QueryParser.escape(t.nextToken());
query.append("@").append(NamespaceService.CONTENT_MODEL_PREFIX).append("\\:firstName:\"*");
query.append(term);
query.append("*\" @").append(NamespaceService.CONTENT_MODEL_PREFIX).append("\\:lastName:\"*");
query.append(term);
query.append("*\" ");
}
// define the search parameters
SearchParameters params = new SearchParameters();
params.setLanguage(SearchService.LANGUAGE_LUCENE);
params.addStore(this.storeRef);
params.setQuery(query.toString());
ResultSet results = null;
try
{
results = services.getSearchService().query(params);
people = results.getNodeRefs().toArray();
}
finally
{
if (results != null)
{
results.close();
}
}
}
}
if (people == null)
{
people = new Object[0];
}
else if (maxResults > 0 && people.length > maxResults)
{
Object[] copy = new Object[maxResults];
System.arraycopy(people, 0, copy, 0, maxResults);
people = copy;
}
return Context.getCurrentContext().newArray(getScope(), people);
}