mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-991: Failed to applay patch AVMToADMRemoteStorePatch during upgrade from 3.4.13 to 4.2.0 with RM on Postgres
* all rm module patches are executed in their own transaction * all behaviours are turned off when executing a rm module patch git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@56088 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.patch;
|
||||
|
||||
import org.alfresco.repo.module.AbstractModuleComponent;
|
||||
import org.alfresco.repo.policy.BehaviourFilter;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -34,6 +36,28 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent
|
||||
/** logger */
|
||||
protected static Log logger = LogFactory.getLog(ModulePatchComponent.class);
|
||||
|
||||
/** Retrying transaction helper */
|
||||
protected RetryingTransactionHelper retryingTransactionHelper;
|
||||
|
||||
/** Behaviour filter */
|
||||
protected BehaviourFilter behaviourFilter;
|
||||
|
||||
/**
|
||||
* @param retryingTransactionHelper retrying transaction helper
|
||||
*/
|
||||
public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper)
|
||||
{
|
||||
this.retryingTransactionHelper = retryingTransactionHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param behaviourFilter behaviour filter
|
||||
*/
|
||||
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
|
||||
{
|
||||
this.behaviourFilter = behaviourFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal()
|
||||
*/
|
||||
@@ -47,7 +71,30 @@ public abstract class ModulePatchComponent extends AbstractModuleComponent
|
||||
logger.info("Module patch component '" + getName() + "' is executing ...");
|
||||
}
|
||||
|
||||
executePatch();
|
||||
// execute path within an isolated transaction
|
||||
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
behaviourFilter.disableBehaviour();
|
||||
try
|
||||
{
|
||||
executePatch();
|
||||
}
|
||||
finally
|
||||
{
|
||||
behaviourFilter.enableBehaviour();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}, false, true);
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug(" ... completed module patch '" + getName() + "'");
|
||||
}
|
||||
}
|
||||
catch (Throwable exception)
|
||||
{
|
||||
|
@@ -128,11 +128,6 @@ public class NotificationTemplatePatch extends ModulePatchComponent
|
||||
@Override
|
||||
protected void executePatch() throws Throwable
|
||||
{
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("RM Module NotificationTemplatePatch ...");
|
||||
}
|
||||
|
||||
NodeRef supersededTemplate = notificationHelper.getSupersededTemplate();
|
||||
updateTemplate(supersededTemplate, PATH_SUPERSEDED);
|
||||
|
||||
|
@@ -27,7 +27,6 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
@@ -67,9 +66,7 @@ public class RMv21BehaviorScriptsPatch extends ModulePatchComponent implements B
|
||||
|
||||
/** File Folder Service */
|
||||
private FileFolderService fileFolderService;
|
||||
|
||||
private RetryingTransactionHelper retryingTransactionHelper;
|
||||
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
@@ -80,19 +77,10 @@ public class RMv21BehaviorScriptsPatch extends ModulePatchComponent implements B
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper)
|
||||
{
|
||||
this.retryingTransactionHelper = retryingTransactionHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executePatch() throws Throwable
|
||||
{
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("RM module: RMv21BehaviorScriptsPatch executing ...");
|
||||
}
|
||||
|
||||
{
|
||||
// check that the rm config root has been correctly bootstrapped
|
||||
if (nodeService.exists(RM_CONFIG) == false)
|
||||
{
|
||||
@@ -168,11 +156,6 @@ public class RMv21BehaviorScriptsPatch extends ModulePatchComponent implements B
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug(" ... complete");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -84,11 +84,6 @@ public class RMv21CapabilityPatch extends ModulePatchComponent
|
||||
@Override
|
||||
protected void executePatch() throws Throwable
|
||||
{
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("RM module: RMv21CapabilityPatch executing ...");
|
||||
}
|
||||
|
||||
Set<NodeRef> filePlans = filePlanService.getFilePlans();
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
@@ -136,11 +131,6 @@ public class RMv21CapabilityPatch extends ModulePatchComponent
|
||||
FilePlanRoleService.ROLE_RECORDS_MANAGER,
|
||||
FilePlanRoleService.ROLE_SECURITY_OFFICER);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug(" ... complete");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -109,11 +109,6 @@ public class RMv21RecordInheritancePatch extends ModulePatchComponent
|
||||
@Override
|
||||
protected void executePatch() throws Throwable
|
||||
{
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("RM module: RMv21RecordInheritancePatch executing ...");
|
||||
}
|
||||
|
||||
Pair<Long, QName> aspectPair = qnameDAO.getQName(ASPECT_RECORD);
|
||||
if (aspectPair != null)
|
||||
{
|
||||
@@ -143,10 +138,5 @@ public class RMv21RecordInheritancePatch extends ModulePatchComponent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug(" ... complete");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -65,11 +65,6 @@ public class RMv21RolesPatch extends ModulePatchComponent implements BeanNameAwa
|
||||
@Override
|
||||
protected void executePatch() throws Throwable
|
||||
{
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("RM module: RMv21RolesPatch executing ...");
|
||||
}
|
||||
|
||||
Set<NodeRef> filePlans = filePlanService.getFilePlans();
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
@@ -101,11 +96,6 @@ public class RMv21RolesPatch extends ModulePatchComponent implements BeanNameAwa
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug(" ... complete");
|
||||
}
|
||||
}
|
||||
|
||||
private void addAuthorityToZone(String roleGroupName)
|
||||
|
@@ -31,8 +31,6 @@ import org.alfresco.module.org_alfresco_module_rm.role.Role;
|
||||
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;
|
||||
@@ -55,25 +53,18 @@ public class RMv2FilePlanNodeRefPatch extends ModulePatchComponent
|
||||
private static Log logger = LogFactory.getLog(RMv2FilePlanNodeRefPatch.class);
|
||||
|
||||
private NodeService nodeService;
|
||||
private BehaviourFilter behaviourFilter;
|
||||
private PatchDAO patchDAO;
|
||||
private NodeDAO nodeDAO;
|
||||
private QNameDAO qnameDAO;
|
||||
private PermissionService permissionService;
|
||||
private FilePlanService filePlanService;
|
||||
private FilePlanRoleService filePlanRoleService;
|
||||
private RetryingTransactionHelper retryingTransactionHelper;
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
|
||||
{
|
||||
this.behaviourFilter = behaviourFilter;
|
||||
}
|
||||
|
||||
public void setPatchDAO(PatchDAO patchDAO)
|
||||
{
|
||||
this.patchDAO = patchDAO;
|
||||
@@ -105,11 +96,6 @@ public class RMv2FilePlanNodeRefPatch extends ModulePatchComponent
|
||||
this.filePlanRoleService = filePlanRoleService;
|
||||
}
|
||||
|
||||
public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper)
|
||||
{
|
||||
this.retryingTransactionHelper = retryingTransactionHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePlanService file plan service
|
||||
*/
|
||||
@@ -124,81 +110,56 @@ public class RMv2FilePlanNodeRefPatch extends ModulePatchComponent
|
||||
@Override
|
||||
protected void executePatch() throws Throwable
|
||||
{
|
||||
retryingTransactionHelper.doInTransaction(new Work(), false, true);
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
Pair<Long, QName> aspectPair = qnameDAO.getQName(RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT);
|
||||
if (aspectPair != null)
|
||||
{
|
||||
logger.debug(" ... complete RM Module RMv2FilePlanNodeRef Patch");
|
||||
}
|
||||
|
||||
}
|
||||
List<Long> filePlanComponents = patchDAO.getNodesByAspectQNameId(aspectPair.getFirst(), 0L, patchDAO.getMaxAdmNodeID());
|
||||
|
||||
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)
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
List<Long> filePlanComponents = patchDAO.getNodesByAspectQNameId(aspectPair.getFirst(), 0L, patchDAO.getMaxAdmNodeID());
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug(" ... updating " + filePlanComponents.size() + " items" );
|
||||
}
|
||||
|
||||
behaviourFilter.disableBehaviour();
|
||||
try
|
||||
{
|
||||
for (Long filePlanComponent : filePlanComponents)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
logger.debug(" ... updating " + filePlanComponents.size() + " items" );
|
||||
}
|
||||
|
||||
// nothing to do
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (Long filePlanComponent : filePlanComponents)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
// 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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -49,8 +49,6 @@ public class RMv2ModelPatch extends ModulePatchComponent
|
||||
private PatchDAO patchDAO;
|
||||
private NodeDAO nodeDAO;
|
||||
private QNameDAO qnameDAO;
|
||||
private RetryingTransactionHelper retryingTransactionHelper;
|
||||
|
||||
|
||||
public void setPatchDAO(PatchDAO patchDAO)
|
||||
{
|
||||
@@ -67,33 +65,21 @@ public class RMv2ModelPatch extends ModulePatchComponent
|
||||
this.qnameDAO = qnameDAO;
|
||||
}
|
||||
|
||||
public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper)
|
||||
{
|
||||
this.retryingTransactionHelper = retryingTransactionHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal()
|
||||
*/
|
||||
@Override
|
||||
protected void executePatch() throws Throwable
|
||||
{
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("RM Module RMv2ModelPatch ...");
|
||||
}
|
||||
|
||||
updateQName(QName.createQName(DOD_URI, "filePlan"), TYPE_FILE_PLAN, "TYPE");
|
||||
updateQName(QName.createQName(DOD_URI, "recordCategory"), TYPE_RECORD_CATEGORY, "TYPE");
|
||||
updateQName(QName.createQName(DOD_URI, "ghosted"), ASPECT_GHOSTED, "ASPECT");
|
||||
}
|
||||
|
||||
private void updateQName(QName qnameBefore, QName qnameAfter, String reindexClass)
|
||||
{
|
||||
|
||||
{
|
||||
Work work = new Work(qnameBefore, qnameAfter, reindexClass);
|
||||
retryingTransactionHelper.doInTransaction(work, false, true);
|
||||
|
||||
}
|
||||
|
||||
private class Work implements RetryingTransactionHelper.RetryingTransactionCallback<Integer>
|
||||
@@ -102,6 +88,13 @@ public class RMv2ModelPatch extends ModulePatchComponent
|
||||
private QName qnameAfter;
|
||||
private String reindexClass;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param qnameBefore qname before
|
||||
* @param qnameAfter qname after
|
||||
* @param reindexClass reindex class
|
||||
*/
|
||||
Work(QName qnameBefore, QName qnameAfter, String reindexClass)
|
||||
{
|
||||
this.qnameBefore = qnameBefore;
|
||||
@@ -109,8 +102,7 @@ public class RMv2ModelPatch extends ModulePatchComponent
|
||||
this.reindexClass = reindexClass;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
/**
|
||||
* @see org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback#execute()
|
||||
*/
|
||||
@Override
|
||||
|
@@ -115,11 +115,6 @@ public class RMv2RMAdminUserPatch extends ModulePatchComponent implements BeanNa
|
||||
@Override
|
||||
protected void executePatch() throws Throwable
|
||||
{
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("RM Module RMv2RMAdminUserPatch ...");
|
||||
}
|
||||
|
||||
String user = filePlanAuthenticationService.getRmAdminUserName();
|
||||
String firstName = I18NUtil.getMessage(MSG_FIRST_NAME);
|
||||
String lastName = I18NUtil.getMessage(MSG_LAST_NAME);
|
||||
@@ -148,11 +143,6 @@ public class RMv2RMAdminUserPatch extends ModulePatchComponent implements BeanNa
|
||||
{
|
||||
filePlanRoleService.assignRoleToAuthority(filePlan, FilePlanRoleService.ROLE_ADMIN, user);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug(" ... RMv2RMAdminUserPatch complete");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -72,11 +72,6 @@ public class RMv2SavedSearchPatch extends ModulePatchComponent
|
||||
@Override
|
||||
protected void executePatch() throws Throwable
|
||||
{
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("RM Module RMv2SavedSearchPatch ...");
|
||||
}
|
||||
|
||||
if (siteService.getSite(RM_SITE_ID) != null)
|
||||
{
|
||||
// get the saved searches
|
||||
@@ -98,11 +93,6 @@ public class RMv2SavedSearchPatch extends ModulePatchComponent
|
||||
savedSearchDetails.getSearchParameters(),
|
||||
savedSearchDetails.isPublic());
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug(" ... complete");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user