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">
|
<if test="pattern != null">
|
||||||
and prop4.string_value like #{pattern} <include refid="alfresco.util.escape"/>
|
and prop4.string_value like #{pattern} <include refid="alfresco.util.escape"/>
|
||||||
</if>
|
</if>
|
||||||
|
<include refid="alfresco.node.select_ChildAssoc_OrderBy"/>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="select_ChildAssocsOfParent" parameterType="ChildAssoc" resultMap="result_ChildAssoc">
|
<select id="select_ChildAssocsOfParent" parameterType="ChildAssoc" resultMap="result_ChildAssoc">
|
||||||
|
@@ -1,28 +1,28 @@
|
|||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
* provided under the following open source license terms:
|
* provided under the following open source license terms:
|
||||||
*
|
*
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.node.getchildren;
|
package org.alfresco.repo.node.getchildren;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -74,6 +74,7 @@ import org.alfresco.service.cmr.repository.ContentWriter;
|
|||||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
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.AccessStatus;
|
||||||
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
||||||
import org.alfresco.service.cmr.security.PermissionService;
|
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.test_category.OwnJVMTestsCategory;
|
||||||
import org.alfresco.util.AlfrescoCollator;
|
import org.alfresco.util.AlfrescoCollator;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
import org.alfresco.util.PropertyMap;
|
import org.alfresco.util.PropertyMap;
|
||||||
import org.alfresco.util.registry.NamedObjectRegistry;
|
import org.alfresco.util.registry.NamedObjectRegistry;
|
||||||
@@ -212,7 +214,7 @@ public class GetChildrenCannedQueryTest extends TestCase
|
|||||||
bootstrap.setTenantService(tenantService);
|
bootstrap.setTenantService(tenantService);
|
||||||
bootstrap.bootstrap();
|
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+"aaaa", TEST_USER_PREFIX+"bbbb", TEST_USER_PREFIX+"cccc");
|
||||||
createUser(TEST_USER_PREFIX+"cccc", TEST_USER_PREFIX+"dddd", TEST_USER_PREFIX+"eeee");
|
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);
|
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