diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java
index 34ff344f92..6d9a6007fb 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java
@@ -51,6 +51,7 @@ public class RecordCategoriesAPI extends BaseAPI
private static final Logger LOGGER = LoggerFactory.getLogger(RecordCategoriesAPI.class);
private static final String RM_ACTIONS_API = "{0}rma/actions/ExecutionQueue";
private static final String DISPOSITION_ACTIONS_API = "{0}node/{1}/dispositionschedule/dispositionactiondefinitions";
+ private static final String DISPOSITION_SCHEDULE_API = "{0}node/{1}/dispositionschedule";
/**
* Creates a retention schedule for the category given as parameter
@@ -71,6 +72,21 @@ public class RecordCategoriesAPI extends BaseAPI
return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API);
}
+ /**
+ * Get the disposition schedule nodeRef
+ *
+ * @param user
+ * @param password
+ * @param categoryName
+ * @return the disposition schedule nodeRef
+ */
+ public String getDispositionScheduleNodeRef(String user, String password, String categoryName)
+ {
+ String catNodeRef = NODE_PREFIX + getItemNodeRef(user, password, "/" + categoryName);
+ JSONObject dispositionSchedule = doGetRequest(user, password, MessageFormat.format(DISPOSITION_SCHEDULE_API, "{0}", catNodeRef));
+ return dispositionSchedule.getJSONObject("data").getString("nodeRef").replace(getNodeRefSpacesStore(), "");
+ }
+
/**
* Sets retention schedule authority and instructions, also if it is applied to records or folders
*
diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java
new file mode 100644
index 0000000000..cc7130ce67
--- /dev/null
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java
@@ -0,0 +1,108 @@
+/*
+ * #%L
+ * Alfresco Records Management Module
+ * %%
+ * Copyright (C) 2005 - 2018 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.rest.v0.service;
+
+
+import java.util.HashMap;
+
+import org.alfresco.rest.core.v0.BaseAPI;
+import org.alfresco.rest.v0.RecordCategoriesAPI;
+import org.alfresco.utility.data.DataUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Service for different disposition schedule actions
+ *
+ * @author jcule, cagache
+ * @since 2.6.2
+ */
+@Service
+public class DispositionScheduleService extends BaseAPI
+{
+ @Autowired
+ private RecordCategoriesAPI recordCategoriesAPI;
+
+ @Autowired
+ private DataUser dataUser;
+
+ /**
+ * Helper method for adding a cut off after period step
+ *
+ * @param categoryName the category in whose schedule the step will be added
+ * @param period
+ * @return
+ */
+ public void addCutOffAfterPeriodStep(String categoryName, String period)
+ {
+ HashMap cutOffStep = new HashMap<>();
+ cutOffStep.put(RETENTION_SCHEDULE.NAME, "cutoff");
+ cutOffStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period);
+ cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Cut off after a period step");
+ recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(),
+ dataUser.getAdminUser().getPassword(), categoryName, cutOffStep);
+ }
+
+ /**
+ * Helper method for adding a retain after period step
+ *
+ * @param categoryName the category in whose schedule the step will be added
+ * @param period
+ * @return
+ */
+ public void addRetainAfterPeriodStep(String categoryName, String period)
+ {
+ HashMap cutOffStep = new HashMap<>();
+ cutOffStep.put(RETENTION_SCHEDULE.NAME, "retain");
+ cutOffStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period);
+ cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Retain after a period step");
+ recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(),
+ dataUser.getAdminUser().getPassword(), categoryName, cutOffStep);
+ }
+
+ /**
+ * Helper method to create retention schedule with general fields for the given category as admin
+ * and apply it to the records
+ *
+ * @param categoryName
+ * @param appliedToRecords
+ */
+ public void createCategoryRetentionSchedule(String categoryName, Boolean appliedToRecords)
+ {
+ recordCategoriesAPI.createRetentionSchedule(dataUser.getAdminUser().getUsername(),
+ dataUser.getAdminUser().getPassword(), categoryName);
+ String retentionScheduleNodeRef = recordCategoriesAPI.getDispositionScheduleNodeRef(
+ dataUser.getAdminUser().getUsername(), dataUser.getAdminUser().getPassword(), categoryName);
+
+ HashMap retentionScheduleGeneralFields = new HashMap<>();
+ retentionScheduleGeneralFields.put(RETENTION_SCHEDULE.RETENTION_AUTHORITY, "Authority");
+ retentionScheduleGeneralFields.put(RETENTION_SCHEDULE.RETENTION_INSTRUCTIONS, "Instructions");
+ recordCategoriesAPI.setRetentionScheduleGeneralFields(dataUser.getAdminUser().getUsername(),
+ dataUser.getAdminUser().getPassword(), retentionScheduleNodeRef, retentionScheduleGeneralFields,
+ appliedToRecords);
+ }
+}
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java
new file mode 100644
index 0000000000..9a0b428d34
--- /dev/null
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java
@@ -0,0 +1,78 @@
+/*
+ * #%L
+ * Alfresco Records Management Module
+ * %%
+ * Copyright (C) 2005 - 2018 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.rest.rm.community.recordcategories;
+
+import static org.alfresco.utility.data.RandomData.getRandomName;
+import static org.alfresco.utility.report.log.Step.STEP;
+
+import org.alfresco.rest.rm.community.base.BaseRMRestTest;
+import org.alfresco.rest.rm.community.model.record.Record;
+import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
+import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
+import org.alfresco.rest.v0.service.DispositionScheduleService;
+import org.alfresco.test.AlfrescoTest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class DispositionScheduleInheritanceTests extends BaseRMRestTest
+{
+ @Autowired
+ private DispositionScheduleService dispositionScheduleService;
+
+ @AlfrescoTest (jira = "MNT-19967")
+ @Test (
+ description = "Folders and records under a child record category should inherit the retention schedule of the parent record category."
+ )
+ public void testDispositionScheduleInheritance() throws Exception
+ {
+ STEP("Create record category with retention schedule and apply it to records.");
+ RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory"));
+ dispositionScheduleService.createCategoryRetentionSchedule(rootCategory.getName(), true);
+
+ STEP("Add retention schedule cut off step with immediate period.");
+ dispositionScheduleService.addCutOffAfterPeriodStep(rootCategory.getName(), "immediately");
+
+ STEP("Add retention schedule retain step with immediate period.");
+ dispositionScheduleService.addRetainAfterPeriodStep(rootCategory.getName(), "immediately");
+
+ STEP("Create a subcategory with a record folder");
+ RecordCategoryChild subCategory = createRecordCategory(rootCategory.getId(), getRandomName("subCategory"));
+ RecordCategoryChild recFolder = createFolder(subCategory.getId(), getRandomName("recFolder"));
+
+ STEP("Create 2 records in the record folder. Complete one of them.");
+ Record elRecord = createElectronicRecord(recFolder.getId(), getRandomName("elRecord"));
+ Record nonElRecord = createNonElectronicRecord(recFolder.getId(), getRandomName("nonElRecord"));
+ getRestAPIFactory().getRecordsAPI().completeRecord(nonElRecord.getId());
+
+ STEP("Check that both records inherit root category retention schedule");
+ Assert.assertTrue(elRecord.getProperties().getRecordSearchHasDispositionSchedule(),
+ "rma:recordSearchHasDispositionSchedule property should be true");
+ Assert.assertTrue(nonElRecord.getProperties().getRecordSearchHasDispositionSchedule(),
+ "rma:recordSearchHasDispositionSchedule property should be true");
+ }
+}