Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)

124739 gjames: ACE-5295: listArchivedNodes now works for non-admin users


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126580 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jamal Kaabi-Mofrad
2016-05-10 11:38:09 +00:00
parent 57310498c9
commit ce22405fd1
2 changed files with 19 additions and 6 deletions

View File

@@ -724,7 +724,7 @@ public class NodeArchiveServiceImpl implements NodeArchiveService
private Pair<NodeRef, QName> getArchiveNodeRefAssocTypePair(final NodeRef archiveStoreRootNodeRef) private Pair<NodeRef, QName> getArchiveNodeRefAssocTypePair(final NodeRef archiveStoreRootNodeRef)
{ {
String currentUser = getCurrentUser(); final String currentUser = getCurrentUser();
if (archiveStoreRootNodeRef == null || !nodeService.exists(archiveStoreRootNodeRef)) if (archiveStoreRootNodeRef == null || !nodeService.exists(archiveStoreRootNodeRef))
{ {
@@ -738,12 +738,19 @@ public class NodeArchiveServiceImpl implements NodeArchiveService
} }
else else
{ {
List<ChildAssociationRef> list = nodeService.getChildrenByName(archiveStoreRootNodeRef, List<ChildAssociationRef> list = AuthenticationUtil.runAs(new RunAsWork<List<ChildAssociationRef>>()
{
@Override
public List<ChildAssociationRef> doWork() throws Exception
{
return nodeService.getChildrenByName(archiveStoreRootNodeRef,
ContentModel.ASSOC_ARCHIVE_USER_LINK, ContentModel.ASSOC_ARCHIVE_USER_LINK,
Collections.singletonList(currentUser)); Collections.singletonList(currentUser));
}
}, AuthenticationUtil.getAdminUserName());
// Empty list means that the current user hasn't deleted anything yet. // Empty list means that the current user hasn't deleted anything yet.
if (list.isEmpty()) if (list == null || list.isEmpty())
{ {
return new Pair<NodeRef, QName>(null, null); return new Pair<NodeRef, QName>(null, null);
} }

View File

@@ -1014,6 +1014,9 @@ public class ArchiveAndRestoreTest extends TestCase
// USER_B deletes "bb" // USER_B deletes "bb"
nodeService.deleteNode(bb); nodeService.deleteNode(bb);
result = nodeArchiveService.listArchivedNodes(queryBuilder);
assertEquals("USER_B deleted 1 item and USER_B can see it.", 1, result.getPage().size());
result = runListArchivedNodesAsAdmin(queryBuilder); result = runListArchivedNodesAsAdmin(queryBuilder);
assertEquals("USER_B deleted only 1 item.", 1, result.getPage().size()); assertEquals("USER_B deleted only 1 item.", 1, result.getPage().size());
@@ -1026,6 +1029,9 @@ public class ArchiveAndRestoreTest extends TestCase
this.archiveStoreRootNodeRef, paging) this.archiveStoreRootNodeRef, paging)
.build(); .build();
result = nodeArchiveService.listArchivedNodes(queryBuilder);
assertEquals("USER_A deleted 1 item and USER_A can see it.", 1, result.getPage().size());
result = runListArchivedNodesAsAdmin(queryBuilder); result = runListArchivedNodesAsAdmin(queryBuilder);
assertEquals("USER_A deleted only 1 item.", 1, result.getPage().size()); assertEquals("USER_A deleted only 1 item.", 1, result.getPage().size());
assertEquals(QNAME_AA.getLocalName(), assertEquals(QNAME_AA.getLocalName(),