diff --git a/config/alfresco/messages/patch-service.properties b/config/alfresco/messages/patch-service.properties
index ed48519c09..0545accfe7 100644
--- a/config/alfresco/messages/patch-service.properties
+++ b/config/alfresco/messages/patch-service.properties
@@ -138,7 +138,7 @@ patch.contentFormFolderType.description=Update WCM Content Form folder type.
patch.contentFormFolderType.result=Updated {0} WCM Content Form objects to 'wcm:formfolder' type.
patch.groupNamesAsIdentifiers.description=Reindex usr:authorityContainer gids as identifiers
-patch.groupNamesAsIdentifiers.result=Reindex usr:authorityContainer gids as identifiers
+patch.groupNamesAsIdentifiers.result=Reindexed usr:authorityContainer with identifiers
patch.invalidUserPersonAndGroup.description=Fix up invalid uids for people and users; and invalid gids for groups
patch.invalidUserPersonAndGroup.result=Fixed ''{0}'' invalid user nodes, ''{1}'' invalid person nodes and ''{2}'' invalid authority nodes.
@@ -151,3 +151,7 @@ patch.webscriptsExtension.description=Adds Web Scripts Extension to Data Diction
patch.AVMLayeredSnapshot.description=Set indirectionVersion on Layered Nodes.
patch.AVMLayeredSnapshot.result=Layered Node indirectionVersions set.
+
+patch.groupMembersAsIdentifiers.description=Reindex usr:authorityContainer members as identifiers=======
+
+
diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml
index 7045f8f272..c7ca0022ec 100644
--- a/config/alfresco/patch/patch-services-context.xml
+++ b/config/alfresco/patch/patch-services-context.xml
@@ -770,7 +770,7 @@
alfresco/bootstrap/webScriptsExtensions.xml
-
+
patch.AVMLayeredSnapshot
@@ -783,4 +783,21 @@
+
+ patch.groupMembersAsIdentifiers
+ patch.groupMembersAsIdentifiers.description
+ 0
+ 56
+ 57
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/alfresco/version.properties b/config/alfresco/version.properties
index 8debfe7463..63ca630a8d 100644
--- a/config/alfresco/version.properties
+++ b/config/alfresco/version.properties
@@ -19,4 +19,4 @@ version.build=@build-number@
# Schema number
-version.schema=56
+version.schema=57
diff --git a/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneIndexerImpl.java b/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneIndexerImpl.java
index a3a6d8026f..0af84c036b 100644
--- a/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneIndexerImpl.java
+++ b/source/java/org/alfresco/repo/search/impl/lucene/ADMLuceneIndexerImpl.java
@@ -335,9 +335,9 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
*
* @param storeRef
* @param deltaId
- * @param config
+ * @param config
* @return - the indexer instance
- * @throws LuceneIndexException
+ * @throws LuceneIndexException
*/
public static ADMLuceneIndexerImpl getUpdateIndexer(StoreRef storeRef, String deltaId, LuceneConfig config)
throws LuceneIndexException
@@ -446,10 +446,6 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
}
-
-
-
-
static class Counter
{
int countInParent = 0;
@@ -486,6 +482,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
/**
* Helper class to hold two related objects
+ *
* @param first
* @param second
*/
@@ -497,6 +494,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
/**
* Get the first
+ *
* @return - first
*/
public F getFirst()
@@ -506,6 +504,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
/**
* Get the second
+ *
* @return -second
*/
public S getSecond()
@@ -518,8 +517,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
boolean includeDirectoryDocuments)
{
NodeRef nodeRef = new NodeRef(stringNodeRef);
-
-
+
Map nodeCounts = getNodeCounts(nodeRef);
List docs = new ArrayList();
ChildAssociationRef qNameRef = null;
@@ -715,11 +713,12 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
* true to ignore all properties that must be indexed non-atomically
* @return Returns true if the property was indexed atomically, or false if it should be done asynchronously
*/
- protected boolean indexProperty(NodeRef nodeRef, QName propertyName, Serializable value, Document doc, boolean indexAtomicPropertiesOnly)
+ protected boolean indexProperty(NodeRef nodeRef, QName propertyName, Serializable value, Document doc,
+ boolean indexAtomicPropertiesOnly)
{
String attributeName = "@"
+ QName.createQName(propertyName.getNamespaceURI(), ISO9075.encode(propertyName.getLocalName()));
-
+
boolean store = true;
boolean index = true;
boolean tokenise = true;
@@ -727,7 +726,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
boolean isContent = false;
boolean isMultiLingual = false;
boolean isText = false;
-
+
PropertyDefinition propertyDef = getDictionaryService().getProperty(propertyName);
if (propertyDef != null)
{
@@ -749,7 +748,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
// we are only doing atomic properties and the property is definitely non-atomic
return false;
}
-
+
if (!indexAtomicPropertiesOnly)
{
doc.removeFields(propertyName.toString());
@@ -774,7 +773,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
// nothing to index
continue;
}
-
+
if (isContent)
{
ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, serializableValue);
@@ -789,7 +788,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
Field.Index.UN_TOKENIZED, Field.TermVector.NO));
doc.add(new Field(attributeName + ".size", Long.toString(contentData.getSize()), Field.Store.NO,
Field.Index.TOKENIZED, Field.TermVector.NO));
-
+
// TODO: Use the node locale in preferanced to the system locale
Locale locale = contentData.getLocale();
if (locale == null)
@@ -806,7 +805,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
}
doc.add(new Field(attributeName + ".locale", locale.toString().toLowerCase(), Field.Store.NO,
Field.Index.UN_TOKENIZED, Field.TermVector.NO));
-
+
ContentReader reader = contentService.getReader(nodeRef, propertyName);
if (reader != null && reader.exists())
{
@@ -852,7 +851,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
writer.setEncoding("UTF-8");
try
{
-
+
transformer.transform(reader, writer);
// point the reader to the new-written content
reader = writer.getReader();
@@ -890,7 +889,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
// isr = new InputStreamReader(ris);
// }
// doc.add(new Field("TEXT", isr, Field.TermVector.NO));
-
+
InputStream ris = reader.getReader().getContentInputStream();
try
{
@@ -928,7 +927,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
{
Field.Store fieldStore = store ? Field.Store.YES : Field.Store.NO;
Field.Index fieldIndex;
-
+
if (index)
{
if (tokenise)
@@ -944,7 +943,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
{
fieldIndex = Field.Index.NO;
}
-
+
if ((fieldIndex != Field.Index.NO) || (fieldStore != Field.Store.NO))
{
if (isMultiLingual)
@@ -962,20 +961,23 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
else if (isText)
{
// Temporary special case for uids and gids
- if(propertyName.equals(ContentModel.PROP_USER_USERNAME) || propertyName.equals(ContentModel.PROP_USERNAME) || propertyName.equals(ContentModel.PROP_AUTHORITY_NAME))
+ if (propertyName.equals(ContentModel.PROP_USER_USERNAME)
+ || propertyName.equals(ContentModel.PROP_USERNAME)
+ || propertyName.equals(ContentModel.PROP_AUTHORITY_NAME)
+ || propertyName.equals(ContentModel.PROP_MEMBERS))
{
doc.add(new Field(attributeName, strValue, fieldStore, fieldIndex, Field.TermVector.NO));
}
-
+
// TODO: Use the node locale in preferanced to the system locale
Locale locale = null;
-
+
Serializable localeProperty = nodeService.getProperty(nodeRef, ContentModel.PROP_LOCALE);
if (localeProperty != null)
{
locale = DefaultTypeConverter.INSTANCE.convert(Locale.class, localeProperty);
}
-
+
if (locale == null)
{
locale = I18NUtil.getLocale();
@@ -999,10 +1001,10 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
}
}
}
-
+
return wereAllAtomic;
}
-
+
/**
* Does the node type or any applied aspect allow this node to have child associations?
*
@@ -1235,7 +1237,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
"Failed to execute query to find content which needs updating in the index", e);
}
- for(int i = 0; i < hits.length(); i++)
+ for (int i = 0; i < hits.length(); i++)
{
Document doc = hits.doc(i);
Helper helper = new Helper(doc.getField("ID").stringValue(), doc.getField("TX").stringValue());
@@ -1275,7 +1277,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
{
// Document document = helper.document;
NodeRef ref = new NodeRef(helper.ref);
-// bypass nodes that have disappeared
+ // bypass nodes that have disappeared
if (!nodeService.exists(ref))
{
continue;
@@ -1373,7 +1375,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
flushPending();
// prepareToMergeIntoMain();
}
-
+
protected void doCommit() throws IOException
{
if (indexUpdateStatus == IndexUpdateStatus.ASYNCHRONOUS)
@@ -1391,18 +1393,18 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl imp
callBack.indexCompleted(store, remainingCount, null);
}
}
-
+
protected void doRollBack() throws IOException
{
if (callBack != null)
{
callBack.indexCompleted(store, 0, null);
- }
+ }
}
-
+
protected void doSetRollbackOnly() throws IOException
{
-
+
}
}
diff --git a/source/java/org/alfresco/repo/search/impl/lucene/AVMLuceneIndexerImpl.java b/source/java/org/alfresco/repo/search/impl/lucene/AVMLuceneIndexerImpl.java
index 7956d07e92..ea8e290dca 100644
--- a/source/java/org/alfresco/repo/search/impl/lucene/AVMLuceneIndexerImpl.java
+++ b/source/java/org/alfresco/repo/search/impl/lucene/AVMLuceneIndexerImpl.java
@@ -938,7 +938,8 @@ public class AVMLuceneIndexerImpl extends AbstractLuceneIndexerImpl impl
// Temporary special case for uids and gids
if (propertyName.equals(ContentModel.PROP_USER_USERNAME)
|| propertyName.equals(ContentModel.PROP_USERNAME)
- || propertyName.equals(ContentModel.PROP_AUTHORITY_NAME))
+ || propertyName.equals(ContentModel.PROP_AUTHORITY_NAME)
+ || propertyName.equals(ContentModel.PROP_MEMBERS))
{
doc.add(new Field(attributeName, strValue, fieldStore, fieldIndex, Field.TermVector.NO));
}
diff --git a/source/java/org/alfresco/repo/search/impl/lucene/LuceneAnalyser.java b/source/java/org/alfresco/repo/search/impl/lucene/LuceneAnalyser.java
index bf7329da0b..0f8c2834a2 100644
--- a/source/java/org/alfresco/repo/search/impl/lucene/LuceneAnalyser.java
+++ b/source/java/org/alfresco/repo/search/impl/lucene/LuceneAnalyser.java
@@ -167,7 +167,8 @@ public class LuceneAnalyser extends Analyzer
if (propertyQName.equals(ContentModel.PROP_USER_USERNAME)
|| propertyQName.equals(ContentModel.PROP_USERNAME)
- || propertyQName.equals(ContentModel.PROP_AUTHORITY_NAME))
+ || propertyQName.equals(ContentModel.PROP_AUTHORITY_NAME)
+ || propertyQName.equals(ContentModel.PROP_MEMBERS))
{
analyser = new VerbatimAnalyser(true);
}
diff --git a/source/java/org/alfresco/repo/security/authentication/userModel.xml b/source/java/org/alfresco/repo/security/authentication/userModel.xml
index 03e995403a..ce732b07c2 100644
--- a/source/java/org/alfresco/repo/security/authentication/userModel.xml
+++ b/source/java/org/alfresco/repo/security/authentication/userModel.xml
@@ -80,11 +80,6 @@
d:text
true
-
- true
- false
- false
-
diff --git a/source/java/org/alfresco/repo/security/authority/AuthorityDAOImpl.java b/source/java/org/alfresco/repo/security/authority/AuthorityDAOImpl.java
index eb790632b9..368a8fbcdb 100644
--- a/source/java/org/alfresco/repo/security/authority/AuthorityDAOImpl.java
+++ b/source/java/org/alfresco/repo/security/authority/AuthorityDAOImpl.java
@@ -126,7 +126,7 @@ public class AuthorityDAOImpl implements AuthorityDAO
nodeService.setProperty(parentRef, ContentModel.PROP_MEMBERS, members);
userToAuthorityCache.remove(childName);
}
- else if (AuthorityType.getAuthorityType(childName).equals(AuthorityType.GROUP))
+ else if (AuthorityType.getAuthorityType(childName).equals(AuthorityType.GROUP))
{
NodeRef childRef = getAuthorityOrNull(childName);
if (childRef == null)
@@ -139,7 +139,8 @@ public class AuthorityDAOImpl implements AuthorityDAO
}
else
{
- throw new AlfrescoRuntimeException("Authorities of the type "+AuthorityType.getAuthorityType(childName)+" may not be added to other authorities");
+ throw new AlfrescoRuntimeException("Authorities of the type "
+ + AuthorityType.getAuthorityType(childName) + " may not be added to other authorities");
}
}
@@ -250,11 +251,11 @@ public class AuthorityDAOImpl implements AuthorityDAO
public Set getContainingAuthorities(AuthorityType type, String name, boolean immediate)
{
- if (AuthorityType.getAuthorityType(name).equals(AuthorityType.USER) && ! immediate && (type == null))
+ if (AuthorityType.getAuthorityType(name).equals(AuthorityType.USER) && !immediate && (type == null))
{
// Cache user to authority look ups
HashSet authorities = userToAuthorityCache.get(name);
- if(authorities == null)
+ if (authorities == null)
{
authorities = new HashSet();
findAuthorities(type, name, authorities, true, !immediate);
@@ -264,9 +265,9 @@ public class AuthorityDAOImpl implements AuthorityDAO
}
else
{
- HashSet authorities = new HashSet();
- findAuthorities(type, name, authorities, true, !immediate);
- return authorities;
+ HashSet authorities = new HashSet();
+ findAuthorities(type, name, authorities, true, !immediate);
+ return authorities;
}
}
@@ -279,12 +280,35 @@ public class AuthorityDAOImpl implements AuthorityDAO
}
else if (AuthorityType.getAuthorityType(name).equals(AuthorityType.USER))
{
- for (NodeRef ref : getUserContainers(name))
+ if (parents)
{
- findAuthorities(type, ref, authorities, parents, recursive, true);
+ for (NodeRef ref : getUserContainers(name))
+ {
+ if (recursive)
+ {
+ findAuthorities(type, ref, authorities, parents, recursive, true);
+ }
+ else
+ {
+ String authorityName = DefaultTypeConverter.INSTANCE.convert(String.class, nodeService
+ .getProperty(ref, ContentModel.PROP_AUTHORITY_NAME));
+ if (type == null)
+ {
+ authorities.add(authorityName);
+ }
+ else
+ {
+ AuthorityType authorityType = AuthorityType.getAuthorityType(authorityName);
+ if (authorityType.equals(type))
+ {
+ authorities.add(authorityName);
+ }
+ }
+ }
+ }
}
-
}
+
else
{
NodeRef ref = getAuthorityOrNull(name);
@@ -511,14 +535,14 @@ public class AuthorityDAOImpl implements AuthorityDAO
QName type = nodeService.getType(authorityRef);
if (type.equals(ContentModel.TYPE_AUTHORITY_CONTAINER))
{
- name = (String)nodeService.getProperty(authorityRef, ContentModel.PROP_AUTHORITY_NAME);
+ name = (String) nodeService.getProperty(authorityRef, ContentModel.PROP_AUTHORITY_NAME);
}
else if (type.equals(ContentModel.TYPE_AUTHORITY))
{
- name = (String)nodeService.getProperty(authorityRef, ContentModel.PROP_USER_USERNAME);
+ name = (String) nodeService.getProperty(authorityRef, ContentModel.PROP_USER_USERNAME);
}
}
return name;
}
-
+
}
diff --git a/source/java/org/alfresco/repo/security/authority/AuthorityServiceTest.java b/source/java/org/alfresco/repo/security/authority/AuthorityServiceTest.java
index e3f001882e..95357e281c 100644
--- a/source/java/org/alfresco/repo/security/authority/AuthorityServiceTest.java
+++ b/source/java/org/alfresco/repo/security/authority/AuthorityServiceTest.java
@@ -24,18 +24,25 @@
*/
package org.alfresco.repo.security.authority;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.transaction.UserTransaction;
import junit.framework.TestCase;
+import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.service.ServiceRegistry;
+import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.security.PersonService;
+import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper;
import org.springframework.context.ApplicationContext;
@@ -523,4 +530,248 @@ public class AuthorityServiceTest extends TestCase
assertTrue(pubAuthorityService.getContainedAuthorities(null, auth1, false).contains("andy"));
}
+
+
+ public void test_AR_1510()
+ {
+ personService.getPerson("andy1");
+ personService.getPerson("andy2");
+ personService.getPerson("andy3");
+ personService.getPerson("andy4");
+ personService.getPerson("andy5");
+ personService.getPerson("andy6");
+ assertEquals(0, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
+ assertEquals(0, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
+ String auth1 = pubAuthorityService.createAuthority(AuthorityType.GROUP, null, "one");
+ pubAuthorityService.addAuthority(auth1, "andy1");
+ String auth2 = pubAuthorityService.createAuthority(AuthorityType.GROUP, auth1, "two");
+ pubAuthorityService.addAuthority(auth2, "andy1");
+ pubAuthorityService.addAuthority(auth2, "andy2");
+ String auth3 = pubAuthorityService.createAuthority(AuthorityType.GROUP, auth2, "three");
+ pubAuthorityService.addAuthority(auth3, "andy3");
+ String auth4 = pubAuthorityService.createAuthority(AuthorityType.GROUP, auth3, "four");
+ pubAuthorityService.addAuthority(auth4, "andy1");
+ pubAuthorityService.addAuthority(auth4, "andy4");
+ String auth5 = pubAuthorityService.createAuthority(AuthorityType.GROUP, auth4, "five");
+ pubAuthorityService.addAuthority(auth5, "andy1");
+ pubAuthorityService.addAuthority(auth5, "andy5");
+ String auth6 = pubAuthorityService.createAuthority(AuthorityType.GROUP, auth3, "six");
+ pubAuthorityService.addAuthority(auth6, "andy1");
+ pubAuthorityService.addAuthority(auth6, "andy5");
+ pubAuthorityService.addAuthority(auth6, "andy6");
+
+ assertEquals(2, pubAuthorityService.getContainedAuthorities(null, auth1, true).size());
+ assertEquals(11, pubAuthorityService.getContainedAuthorities(null, auth1, false).size());
+ assertEquals(3, pubAuthorityService.getContainedAuthorities(null, auth2, true).size());
+ assertEquals(10, pubAuthorityService.getContainedAuthorities(null, auth2, false).size());
+ assertEquals(3, pubAuthorityService.getContainedAuthorities(null, auth3, true).size());
+ assertEquals(8, pubAuthorityService.getContainedAuthorities(null, auth3, false).size());
+ assertEquals(3, pubAuthorityService.getContainedAuthorities(null, auth4, true).size());
+ assertEquals(4, pubAuthorityService.getContainedAuthorities(null, auth4, false).size());
+ assertEquals(2, pubAuthorityService.getContainedAuthorities(null, auth5, true).size());
+ assertEquals(2, pubAuthorityService.getContainedAuthorities(null, auth5, false).size());
+ assertEquals(3, pubAuthorityService.getContainedAuthorities(null, auth6, true).size());
+ assertEquals(3, pubAuthorityService.getContainedAuthorities(null, auth6, false).size());
+
+ assertEquals(0, pubAuthorityService.getContainedAuthorities(null, "andy1", true).size());
+ assertEquals(0, pubAuthorityService.getContainedAuthorities(null, "andy1", false).size());
+ assertEquals(0, pubAuthorityService.getContainedAuthorities(null, "andy2", true).size());
+ assertEquals(0, pubAuthorityService.getContainedAuthorities(null, "andy2", false).size());
+ assertEquals(0, pubAuthorityService.getContainedAuthorities(null, "andy3", true).size());
+ assertEquals(0, pubAuthorityService.getContainedAuthorities(null, "andy3", false).size());
+ assertEquals(0, pubAuthorityService.getContainedAuthorities(null, "andy4", true).size());
+ assertEquals(0, pubAuthorityService.getContainedAuthorities(null, "andy4", false).size());
+ assertEquals(0, pubAuthorityService.getContainedAuthorities(null, "andy5", true).size());
+ assertEquals(0, pubAuthorityService.getContainedAuthorities(null, "andy5", false).size());
+ assertEquals(0, pubAuthorityService.getContainedAuthorities(null, "andy6", true).size());
+ assertEquals(0, pubAuthorityService.getContainedAuthorities(null, "andy6", false).size());
+
+ assertEquals(1, pubAuthorityService.getContainedAuthorities(AuthorityType.GROUP, auth1, true).size());
+ assertEquals(5, pubAuthorityService.getContainedAuthorities(AuthorityType.GROUP, auth1, false).size());
+ assertEquals(1, pubAuthorityService.getContainedAuthorities(AuthorityType.GROUP, auth2, true).size());
+ assertEquals(4, pubAuthorityService.getContainedAuthorities(AuthorityType.GROUP, auth2, false).size());
+ assertEquals(2, pubAuthorityService.getContainedAuthorities(AuthorityType.GROUP, auth3, true).size());
+ assertEquals(3, pubAuthorityService.getContainedAuthorities(AuthorityType.GROUP, auth3, false).size());
+ assertEquals(1, pubAuthorityService.getContainedAuthorities(AuthorityType.GROUP, auth4, true).size());
+ assertEquals(1, pubAuthorityService.getContainedAuthorities(AuthorityType.GROUP, auth4, false).size());
+ assertEquals(0, pubAuthorityService.getContainedAuthorities(AuthorityType.GROUP, auth5, true).size());
+ assertEquals(0, pubAuthorityService.getContainedAuthorities(AuthorityType.GROUP, auth5, false).size());
+ assertEquals(0, pubAuthorityService.getContainedAuthorities(AuthorityType.GROUP, auth6, true).size());
+ assertEquals(0, pubAuthorityService.getContainedAuthorities(AuthorityType.GROUP, auth6, false).size());
+
+ assertEquals(1, pubAuthorityService.getContainedAuthorities(AuthorityType.USER, auth1, true).size());
+ assertEquals(6, pubAuthorityService.getContainedAuthorities(AuthorityType.USER, auth1, false).size());
+ assertEquals(2, pubAuthorityService.getContainedAuthorities(AuthorityType.USER, auth2, true).size());
+ assertEquals(6, pubAuthorityService.getContainedAuthorities(AuthorityType.USER, auth2, false).size());
+ assertEquals(1, pubAuthorityService.getContainedAuthorities(AuthorityType.USER, auth3, true).size());
+ assertEquals(5, pubAuthorityService.getContainedAuthorities(AuthorityType.USER, auth3, false).size());
+ assertEquals(2, pubAuthorityService.getContainedAuthorities(AuthorityType.USER, auth4, true).size());
+ assertEquals(3, pubAuthorityService.getContainedAuthorities(AuthorityType.USER, auth4, false).size());
+ assertEquals(2, pubAuthorityService.getContainedAuthorities(AuthorityType.USER, auth5, true).size());
+ assertEquals(2, pubAuthorityService.getContainedAuthorities(AuthorityType.USER, auth5, false).size());
+ assertEquals(3, pubAuthorityService.getContainedAuthorities(AuthorityType.USER, auth6, true).size());
+ assertEquals(3, pubAuthorityService.getContainedAuthorities(AuthorityType.USER, auth6, false).size());
+
+ // containing
+
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(null, auth1, true).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(null, auth1, false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(null, auth2, true).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(null, auth2, false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(null, auth3, true).size());
+ assertEquals(2, pubAuthorityService.getContainingAuthorities(null, auth3, false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(null, auth4, true).size());
+ assertEquals(3, pubAuthorityService.getContainingAuthorities(null, auth4, false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(null, auth5, true).size());
+ assertEquals(4, pubAuthorityService.getContainingAuthorities(null, auth5, false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(null, auth6, true).size());
+ assertEquals(3, pubAuthorityService.getContainingAuthorities(null, auth6, false).size());
+
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, auth1, true).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, auth1, false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, auth2, true).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, auth2, false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, auth3, true).size());
+ assertEquals(2, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, auth3, false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, auth4, true).size());
+ assertEquals(3, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, auth4, false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, auth5, true).size());
+ assertEquals(4, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, auth5, false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, auth6, true).size());
+ assertEquals(3, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, auth6, false).size());
+
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, auth1, true).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, auth1, false).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, auth2, true).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, auth2, false).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, auth3, true).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, auth3, false).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, auth4, true).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, auth4, false).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, auth5, true).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, auth5, false).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, auth6, true).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, auth6, false).size());
+
+
+ assertEquals(5, pubAuthorityService.getContainingAuthorities(null, "andy1", true).size());
+ assertEquals(6, pubAuthorityService.getContainingAuthorities(null, "andy1", false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(null, "andy2", true).size());
+ assertEquals(2, pubAuthorityService.getContainingAuthorities(null, "andy2", false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(null, "andy3", true).size());
+ assertEquals(3, pubAuthorityService.getContainingAuthorities(null, "andy3", false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(null, "andy4", true).size());
+ assertEquals(4, pubAuthorityService.getContainingAuthorities(null, "andy4", false).size());
+ assertEquals(2, pubAuthorityService.getContainingAuthorities(null, "andy5", true).size());
+ assertEquals(6, pubAuthorityService.getContainingAuthorities(null, "andy5", false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(null, "andy6", true).size());
+ assertEquals(4, pubAuthorityService.getContainingAuthorities(null, "andy6", false).size());
+
+ assertEquals(5, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, "andy1", true).size());
+ assertEquals(6, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, "andy1", false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, "andy2", true).size());
+ assertEquals(2, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, "andy2", false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, "andy3", true).size());
+ assertEquals(3, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, "andy3", false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, "andy4", true).size());
+ assertEquals(4, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, "andy4", false).size());
+ assertEquals(2, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, "andy5", true).size());
+ assertEquals(6, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, "andy5", false).size());
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, "andy6", true).size());
+ assertEquals(4, pubAuthorityService.getContainingAuthorities(AuthorityType.GROUP, "andy6", false).size());
+
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, "andy1", true).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, "andy1", false).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, "andy2", true).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, "andy2", false).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, "andy3", true).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, "andy3", false).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, "andy4", true).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, "andy4", false).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, "andy5", true).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, "andy5", false).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, "andy6", true).size());
+ assertEquals(0, pubAuthorityService.getContainingAuthorities(AuthorityType.USER, "andy6", false).size());
+ }
+
+
+
+ /**
+ * Test toknisation of group members
+ *
+ */
+ public void test_AR_1517__AND__AR_1411()
+ {
+ personService.getPerson("1234");
+ assertTrue(personService.personExists("1234"));
+ personService.getPerson("Loon");
+ assertTrue(personService.personExists("Loon"));
+ personService.getPerson("andy");
+ assertTrue(personService.personExists("andy"));
+ personService.createPerson(createDefaultProperties("Novalike", "Nova", "Like", "Nove@Like", "Sun", null));
+ assertTrue(personService.personExists("Novalike"));
+ personService.getPerson("1andy");
+ assertTrue(personService.personExists("1andy"));
+ personService.getPerson("andy2");
+ assertTrue(personService.personExists("andy2"));
+ personService.getPerson("an3dy");
+ assertTrue(personService.personExists("an3dy"));
+
+
+ assertEquals(0, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
+ assertEquals(0, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
+ String auth1 = pubAuthorityService.createAuthority(AuthorityType.GROUP, null, "one");
+ pubAuthorityService.addAuthority(auth1, "1234");
+ String auth2 = pubAuthorityService.createAuthority(AuthorityType.GROUP, null, "two");
+ pubAuthorityService.addAuthority(auth2, "andy");
+ String auth3 = pubAuthorityService.createAuthority(AuthorityType.GROUP, null, "three");
+ pubAuthorityService.addAuthority(auth3, "Novalike");
+ String auth4 = pubAuthorityService.createAuthority(AuthorityType.GROUP, null, "four");
+ pubAuthorityService.addAuthority(auth4, "1andy");
+ String auth5 = pubAuthorityService.createAuthority(AuthorityType.GROUP, null, "five");
+ pubAuthorityService.addAuthority(auth5, "andy2");
+ String auth6 = pubAuthorityService.createAuthority(AuthorityType.GROUP, null, "six");
+ pubAuthorityService.addAuthority(auth6, "an3dy");
+
+
+ assertEquals(1, pubAuthorityService.getContainedAuthorities(null, auth1, true).size());
+ assertTrue(pubAuthorityService.getContainedAuthorities(null, auth1, true).contains("1234"));
+ assertEquals(1, pubAuthorityService.getContainedAuthorities(null, auth2, true).size());
+ assertTrue(pubAuthorityService.getContainedAuthorities(null, auth2, true).contains("andy"));
+ assertEquals(1, pubAuthorityService.getContainedAuthorities(null, auth3, true).size());
+ assertTrue(pubAuthorityService.getContainedAuthorities(null, auth3, true).contains("Novalike"));
+ assertEquals(1, pubAuthorityService.getContainedAuthorities(null, auth4, true).size());
+ assertTrue(pubAuthorityService.getContainedAuthorities(null, auth4, true).contains("1andy"));
+ assertEquals(1, pubAuthorityService.getContainedAuthorities(null, auth5, true).size());
+ assertTrue(pubAuthorityService.getContainedAuthorities(null, auth5, true).contains("andy2"));
+ assertEquals(1, pubAuthorityService.getContainedAuthorities(null, auth6, true).size());
+ assertTrue(pubAuthorityService.getContainedAuthorities(null, auth6, true).contains("an3dy"));
+
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(null, "1234", false).size());
+ assertTrue(pubAuthorityService.getContainingAuthorities(null, "1234", false).contains(auth1));
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(null, "andy", false).size());
+ assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy", false).contains(auth2));
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(null, "Novalike", false).size());
+ assertTrue(pubAuthorityService.getContainingAuthorities(null, "Novalike", false).contains(auth3));
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(null, "1andy", false).size());
+ assertTrue(pubAuthorityService.getContainingAuthorities(null, "1andy", false).contains(auth4));
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(null, "andy2", false).size());
+ assertTrue(pubAuthorityService.getContainingAuthorities(null, "andy2", false).contains(auth5));
+ assertEquals(1, pubAuthorityService.getContainingAuthorities(null, "an3dy", false).size());
+ assertTrue(pubAuthorityService.getContainingAuthorities(null, "an3dy", false).contains(auth6));
+
+ }
+
+ private Map createDefaultProperties(String userName, String firstName, String lastName,
+ String email, String orgId, NodeRef home)
+ {
+ HashMap properties = new HashMap();
+ properties.put(ContentModel.PROP_USERNAME, userName);
+ properties.put(ContentModel.PROP_HOMEFOLDER, home);
+ properties.put(ContentModel.PROP_FIRSTNAME, firstName);
+ properties.put(ContentModel.PROP_LASTNAME, lastName);
+ properties.put(ContentModel.PROP_EMAIL, email);
+ properties.put(ContentModel.PROP_ORGID, orgId);
+ return properties;
+ }
}