mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-9154: SVC 44: Lucene removal: Forms picker webscript (Removed the lucene group search)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28553 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -32,6 +32,7 @@ import junit.framework.TestCase;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.domain.permissions.AclDAO;
|
||||
import org.alfresco.repo.jscript.ScriptNode;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
||||
@@ -140,15 +141,15 @@ public class ScriptAuthorityServiceTest extends TestCase
|
||||
}
|
||||
|
||||
// And the group
|
||||
if(authorityService.authorityExists(GROUP_A_FULL))
|
||||
if (authorityService.authorityExists(GROUP_A_FULL))
|
||||
{
|
||||
authorityService.deleteAuthority(GROUP_A_FULL);
|
||||
}
|
||||
if(authorityService.authorityExists(GROUP_B_FULL))
|
||||
if (authorityService.authorityExists(GROUP_B_FULL))
|
||||
{
|
||||
authorityService.deleteAuthority(GROUP_B_FULL);
|
||||
}
|
||||
if(authorityService.authorityExists(GROUP_C_FULL))
|
||||
if (authorityService.authorityExists(GROUP_C_FULL))
|
||||
{
|
||||
authorityService.deleteAuthority(GROUP_C_FULL);
|
||||
}
|
||||
@@ -201,9 +202,9 @@ public class ScriptAuthorityServiceTest extends TestCase
|
||||
ScriptGroup groupC = null;
|
||||
for(ScriptGroup group : groups)
|
||||
{
|
||||
if(group.getShortName().equals(GROUP_A)) groupA = group;
|
||||
if(group.getShortName().equals(GROUP_B)) groupB = group;
|
||||
if(group.getShortName().equals(GROUP_C)) groupC = group;
|
||||
if (group.getShortName().equals(GROUP_A)) groupA = group;
|
||||
if (group.getShortName().equals(GROUP_B)) groupB = group;
|
||||
if (group.getShortName().equals(GROUP_C)) groupC = group;
|
||||
}
|
||||
assertNotNull(GROUP_A + " not found in " + groups, groupA);
|
||||
assertNotNull(GROUP_B + " not found in " + groups, groupB);
|
||||
@@ -213,6 +214,11 @@ public class ScriptAuthorityServiceTest extends TestCase
|
||||
assertEquals(GROUP_A, groupA.getShortName());
|
||||
assertEquals(GROUP_A, groupA.getDisplayName());
|
||||
assertEquals(GROUP_A_FULL, groupA.getFullName());
|
||||
|
||||
// return the NodeRef for the group and check
|
||||
ScriptNode groupANode = groupA.getGroupNode();
|
||||
assertEquals(groupA.getDisplayName(), groupANode.getProperties().get("authorityDisplayName"));
|
||||
assertEquals(groupA.getFullName(), groupANode.getProperties().get("authorityName"));
|
||||
}
|
||||
|
||||
public void testZones()
|
||||
@@ -226,14 +232,14 @@ public class ScriptAuthorityServiceTest extends TestCase
|
||||
|
||||
// Check groups
|
||||
ScriptGroup[] groups = service.searchGroups(
|
||||
GROUP_A, new ScriptPagingDetails(10,0), "default"
|
||||
);
|
||||
GROUP_A, new ScriptPagingDetails(10,0), "default");
|
||||
|
||||
assertEquals(1, groups.length);
|
||||
assertEquals(GROUP_A, groups[0].getShortName());
|
||||
|
||||
groups = service.searchGroups(
|
||||
GROUP_A.substring(0, GROUP_A.length()-1), new ScriptPagingDetails(10,0), "default"
|
||||
);
|
||||
GROUP_A.substring(0, GROUP_A.length()-1), new ScriptPagingDetails(10,0), "default");
|
||||
|
||||
assertEquals(3, groups.length);
|
||||
assertEquals(GROUP_A, groups[0].getShortName());
|
||||
assertEquals(GROUP_B, groups[1].getShortName());
|
||||
@@ -241,29 +247,29 @@ public class ScriptAuthorityServiceTest extends TestCase
|
||||
|
||||
// Check groups with paging
|
||||
groups = service.searchGroups(
|
||||
GROUP_A.substring(0, GROUP_A.length()-1), new ScriptPagingDetails(2,0), "default"
|
||||
);
|
||||
GROUP_A.substring(0, GROUP_A.length()-1), new ScriptPagingDetails(2,0), "default");
|
||||
|
||||
assertEquals(2, groups.length);
|
||||
assertEquals(GROUP_A, groups[0].getShortName());
|
||||
assertEquals(GROUP_B, groups[1].getShortName());
|
||||
|
||||
groups = service.searchGroups(
|
||||
GROUP_A.substring(0, GROUP_A.length()-1), new ScriptPagingDetails(2, 2), "default"
|
||||
);
|
||||
GROUP_A.substring(0, GROUP_A.length()-1), new ScriptPagingDetails(2, 2), "default");
|
||||
|
||||
assertEquals(1, groups.length);
|
||||
assertEquals(GROUP_C, groups[0].getShortName());
|
||||
|
||||
|
||||
// Check root groups
|
||||
groups = service.searchRootGroups(
|
||||
GROUP_A, new ScriptPagingDetails(10,0), "default"
|
||||
);
|
||||
GROUP_A, new ScriptPagingDetails(10,0), "default");
|
||||
|
||||
assertEquals(1, groups.length);
|
||||
assertEquals(GROUP_A, groups[0].getShortName());
|
||||
|
||||
groups = service.searchRootGroups(
|
||||
GROUP_A.substring(0, GROUP_A.length()-1)+"*", new ScriptPagingDetails(10,0), "default"
|
||||
);
|
||||
GROUP_A.substring(0, GROUP_A.length()-1)+"*", new ScriptPagingDetails(10,0), "default");
|
||||
|
||||
assertEquals(2, groups.length);
|
||||
assertEquals(GROUP_A, groups[0].getShortName());
|
||||
assertEquals(GROUP_C, groups[1].getShortName());
|
||||
@@ -278,16 +284,16 @@ public class ScriptAuthorityServiceTest extends TestCase
|
||||
|
||||
groups = service.searchGroupsInZone(
|
||||
GROUP_A.substring(0, GROUP_A.length()-1), AuthorityService.ZONE_APP_SHARE,
|
||||
new ScriptPagingDetails(10,0), "default"
|
||||
);
|
||||
new ScriptPagingDetails(10,0), "default");
|
||||
|
||||
assertEquals(2, groups.length);
|
||||
assertEquals(GROUP_A, groups[0].getShortName());
|
||||
assertEquals(GROUP_B, groups[1].getShortName());
|
||||
|
||||
groups = service.searchGroupsInZone(
|
||||
GROUP_A.substring(0, GROUP_A.length()-1), AuthorityService.ZONE_APP_WCM,
|
||||
new ScriptPagingDetails(10,0), "default"
|
||||
);
|
||||
new ScriptPagingDetails(10,0), "default");
|
||||
|
||||
assertEquals(1, groups.length);
|
||||
assertEquals(GROUP_B, groups[0].getShortName());
|
||||
|
||||
@@ -295,15 +301,15 @@ public class ScriptAuthorityServiceTest extends TestCase
|
||||
// And root groups in zones
|
||||
groups = service.searchRootGroupsInZone(
|
||||
GROUP_A.substring(0, GROUP_A.length()-1)+"*", AuthorityService.ZONE_APP_SHARE,
|
||||
new ScriptPagingDetails(10,0), "default"
|
||||
);
|
||||
new ScriptPagingDetails(10,0), "default");
|
||||
|
||||
assertEquals(1, groups.length);
|
||||
assertEquals(GROUP_A, groups[0].getShortName());
|
||||
|
||||
groups = service.searchRootGroupsInZone(
|
||||
GROUP_A.substring(0, GROUP_A.length()-1)+"*", AuthorityService.ZONE_APP_WCM,
|
||||
new ScriptPagingDetails(10,0), "default"
|
||||
);
|
||||
new ScriptPagingDetails(10,0), "default");
|
||||
|
||||
// B apparently counts as a root group in the WCM zone as it's
|
||||
// parent group A isn't in that zone too
|
||||
assertEquals(1, groups.length);
|
||||
@@ -334,8 +340,8 @@ public class ScriptAuthorityServiceTest extends TestCase
|
||||
ScriptUser userB = null;
|
||||
for(ScriptUser user : users)
|
||||
{
|
||||
if(user.getFullName().equals(USER_A)) userA = user;
|
||||
if(user.getFullName().equals(USER_B)) userB = user;
|
||||
if (user.getFullName().equals(USER_A)) userA = user;
|
||||
if (user.getFullName().equals(USER_B)) userB = user;
|
||||
}
|
||||
assertNotNull(userA);
|
||||
assertNotNull(userB);
|
||||
@@ -377,16 +383,16 @@ public class ScriptAuthorityServiceTest extends TestCase
|
||||
ScriptUser[] users = service.searchUsers(
|
||||
AuthenticationUtil.getAdminUserName(),
|
||||
new ScriptPagingDetails(10, 0),
|
||||
"userName"
|
||||
);
|
||||
"userName");
|
||||
|
||||
assertTrue("Admin not found", users.length > 0);
|
||||
|
||||
// Try to find our test users
|
||||
users = service.searchUsers(
|
||||
USER_A.substring(0, USER_A.length()-1),
|
||||
new ScriptPagingDetails(10, 0),
|
||||
"userName"
|
||||
);
|
||||
"userName");
|
||||
|
||||
assertEquals("Users count wrong " + users, 3, users.length);
|
||||
|
||||
// Check on the username sorting
|
||||
@@ -404,8 +410,8 @@ public class ScriptAuthorityServiceTest extends TestCase
|
||||
users = service.searchUsers(
|
||||
USER_A.substring(0, USER_A.length()-1),
|
||||
new ScriptPagingDetails(10, 0),
|
||||
"userName"
|
||||
);
|
||||
"userName");
|
||||
|
||||
assertEquals("Users count wrong " + users, 3, users.length);
|
||||
assertEquals(USER_A, users[0].getPerson().getProperties().get("userName"));
|
||||
assertEquals(USER_B, users[1].getPerson().getProperties().get("userName"));
|
||||
@@ -415,8 +421,8 @@ public class ScriptAuthorityServiceTest extends TestCase
|
||||
users = service.searchUsers(
|
||||
USER_A.substring(0, USER_A.length()-1),
|
||||
new ScriptPagingDetails(10, 0),
|
||||
"firstName"
|
||||
);
|
||||
"firstName");
|
||||
|
||||
assertEquals("Users count wrong " + users, 3, users.length);
|
||||
assertEquals(USER_B, users[0].getPerson().getProperties().get("userName"));
|
||||
assertEquals(USER_A, users[1].getPerson().getProperties().get("userName"));
|
||||
@@ -426,8 +432,8 @@ public class ScriptAuthorityServiceTest extends TestCase
|
||||
users = service.searchUsers(
|
||||
USER_A.substring(0, USER_A.length()-1),
|
||||
new ScriptPagingDetails(10, 0),
|
||||
"lastName"
|
||||
);
|
||||
"lastName");
|
||||
|
||||
assertEquals("Users count wrong " + users, 3, users.length);
|
||||
assertEquals(USER_C, users[0].getPerson().getProperties().get("userName"));
|
||||
assertEquals(USER_A, users[1].getPerson().getProperties().get("userName"));
|
||||
|
@@ -31,7 +31,9 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.alfresco.repo.jscript.ScriptNode;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.AuthorityType;
|
||||
import org.alfresco.util.ModelUtil;
|
||||
@@ -55,6 +57,7 @@ public class ScriptGroup implements Authority, Serializable
|
||||
private String displayName;
|
||||
private Set<String> childAuthorityNames;
|
||||
private Boolean isAdmin;
|
||||
private NodeRef groupNodeRef;
|
||||
private Scriptable scope;
|
||||
|
||||
/**
|
||||
@@ -101,26 +104,31 @@ public class ScriptGroup implements Authority, Serializable
|
||||
authorityService.deleteAuthority(fullName);
|
||||
}
|
||||
|
||||
public void setAuthorityType(ScriptAuthorityType authorityType) {
|
||||
public void setAuthorityType(ScriptAuthorityType authorityType)
|
||||
{
|
||||
this.authorityType = authorityType;
|
||||
}
|
||||
|
||||
public ScriptAuthorityType getAuthorityType() {
|
||||
public ScriptAuthorityType getAuthorityType()
|
||||
{
|
||||
return authorityType;
|
||||
}
|
||||
|
||||
public void setShortName(String shortName) {
|
||||
public void setShortName(String shortName)
|
||||
{
|
||||
this.shortName = shortName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short name
|
||||
*/
|
||||
public String getShortName() {
|
||||
public String getShortName()
|
||||
{
|
||||
return shortName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
public void setFullName(String fullName)
|
||||
{
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
@@ -128,7 +136,8 @@ public class ScriptGroup implements Authority, Serializable
|
||||
* Get the full internal name, also known
|
||||
* as the Authority Name
|
||||
*/
|
||||
public String getFullName() {
|
||||
public String getFullName()
|
||||
{
|
||||
return fullName;
|
||||
}
|
||||
|
||||
@@ -136,7 +145,8 @@ public class ScriptGroup implements Authority, Serializable
|
||||
* Change the display name for this group. Need administrator permission to call this method to change a display name.
|
||||
* @param displayName
|
||||
*/
|
||||
public void setDisplayName(String displayName) {
|
||||
public void setDisplayName(String displayName)
|
||||
{
|
||||
if (this.displayName != null && !this.displayName.equals(displayName))
|
||||
{
|
||||
authorityService.setAuthorityDisplayName(fullName, displayName);
|
||||
@@ -144,7 +154,8 @@ public class ScriptGroup implements Authority, Serializable
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
public String getDisplayName()
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@@ -497,6 +508,32 @@ public class ScriptGroup implements Authority, Serializable
|
||||
authorityService.removeAuthority(fullName, fullAuthorityName);
|
||||
clearCaches();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the NodeRef of the group
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public NodeRef getGroupNodeRef()
|
||||
{
|
||||
if (groupNodeRef == null)
|
||||
{
|
||||
// Lazy lookup for Authority based creation
|
||||
groupNodeRef = authorityService.getAuthorityNodeRef(fullName);
|
||||
}
|
||||
|
||||
return groupNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a ScriptNode wrapping the group
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public ScriptNode getGroupNode()
|
||||
{
|
||||
return new ScriptNode(getGroupNodeRef(), serviceRegistry, this.scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the caches
|
||||
|
Reference in New Issue
Block a user