diff --git a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/node-common-SqlMap.xml b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/node-common-SqlMap.xml
index 6da6cd4f01..6d4beedb45 100644
--- a/config/alfresco/ibatis/org.hibernate.dialect.Dialect/node-common-SqlMap.xml
+++ b/config/alfresco/ibatis/org.hibernate.dialect.Dialect/node-common-SqlMap.xml
@@ -944,6 +944,10 @@
left join alf_node_properties prop3 on (prop3.node_id = childNode.id and prop3.qname_id = #{prop3qnameId})
+
+ join alf_node_properties prop4 on (prop4.node_id = childNode.id)
+ join alf_qname qname on (prop4.qname_id = qname.id and qname.id = #{namePropertyQNameId})
+
where
assoc.parent_node_id = #{parentNodeId}
@@ -952,6 +956,9 @@
#{item}
+
+ and prop4.string_value like #{pattern}
+
@@ -968,6 +975,10 @@
alf_child_assoc assoc
join alf_node childNode on (childNode.id = assoc.child_node_id)
join alf_store childStore on (childStore.id = childNode.store_id)
+
+ join alf_node_properties prop4 on (prop4.node_id = childNode.id)
+ join alf_qname qname on (prop4.qname_id = qname.id and qname.id = #{namePropertyQNameId})
+
where
assoc.parent_node_id = #{parentNodeId}
@@ -976,6 +987,9 @@
#{item}
+
+ and prop4.string_value like #{pattern}
+
diff --git a/source/java/org/alfresco/repo/calendar/CalendarServiceImpl.java b/source/java/org/alfresco/repo/calendar/CalendarServiceImpl.java
index 59c13d013f..5d16da09f6 100644
--- a/source/java/org/alfresco/repo/calendar/CalendarServiceImpl.java
+++ b/source/java/org/alfresco/repo/calendar/CalendarServiceImpl.java
@@ -259,7 +259,7 @@ public class CalendarServiceImpl implements CalendarService
// Run the canned query
GetChildrenCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN);
GetChildrenCannedQuery cq = (GetChildrenCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(
- container, types, null, sort, paging);
+ container, null, types, null, sort, paging);
// Execute the canned query
CannedQueryResults results = cq.execute();
diff --git a/source/java/org/alfresco/repo/jscript/ScriptNode.java b/source/java/org/alfresco/repo/jscript/ScriptNode.java
index b1f8e5d859..bfca19cc60 100644
--- a/source/java/org/alfresco/repo/jscript/ScriptNode.java
+++ b/source/java/org/alfresco/repo/jscript/ScriptNode.java
@@ -641,7 +641,7 @@ public class ScriptNode implements Serializable, Scopeable, NamespacePrefixResol
PagingRequest pageRequest = new PagingRequest(skipOffset, maxItems, queryExecutionId);
pageRequest.setRequestTotalCountMax(requestTotalCountMax);
- PagingResults pageOfNodeInfos = this.fileFolderService.list(this.nodeRef, files, folders, ignoreTypeQNames, sortProps, pageRequest);
+ PagingResults pageOfNodeInfos = this.fileFolderService.list(this.nodeRef, files, folders, null, ignoreTypeQNames, sortProps, pageRequest);
List nodeInfos = pageOfNodeInfos.getPage();
diff --git a/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImpl.java b/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImpl.java
index c68b9cee7a..bfd5561dad 100644
--- a/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImpl.java
+++ b/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImpl.java
@@ -43,6 +43,7 @@ import org.alfresco.repo.node.getchildren.GetChildrenCannedQueryFactory;
import org.alfresco.repo.search.QueryParameterDefImpl;
import org.alfresco.repo.security.permissions.PermissionCheckedCollection.PermissionCheckedCollectionMixin;
import org.alfresco.repo.security.permissions.PermissionCheckedValue.PermissionCheckedValueMixin;
+import org.alfresco.service.Auditable;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.model.FileExistsException;
@@ -348,19 +349,8 @@ public class FileFolderServiceImpl implements FileFolderService
return results;
}
- /* (non-Javadoc)
- * @see org.alfresco.service.cmr.model.FileFolderService#list(org.alfresco.service.cmr.repository.NodeRef, boolean, boolean, java.util.Set, org.alfresco.service.cmr.model.PagingSortRequest)
- */
- public PagingResults list(NodeRef contextNodeRef, boolean files, boolean folders, Set ignoreQNameTypes, List> sortProps, PagingRequest pagingRequest)
+ private PagingResults getPagingResults(PagingRequest pagingRequest, final CannedQueryResults results)
{
- ParameterCheck.mandatory("contextNodeRef", contextNodeRef);
- ParameterCheck.mandatory("pagingRequest", pagingRequest);
-
- Set searchTypeQNames = buildTypes(files, folders, ignoreQNameTypes);
-
- // execute query
- final CannedQueryResults results = listImpl(contextNodeRef, searchTypeQNames, sortProps, pagingRequest);
-
List nodeRefs = null;
if (results.getPageCount() > 0)
{
@@ -411,7 +401,43 @@ public class FileFolderServiceImpl implements FileFolderService
{
return totalCount;
}
- };
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see org.alfresco.service.cmr.model.FileFolderService#list(org.alfresco.service.cmr.repository.NodeRef, boolean, boolean, java.util.Set, org.alfresco.service.cmr.model.PagingSortRequest)
+ */
+ @Auditable(parameters = {"contextNodeRef", "files", "folders", "ignoreTypeQNames", "sortProps", "pagingRequest"})
+ public PagingResults list(NodeRef contextNodeRef,
+ boolean files,
+ boolean folders,
+ Set ignoreTypeQNames,
+ List> sortProps,
+ PagingRequest pagingRequest)
+ {
+ ParameterCheck.mandatory("contextNodeRef", contextNodeRef);
+ ParameterCheck.mandatory("pagingRequest", pagingRequest);
+
+ Set searchTypeQNames = buildTypes(files, folders, ignoreTypeQNames);
+
+ // execute query
+ final CannedQueryResults results = listImpl(contextNodeRef, null, searchTypeQNames, sortProps, pagingRequest);
+ return getPagingResults(pagingRequest, results);
+ }
+
+ /* (non-Javadoc)
+ * @see org.alfresco.service.cmr.model.FileFolderService#list(org.alfresco.service.cmr.repository.NodeRef, boolean, boolean, String, java.util.Set, org.alfresco.service.cmr.model.PagingSortRequest)
+ */
+ public PagingResults list(NodeRef contextNodeRef, boolean files, boolean folders, String pattern, Set ignoreQNameTypes, List> sortProps, PagingRequest pagingRequest)
+ {
+ ParameterCheck.mandatory("contextNodeRef", contextNodeRef);
+ ParameterCheck.mandatory("pagingRequest", pagingRequest);
+
+ Set searchTypeQNames = buildTypes(files, folders, ignoreQNameTypes);
+
+ // execute query
+ final CannedQueryResults results = listImpl(contextNodeRef, pattern, searchTypeQNames, sortProps, pagingRequest);
+ return getPagingResults(pagingRequest, results);
}
private CannedQueryResults listImpl(NodeRef contextNodeRef, boolean files, boolean folders)
@@ -422,18 +448,18 @@ public class FileFolderServiceImpl implements FileFolderService
private CannedQueryResults listImpl(NodeRef contextNodeRef, Set searchTypeQNames)
{
- return listImpl(contextNodeRef, searchTypeQNames, null, new PagingRequest(defaultListMaxResults, null));
+ return listImpl(contextNodeRef, null, searchTypeQNames, null, new PagingRequest(defaultListMaxResults, null));
}
// note: similar to getChildAssocs(contextNodeRef, searchTypeQNames) but enables paging features, including max items, sorting etc (with permissions per-applied)
- private CannedQueryResults listImpl(NodeRef contextNodeRef, Set searchTypeQNames, List> sortProps, PagingRequest pagingRequest)
+ private CannedQueryResults listImpl(NodeRef contextNodeRef, String pattern, Set searchTypeQNames, List> sortProps, PagingRequest pagingRequest)
{
Long start = (logger.isDebugEnabled() ? System.currentTimeMillis() : null);
// get canned query
GetChildrenCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_FILEFOLDER_LIST);
- GetChildrenCannedQuery cq = (GetChildrenCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(contextNodeRef, searchTypeQNames, null, sortProps, pagingRequest);
+ GetChildrenCannedQuery cq = (GetChildrenCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(contextNodeRef, pattern, searchTypeQNames, null, sortProps, pagingRequest);
// execute canned query
CannedQueryResults results = cq.execute();
@@ -453,6 +479,33 @@ public class FileFolderServiceImpl implements FileFolderService
return results;
}
+// private CannedQueryResults listImpl(NodeRef contextNodeRef, String pattern, List> sortProps, PagingRequest pagingRequest)
+// {
+// Long start = (logger.isDebugEnabled() ? System.currentTimeMillis() : null);
+//
+// // get canned query
+// GetChildrenCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_FILEFOLDER_LIST);
+//
+// GetChildrenCannedQuery cq = (GetChildrenCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(contextNodeRef, null, pattern, null, sortProps, pagingRequest);
+//
+// // execute canned query
+// CannedQueryResults results = cq.execute();
+//
+// if (start != null)
+// {
+// int cnt = results.getPagedResultCount();
+// int skipCount = pagingRequest.getSkipCount();
+// int maxItems = pagingRequest.getMaxItems();
+// boolean hasMoreItems = results.hasMoreItems();
+// Pair totalCount = (pagingRequest.getRequestTotalCountMax() > 0 ? results.getTotalResultCount() : null);
+// int pageNum = (skipCount / maxItems) + 1;
+//
+// logger.debug("List: "+cnt+" items in "+(System.currentTimeMillis()-start)+" msecs [pageNum="+pageNum+",skip="+skipCount+",max="+maxItems+",hasMorePages="+hasMoreItems+",totalCount="+totalCount+",parentNodeRef="+contextNodeRef+"]");
+// }
+//
+// return results;
+// }
+
public List listFiles(NodeRef contextNodeRef)
{
// execute the query
diff --git a/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImplTest.java b/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImplTest.java
index 93c3face00..ecc19e2d78 100644
--- a/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImplTest.java
+++ b/source/java/org/alfresco/repo/model/filefolder/FileFolderServiceImplTest.java
@@ -218,7 +218,7 @@ public class FileFolderServiceImplTest extends TestCase
// sanity checks only (see also GetChildrenCannedQueryTest)
PagingRequest pagingRequest = new PagingRequest(100, null);
- PagingResults pagingResults = fileFolderService.list(workingRootNodeRef, true, true, null, null, pagingRequest);
+ PagingResults pagingResults = fileFolderService.list(workingRootNodeRef, true, true, null, null, null, pagingRequest);
assertNotNull(pagingResults);
assertFalse(pagingResults.hasMoreItems());
@@ -235,7 +235,7 @@ public class FileFolderServiceImplTest extends TestCase
// empty list if skip count greater than number of results (ALF-7884)
pagingRequest = new PagingRequest(1000, 3, null);
- pagingResults = fileFolderService.list(workingRootNodeRef, true, true, null, null, pagingRequest);
+ pagingResults = fileFolderService.list(workingRootNodeRef, true, true, null, null, null, pagingRequest);
assertNotNull(pagingResults);
assertFalse(pagingResults.hasMoreItems());
@@ -899,9 +899,17 @@ public class FileFolderServiceImplTest extends TestCase
*/
public void testGetType() throws Exception
{
- I18NUtil.setContentLocale(Locale.CANADA);
- FileFolderServiceType type = fileFolderService.getType(ContentModel.TYPE_FOLDER);
- assertEquals("Type incorrect for folder", FileFolderServiceType.FOLDER, type);
+ Locale savedLocale = I18NUtil.getContentLocaleOrNull();
+ try
+ {
+ I18NUtil.setContentLocale(Locale.CANADA);
+ FileFolderServiceType type = fileFolderService.getType(ContentModel.TYPE_FOLDER);
+ assertEquals("Type incorrect for folder", FileFolderServiceType.FOLDER, type);
+ }
+ finally
+ {
+ I18NUtil.setContentLocale(savedLocale);
+ }
}
public void testETHREEOH_3088_MoveIntoSelf() throws Exception
@@ -1129,5 +1137,56 @@ public class FileFolderServiceImplTest extends TestCase
assertEquals("cm:modified should not have changed (level too high)",
modifiedTooHigh,
nodeService.getProperty(workingRootNodeRef, ContentModel.PROP_MODIFIED));
- }
+ }
+
+ public void testPatterns()
+ {
+ // sanity checks only (see also GetChildrenCannedQueryTest)
+
+ I18NUtil.setContentLocale(Locale.CANADA);
+
+ // test 1
+ PagingRequest pagingRequest = new PagingRequest(100, null);
+ PagingResults pagingResults = fileFolderService.list(workingRootNodeRef, true, true, "L0%", null, null, pagingRequest);
+
+ assertNotNull(pagingResults);
+ assertFalse(pagingResults.hasMoreItems());
+ assertNull(pagingResults.getTotalResultCount());
+
+ List files = pagingResults.getPage();
+
+ // check
+ String[] expectedNames = new String[]
+ { NAME_L0_FILE_A, NAME_L0_FILE_B, NAME_L0_FOLDER_A, NAME_L0_FOLDER_B, NAME_L0_FOLDER_C };
+ checkFileList(files, 2, 3, expectedNames);
+
+ // test 2
+ pagingResults = fileFolderService.list(workingRootNodeRef, true, true, "L1%", null, null, pagingRequest);
+
+ assertNotNull(pagingResults);
+ assertFalse(pagingResults.hasMoreItems());
+ assertNull(pagingResults.getTotalResultCount());
+
+ files = pagingResults.getPage();
+
+ // check
+ expectedNames = new String[]
+ { };
+ checkFileList(files, 0, 0, expectedNames);
+
+ // test 3
+ pagingResults = fileFolderService.list(workingRootNodeRef, true, true, "L0%File%", null, null, pagingRequest);
+
+ assertNotNull(pagingResults);
+ assertFalse(pagingResults.hasMoreItems());
+ assertNull(pagingResults.getTotalResultCount());
+
+ files = pagingResults.getPage();
+
+ // check
+ expectedNames = new String[]
+ { NAME_L0_FILE_A, NAME_L0_FILE_B };
+ checkFileList(files, 2, 0, expectedNames);
+
+ }
}
diff --git a/source/java/org/alfresco/repo/node/getchildren/FilterSortNodeEntity.java b/source/java/org/alfresco/repo/node/getchildren/FilterSortNodeEntity.java
index 96984173a8..9752fff8c8 100644
--- a/source/java/org/alfresco/repo/node/getchildren/FilterSortNodeEntity.java
+++ b/source/java/org/alfresco/repo/node/getchildren/FilterSortNodeEntity.java
@@ -46,6 +46,8 @@ public class FilterSortNodeEntity
private Long prop2qnameId;
private Long prop3qnameId;
private List childNodeTypeQNameIds;
+ private String pattern;
+ private Long namePropertyQNameId;
private boolean auditableProps;
private boolean nodeType;
@@ -67,7 +69,27 @@ public class FilterSortNodeEntity
this.id = id;
}
- public NodePropertyEntity getProp1()
+ public String getPattern()
+ {
+ return pattern;
+ }
+
+ public void setPattern(String pattern)
+ {
+ this.pattern = pattern;
+ }
+
+ public Long getNamePropertyQNameId()
+ {
+ return namePropertyQNameId;
+ }
+
+ public void setNamePropertyQNameId(Long namePropertyQNameId)
+ {
+ this.namePropertyQNameId = namePropertyQNameId;
+ }
+
+ public NodePropertyEntity getProp1()
{
return prop1;
}
diff --git a/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQuery.java b/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQuery.java
index 2712ee66b0..07b33a46ed 100644
--- a/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQuery.java
+++ b/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQuery.java
@@ -153,6 +153,7 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions childNodeTypeQNames = paramBean.getChildTypeQNames();
final List filterProps = paramBean.getFilterProps();
+ String pattern = paramBean.getPattern();
// Get sort details
CannedQuerySortDetails sortDetails = parameters.getSortDetails();
@@ -190,6 +191,19 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions nameQName = qnameDAO.getQName(ContentModel.PROP_NAME);
+ if(nameQName == null)
+ {
+ throw new AlfrescoRuntimeException("Unable to determine qname id of name property");
+ }
+ params.setNamePropertyQNameId(nameQName.getFirst());
+ params.setPattern(pattern);
+ }
+
final List result;
if (filterSortPropCnt > 0)
diff --git a/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQueryFactory.java b/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQueryFactory.java
index 8c2944ade6..5d40adf0fd 100644
--- a/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQueryFactory.java
+++ b/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQueryFactory.java
@@ -123,7 +123,7 @@ public class GetChildrenCannedQueryFactory extends AbstractCannedQueryFactory getCannedQuery(NodeRef parentRef, Set childTypeQNames, List filterProps, List> sortProps, PagingRequest pagingRequest)
+ public CannedQuery getCannedQuery(NodeRef parentRef, String pattern, Set childTypeQNames, List filterProps, List> sortProps, PagingRequest pagingRequest)
{
ParameterCheck.mandatory("parentRef", parentRef);
ParameterCheck.mandatory("pagingRequest", pagingRequest);
@@ -131,8 +131,8 @@ public class GetChildrenCannedQueryFactory extends AbstractCannedQueryFactory getCannedQuery(NodeRef parentRef, Set childTypeQNames, PagingRequest pagingRequest)
+ public CannedQuery getCannedQuery(NodeRef parentRef, String pattern,Set childTypeQNames, PagingRequest pagingRequest)
{
- return getCannedQuery(parentRef, childTypeQNames, null, null, pagingRequest);
+ return getCannedQuery(parentRef, pattern, childTypeQNames, null, null, pagingRequest);
}
@Override
diff --git a/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQueryParams.java b/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQueryParams.java
index 6bee839186..cad7c3ee44 100644
--- a/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQueryParams.java
+++ b/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQueryParams.java
@@ -22,6 +22,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
+import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -37,13 +38,18 @@ public class GetChildrenCannedQueryParams
private Set childTypeQNames = Collections.emptySet();
private List filterProps = Collections.emptyList();
+ private String pattern = null;
- public GetChildrenCannedQueryParams(NodeRef parentRef, Set childTypeQNames, List filterProps)
+ public GetChildrenCannedQueryParams(NodeRef parentRef, Set childTypeQNames, List filterProps, String pattern)
{
this.parentRef = parentRef;
-
+
if (childTypeQNames != null) { this.childTypeQNames = childTypeQNames; }
if (filterProps != null) { this.filterProps = filterProps; }
+ if (pattern != null)
+ {
+ this.pattern = pattern;
+ }
}
public NodeRef getParentRef()
@@ -60,4 +66,9 @@ public class GetChildrenCannedQueryParams
{
return filterProps;
}
+
+ public String getPattern()
+ {
+ return pattern;
+ }
}
diff --git a/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQueryTest.java b/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQueryTest.java
index f940f95b6c..c5f6f958df 100644
--- a/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQueryTest.java
+++ b/source/java/org/alfresco/repo/node/getchildren/GetChildrenCannedQueryTest.java
@@ -141,7 +141,7 @@ public class GetChildrenCannedQueryTest extends TestCase
getChildrenCannedQueryFactory.setMethodSecurity((MethodSecurityBean)ctx.getBean("FileFolderService_security_list"));
getChildrenCannedQueryFactory.afterPropertiesSet();
-
+
if (! setupTestData)
{
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
@@ -177,7 +177,7 @@ public class GetChildrenCannedQueryTest extends TestCase
loadContent(testParentFolder, "quick.xml", "ZZ title" +TEST_RUN, "BB description", canRead, permMisses);
setupTestData = true;
-
+
// double-check permissions - see testPermissions
AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER);
@@ -529,6 +529,87 @@ public class GetChildrenCannedQueryTest extends TestCase
}
}
+ public void testPatterns() throws Exception
+ {
+ AuthenticationUtil.pushAuthentication();
+ AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
+
+ NodeRef parentNodeRef = nodeService.createNode(
+ repositoryHelper.getCompanyHome(),
+ ContentModel.ASSOC_CONTAINS,
+ QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, getName()),
+ ContentModel.TYPE_FOLDER, null).getChildRef();
+
+ // set up some nodes to test patterns
+ NodeRef nodeRef1 = createContent(parentNodeRef, "page.component-1-2.user~admin~dashboard.xml", ContentModel.TYPE_CONTENT);
+ NodeRef nodeRef2 = createContent(parentNodeRef, "page.component-1-4.user~admin~dashboard.xml", ContentModel.TYPE_CONTENT);
+ NodeRef nodeRef3 = createContent(parentNodeRef, "page.xml", ContentModel.TYPE_CONTENT);
+ NodeRef nodeRef4 = createContent(parentNodeRef, "page.component-1-4.user~admin~panel.xml", ContentModel.TYPE_CONTENT);
+
+ AuthenticationUtil.popAuthentication();
+
+ String pattern = "page.%.user~admin~dashboard.xml";
+ PagingResults results = list(parentNodeRef, -1, -1, 0, pattern, null);
+ assertFalse(results.hasMoreItems());
+
+ int totalCnt = results.getPage().size();
+ assertTrue(totalCnt == 2);
+ assertEquals(nodeRef1, results.getPage().get(0));
+ assertEquals(nodeRef2, results.getPage().get(1));
+
+ pattern = "%";
+ results = list(parentNodeRef, -1, -1, 0, pattern, null);
+ assertFalse(results.hasMoreItems());
+ totalCnt = results.getPage().size();
+ assertTrue(totalCnt == 4);
+ assertEquals(nodeRef1, results.getPage().get(0));
+ assertEquals(nodeRef2, results.getPage().get(1));
+ assertEquals(nodeRef3, results.getPage().get(2));
+ assertEquals(nodeRef4, results.getPage().get(3));
+
+ pattern = "foo%bar";
+ results = list(parentNodeRef, -1, -1, 0, pattern, null);
+ assertFalse(results.hasMoreItems());
+ totalCnt = results.getPage().size();
+ assertTrue(totalCnt == 0);
+
+ pattern = "page.%.admin~dashboard.xml";
+ results = list(parentNodeRef, -1, -1, 0, pattern, null);
+ assertFalse(results.hasMoreItems());
+ totalCnt = results.getPage().size();
+ assertTrue(totalCnt == 0);
+
+ pattern = "page.%.user~admin~%.xml";
+ results = list(parentNodeRef, -1, -1, 0, pattern, null);
+ assertFalse(results.hasMoreItems());
+ totalCnt = results.getPage().size();
+ assertTrue(totalCnt == 3);
+ }
+
+ // test helper method - optional filtering/sorting
+ private PagingResults list(NodeRef parentNodeRef, final int skipCount, final int maxItems, final int requestTotalCountMax, String pattern, List> sortProps)
+ {
+ PagingRequest pagingRequest = new PagingRequest(skipCount, maxItems, null);
+ pagingRequest.setRequestTotalCountMax(requestTotalCountMax);
+
+ // get canned query
+ GetChildrenCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenCannedQueryFactory)cannedQueryRegistry.getNamedObject("getChildrenCannedQueryFactory");
+ GetChildrenCannedQuery cq = (GetChildrenCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(parentNodeRef, pattern, null, null, sortProps, pagingRequest);
+
+ // execute canned query
+ CannedQueryResults results = cq.execute();
+
+ List nodeRefs = results.getPages().get(0);
+
+ Integer totalCount = null;
+ if (requestTotalCountMax > 0)
+ {
+ totalCount = results.getTotalResultCount().getFirst();
+ }
+
+ return new PagingNodeRefResultsImpl(nodeRefs, results.hasMoreItems(), totalCount, false);
+ }
+
private void filterByTypeAndCheck(NodeRef parentNodeRef, Set childTypeQNames, Set antiChildTypeQNames)
{
// belts-and-braces
@@ -752,7 +833,7 @@ public class GetChildrenCannedQueryTest extends TestCase
// get canned query
GetChildrenCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenCannedQueryFactory)cannedQueryRegistry.getNamedObject("getChildrenCannedQueryFactory");
- GetChildrenCannedQuery cq = (GetChildrenCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(parentNodeRef, childTypeQNames, filterProps, sortProps, pagingRequest);
+ GetChildrenCannedQuery cq = (GetChildrenCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(parentNodeRef, null, childTypeQNames, filterProps, sortProps, pagingRequest);
// execute canned query
CannedQueryResults results = cq.execute();
@@ -824,7 +905,7 @@ public class GetChildrenCannedQueryTest extends TestCase
properties).getChildRef();
}
- private void createContent(NodeRef parentNodeRef, String fileName, QName contentType) throws IOException
+ private NodeRef createContent(NodeRef parentNodeRef, String fileName, QName contentType) throws IOException
{
Map properties = new HashMap();
properties.put(ContentModel.PROP_NAME, fileName);
@@ -846,6 +927,8 @@ public class GetChildrenCannedQueryTest extends TestCase
ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
writer.setMimetype(mimetypeService.guessMimetype(fileName));
writer.putContent("my text content");
+
+ return nodeRef;
}
private void loadContent(NodeRef parentNodeRef, String inFileName, String title, String description, boolean readAllowed, Set results) throws IOException
diff --git a/source/java/org/alfresco/repo/security/person/PersonServiceImpl.java b/source/java/org/alfresco/repo/security/person/PersonServiceImpl.java
index 21989ac568..2340e84bb3 100644
--- a/source/java/org/alfresco/repo/security/person/PersonServiceImpl.java
+++ b/source/java/org/alfresco/repo/security/person/PersonServiceImpl.java
@@ -1214,7 +1214,7 @@ public class PersonServiceImpl extends TransactionListenerAdapter implements Per
}
}
- GetChildrenCannedQuery cq = (GetChildrenCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(contextNodeRef, childTypeQNames, filterProps, sortProps, pagingRequest);
+ GetChildrenCannedQuery cq = (GetChildrenCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(contextNodeRef, null, childTypeQNames, filterProps, sortProps, pagingRequest);
// execute canned query
final CannedQueryResults results = cq.execute();
diff --git a/source/java/org/alfresco/repo/site/SiteServiceImpl.java b/source/java/org/alfresco/repo/site/SiteServiceImpl.java
index b220d91e68..639578ed8f 100644
--- a/source/java/org/alfresco/repo/site/SiteServiceImpl.java
+++ b/source/java/org/alfresco/repo/site/SiteServiceImpl.java
@@ -892,7 +892,7 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
final String cQBeanName = "siteGetChildrenCannedQueryFactory";
GetChildrenCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenCannedQueryFactory)cannedQueryRegistry.getNamedObject(cQBeanName);
- GetChildrenCannedQuery cq = (GetChildrenCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(getSiteRoot(), searchTypeQNames,
+ GetChildrenCannedQuery cq = (GetChildrenCannedQuery)getChildrenCannedQueryFactory.getCannedQuery(getSiteRoot(), null, searchTypeQNames,
filterProps, sortProps, pagingRequest);
// execute canned query
diff --git a/source/java/org/alfresco/service/cmr/model/FileFolderService.java b/source/java/org/alfresco/service/cmr/model/FileFolderService.java
index a828b20609..b3320c5988 100644
--- a/source/java/org/alfresco/service/cmr/model/FileFolderService.java
+++ b/source/java/org/alfresco/service/cmr/model/FileFolderService.java
@@ -69,6 +69,23 @@ public interface FileFolderService
List> sortProps,
PagingRequest pagingRequest);
+ /**
+ * Lists page of immediate child files and/or folders of the given context node
+ * with pattern matching and optional filtering (exclusion of certain child file/folder subtypes) and sorting
+ *
+ * Pattern uses '%' as a wildcard
+ *
+ * @since 4.0
+ */
+ @Auditable(parameters = {"contextNodeRef", "files", "folders", "ignoreTypeQNames", "sortProps", "pagingRequest"})
+ public PagingResults list(NodeRef contextNodeRef,
+ boolean files,
+ boolean folders,
+ String pattern,
+ Set ignoreTypeQNames,
+ List> sortProps,
+ PagingRequest pagingRequest);
+
/**
* Lists all immediate child files of the given context node
*