mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged BRANCHES/DEV/CONV_V413 to HEAD:
47044: CLOUD-1349: Fix MultiTDemoTest.testDeleteArchiveAndRestoreContent git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@47045 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -39,7 +39,10 @@ import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.query.PagingRequest;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.model.Repository;
|
||||
import org.alfresco.repo.node.archive.NodeArchiveService;
|
||||
import org.alfresco.repo.node.archive.RestoreNodeReport;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.security.permissions.impl.AccessPermissionImpl;
|
||||
import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
@@ -96,6 +99,8 @@ public class MultiTDemoTest extends TestCase
|
||||
);
|
||||
|
||||
private NodeService nodeService;
|
||||
private NodeArchiveService nodeArchiveService;
|
||||
private NamespaceService namespaceService;
|
||||
private MutableAuthenticationService authenticationService;
|
||||
private PersonService personService;
|
||||
private SiteService siteService;
|
||||
@@ -167,6 +172,8 @@ public class MultiTDemoTest extends TestCase
|
||||
super.setUp();
|
||||
|
||||
nodeService = (NodeService) ctx.getBean("NodeService");
|
||||
nodeArchiveService = (NodeArchiveService) ctx.getBean("nodeArchiveService");
|
||||
namespaceService = (NamespaceService) ctx.getBean("NamespaceService");
|
||||
authenticationService = (MutableAuthenticationService) ctx.getBean("AuthenticationService");
|
||||
tenantAdminService = (TenantAdminService) ctx.getBean("tenantAdminService");
|
||||
tenantService = (TenantService) ctx.getBean("tenantService");
|
||||
@@ -183,6 +190,7 @@ public class MultiTDemoTest extends TestCase
|
||||
usageService = (UsageService) ctx.getBean("usageService");
|
||||
transactionService = (TransactionService) ctx.getBean("TransactionService");
|
||||
fileFolderService = (FileFolderService) ctx.getBean("FileFolderService");
|
||||
ownableService = (OwnableService) ctx.getBean("OwnableService");
|
||||
repositoryHelper = (Repository) ctx.getBean("repositoryHelper");
|
||||
siteService = (SiteService) ctx.getBean("SiteService");
|
||||
|
||||
@@ -1103,11 +1111,48 @@ public class MultiTDemoTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
// TODO pending THOR-201 / CLOUD-1349 fix
|
||||
public void xtest16DeleteArchiveAndRestoreContent()
|
||||
public void test16DeleteArchiveAndRestoreContent()
|
||||
{
|
||||
logger.info("test delete/archive & restore content");
|
||||
|
||||
// note: CLOUD-1349 - ownership is based on fully authenticated user (else restoreNode fails for non-Admin user)
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
|
||||
final String superAdmin = AuthenticationUtil.getAdminUserName();
|
||||
|
||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||
{
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// super tenant - admin user
|
||||
deleteArchiveAndRestoreContent(superAdmin, TenantService.DEFAULT_DOMAIN);
|
||||
return null;
|
||||
}
|
||||
|
||||
}, superAdmin);
|
||||
|
||||
final String superAnoUser = "superAnoUser";
|
||||
|
||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||
{
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
createUser(superAnoUser, TenantService.DEFAULT_DOMAIN, superAnoUser);
|
||||
return null;
|
||||
}
|
||||
}, superAdmin);
|
||||
|
||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||
{
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// super tenant - ano user
|
||||
deleteArchiveAndRestoreContent(superAnoUser, TenantService.DEFAULT_DOMAIN);
|
||||
|
||||
return null;
|
||||
}
|
||||
}, superAnoUser);
|
||||
|
||||
for (final String tenantDomain : tenants)
|
||||
{
|
||||
final String tenantUserName = tenantService.getDomainUser(TEST_USER1, tenantDomain);
|
||||
@@ -1116,8 +1161,21 @@ public class MultiTDemoTest extends TestCase
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
NodeRef homeSpaceRef = getHomeSpaceFolderNode(tenantUserName);
|
||||
NodeRef contentRef = addContent(homeSpaceRef, tenantUserName+" tqbfjotld.txt", "The quick brown fox jumps over the lazy dog (tenant " + tenantDomain + ")", MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
deleteArchiveAndRestoreContent(tenantUserName, tenantDomain);
|
||||
|
||||
return null;
|
||||
}
|
||||
}, tenantUserName);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteArchiveAndRestoreContent(String userName, String tenantDomain)
|
||||
{
|
||||
NodeRef homeSpaceRef = getHomeSpaceFolderNode(userName);
|
||||
NodeRef contentRef = addContent(homeSpaceRef, userName+" "+System.currentTimeMillis()+" tqbfjotld.txt", "The quick brown fox jumps over the lazy dog (tenant " + tenantDomain + ")", MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
|
||||
assertEquals(userName, ownableService.getOwner(contentRef));
|
||||
permissionService.hasPermission(contentRef, PermissionService.DELETE_NODE);
|
||||
|
||||
NodeRef storeArchiveNode = nodeService.getStoreArchiveNode(contentRef.getStoreRef());
|
||||
|
||||
@@ -1127,12 +1185,21 @@ public class MultiTDemoTest extends TestCase
|
||||
StoreRef archiveStoreRef = storeArchiveNode.getStoreRef();
|
||||
NodeRef archivedContentRef = new NodeRef(archiveStoreRef, contentRef.getId());
|
||||
|
||||
nodeService.restoreNode(archivedContentRef, null, null, null);
|
||||
assertEquals(userName, ownableService.getOwner(archivedContentRef));
|
||||
permissionService.hasPermission(archivedContentRef, PermissionService.DELETE_NODE);
|
||||
|
||||
return null;
|
||||
}
|
||||
}, tenantUserName);
|
||||
}
|
||||
//nodeService.restoreNode(archivedContentRef, null, null, null);
|
||||
RestoreNodeReport report = nodeArchiveService.restoreArchivedNode(archivedContentRef);
|
||||
assertNotNull(report);
|
||||
|
||||
NodeRef restoredNodeRef = report.getRestoredNodeRef();
|
||||
assertNotNull(restoredNodeRef);
|
||||
|
||||
archivedContentRef = new NodeRef(archiveStoreRef, restoredNodeRef.getId());
|
||||
|
||||
nodeService.deleteNode(restoredNodeRef);
|
||||
|
||||
nodeArchiveService.purgeArchivedNode(archivedContentRef);
|
||||
}
|
||||
|
||||
public void test17CustomModels()
|
||||
|
Reference in New Issue
Block a user