mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-15 15:02:20 +00:00
REPO-1204 / MNT-16742: getChildren returns duplicate nodes
- fallout from MNT-12894 - noticed by customer when iterating via CMIS getChildren with no explict sort order - we need to put back an implicit sort order, if none is specified - note: todo - we could consider optimising further for those use-cases where maxItems is greater than a pre-configured threshold (eg. > 1000) and we don't expect to sensibly page through that many results git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@135457 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1131,6 +1131,7 @@
|
||||
<if test="pattern != null">
|
||||
and prop4.string_value like #{pattern} <include refid="alfresco.util.escape"/>
|
||||
</if>
|
||||
<include refid="alfresco.node.select_ChildAssoc_OrderBy"/>
|
||||
</select>
|
||||
|
||||
<select id="select_ChildAssocsOfParent" parameterType="ChildAssoc" resultMap="result_ChildAssoc">
|
||||
|
@@ -74,6 +74,7 @@ import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
@@ -84,6 +85,7 @@ import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.test_category.OwnJVMTestsCategory;
|
||||
import org.alfresco.util.AlfrescoCollator;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.PropertyMap;
|
||||
import org.alfresco.util.registry.NamedObjectRegistry;
|
||||
@@ -212,7 +214,7 @@ public class GetChildrenCannedQueryTest extends TestCase
|
||||
bootstrap.setTenantService(tenantService);
|
||||
bootstrap.bootstrap();
|
||||
|
||||
createUser(TEST_USER_PREFIX, TEST_USER, TEST_USER);
|
||||
createUser(TEST_USER, TEST_USER, TEST_USER);
|
||||
|
||||
createUser(TEST_USER_PREFIX+"aaaa", TEST_USER_PREFIX+"bbbb", TEST_USER_PREFIX+"cccc");
|
||||
createUser(TEST_USER_PREFIX+"cccc", TEST_USER_PREFIX+"dddd", TEST_USER_PREFIX+"eeee");
|
||||
@@ -1509,4 +1511,68 @@ public class GetChildrenCannedQueryTest extends TestCase
|
||||
personService.createPerson(ppOne);
|
||||
}
|
||||
}
|
||||
|
||||
// REPO-1204 / MNT-16742 (fallout from MNT-12894)
|
||||
public void testPagingGetChildrenCannedQueryWithoutProps() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
int itemCount = 1500;
|
||||
int repeatListCount = 5;
|
||||
|
||||
Set<QName> assocTypeQNames = new HashSet<>(1);
|
||||
assocTypeQNames.add(ContentModel.ASSOC_CONTAINS);
|
||||
|
||||
Set<QName> childTypeQNames = new HashSet<>(1);
|
||||
childTypeQNames.add(ContentModel.TYPE_FOLDER);
|
||||
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||
|
||||
NodeRef testFolder = repositoryHelper.getCompanyHome();
|
||||
|
||||
NodeRef parentFolder = createFolder(testFolder, "testCreateList-"+ GUID.generate(), ContentModel.TYPE_FOLDER);
|
||||
|
||||
for (int i = 1; i <= itemCount; i++)
|
||||
{
|
||||
String folderName = "folder_" + GUID.generate();
|
||||
createFolder(parentFolder, folderName, ContentModel.TYPE_FOLDER);
|
||||
}
|
||||
|
||||
for (int j = 1; j <= repeatListCount; j++)
|
||||
{
|
||||
// page/iterate through the children
|
||||
boolean hasMore = true;
|
||||
int skipCount = 0;
|
||||
int maxItems = 100;
|
||||
|
||||
int count = 0;
|
||||
Set<String> docIds = new HashSet<>(itemCount);
|
||||
|
||||
while (hasMore)
|
||||
{
|
||||
// note: mimic similar to AlfrescoServiceCmisServiceImpl
|
||||
PagingResults<NodeRef> results = list(parentFolder, skipCount, maxItems, skipCount + 10000, assocTypeQNames, childTypeQNames, null, null, null, null);
|
||||
hasMore = results.hasMoreItems();
|
||||
skipCount = skipCount + maxItems;
|
||||
|
||||
for (NodeRef nodeRef : results.getPage())
|
||||
{
|
||||
docIds.add(nodeRef.getId());
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals(itemCount, count);
|
||||
assertEquals(itemCount, docIds.size());
|
||||
}
|
||||
|
||||
System.out.println("Test time: " + (System.currentTimeMillis() - startTime) + " ms");
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user