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:
Roy Wetherall
2014-07-02 02:45:53 +00:00
parent 3873bb592a
commit b222acd167
6 changed files with 80 additions and 104 deletions

View File

@@ -48,8 +48,8 @@
<property name="sinceVersion" value="2.1"/> <property name="sinceVersion" value="2.1"/>
<property name="appliesFromVersion" value="2.1"/> <property name="appliesFromVersion" value="2.1"/>
<property name="filePlanService" ref="FilePlanService"/> <property name="filePlanService" ref="FilePlanService"/>
<property name="filePlanRoleService" ref="FilePlanRoleService"/> <property name="authorityService" ref="authorityService"/>
<property name="capabilityService" ref="CapabilityService"/> <property name="permissionService" ref="permissionService"/>
</bean> </bean>
<bean id="org_alfresco_module_rm_RMv21RecordInheritancePatch" <bean id="org_alfresco_module_rm_RMv21RecordInheritancePatch"

View File

@@ -22,8 +22,8 @@
<property name="fixesToSchema" value="1001"/> <property name="fixesToSchema" value="1001"/>
<property name="targetSchema" value="1002"/> <property name="targetSchema" value="1002"/>
<property name="filePlanService" ref="FilePlanService"/> <property name="filePlanService" ref="FilePlanService"/>
<property name="filePlanRoleService" ref="FilePlanRoleService"/> <property name="permissionService" ref="permissionService"/>
<property name="capabilityService" ref="CapabilityService"/> <property name="authorityService" ref="authorityService"/>
</bean> </bean>
<bean id="rm.dodModelSeparationModulePatch" <bean id="rm.dodModelSeparationModulePatch"
@@ -77,8 +77,8 @@
<property name="fixesToSchema" value="1006"/> <property name="fixesToSchema" value="1006"/>
<property name="targetSchema" value="1007"/> <property name="targetSchema" value="1007"/>
<property name="filePlanService" ref="FilePlanService"/> <property name="filePlanService" ref="FilePlanService"/>
<property name="filePlanRoleService" ref="FilePlanRoleService"/> <property name="permissionService" ref="permissionService"/>
<property name="capabilityService" ref="CapabilityService"/> <property name="authorityService" ref="authorityService"/>
</bean> </bean>
<bean id="rm.removeInPlaceRolesFromAllPatch" <bean id="rm.removeInPlaceRolesFromAllPatch"
@@ -99,8 +99,8 @@
<property name="fixesToSchema" value="1008"/> <property name="fixesToSchema" value="1008"/>
<property name="targetSchema" value="1009"/> <property name="targetSchema" value="1009"/>
<property name="filePlanService" ref="FilePlanService"/> <property name="filePlanService" ref="FilePlanService"/>
<property name="filePlanRoleService" ref="FilePlanRoleService"/> <property name="permissionService" ref="permissionService"/>
<property name="capabilityService" ref="CapabilityService"/> <property name="authorityService" ref="authorityService"/>
</bean> </bean>
</beans> </beans>

View File

@@ -146,6 +146,9 @@ public abstract class AbstractModulePatch implements ModulePatch, BeanNameAware
return moduleId; return moduleId;
} }
/**
* @param fixesFromSchema fixes from schema value
*/
public void setFixesFromSchema(int fixesFromSchema) public void setFixesFromSchema(int fixesFromSchema)
{ {
this.fixesFromSchema = fixesFromSchema; this.fixesFromSchema = fixesFromSchema;
@@ -160,6 +163,9 @@ public abstract class AbstractModulePatch implements ModulePatch, BeanNameAware
return fixesFromSchema; return fixesFromSchema;
} }
/**
* @param fixesToSchema fixes to schema value
*/
public void setFixesToSchema(int fixesToSchema) public void setFixesToSchema(int fixesToSchema)
{ {
this.fixesToSchema = fixesToSchema; this.fixesToSchema = fixesToSchema;
@@ -206,15 +212,16 @@ public abstract class AbstractModulePatch implements ModulePatch, BeanNameAware
",to=" + fixesToSchema + ",to=" + fixesToSchema +
",target=" + targetSchema); ",target=" + targetSchema);
} }
// do patch in transaction
transactionService.getRetryingTransactionHelper().doInTransaction( transactionService.getRetryingTransactionHelper().doInTransaction(
new ApplyCallback(), new ApplyCallback(),
true, true,
false); false);
if (LOGGER.isDebugEnabled()) if (LOGGER.isInfoEnabled())
{ {
LOGGER.debug(" ... module patch applied"); LOGGER.info(" ... module patch applied");
} }
} }

View File

@@ -21,13 +21,12 @@ package org.alfresco.module.org_alfresco_module_rm.patch.common;
import java.util.Set; import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException; 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.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch; 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.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. * Abstract implementation of capability patch.
@@ -40,26 +39,26 @@ public abstract class CapabilityPatch extends AbstractModulePatch
/** File plan service */ /** File plan service */
private FilePlanService filePlanService; private FilePlanService filePlanService;
/** File plan role service */ /** authority service */
private FilePlanRoleService filePlanRoleService; private AuthorityService authorityService;
/** Capability service */ /** permission service */
private CapabilityService capabilityService; 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) protected void addCapability(NodeRef filePlan, String capabilityName, String ... roles)
{ {
Capability capability = capabilityService.getCapability(capabilityName); for (String role : roles)
if (capability == null)
{ {
throw new AlfrescoRuntimeException("Can't patch capabilities, because capability " + capabilityName + " does not exist."); String fullRoleName = role + filePlan.getId();
} String roleAuthority = authorityService.getName(AuthorityType.GROUP, fullRoleName);
if (roleAuthority == null)
for (String roleName : roles)
{
Role role = filePlanRoleService.getRole(filePlan, roleName);
if (role != null)
{ {
// get the roles current capabilities throw new AlfrescoRuntimeException("Role " + role + " does not exist.");
Set<Capability> capabilities = role.getCapabilities(); }
else
// only update if the capability is missing {
if (!capabilities.contains(capability)) permissionService.setPermission(filePlan, roleAuthority, capabilityName, true);
{
if (LOGGER.isDebugEnabled())
{
LOGGER.debug(" ... adding capability " + capabilityName + " to role " + role.getName());
}
capabilities.add(capability);
filePlanRoleService.updateRole(filePlan, role.getName(), role.getDisplayLabel(), capabilities);
}
} }
} }
} }

View File

@@ -93,7 +93,7 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent
{ {
LOGGER.info("Module patch component '" + getName() + "' is executing ..."); LOGGER.info("Module patch component '" + getName() + "' is executing ...");
} }
// execute path within an isolated transaction // execute path within an isolated transaction
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{ {

View File

@@ -21,12 +21,12 @@ package org.alfresco.module.org_alfresco_module_rm.patch.v21;
import java.util.Set; import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException; 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.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; 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.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. * RM v2.1 patch to updated modified capabilities.
@@ -39,28 +39,12 @@ public class RMv21CapabilityPatch extends RMv21PatchComponent
{ {
/** File plan service */ /** File plan service */
private FilePlanService filePlanService; private FilePlanService filePlanService;
/** File plan role service */ /** authority service */
private FilePlanRoleService filePlanRoleService; private AuthorityService authorityService;
/** Capability service */ /** permission service */
private CapabilityService capabilityService; private PermissionService permissionService;
/**
* @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;
}
/** /**
* @param filePlanService file plan service * @param filePlanService file plan service
@@ -78,6 +62,22 @@ public class RMv21CapabilityPatch extends RMv21PatchComponent
protected Set<NodeRef> getFilePlans() protected Set<NodeRef> getFilePlans()
{ {
return filePlanService.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 capabilityName capability name
* @param roles roles * @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); for (String role : roles)
if (capability == null)
{ {
throw new AlfrescoRuntimeException("Unable to bootstrap RMv21 capabilities, because capability " + capabilityName + " does not exist."); String fullRoleName = role + filePlan.getId();
} String roleAuthority = authorityService.getName(AuthorityType.GROUP, fullRoleName);
if (roleAuthority == null)
for (String roleName : roles)
{
Role role = filePlanRoleService.getRole(filePlan, roleName);
if (role != null)
{ {
// get the roles current capabilities throw new AlfrescoRuntimeException("Role " + role + " does not exist.");
Set<Capability> capabilities = role.getCapabilities(); }
else
// only update if the capability is missing {
if (!capabilities.contains(capability)) permissionService.setPermission(filePlan, roleAuthority, capabilityName, true);
{
if (LOGGER.isDebugEnabled())
{
LOGGER.debug(" ... adding capability " + capabilityName + " to role " + role.getName());
}
capabilities.add(capability);
filePlanRoleService.updateRole(filePlan, role.getName(), role.getDisplayLabel(), capabilities);
}
} }
} }
} }