Merged BRANCHES/2.0.1.x to HEAD:

55708: [RM-904] Actions are missing within Records Management Site for Record Series and its children. Patches are implemented as components.  Components are loaded in a single thread. The work of a patch should be wrapped in its own transaction to isolate it from the changes of other patches and allowing patches to commit work before working on the next patch.Moved all work of RMv2ModelPatch into the RetryingTransactionCallback.  RetryingTransactionHelper set to create new thread.
Add RetryingTransactionHelper to RMv2FilePlanNodeRefPatch. Move all of the work of the patch into the callback.  Helper creates new thread.



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@56010 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2013-09-26 04:57:47 +00:00
parent fb24c0a9a8
commit 15e6ad0a82
3 changed files with 116 additions and 92 deletions

View File

@@ -66,6 +66,7 @@
<property name="permissionService" ref="PermissionService"/>
<property name="filePlanService" ref="FilePlanService" />
<property name="filePlanRoleService" ref="filePlanRoleService" />
<property name="retryingTransactionHelper" ref="retryingTransactionHelper"/>
</bean>
<bean id="org_alfresco_module_rm_RMv2SavedSearchPatch"

View File

@@ -32,6 +32,7 @@ import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.domain.patch.PatchDAO;
import org.alfresco.repo.domain.qname.QNameDAO;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.Period;
@@ -61,6 +62,7 @@ public class RMv2FilePlanNodeRefPatch extends ModulePatchComponent
private PermissionService permissionService;
private FilePlanService filePlanService;
private FilePlanRoleService filePlanRoleService;
private RetryingTransactionHelper retryingTransactionHelper;
public void setNodeService(NodeService nodeService)
{
@@ -103,6 +105,11 @@ public class RMv2FilePlanNodeRefPatch extends ModulePatchComponent
this.filePlanRoleService = filePlanRoleService;
}
public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper)
{
this.retryingTransactionHelper = retryingTransactionHelper;
}
/**
* @param filePlanService file plan service
*/
@@ -117,63 +124,81 @@ public class RMv2FilePlanNodeRefPatch extends ModulePatchComponent
@Override
protected void executePatch() throws Throwable
{
Pair<Long, QName> aspectPair = qnameDAO.getQName(ASPECT_FILE_PLAN_COMPONENT);
if (aspectPair != null)
retryingTransactionHelper.doInTransaction(new Work(), false, true);
if (logger.isDebugEnabled() == true)
{
List<Long> filePlanComponents = patchDAO.getNodesByAspectQNameId(aspectPair.getFirst(), 0L, patchDAO.getMaxAdmNodeID());
logger.debug(" ... complete RM Module RMv2FilePlanNodeRef Patch");
}
}
if (logger.isDebugEnabled() == true)
private class Work implements RetryingTransactionHelper.RetryingTransactionCallback<Integer>
{
@Override
public Integer execute() throws Throwable
{
Pair<Long, QName> aspectPair = qnameDAO.getQName(RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT);
if (aspectPair != null)
{
logger.debug(" ... updating " + filePlanComponents.size() + " items" );
}
behaviourFilter.disableBehaviour();
try
{
for (Long filePlanComponent : filePlanComponents)
List<Long> filePlanComponents = patchDAO.getNodesByAspectQNameId(aspectPair.getFirst(), 0L, patchDAO.getMaxAdmNodeID());
if (logger.isDebugEnabled() == true)
{
Pair<Long, NodeRef> recordPair = nodeDAO.getNodePair(filePlanComponent);
NodeRef filePlanComponentNodeRef = recordPair.getSecond();
NodeRef filePlan = filePlanService.getFilePlan(filePlanComponentNodeRef);
// set the file plan node reference
if (nodeService.getProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF) == null)
logger.debug(" ... updating " + filePlanComponents.size() + " items" );
}
behaviourFilter.disableBehaviour();
try
{
for (Long filePlanComponent : filePlanComponents)
{
nodeService.setProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF, filePlan);
}
// only set the rmadmin permissions on record categories, record folders and records
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(filePlanComponentNodeRef);
if (FilePlanComponentKind.RECORD_CATEGORY.equals(kind) == true ||
FilePlanComponentKind.RECORD_FOLDER.equals(kind) == true ||
FilePlanComponentKind.RECORD.equals(kind) == true )
{
// ensure the that the records management role has read and file on the node
Role adminRole = filePlanRoleService.getRole(filePlan, "Administrator");
if (adminRole != null)
{
permissionService.setPermission(filePlanComponentNodeRef, adminRole.getRoleGroupName(), RMPermissionModel.FILING, true);
}
Pair<Long, NodeRef> recordPair = nodeDAO.getNodePair(filePlanComponent);
NodeRef filePlanComponentNodeRef = recordPair.getSecond();
// ensure that the default vital record default values have been set (RM-753)
Serializable vitalRecordIndicator = nodeService.getProperty(filePlanComponentNodeRef, PROP_VITAL_RECORD_INDICATOR);
if (vitalRecordIndicator == null)
NodeRef filePlan = filePlanService.getFilePlan(filePlanComponentNodeRef);
// set the file plan node reference
if (nodeService.getProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF) == null)
{
nodeService.setProperty(filePlanComponentNodeRef, PROP_VITAL_RECORD_INDICATOR, false);
}
Serializable reviewPeriod = nodeService.getProperty(filePlanComponentNodeRef, PROP_REVIEW_PERIOD);
if (reviewPeriod == null)
nodeService.setProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF, filePlan);
}
// only set the rmadmin permissions on record categories, record folders and records
FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(filePlanComponentNodeRef);
if (FilePlanComponentKind.RECORD_CATEGORY.equals(kind) == true ||
FilePlanComponentKind.RECORD_FOLDER.equals(kind) == true ||
FilePlanComponentKind.RECORD.equals(kind) == true )
{
nodeService.setProperty(filePlanComponentNodeRef, PROP_REVIEW_PERIOD, new Period("none|0"));
// ensure the that the records management role has read and file on the node
Role adminRole = filePlanRoleService.getRole(filePlan, "Administrator");
if (adminRole != null)
{
permissionService.setPermission(filePlanComponentNodeRef, adminRole.getRoleGroupName(), RMPermissionModel.FILING, true);
}
// ensure that the default vital record default values have been set (RM-753)
Serializable vitalRecordIndicator = nodeService.getProperty(filePlanComponentNodeRef, PROP_VITAL_RECORD_INDICATOR);
if (vitalRecordIndicator == null)
{
nodeService.setProperty(filePlanComponentNodeRef, PROP_VITAL_RECORD_INDICATOR, false);
}
Serializable reviewPeriod = nodeService.getProperty(filePlanComponentNodeRef, PROP_REVIEW_PERIOD);
if (reviewPeriod == null)
{
nodeService.setProperty(filePlanComponentNodeRef, PROP_REVIEW_PERIOD, new Period("none|0"));
}
}
}
}
finally
{
behaviourFilter.enableBehaviour();
}
}
finally
{
behaviourFilter.enableBehaviour();
}
}
}
// nothing to do
return 0;
}
}
}

View File

@@ -51,6 +51,7 @@ public class RMv2ModelPatch extends ModulePatchComponent
private QNameDAO qnameDAO;
private RetryingTransactionHelper retryingTransactionHelper;
public void setPatchDAO(PatchDAO patchDAO)
{
this.patchDAO = patchDAO;
@@ -89,44 +90,22 @@ public class RMv2ModelPatch extends ModulePatchComponent
private void updateQName(QName qnameBefore, QName qnameAfter, String reindexClass)
{
Long maxNodeId = patchDAO.getMaxAdmNodeID();
Pair<Long, QName> before = qnameDAO.getQName(qnameBefore);
Work work = new Work(qnameBefore, qnameAfter, reindexClass);
retryingTransactionHelper.doInTransaction(work, false, true);
if (before != null)
{
for (Long i = 0L; i < maxNodeId; i+=BATCH_SIZE)
{
Work work = new Work(before.getFirst(), i, reindexClass);
retryingTransactionHelper.doInTransaction(work, false, true);
}
qnameDAO.updateQName(qnameBefore, qnameAfter);
if (logger.isDebugEnabled() == true)
{
logger.debug(" ... updated qname " + qnameBefore.toString());
}
}
else
{
if (logger.isDebugEnabled() == true)
{
logger.debug(" ... no need to update qname " + qnameBefore.toString());
}
}
}
private class Work implements RetryingTransactionHelper.RetryingTransactionCallback<Integer>
{
private long qnameId;
private long lower;
private QName qnameBefore;
private QName qnameAfter;
private String reindexClass;
Work(long qnameId, long lower, String reindexClass)
Work(QName qnameBefore, QName qnameAfter, String reindexClass)
{
this.qnameId = qnameId;
this.lower = lower;
this.qnameBefore = qnameBefore;
this.qnameAfter = qnameAfter;
this.reindexClass = reindexClass;
}
@@ -137,24 +116,43 @@ public class RMv2ModelPatch extends ModulePatchComponent
@Override
public Integer execute() throws Throwable
{
if ("TYPE".equals(reindexClass))
Long maxNodeId = patchDAO.getMaxAdmNodeID();
Pair<Long, QName> before = qnameDAO.getQName(qnameBefore);
if (before != null)
{
List<Long> nodeIds = patchDAO.getNodesByTypeQNameId(qnameId, lower, lower + BATCH_SIZE);
nodeDAO.touchNodes(nodeDAO.getCurrentTransactionId(true), nodeIds);
return nodeIds.size();
}
else if ("ASPECT".equals(reindexClass))
{
List<Long> nodeIds = patchDAO.getNodesByAspectQNameId(qnameId, lower, lower + BATCH_SIZE);
nodeDAO.touchNodes(nodeDAO.getCurrentTransactionId(true), nodeIds);
return nodeIds.size();
}
for (Long i = 0L; i < maxNodeId; i+=BATCH_SIZE)
{
if ("TYPE".equals(reindexClass))
{
List<Long> nodeIds = patchDAO.getNodesByTypeQNameId(before.getFirst(), i, i + BATCH_SIZE);
nodeDAO.touchNodes(nodeDAO.getCurrentTransactionId(true), nodeIds);
}
else if ("ASPECT".equals(reindexClass))
{
List<Long> nodeIds = patchDAO.getNodesByAspectQNameId(before.getFirst(), i, i + BATCH_SIZE);
nodeDAO.touchNodes(nodeDAO.getCurrentTransactionId(true), nodeIds);
}
}
qnameDAO.updateQName(qnameBefore, qnameAfter);
if (logger.isDebugEnabled() == true)
{
logger.debug(" ... updated qname " + qnameBefore.toString());
}
}
else
{
// nothing to do
return 0;
if (logger.isDebugEnabled() == true)
{
logger.debug(" ... no need to update qname " + qnameBefore.toString());
}
}
}
}
//nothing to do
return 0;
}
}
}