mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM Performance testing:
* added helper code to load large numbers of users and groups into RM roles * improved performance of role user/group management console from 13 seconds with 100 groups with a 100 users, down to less than a second * role user/group console now only shows users and groups explicitly assigned to the role to help scale the UI (and make more sense!) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@75102 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -583,7 +583,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
||||
{
|
||||
String capabilityName = permission.getPermission();
|
||||
Capability capability = capabilityService.getCapability(capabilityName);
|
||||
if (capability != null)
|
||||
if (capability != null && !capability.isPrivate())
|
||||
{
|
||||
capabilities.add(capability);
|
||||
}
|
||||
@@ -790,7 +790,7 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Can not get authorities for role " + roleName + ", because it does not exist. (filePlan=" + filePlan.toString() + ")");
|
||||
}
|
||||
return authorityService.getContainedAuthorities(authorityType, role.getRoleGroupName(), false);
|
||||
return authorityService.getContainedAuthorities(authorityType, role.getRoleGroupName(), true);
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
|
||||
|
@@ -29,6 +29,7 @@ import org.alfresco.module.org_alfresco_module_rm.role.Role;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.AuthorityType;
|
||||
import org.apache.cxf.common.util.StringUtils;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
@@ -172,7 +173,11 @@ public class RoleDeclarativeWebScript extends DeclarativeWebScript
|
||||
|
||||
for (String authority : authorities)
|
||||
{
|
||||
String displayLabel = authorityService.getAuthorityDisplayName(authority);
|
||||
String displayLabel = authority;
|
||||
if (!AuthorityType.getAuthorityType(authority).equals(AuthorityType.USER))
|
||||
{
|
||||
displayLabel = authorityService.getAuthorityDisplayName(authority);
|
||||
}
|
||||
result.add(new AuthorityItem(authority, displayLabel));
|
||||
}
|
||||
|
||||
|
@@ -1,16 +1,26 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.system;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.AuthorityType;
|
||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||
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.junit.Assert;
|
||||
@@ -26,6 +36,10 @@ public class DataLoadSystemTest
|
||||
protected RecordFolderService recordFolderService;
|
||||
protected RecordService recordService;
|
||||
protected TransactionService transactionService;
|
||||
protected AuthorityService authorityService;
|
||||
protected MutableAuthenticationService authenticationService;
|
||||
protected PersonService personService;
|
||||
protected FilePlanRoleService filePlanRoleService;
|
||||
|
||||
/** config locations */
|
||||
protected String[] getConfigLocations()
|
||||
@@ -37,31 +51,98 @@ public class DataLoadSystemTest
|
||||
};
|
||||
}
|
||||
|
||||
/** data sizing parameters */
|
||||
/** transaction batch size */
|
||||
private static final int BATCH_SIZE = 100;
|
||||
private static final int ROOT_CATEGORY_COUNT = 1;
|
||||
private static final int RECORD_FOLDER_COUNT = 1;
|
||||
private static final int RECORD_COUNT = 15000;
|
||||
|
||||
/** file plan sizing */
|
||||
private static final int ROOT_CATEGORY_COUNT = 0;
|
||||
private static final int RECORD_FOLDER_COUNT = 0;
|
||||
private static final int RECORD_COUNT = 0;
|
||||
|
||||
/** rm user sizing */
|
||||
private static final int RM_GROUP_COUNT = 0;
|
||||
private static final int RM_USER_COUNT = 0;
|
||||
|
||||
/** application context */
|
||||
private ApplicationContext applicationContext;
|
||||
CommonRMTestUtils utils;
|
||||
|
||||
private int totalCount;
|
||||
private List<NodeRef> recordCategories;
|
||||
private List<NodeRef> recordFolders;
|
||||
private List<String> groups;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
applicationContext = ApplicationContextHelper.getApplicationContext(getConfigLocations());
|
||||
utils = new CommonRMTestUtils(applicationContext);
|
||||
|
||||
filePlanService = (FilePlanService)applicationContext.getBean("FilePlanService");
|
||||
recordFolderService = (RecordFolderService)applicationContext.getBean("RecordFolderService");
|
||||
recordService = (RecordService)applicationContext.getBean("RecordService");
|
||||
transactionService = (TransactionService)applicationContext.getBean("transactionService");
|
||||
authorityService = (AuthorityService)applicationContext.getBean("authorityService");
|
||||
authenticationService = (MutableAuthenticationService)applicationContext.getBean("AuthenticationService");
|
||||
personService = (PersonService)applicationContext.getBean("personService");
|
||||
filePlanRoleService = (FilePlanRoleService)applicationContext.getBean("filePlanRoleService");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loadData()
|
||||
private void loadAllData()
|
||||
{
|
||||
loadFilePlanData();
|
||||
loadRMUsersAndGroups();
|
||||
}
|
||||
|
||||
|
||||
private void loadRMUsersAndGroups()
|
||||
{
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
final NodeRef filePlan = filePlanService.getFilePlanBySiteId(FilePlanService.DEFAULT_RM_SITE_ID);
|
||||
if (filePlan == null)
|
||||
{
|
||||
Assert.fail("The default RM site is not present.");
|
||||
}
|
||||
|
||||
groups = new ArrayList<String>();
|
||||
|
||||
repeatInTransactionBatches(new RunAsWork<Void>()
|
||||
{
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
String groupName = GUID.generate();
|
||||
System.out.println("Creating group " + groupName);
|
||||
groups.add("GROUP_" + authorityService.createAuthority(AuthorityType.GROUP, groupName));
|
||||
filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_RECORDS_MANAGER, groupName);
|
||||
return null;
|
||||
}
|
||||
}, RM_GROUP_COUNT);
|
||||
|
||||
for (final String group : groups)
|
||||
{
|
||||
repeatInTransactionBatches(new RunAsWork<Void>()
|
||||
{
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
String userName = GUID.generate();
|
||||
System.out.println("Creating user " + userName + " and adding to group " + group);
|
||||
createPerson(userName, true);
|
||||
authorityService.addAuthority(group, userName);
|
||||
return null;
|
||||
}
|
||||
}, RM_USER_COUNT);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadFilePlanData()
|
||||
{
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@@ -117,7 +198,18 @@ public class DataLoadSystemTest
|
||||
});
|
||||
}
|
||||
|
||||
protected void repeatInTransactionBatches(final RunAsWork<Void> work, final int count) throws Exception
|
||||
private NodeRef createPerson(String userName, boolean createAuth)
|
||||
{
|
||||
if (createAuth)
|
||||
{
|
||||
authenticationService.createAuthentication(userName, "password".toCharArray());
|
||||
}
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||
properties.put(ContentModel.PROP_USERNAME, userName);
|
||||
return personService.createPerson(properties);
|
||||
}
|
||||
|
||||
private void repeatInTransactionBatches(final RunAsWork<Void> work, final int count) throws Exception
|
||||
{
|
||||
totalCount = 0;
|
||||
while (totalCount < count)
|
||||
|
Reference in New Issue
Block a user