mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix to AVM->ADM Share Site migration patch to disable rules during node processing
- recent changes (unsure which...) mean that somewhere in rules services a RunAs(system) is interfering with the RunAs(user) already set on the outer txn - this means that all Share sites migrated from 3.X to 4.0 in the last couple of weeks (including Community 4.0a) will not have the correct user permissions. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30914 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -2940,6 +2940,7 @@
|
|||||||
<property name="fileFolderService" ref="fileFolderService" />
|
<property name="fileFolderService" ref="fileFolderService" />
|
||||||
<property name="contentService" ref="contentService" />
|
<property name="contentService" ref="contentService" />
|
||||||
<property name="siteService" ref="SiteService" />
|
<property name="siteService" ref="SiteService" />
|
||||||
|
<property name="ruleService" ref="RuleService" />
|
||||||
<property name="avmService" ref="AVMService" />
|
<property name="avmService" ref="AVMService" />
|
||||||
<property name="avmStore"><value>sitestore</value></property>
|
<property name="avmStore"><value>sitestore</value></property>
|
||||||
<property name="avmRootPath"><value>/alfresco/site-data</value></property>
|
<property name="avmRootPath"><value>/alfresco/site-data</value></property>
|
||||||
|
@@ -41,7 +41,6 @@ import org.alfresco.repo.batch.BatchProcessWorkProvider;
|
|||||||
import org.alfresco.repo.batch.BatchProcessor;
|
import org.alfresco.repo.batch.BatchProcessor;
|
||||||
import org.alfresco.repo.batch.BatchProcessor.BatchProcessWorker;
|
import org.alfresco.repo.batch.BatchProcessor.BatchProcessWorker;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
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.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||||
import org.alfresco.service.cmr.avm.AVMService;
|
import org.alfresco.service.cmr.avm.AVMService;
|
||||||
@@ -55,6 +54,7 @@ import org.alfresco.service.cmr.repository.ContentWriter;
|
|||||||
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
|
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
|
||||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.rule.RuleService;
|
||||||
import org.alfresco.service.cmr.site.SiteInfo;
|
import org.alfresco.service.cmr.site.SiteInfo;
|
||||||
import org.alfresco.service.cmr.site.SiteService;
|
import org.alfresco.service.cmr.site.SiteService;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
@@ -111,6 +111,7 @@ public class AVMToADMRemoteStorePatch extends AbstractPatch
|
|||||||
private FileFolderService fileFolderService;
|
private FileFolderService fileFolderService;
|
||||||
private SiteService siteService;
|
private SiteService siteService;
|
||||||
private AVMService avmService;
|
private AVMService avmService;
|
||||||
|
private RuleService ruleService;
|
||||||
private String avmStore;
|
private String avmStore;
|
||||||
private String avmRootPath = "/";
|
private String avmRootPath = "/";
|
||||||
|
|
||||||
@@ -147,6 +148,14 @@ public class AVMToADMRemoteStorePatch extends AbstractPatch
|
|||||||
this.avmService = avmService;
|
this.avmService = avmService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ruleService the rule service to set
|
||||||
|
*/
|
||||||
|
public void setRuleService(RuleService ruleService)
|
||||||
|
{
|
||||||
|
this.ruleService = ruleService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param avmStore the avmStore to set
|
* @param avmStore the avmStore to set
|
||||||
*/
|
*/
|
||||||
@@ -306,6 +315,7 @@ public class AVMToADMRemoteStorePatch extends AbstractPatch
|
|||||||
{
|
{
|
||||||
// create the 'surf-config' folder for the site and cache the NodeRef to it
|
// create the 'surf-config' folder for the site and cache the NodeRef to it
|
||||||
NodeRef surfConfigRef = getSurfConfigNodeRef(siteRef);
|
NodeRef surfConfigRef = getSurfConfigNodeRef(siteRef);
|
||||||
|
// TODO: create components and pages folders here would also reduce contention
|
||||||
siteReferenceCache.put(siteName, surfConfigRef);
|
siteReferenceCache.put(siteName, surfConfigRef);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -360,12 +370,14 @@ public class AVMToADMRemoteStorePatch extends AbstractPatch
|
|||||||
@Override
|
@Override
|
||||||
public void beforeProcess() throws Throwable
|
public void beforeProcess() throws Throwable
|
||||||
{
|
{
|
||||||
|
ruleService.disableRules();
|
||||||
AuthenticationUtil.setRunAsUser(tenantSystemUser);
|
AuthenticationUtil.setRunAsUser(tenantSystemUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterProcess() throws Throwable
|
public void afterProcess() throws Throwable
|
||||||
{
|
{
|
||||||
|
ruleService.enableRules();
|
||||||
AuthenticationUtil.clearCurrentSecurityContext();
|
AuthenticationUtil.clearCurrentSecurityContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -524,20 +536,21 @@ public class AVMToADMRemoteStorePatch extends AbstractPatch
|
|||||||
if (userId != null)
|
if (userId != null)
|
||||||
{
|
{
|
||||||
// run as the appropriate user id to execute
|
// run as the appropriate user id to execute
|
||||||
final NodeRef parentFolderRef = parentFolder;
|
AuthenticationUtil.pushAuthentication();
|
||||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
AuthenticationUtil.setFullyAuthenticatedUser(userId);
|
||||||
{
|
try
|
||||||
public Void doWork() throws Exception
|
|
||||||
{
|
{
|
||||||
// create new node and perform writer content copy of the content from the AVM to the DM store
|
// create new node and perform writer content copy of the content from the AVM to the DM store
|
||||||
FileInfo fileInfo = fileFolderService.create(
|
FileInfo fileInfo = fileFolderService.create(
|
||||||
parentFolderRef, avmNode.getName(), ContentModel.TYPE_CONTENT);
|
parentFolder, avmNode.getName(), ContentModel.TYPE_CONTENT);
|
||||||
ContentWriter writer = contentService.getWriter(
|
ContentWriter writer = contentService.getWriter(
|
||||||
fileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true);
|
fileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true);
|
||||||
writer.putContent(avmService.getContentReader(-1, avmNode.getPath()));
|
writer.putContent(avmService.getContentReader(-1, avmNode.getPath()));
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}, userId);
|
finally
|
||||||
|
{
|
||||||
|
AuthenticationUtil.popAuthentication();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user