mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1465: RMv21CapabilityPatch takes ages to complete
* observered performance of capability patches improved * RMv21CapabilityPatch observered at 4478ms (in profiler) down to 200ms after changes git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@75530 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -146,6 +146,9 @@ public abstract class AbstractModulePatch implements ModulePatch, BeanNameAware
|
||||
return moduleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fixesFromSchema fixes from schema value
|
||||
*/
|
||||
public void setFixesFromSchema(int fixesFromSchema)
|
||||
{
|
||||
this.fixesFromSchema = fixesFromSchema;
|
||||
@@ -160,6 +163,9 @@ public abstract class AbstractModulePatch implements ModulePatch, BeanNameAware
|
||||
return fixesFromSchema;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fixesToSchema fixes to schema value
|
||||
*/
|
||||
public void setFixesToSchema(int fixesToSchema)
|
||||
{
|
||||
this.fixesToSchema = fixesToSchema;
|
||||
@@ -206,15 +212,16 @@ public abstract class AbstractModulePatch implements ModulePatch, BeanNameAware
|
||||
",to=" + fixesToSchema +
|
||||
",target=" + targetSchema);
|
||||
}
|
||||
|
||||
|
||||
// do patch in transaction
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(
|
||||
new ApplyCallback(),
|
||||
true,
|
||||
false);
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
|
||||
if (LOGGER.isInfoEnabled())
|
||||
{
|
||||
LOGGER.debug(" ... module patch applied");
|
||||
LOGGER.info(" ... module patch applied");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -21,13 +21,12 @@ package org.alfresco.module.org_alfresco_module_rm.patch.common;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.Role;
|
||||
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.PermissionService;
|
||||
|
||||
/**
|
||||
* Abstract implementation of capability patch.
|
||||
@@ -40,26 +39,26 @@ public abstract class CapabilityPatch extends AbstractModulePatch
|
||||
/** File plan service */
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
/** File plan role service */
|
||||
private FilePlanRoleService filePlanRoleService;
|
||||
|
||||
/** Capability service */
|
||||
private CapabilityService capabilityService;
|
||||
|
||||
/** authority service */
|
||||
private AuthorityService authorityService;
|
||||
|
||||
/** permission service */
|
||||
private PermissionService permissionService;
|
||||
|
||||
/**
|
||||
* @param filePlanRoleService file plan role service
|
||||
* @param authorityService authority service
|
||||
*/
|
||||
public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService)
|
||||
public void setAuthorityService(AuthorityService authorityService)
|
||||
{
|
||||
this.filePlanRoleService = filePlanRoleService;
|
||||
this.authorityService = authorityService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param capabilityService capability service
|
||||
* @param permissionService permission service
|
||||
*/
|
||||
public void setCapabilityService(CapabilityService capabilityService)
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.capabilityService = capabilityService;
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,32 +88,17 @@ public abstract class CapabilityPatch extends AbstractModulePatch
|
||||
*/
|
||||
protected void addCapability(NodeRef filePlan, String capabilityName, String ... roles)
|
||||
{
|
||||
Capability capability = capabilityService.getCapability(capabilityName);
|
||||
if (capability == null)
|
||||
for (String role : roles)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Can't patch capabilities, because capability " + capabilityName + " does not exist.");
|
||||
}
|
||||
|
||||
for (String roleName : roles)
|
||||
{
|
||||
Role role = filePlanRoleService.getRole(filePlan, roleName);
|
||||
|
||||
if (role != null)
|
||||
String fullRoleName = role + filePlan.getId();
|
||||
String roleAuthority = authorityService.getName(AuthorityType.GROUP, fullRoleName);
|
||||
if (roleAuthority == null)
|
||||
{
|
||||
// get the roles current capabilities
|
||||
Set<Capability> capabilities = role.getCapabilities();
|
||||
|
||||
// only update if the capability is missing
|
||||
if (!capabilities.contains(capability))
|
||||
{
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug(" ... adding capability " + capabilityName + " to role " + role.getName());
|
||||
}
|
||||
|
||||
capabilities.add(capability);
|
||||
filePlanRoleService.updateRole(filePlan, role.getName(), role.getDisplayLabel(), capabilities);
|
||||
}
|
||||
throw new AlfrescoRuntimeException("Role " + role + " does not exist.");
|
||||
}
|
||||
else
|
||||
{
|
||||
permissionService.setPermission(filePlan, roleAuthority, capabilityName, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -93,7 +93,7 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent
|
||||
{
|
||||
LOGGER.info("Module patch component '" + getName() + "' is executing ...");
|
||||
}
|
||||
|
||||
|
||||
// execute path within an isolated transaction
|
||||
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
|
||||
{
|
||||
|
@@ -21,12 +21,12 @@ package org.alfresco.module.org_alfresco_module_rm.patch.v21;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.role.Role;
|
||||
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.PermissionService;
|
||||
|
||||
/**
|
||||
* RM v2.1 patch to updated modified capabilities.
|
||||
@@ -39,28 +39,12 @@ public class RMv21CapabilityPatch extends RMv21PatchComponent
|
||||
{
|
||||
/** File plan service */
|
||||
private FilePlanService filePlanService;
|
||||
|
||||
/** File plan role service */
|
||||
private FilePlanRoleService filePlanRoleService;
|
||||
|
||||
/** Capability service */
|
||||
private CapabilityService capabilityService;
|
||||
|
||||
/**
|
||||
* @param filePlanRoleService file plan role service
|
||||
*/
|
||||
public void setFilePlanRoleService(FilePlanRoleService filePlanRoleService)
|
||||
{
|
||||
this.filePlanRoleService = filePlanRoleService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param capabilityService capability service
|
||||
*/
|
||||
public void setCapabilityService(CapabilityService capabilityService)
|
||||
{
|
||||
this.capabilityService = capabilityService;
|
||||
}
|
||||
|
||||
/** authority service */
|
||||
private AuthorityService authorityService;
|
||||
|
||||
/** permission service */
|
||||
private PermissionService permissionService;
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
@@ -78,6 +62,22 @@ public class RMv21CapabilityPatch extends RMv21PatchComponent
|
||||
protected Set<NodeRef> getFilePlans()
|
||||
{
|
||||
return filePlanService.getFilePlans();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param authorityService authority service
|
||||
*/
|
||||
public void setAuthorityService(AuthorityService authorityService)
|
||||
{
|
||||
this.authorityService = authorityService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param permissionService permission service
|
||||
*/
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,34 +87,19 @@ public class RMv21CapabilityPatch extends RMv21PatchComponent
|
||||
* @param capabilityName capability name
|
||||
* @param roles roles
|
||||
*/
|
||||
protected void addCapability(NodeRef filePlan, String capabilityName, String ... roles)
|
||||
private void addCapability(NodeRef filePlan, String capabilityName, String ... roles)
|
||||
{
|
||||
Capability capability = capabilityService.getCapability(capabilityName);
|
||||
if (capability == null)
|
||||
for (String role : roles)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to bootstrap RMv21 capabilities, because capability " + capabilityName + " does not exist.");
|
||||
}
|
||||
|
||||
for (String roleName : roles)
|
||||
{
|
||||
Role role = filePlanRoleService.getRole(filePlan, roleName);
|
||||
|
||||
if (role != null)
|
||||
String fullRoleName = role + filePlan.getId();
|
||||
String roleAuthority = authorityService.getName(AuthorityType.GROUP, fullRoleName);
|
||||
if (roleAuthority == null)
|
||||
{
|
||||
// get the roles current capabilities
|
||||
Set<Capability> capabilities = role.getCapabilities();
|
||||
|
||||
// only update if the capability is missing
|
||||
if (!capabilities.contains(capability))
|
||||
{
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug(" ... adding capability " + capabilityName + " to role " + role.getName());
|
||||
}
|
||||
|
||||
capabilities.add(capability);
|
||||
filePlanRoleService.updateRole(filePlan, role.getName(), role.getDisplayLabel(), capabilities);
|
||||
}
|
||||
throw new AlfrescoRuntimeException("Role " + role + " does not exist.");
|
||||
}
|
||||
else
|
||||
{
|
||||
permissionService.setPermission(filePlan, roleAuthority, capabilityName, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user