From 7b3628a1e396a4e541b8d6a97b6291ab3447933d Mon Sep 17 00:00:00 2001 From: jcule Date: Mon, 25 Sep 2017 18:31:43 +0100 Subject: [PATCH 1/5] RM-5416: REST API Tests for Folder Classification --- .../org/alfresco/rest/core/RMRestWrapper.java | 7 ++ .../alfresco/rest/core/RestAPIFactory.java | 7 ++ .../rm/community/base/BaseRMRestTest.java | 79 +++++++++++++++++++ 3 files changed, 93 insertions(+) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestWrapper.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestWrapper.java index 7a529e0633..acc44a6114 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestWrapper.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestWrapper.java @@ -34,6 +34,7 @@ import org.alfresco.rest.model.RestHtmlResponse; import org.alfresco.rest.model.RestSiteModel; import org.alfresco.rest.model.RestSiteModelsCollection; import org.alfresco.rest.requests.coreAPI.RestCoreAPI; +import org.alfresco.rest.requests.search.SearchAPI; import org.alfresco.rest.rm.community.requests.gscore.GSCoreAPI; import org.alfresco.utility.model.StatusModel; import org.alfresco.utility.model.UserModel; @@ -145,6 +146,12 @@ public class RMRestWrapper return restWrapper.withCoreAPI(); } + /** Get the Alfresco Search API. */ + public SearchAPI withSearchAPI() + { + return restWrapper.withSearchAPI(); + } + /** * You can handle the request sent to server by calling this method. * If for example you want to sent multipart form data you can use:
diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RestAPIFactory.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RestAPIFactory.java
index 710413fa33..10b71423d9 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RestAPIFactory.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RestAPIFactory.java
@@ -32,6 +32,7 @@ import javax.annotation.Resource;
 
 import org.alfresco.rest.requests.Node;
 import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
+import org.alfresco.rest.requests.search.SearchAPI;
 import org.alfresco.rest.rm.community.requests.gscore.GSCoreAPI;
 import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
 import org.alfresco.rest.rm.community.requests.gscore.api.FilesAPI;
@@ -84,6 +85,12 @@ public class RestAPIFactory
         getRmRestWrapper().authenticateUser(userModel != null ? userModel : getDataUser().getAdminUser());
         return getRmRestWrapper().withCoreAPI();
     }
+    
+    private SearchAPI getSearchAPI(UserModel userModel)
+    {
+        getRmRestWrapper().authenticateUser(userModel != null ? userModel : getDataUser().getAdminUser());
+        return getRmRestWrapper().withSearchAPI();
+    }   
 
     public Node getNodeAPI(RepoTestModel model) throws Exception
     {
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java
index 38d4b2959d..3d05133a04 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java
@@ -33,11 +33,14 @@ import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_TITLE
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.ASPECTS_COMPLETED_RECORD;
+import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_TYPE;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
+import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
+import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_USER;
 import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryChildModel;
 import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryModel;
 import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile;
@@ -51,6 +54,7 @@ import static org.testng.Assert.assertTrue;
 
 import java.util.List;
 
+import org.alfresco.dataprep.ContentService;
 import org.alfresco.rest.RestTest;
 import org.alfresco.rest.core.RestAPIFactory;
 import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
@@ -65,8 +69,12 @@ import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainer;
 import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
 import org.alfresco.rest.rm.community.requests.gscore.api.RMSiteAPI;
 import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
+import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
 import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
+import org.alfresco.rest.v0.RMRolesAndActionsAPI;
 import org.alfresco.utility.data.DataUser;
+import org.alfresco.utility.model.FolderModel;
+import org.alfresco.utility.model.SiteModel;
 import org.alfresco.utility.model.UserModel;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
@@ -92,6 +100,14 @@ public class BaseRMRestTest extends RestTest
     @Getter (value = PROTECTED)
     private DataUser dataUser;
 
+    @Autowired
+    @Getter(value = PROTECTED)
+    private ContentService contentService;
+
+    @Autowired
+    @Getter(value = PROTECTED)
+    private RMRolesAndActionsAPI rmRolesAndActionsAPI;
+    
     /**
      * Asserts the given status code
      *
@@ -468,4 +484,67 @@ public class BaseRMRestTest extends RestTest
     {
         return getFilePlanAsUser(getAdminUser(), componentId);
     }
+    
+    /**
+     * Recursively delete a folder
+     *
+     * @param siteModel
+     * @param folder
+     */
+    public void deleteFolder(SiteModel siteModel, FolderModel folder)
+    {
+        contentService.deleteTree(getAdminUser().getUsername(), getAdminUser().getPassword(), siteModel.getId(),
+                    folder.getName());
+    }
+
+    /**
+     * Create an electronic record
+     *
+     * @param parentId the id of the parent
+     * @param name the name of the record
+     * @return the created record
+     * @throws Exception
+     */
+    public Record createElectronicRecord(String parentId, String name) throws Exception
+    {
+        RecordFolderAPI recordFolderAPI = restAPIFactory.getRecordFolderAPI();
+        Record recordModel = Record.builder().name(name).nodeType(CONTENT_TYPE).build();
+        return recordFolderAPI.createRecord(recordModel, parentId);
+    }
+
+    /**
+     * Delete a record folder
+     *
+     * @param recordFolderId the id of the record folder to delete
+     */
+    public void deleteRecordFolder(String recordFolderId)
+    {
+        RecordFolderAPI recordFolderAPI = restAPIFactory.getRecordFolderAPI();
+        recordFolderAPI.deleteRecordFolder(recordFolderId);
+    }
+
+    /**
+     * Delete a record category
+     *
+     * @param recordCategoryId the id of the record category to delete
+     */
+    public void deleteRecordCategory(String recordCategoryId)
+    {
+        RecordCategoryAPI recordCategoryAPI = restAPIFactory.getRecordCategoryAPI();
+        recordCategoryAPI.deleteRecordCategory(recordCategoryId);
+    }
+
+    /**
+     * Assign filling permission on a record category and give the user RM_USER role
+     *
+     * @param user the user to assign the permission to
+     * @param categoryId the id of the category to assign permissions for
+     * @throws Exception
+     */
+    public void assignFillingPermissionsOnCategory(UserModel user, String categoryId) throws Exception
+    {
+        getRestAPIFactory().getRMUserAPI().addUserPermission(categoryId, user, PERMISSION_FILING);
+        rmRolesAndActionsAPI.assignUserToRole(dataUser.getAdminUser().getUsername(),
+                    dataUser.getAdminUser().getPassword(), user.getUsername(), ROLE_RM_USER);
+    }
 }

From b8398ecdac0549b2be76e9a6fbdd1c315381bbdc Mon Sep 17 00:00:00 2001
From: jcule 
Date: Wed, 27 Sep 2017 17:43:57 +0100
Subject: [PATCH 2/5] RM-5416: REST API Tests for Folder Classification -
 various improvements

---
 .../alfresco/rest/rm/community/base/BaseRMRestTest.java   | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java
index 3d05133a04..0216f3ade2 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java
@@ -541,10 +541,10 @@ public class BaseRMRestTest extends RestTest
      * @param categoryId the id of the category to assign permissions for
      * @throws Exception
      */
-    public void assignFillingPermissionsOnCategory(UserModel user, String categoryId) throws Exception
+    public void assignFillingPermissionsOnCategory(UserModel user, String categoryId, String userPermission, String userRole) throws Exception
     {
-        getRestAPIFactory().getRMUserAPI().addUserPermission(categoryId, user, PERMISSION_FILING);
-        rmRolesAndActionsAPI.assignUserToRole(dataUser.getAdminUser().getUsername(),
-                    dataUser.getAdminUser().getPassword(), user.getUsername(), ROLE_RM_USER);
+        getRestAPIFactory().getRMUserAPI().addUserPermission(categoryId, user, userPermission);
+        rmRolesAndActionsAPI.assignUserToRole(getAdminUser().getUsername(),
+                    getAdminUser().getPassword(), user.getUsername(), userRole);
     }
 }

From 6fc5685030f06671d6eff7f2a0bcd207f5087c85 Mon Sep 17 00:00:00 2001
From: Rodica Sutu 
Date: Fri, 29 Sep 2017 09:10:42 +0300
Subject: [PATCH 3/5] refactoring tests to be more independent

---
 .../org/alfresco/rest/core/v0/BaseAPI.java    |  2 +-
 .../rm/community/base/BaseRMRestTest.java     | 74 ++++++++++++++++++-
 2 files changed, 72 insertions(+), 4 deletions(-)

diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java
index c4844156aa..3bd7855468 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java
@@ -74,7 +74,7 @@ public abstract class BaseAPI
 
     /** exception key in JSON response body */
     private static final String EXCEPTION_KEY = "exception";
-    protected static final String NODE_PREFIX = "workspace/SpacesStore/";
+    public static final String NODE_PREFIX = "workspace/SpacesStore/";
     protected static final String UPDATE_METADATA_API = "{0}node/{1}/formprocessor";
     protected static final String ACTIONS_API = "{0}actionQueue";
     protected static final String RM_ACTIONS_API = "{0}rma/actions/ExecutionQueue";
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java
index 0216f3ade2..124df6907a 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java
@@ -52,6 +52,7 @@ import static org.springframework.http.HttpStatus.OK;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.alfresco.dataprep.ContentService;
@@ -71,6 +72,9 @@ import org.alfresco.rest.rm.community.requests.gscore.api.RMSiteAPI;
 import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
 import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
 import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
+import org.alfresco.rest.search.RestRequestQueryModel;
+import org.alfresco.rest.search.SearchNodeModel;
+import org.alfresco.rest.search.SearchRequest;
 import org.alfresco.rest.v0.RMRolesAndActionsAPI;
 import org.alfresco.utility.data.DataUser;
 import org.alfresco.utility.model.FolderModel;
@@ -507,11 +511,24 @@ public class BaseRMRestTest extends RestTest
      */
     public Record createElectronicRecord(String parentId, String name) throws Exception
     {
-        RecordFolderAPI recordFolderAPI = restAPIFactory.getRecordFolderAPI();
+       return createElectronicRecord(parentId, name ,null);
+    }
+
+
+    /**
+     * Create an electronic record
+     *
+     * @param parentId the id of the parent
+     * @param name     the name of the record
+     * @return the created record
+     * @throws Exception
+     */
+    public Record createElectronicRecord(String parentId, String name, UserModel user) throws Exception
+    {
+        RecordFolderAPI recordFolderAPI = restAPIFactory.getRecordFolderAPI(user);
         Record recordModel = Record.builder().name(name).nodeType(CONTENT_TYPE).build();
         return recordFolderAPI.createRecord(recordModel, parentId);
     }
-
     /**
      * Delete a record folder
      *
@@ -541,10 +558,61 @@ public class BaseRMRestTest extends RestTest
      * @param categoryId the id of the category to assign permissions for
      * @throws Exception
      */
-    public void assignFillingPermissionsOnCategory(UserModel user, String categoryId, String userPermission, String userRole) throws Exception
+    public void assignFillingPermissionsOnCategory(UserModel user, String categoryId,
+                                                   String userPermission, String userRole) throws Exception
     {
         getRestAPIFactory().getRMUserAPI().addUserPermission(categoryId, user, userPermission);
         rmRolesAndActionsAPI.assignUserToRole(getAdminUser().getUsername(),
                     getAdminUser().getPassword(), user.getUsername(), userRole);
     }
+
+    /**
+     * Returns search results for the given search term
+     *
+     * @param user
+     * @param term
+     * @return
+     * @throws Exception
+     */
+    public List searchForContentAsUser(UserModel user, String term) throws Exception
+    {
+        getRestAPIFactory().getRmRestWrapper().authenticateUser(user);
+        RestRequestQueryModel queryReq = new RestRequestQueryModel();
+        SearchRequest query = new SearchRequest(queryReq);
+        queryReq.setQuery("cm:name:*" + term + "*");
+
+        List names = new ArrayList<>();
+        // wait for solr indexing
+        int counter = 0;
+        int waitInMilliSeconds = 6000;
+        while (counter < 3)
+        {
+            synchronized (this)
+            {
+                try
+                {
+                    this.wait(waitInMilliSeconds);
+                } catch (InterruptedException e)
+                {
+                }
+            }
+
+            List searchResults = getRestAPIFactory().getRmRestWrapper().withSearchAPI().search(query)
+                                                                     .getEntries();
+            if ((searchResults != null && !searchResults.isEmpty()))
+            {
+                searchResults.forEach(childNode ->
+                {
+                    names.add(childNode.onModel().getName());
+                });
+                break;
+            } else
+            {
+                counter++;
+            }
+            // double wait time to not overdo solr search
+            waitInMilliSeconds = (waitInMilliSeconds * 2);
+        }
+        return names;
+    }
 }

From 9ff6b4f07c9c97256a7e2fdf63622a78c648daa5 Mon Sep 17 00:00:00 2001
From: Rodica Sutu 
Date: Fri, 29 Sep 2017 12:31:14 +0300
Subject: [PATCH 4/5] improve the tests for record folder classification to be
 independent

---
 .../model/recordcategory/RecordCategoryProperties.java         | 3 +++
 .../community/model/recordfolder/RecordFolderProperties.java   | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/recordcategory/RecordCategoryProperties.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/recordcategory/RecordCategoryProperties.java
index cbf9c1e4d3..ea75965d50 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/recordcategory/RecordCategoryProperties.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/recordcategory/RecordCategoryProperties.java
@@ -34,6 +34,8 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR;
 
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 
@@ -59,6 +61,7 @@ import lombok.NoArgsConstructor;
 @EqualsAndHashCode(callSuper = true)
 @NoArgsConstructor
 @AllArgsConstructor
+@JsonIgnoreProperties (ignoreUnknown = true)
 public class RecordCategoryProperties extends TestModel
 {
     /*************************/
diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/recordfolder/RecordFolderProperties.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/recordfolder/RecordFolderProperties.java
index 824cf348a7..65b98ab3d9 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/recordfolder/RecordFolderProperties.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/recordfolder/RecordFolderProperties.java
@@ -40,6 +40,8 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR;
 
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 
@@ -65,6 +67,7 @@ import lombok.NoArgsConstructor;
 @EqualsAndHashCode(callSuper = true)
 @NoArgsConstructor
 @AllArgsConstructor
+@JsonIgnoreProperties (ignoreUnknown = true)
 public class RecordFolderProperties extends TestModel
 {
     /*************************/

From 28704ef015d9a5d5adf07e0e3c8e92c5d9f7c5ff Mon Sep 17 00:00:00 2001
From: Ana Bozianu 
Date: Fri, 29 Sep 2017 11:39:00 +0100
Subject: [PATCH 5/5] Feature/rm 5655 classification beyond highest child

---
 .../query/rm-common-SqlMap.xml                |  20 +-
 .../query/rm-query-context.xml                |  10 +-
 ...ChildrenWithPropertyValuesQueryParams.java |  73 +++++
 .../query/RecordsManagementQueryDAO.java      |  16 ++
 .../query/RecordsManagementQueryDAOImpl.java  |  55 +++-
 .../RecordsManagementQueryDAOImplTest.java    | 252 +++++++++++++++++-
 6 files changed, 419 insertions(+), 7 deletions(-)
 create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/ChildrenWithPropertyValuesQueryParams.java

diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml
index e3f1c1a89d..d3b63f4467 100644
--- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml
+++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-common-SqlMap.xml
@@ -19,5 +19,23 @@
             prop.string_value = ?
             
     
-    
+
+   
+   
+
 
\ No newline at end of file
diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-query-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-query-context.xml
index 59f1687234..5bb4a8b094 100644
--- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-query-context.xml
+++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/query/rm-query-context.xml
@@ -16,9 +16,11 @@
         
     
 
-	
-		
-		
-	
+   
+      
+      
+      
+      
+   
 
 
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/ChildrenWithPropertyValuesQueryParams.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/ChildrenWithPropertyValuesQueryParams.java
new file mode 100644
index 0000000000..b0faa993e4
--- /dev/null
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/ChildrenWithPropertyValuesQueryParams.java
@@ -0,0 +1,73 @@
+/*
+ * #%L
+ * Alfresco Records Management Module
+ * %%
+ * Copyright (C) 2005 - 2017 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * -
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail.  Otherwise, the software is
+ * provided under the following open source license terms:
+ * -
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * -
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ * -
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ * #L%
+ */
+package org.alfresco.module.org_alfresco_module_rm.query;
+
+import java.util.Collection;
+
+/**
+ * Select parameter for select_CountChildrenWithPropertyValues.
+ *
+ * @author Ana Manolache
+ * @since 2.6
+ */
+public class ChildrenWithPropertyValuesQueryParams
+{
+    private Long parentId;
+    private Long propertyQnameId;
+    private Collection propertyValues;
+
+    public Long getParentId()
+    {
+        return parentId;
+    }
+
+    public void setParentId(Long parentId)
+    {
+        this.parentId = parentId;
+    }
+
+    public Long getPropertyQnameId()
+    {
+        return propertyQnameId;
+    }
+
+    public void setPropertyQnameId(Long propertyQnameId)
+    {
+        this.propertyQnameId = propertyQnameId;
+    }
+
+    public Collection getPropertyValues()
+    {
+        return propertyValues;
+    }
+
+    public void setPropertyValues(Collection propertyValues)
+    {
+        this.propertyValues = propertyValues;
+    }
+}
+
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java
index fec9ad5353..afd031cd39 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAO.java
@@ -27,6 +27,11 @@
 
 package org.alfresco.module.org_alfresco_module_rm.query;
 
+import java.util.Collection;
+
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.namespace.QName;
+
 /**
  * Records management query DAO
  * 
@@ -46,4 +51,15 @@ public interface RecordsManagementQueryDAO
      * @return int  count
      */
     int getCountRmaIdentifier(String identifierValue);
+
+    /**
+     * Returns whether a given node contains children with one of the given values for the given property
+     *
+     * @param parent         the parent to evaluate
+     * @param property       the QName of the property to evaluate
+     * @param propertyValues the list of values to look for
+     * @return true if there is at least one child with one of the values from the list set on the given property
+     * false otherwise
+     */
+    public boolean hasChildrenWithPropertyValues(NodeRef parent, QName property, Collection propertyValues);
 }
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java
index 82744e7815..f62712d6ab 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java
@@ -27,11 +27,16 @@
 
 package org.alfresco.module.org_alfresco_module_rm.query;
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
+import org.alfresco.repo.domain.node.NodeDAO;
 import org.alfresco.repo.domain.qname.QNameDAO;
+import org.alfresco.repo.tenant.TenantService;
+import org.alfresco.service.cmr.repository.InvalidNodeRefException;
+import org.alfresco.service.cmr.repository.NodeRef;
 import org.alfresco.service.namespace.QName;
 import org.alfresco.util.Pair;
 import org.mybatis.spring.SqlSessionTemplate;
@@ -45,12 +50,15 @@ import org.mybatis.spring.SqlSessionTemplate;
 public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, RecordsManagementModel
 {
     private static final String COUNT_IDENTIFIER = "alfresco.query.rm.select_CountRMIndentifier";
+    private static final String COUNT_CHILDREN_WITH_PROPERTY_VALUES = "select_CountChildrenWithPropertyValues";
     
     /** SQL session template */
     protected SqlSessionTemplate template;
     
     /** QName DAO */
     protected QNameDAO qnameDAO;
+    protected NodeDAO nodeDAO;
+    protected TenantService tenantService;
     
     /**
      * @param sqlSessionTemplate    SQL session template
@@ -67,7 +75,17 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO,
     {
         this.qnameDAO = qnameDAO;
     }
-    
+
+    public void setNodeDAO(NodeDAO nodeDAO)
+    {
+        this.nodeDAO = nodeDAO;
+    }
+
+    public void setTenantService(TenantService tenantService)
+    {
+        this.tenantService = tenantService;
+    }
+
     /**
      * @see org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO#getCountRmaIdentifier(java.lang.String)
      */
@@ -97,4 +115,39 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO,
         return result;
     }
 
+    @Override
+    public boolean hasChildrenWithPropertyValues(NodeRef parent, QName property, Collection propertyValues)
+    {
+        if(propertyValues.isEmpty())
+        {
+            return false;
+        }
+
+        ChildrenWithPropertyValuesQueryParams queryParams = new ChildrenWithPropertyValuesQueryParams();
+
+        // Set the parent node id
+        Pair nodePair = nodeDAO.getNodePair(tenantService.getName(parent));
+        if (nodePair == null)
+        {
+            throw new InvalidNodeRefException("The parent node does not exist.", parent);
+        }
+        Long parentNodeId = nodePair.getFirst();
+        queryParams.setParentId(parentNodeId);
+
+        // Set the property qname id
+        Pair pair = qnameDAO.getQName(property);
+        if (pair == null)
+        {
+            return false;
+        }
+        queryParams.setPropertyQnameId(pair.getFirst());
+
+
+        // Set the property values
+        queryParams.setPropertyValues(propertyValues);
+
+        // Perform the query
+        Long count = template.selectOne(COUNT_CHILDREN_WITH_PROPERTY_VALUES, queryParams);
+        return count > 0;
+    }
 }
diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementQueryDAOImplTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementQueryDAOImplTest.java
index 5f29c12f7a..49a1fbe101 100644
--- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementQueryDAOImplTest.java
+++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/service/RecordsManagementQueryDAOImplTest.java
@@ -27,10 +27,17 @@
 
 package org.alfresco.module.org_alfresco_module_rm.test.legacy.service;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.alfresco.model.ContentModel;
 import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
 import org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO;
 import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
 import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.namespace.QName;
+import org.alfresco.util.GUID;
 
 /**
  * Records Management Query DAO
@@ -86,5 +93,248 @@ public class RecordsManagementQueryDAOImplTest extends BaseRMTestCase implements
         });
     }
 
-  
+    /**
+     * Given a folder containing 3 files with the descriptions set
+     * When I check if the folder contains children having the description of file2 or file2
+     * Then the answer is positive
+     */
+    @org.junit.Test
+    public void testHasChildrenWithPropertyValues_someChildrenWithValues() throws Exception
+    {
+        doBehaviourDrivenTest(new BehaviourDrivenTest()
+        {
+            NodeRef parentFolder;
+            NodeRef file1;
+            NodeRef file2;
+            NodeRef file3;
+            String propValue1 = "descr1"; // set on file1
+            String propValue2 = "descr2"; // set on file2
+            String propValue3 = "descr3"; // set on file3
+            String propValue4 = "descr4"; // not set on any file
+            Boolean result;
+
+            @Override
+            public void given() throws Exception
+            {
+                setupCollaborationSiteTestDataImpl();
+                parentFolder = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
+                file1 = fileFolderService.create(parentFolder, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
+                file2 = fileFolderService.create(parentFolder, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
+                file3 = fileFolderService.create(parentFolder, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
+
+                nodeService.setProperty(file1, PROP_DESCRIPTION, propValue1);
+                nodeService.setProperty(file2, PROP_DESCRIPTION, propValue2);
+                nodeService.setProperty(file3, PROP_DESCRIPTION, propValue3);
+            }
+
+            @Override
+            public void when() throws Exception
+            {
+                result = queryDAO.hasChildrenWithPropertyValues(parentFolder, PROP_DESCRIPTION, Arrays.asList(propValue1, propValue2, propValue4));
+            }
+
+            @Override
+            public void then() throws Exception
+            {
+                assertTrue(result);
+            }
+
+            @Override
+            public void after() throws Exception
+            {
+                if (parentFolder != null && nodeService.exists(parentFolder))
+                {
+                    nodeService.deleteNode(parentFolder);
+                }
+            }
+        });
+    }
+
+    /**
+     * Given a folder containing 3 files with the descriptions unset
+     * When I check if the folder contains children having certain descriptions
+     * Then the answer is negative
+     */
+    @org.junit.Test
+    public void testHasChildrenWithPropertyValues_propertyNotSetOnChildren() throws Exception
+    {
+        doBehaviourDrivenTest(new BehaviourDrivenTest()
+        {
+            NodeRef parentFolder;
+            NodeRef file1;
+            NodeRef file2;
+            NodeRef file3;
+            Boolean result;
+
+            @Override
+            public void given() throws Exception
+            {
+                setupCollaborationSiteTestDataImpl();
+                parentFolder = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
+                file1 = fileFolderService.create(parentFolder, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
+                file2 = fileFolderService.create(parentFolder, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
+                file3 = fileFolderService.create(parentFolder, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
+            }
+
+            @Override
+            public void when() throws Exception
+            {
+                result = queryDAO.hasChildrenWithPropertyValues(parentFolder, PROP_DESCRIPTION, Arrays.asList("descr1", "descr2", "descr3"));
+            }
+
+            @Override
+            public void then() throws Exception
+            {
+                assertFalse(result);
+            }
+
+            @Override
+            public void after() throws Exception
+            {
+                if (parentFolder != null && nodeService.exists(parentFolder))
+                {
+                    nodeService.deleteNode(parentFolder);
+                }
+            }
+        });
+    }
+
+    /**
+     * Given a folder with no children but the property set on itself
+     * When I check if the folder contains children having certain descriptions
+     * Then the answer is negative
+     */
+    @org.junit.Test
+    public void testHasChildrenWithPropertyValues_noChildren() throws Exception
+    {
+        doBehaviourDrivenTest(new BehaviourDrivenTest()
+        {
+            NodeRef folder;
+            String propValue = "descr";
+            Boolean result;
+
+            @Override
+            public void given() throws Exception
+            {
+                setupCollaborationSiteTestDataImpl();
+                folder = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
+                nodeService.setProperty(folder, PROP_DESCRIPTION, propValue);
+            }
+
+            @Override
+            public void when() throws Exception
+            {
+                result = queryDAO.hasChildrenWithPropertyValues(folder, PROP_DESCRIPTION, Arrays.asList("descr"));
+            }
+
+            @Override
+            public void then() throws Exception
+            {
+                assertFalse(result);
+            }
+
+            @Override
+            public void after() throws Exception
+            {
+                if (folder != null && nodeService.exists(folder))
+                {
+                    nodeService.deleteNode(folder);
+                }
+            }
+        });
+    }
+
+    /**
+     * Given a folder with children and an unused property
+     * When I check if the folder contains children having the unused property
+     * Then the answer is negative
+     */
+    @org.junit.Test
+    public void testHasChildrenWithPropertyValues_propertyNotUsed() throws Exception
+    {
+        doBehaviourDrivenTest(new BehaviourDrivenTest()
+        {
+            NodeRef parentFolder;
+            QName property;
+            Boolean result;
+
+            @Override
+            public void given() throws Exception
+            {
+                setupCollaborationSiteTestDataImpl();
+                parentFolder = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
+                fileFolderService.create(parentFolder, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
+                fileFolderService.create(parentFolder, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
+                property = QName.createQName(URI, "customProp-" + GUID.generate());
+            }
+
+            @Override
+            public void when() throws Exception
+            {
+                result = queryDAO.hasChildrenWithPropertyValues(folder, property, Arrays.asList("descr"));
+            }
+
+            @Override
+            public void then() throws Exception
+            {
+                assertFalse(result);
+            }
+
+            @Override
+            public void after() throws Exception
+            {
+                if (folder != null && nodeService.exists(folder))
+                {
+                    nodeService.deleteNode(folder);
+                }
+            }
+        });
+    }
+
+    /**
+     * Given any folder and any property
+     * When I pass an empty array to the hasChildrenWithPropertyValues method
+     * Then the answer is negative
+     */
+    @org.junit.Test
+    public void testHasChildrenWithPropertyValues_emptyArray() throws Exception
+    {
+        doBehaviourDrivenTest(new BehaviourDrivenTest()
+        {
+            NodeRef parentFolder;
+            NodeRef file1;
+            Boolean result;
+
+            @Override
+            public void given() throws Exception
+            {
+                setupCollaborationSiteTestDataImpl();
+                parentFolder = fileFolderService.create(documentLibrary, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
+                file1 = fileFolderService.create(parentFolder, GUID.generate(), ContentModel.TYPE_FOLDER).getNodeRef();
+
+                nodeService.setProperty(file1, PROP_DESCRIPTION, "descr1");
+            }
+
+            @Override
+            public void when() throws Exception
+            {
+                result = queryDAO.hasChildrenWithPropertyValues(folder, PROP_DESCRIPTION, new ArrayList());
+            }
+
+            @Override
+            public void then() throws Exception
+            {
+                assertFalse(result);
+            }
+
+            @Override
+            public void after() throws Exception
+            {
+                if (folder != null && nodeService.exists(folder))
+                {
+                    nodeService.deleteNode(folder);
+                }
+            }
+        });
+    }
 }