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.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.domain.permissions.AclDAO;
|
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.AuthenticationComponent;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
||||||
@@ -213,6 +214,11 @@ public class ScriptAuthorityServiceTest extends TestCase
|
|||||||
assertEquals(GROUP_A, groupA.getShortName());
|
assertEquals(GROUP_A, groupA.getShortName());
|
||||||
assertEquals(GROUP_A, groupA.getDisplayName());
|
assertEquals(GROUP_A, groupA.getDisplayName());
|
||||||
assertEquals(GROUP_A_FULL, groupA.getFullName());
|
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()
|
public void testZones()
|
||||||
@@ -226,14 +232,14 @@ public class ScriptAuthorityServiceTest extends TestCase
|
|||||||
|
|
||||||
// Check groups
|
// Check groups
|
||||||
ScriptGroup[] groups = service.searchGroups(
|
ScriptGroup[] groups = service.searchGroups(
|
||||||
GROUP_A, new ScriptPagingDetails(10,0), "default"
|
GROUP_A, new ScriptPagingDetails(10,0), "default");
|
||||||
);
|
|
||||||
assertEquals(1, groups.length);
|
assertEquals(1, groups.length);
|
||||||
assertEquals(GROUP_A, groups[0].getShortName());
|
assertEquals(GROUP_A, groups[0].getShortName());
|
||||||
|
|
||||||
groups = service.searchGroups(
|
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(3, groups.length);
|
||||||
assertEquals(GROUP_A, groups[0].getShortName());
|
assertEquals(GROUP_A, groups[0].getShortName());
|
||||||
assertEquals(GROUP_B, groups[1].getShortName());
|
assertEquals(GROUP_B, groups[1].getShortName());
|
||||||
@@ -241,29 +247,29 @@ public class ScriptAuthorityServiceTest extends TestCase
|
|||||||
|
|
||||||
// Check groups with paging
|
// Check groups with paging
|
||||||
groups = service.searchGroups(
|
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(2, groups.length);
|
||||||
assertEquals(GROUP_A, groups[0].getShortName());
|
assertEquals(GROUP_A, groups[0].getShortName());
|
||||||
assertEquals(GROUP_B, groups[1].getShortName());
|
assertEquals(GROUP_B, groups[1].getShortName());
|
||||||
|
|
||||||
groups = service.searchGroups(
|
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(1, groups.length);
|
||||||
assertEquals(GROUP_C, groups[0].getShortName());
|
assertEquals(GROUP_C, groups[0].getShortName());
|
||||||
|
|
||||||
|
|
||||||
// Check root groups
|
// Check root groups
|
||||||
groups = service.searchRootGroups(
|
groups = service.searchRootGroups(
|
||||||
GROUP_A, new ScriptPagingDetails(10,0), "default"
|
GROUP_A, new ScriptPagingDetails(10,0), "default");
|
||||||
);
|
|
||||||
assertEquals(1, groups.length);
|
assertEquals(1, groups.length);
|
||||||
assertEquals(GROUP_A, groups[0].getShortName());
|
assertEquals(GROUP_A, groups[0].getShortName());
|
||||||
|
|
||||||
groups = service.searchRootGroups(
|
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(2, groups.length);
|
||||||
assertEquals(GROUP_A, groups[0].getShortName());
|
assertEquals(GROUP_A, groups[0].getShortName());
|
||||||
assertEquals(GROUP_C, groups[1].getShortName());
|
assertEquals(GROUP_C, groups[1].getShortName());
|
||||||
@@ -278,16 +284,16 @@ public class ScriptAuthorityServiceTest extends TestCase
|
|||||||
|
|
||||||
groups = service.searchGroupsInZone(
|
groups = service.searchGroupsInZone(
|
||||||
GROUP_A.substring(0, GROUP_A.length()-1), AuthorityService.ZONE_APP_SHARE,
|
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(2, groups.length);
|
||||||
assertEquals(GROUP_A, groups[0].getShortName());
|
assertEquals(GROUP_A, groups[0].getShortName());
|
||||||
assertEquals(GROUP_B, groups[1].getShortName());
|
assertEquals(GROUP_B, groups[1].getShortName());
|
||||||
|
|
||||||
groups = service.searchGroupsInZone(
|
groups = service.searchGroupsInZone(
|
||||||
GROUP_A.substring(0, GROUP_A.length()-1), AuthorityService.ZONE_APP_WCM,
|
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(1, groups.length);
|
||||||
assertEquals(GROUP_B, groups[0].getShortName());
|
assertEquals(GROUP_B, groups[0].getShortName());
|
||||||
|
|
||||||
@@ -295,15 +301,15 @@ public class ScriptAuthorityServiceTest extends TestCase
|
|||||||
// And root groups in zones
|
// And root groups in zones
|
||||||
groups = service.searchRootGroupsInZone(
|
groups = service.searchRootGroupsInZone(
|
||||||
GROUP_A.substring(0, GROUP_A.length()-1)+"*", AuthorityService.ZONE_APP_SHARE,
|
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(1, groups.length);
|
||||||
assertEquals(GROUP_A, groups[0].getShortName());
|
assertEquals(GROUP_A, groups[0].getShortName());
|
||||||
|
|
||||||
groups = service.searchRootGroupsInZone(
|
groups = service.searchRootGroupsInZone(
|
||||||
GROUP_A.substring(0, GROUP_A.length()-1)+"*", AuthorityService.ZONE_APP_WCM,
|
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
|
// B apparently counts as a root group in the WCM zone as it's
|
||||||
// parent group A isn't in that zone too
|
// parent group A isn't in that zone too
|
||||||
assertEquals(1, groups.length);
|
assertEquals(1, groups.length);
|
||||||
@@ -377,16 +383,16 @@ public class ScriptAuthorityServiceTest extends TestCase
|
|||||||
ScriptUser[] users = service.searchUsers(
|
ScriptUser[] users = service.searchUsers(
|
||||||
AuthenticationUtil.getAdminUserName(),
|
AuthenticationUtil.getAdminUserName(),
|
||||||
new ScriptPagingDetails(10, 0),
|
new ScriptPagingDetails(10, 0),
|
||||||
"userName"
|
"userName");
|
||||||
);
|
|
||||||
assertTrue("Admin not found", users.length > 0);
|
assertTrue("Admin not found", users.length > 0);
|
||||||
|
|
||||||
// Try to find our test users
|
// Try to find our test users
|
||||||
users = service.searchUsers(
|
users = service.searchUsers(
|
||||||
USER_A.substring(0, USER_A.length()-1),
|
USER_A.substring(0, USER_A.length()-1),
|
||||||
new ScriptPagingDetails(10, 0),
|
new ScriptPagingDetails(10, 0),
|
||||||
"userName"
|
"userName");
|
||||||
);
|
|
||||||
assertEquals("Users count wrong " + users, 3, users.length);
|
assertEquals("Users count wrong " + users, 3, users.length);
|
||||||
|
|
||||||
// Check on the username sorting
|
// Check on the username sorting
|
||||||
@@ -404,8 +410,8 @@ public class ScriptAuthorityServiceTest extends TestCase
|
|||||||
users = service.searchUsers(
|
users = service.searchUsers(
|
||||||
USER_A.substring(0, USER_A.length()-1),
|
USER_A.substring(0, USER_A.length()-1),
|
||||||
new ScriptPagingDetails(10, 0),
|
new ScriptPagingDetails(10, 0),
|
||||||
"userName"
|
"userName");
|
||||||
);
|
|
||||||
assertEquals("Users count wrong " + users, 3, users.length);
|
assertEquals("Users count wrong " + users, 3, users.length);
|
||||||
assertEquals(USER_A, users[0].getPerson().getProperties().get("userName"));
|
assertEquals(USER_A, users[0].getPerson().getProperties().get("userName"));
|
||||||
assertEquals(USER_B, users[1].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(
|
users = service.searchUsers(
|
||||||
USER_A.substring(0, USER_A.length()-1),
|
USER_A.substring(0, USER_A.length()-1),
|
||||||
new ScriptPagingDetails(10, 0),
|
new ScriptPagingDetails(10, 0),
|
||||||
"firstName"
|
"firstName");
|
||||||
);
|
|
||||||
assertEquals("Users count wrong " + users, 3, users.length);
|
assertEquals("Users count wrong " + users, 3, users.length);
|
||||||
assertEquals(USER_B, users[0].getPerson().getProperties().get("userName"));
|
assertEquals(USER_B, users[0].getPerson().getProperties().get("userName"));
|
||||||
assertEquals(USER_A, users[1].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(
|
users = service.searchUsers(
|
||||||
USER_A.substring(0, USER_A.length()-1),
|
USER_A.substring(0, USER_A.length()-1),
|
||||||
new ScriptPagingDetails(10, 0),
|
new ScriptPagingDetails(10, 0),
|
||||||
"lastName"
|
"lastName");
|
||||||
);
|
|
||||||
assertEquals("Users count wrong " + users, 3, users.length);
|
assertEquals("Users count wrong " + users, 3, users.length);
|
||||||
assertEquals(USER_C, users[0].getPerson().getProperties().get("userName"));
|
assertEquals(USER_C, users[0].getPerson().getProperties().get("userName"));
|
||||||
assertEquals(USER_A, users[1].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.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import org.alfresco.repo.jscript.ScriptNode;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
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.AuthorityService;
|
||||||
import org.alfresco.service.cmr.security.AuthorityType;
|
import org.alfresco.service.cmr.security.AuthorityType;
|
||||||
import org.alfresco.util.ModelUtil;
|
import org.alfresco.util.ModelUtil;
|
||||||
@@ -55,6 +57,7 @@ public class ScriptGroup implements Authority, Serializable
|
|||||||
private String displayName;
|
private String displayName;
|
||||||
private Set<String> childAuthorityNames;
|
private Set<String> childAuthorityNames;
|
||||||
private Boolean isAdmin;
|
private Boolean isAdmin;
|
||||||
|
private NodeRef groupNodeRef;
|
||||||
private Scriptable scope;
|
private Scriptable scope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,26 +104,31 @@ public class ScriptGroup implements Authority, Serializable
|
|||||||
authorityService.deleteAuthority(fullName);
|
authorityService.deleteAuthority(fullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAuthorityType(ScriptAuthorityType authorityType) {
|
public void setAuthorityType(ScriptAuthorityType authorityType)
|
||||||
|
{
|
||||||
this.authorityType = authorityType;
|
this.authorityType = authorityType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptAuthorityType getAuthorityType() {
|
public ScriptAuthorityType getAuthorityType()
|
||||||
|
{
|
||||||
return authorityType;
|
return authorityType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShortName(String shortName) {
|
public void setShortName(String shortName)
|
||||||
|
{
|
||||||
this.shortName = shortName;
|
this.shortName = shortName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the short name
|
* Get the short name
|
||||||
*/
|
*/
|
||||||
public String getShortName() {
|
public String getShortName()
|
||||||
|
{
|
||||||
return shortName;
|
return shortName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFullName(String fullName) {
|
public void setFullName(String fullName)
|
||||||
|
{
|
||||||
this.fullName = fullName;
|
this.fullName = fullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +136,8 @@ public class ScriptGroup implements Authority, Serializable
|
|||||||
* Get the full internal name, also known
|
* Get the full internal name, also known
|
||||||
* as the Authority Name
|
* as the Authority Name
|
||||||
*/
|
*/
|
||||||
public String getFullName() {
|
public String getFullName()
|
||||||
|
{
|
||||||
return fullName;
|
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.
|
* Change the display name for this group. Need administrator permission to call this method to change a display name.
|
||||||
* @param displayName
|
* @param displayName
|
||||||
*/
|
*/
|
||||||
public void setDisplayName(String displayName) {
|
public void setDisplayName(String displayName)
|
||||||
|
{
|
||||||
if (this.displayName != null && !this.displayName.equals(displayName))
|
if (this.displayName != null && !this.displayName.equals(displayName))
|
||||||
{
|
{
|
||||||
authorityService.setAuthorityDisplayName(fullName, displayName);
|
authorityService.setAuthorityDisplayName(fullName, displayName);
|
||||||
@@ -144,7 +154,8 @@ public class ScriptGroup implements Authority, Serializable
|
|||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayName() {
|
public String getDisplayName()
|
||||||
|
{
|
||||||
return displayName;
|
return displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,6 +509,32 @@ public class ScriptGroup implements Authority, Serializable
|
|||||||
clearCaches();
|
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
|
* clear the caches
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user