diff --git a/source/java/org/alfresco/repo/avm/AVMCrawlTestP.java b/source/java/org/alfresco/repo/avm/AVMCrawlTestP.java index a12b9bb848..f7a5f8bc70 100644 --- a/source/java/org/alfresco/repo/avm/AVMCrawlTestP.java +++ b/source/java/org/alfresco/repo/avm/AVMCrawlTestP.java @@ -26,7 +26,10 @@ package org.alfresco.repo.avm; import java.util.ArrayList; import java.util.List; +import net.sf.acegisecurity.Authentication; + import org.alfresco.repo.avm.util.BulkLoader; +import org.alfresco.repo.security.authentication.AuthenticationUtil; /** @@ -72,6 +75,7 @@ public class AVMCrawlTestP extends AVMServiceTestBase */ private void testCrawl(int n, String fsPath, int m, long runTime) { + Authentication authentication = AuthenticationUtil.setCurrentUser(AuthenticationUtil.SYSTEM_USER_NAME); try { if (m < 1) @@ -97,7 +101,7 @@ public class AVMCrawlTestP extends AVMServiceTestBase List threads = new ArrayList(); for (int i = 0; i < n; i++) { - crawlers.add(new AVMCrawler(fService)); + crawlers.add(new AVMCrawler(fService, authentication)); threads.add(new Thread(crawlers.get(i))); threads.get(i).start(); } diff --git a/source/java/org/alfresco/repo/avm/AVMCrawler.java b/source/java/org/alfresco/repo/avm/AVMCrawler.java index 8c0900b2bb..72e686e291 100644 --- a/source/java/org/alfresco/repo/avm/AVMCrawler.java +++ b/source/java/org/alfresco/repo/avm/AVMCrawler.java @@ -34,6 +34,9 @@ import java.util.List; import java.util.Map; import java.util.Random; +import net.sf.acegisecurity.Authentication; + +import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.service.cmr.avm.AVMException; import org.alfresco.service.cmr.avm.AVMNodeDescriptor; import org.alfresco.service.cmr.avm.AVMService; @@ -51,6 +54,8 @@ class AVMCrawler implements Runnable * The AVMService to use. */ private AVMService fService; + + private Authentication authentication; /** * The Operation count. @@ -77,9 +82,10 @@ class AVMCrawler implements Runnable * Make up a new one. * @param service The AVMService. */ - public AVMCrawler(AVMService service) + public AVMCrawler(AVMService service, Authentication authentication) { fService = service; + this.authentication = authentication; fOpCount = 0; fDone = false; fError = false; @@ -117,6 +123,7 @@ class AVMCrawler implements Runnable { try { + AuthenticationUtil.setCurrentAuthentication(authentication); while (!fDone) { doCrawl(); @@ -133,6 +140,10 @@ class AVMCrawler implements Runnable fError = true; fErrorStackTrace = sw.toString(); } + finally + { + AuthenticationUtil.clearCurrentSecurityContext(); + } } /**