Added authentication to AVM Crawler

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11225 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2008-10-07 01:17:13 +00:00
parent 5407e7ff37
commit 61ff399d12
2 changed files with 17 additions and 2 deletions

View File

@@ -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<Thread> threads = new ArrayList<Thread>();
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();
}

View File

@@ -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;
@@ -52,6 +55,8 @@ class AVMCrawler implements Runnable
*/
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();
}
}
/**