From 79873a908dda4f12640e335d2da6b403d2acab95 Mon Sep 17 00:00:00 2001 From: jcule Date: Wed, 16 May 2018 11:55:14 +0100 Subject: [PATCH 1/2] RM-6302: Add Edi tFunctionality To Disposition Schedule: automation tests --- .../org/alfresco/rest/core/v0/BaseAPI.java | 2 +- .../alfresco/rest/v0/RecordCategoriesAPI.java | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) 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 e3a37ff998..66c1cdf37d 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 @@ -662,7 +662,7 @@ public abstract class BaseAPI RETENTION_GHOST, RETENTION_ELIGIBLE_FIRST_EVENT, RETENTION_EVENTS, - + COMBINE_DISPOSITION_STEP_CONDITIONS } /** 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..57f2368f56 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 @@ -35,6 +35,7 @@ import java.util.Map; import org.alfresco.rest.core.v0.BaseAPI; import org.apache.http.HttpResponse; import org.json.JSONObject; +import org.json.JSONArray; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -51,6 +52,8 @@ 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 +74,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 * @@ -109,6 +127,34 @@ public class RecordCategoriesAPI extends BaseAPI addPropertyToRequest(requestParams, "ghostOnDestroy", properties, RETENTION_SCHEDULE.RETENTION_GHOST); addPropertyToRequest(requestParams, "periodProperty", properties, RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY); addPropertyToRequest(requestParams, "events", properties, RETENTION_SCHEDULE.RETENTION_EVENTS); + addPropertyToRequest(requestParams, "combineDispositionStepConditions", properties, RETENTION_SCHEDULE.COMBINE_DISPOSITION_STEP_CONDITIONS); + addPropertyToRequest(requestParams, "eligibleOnFirstCompleteEvent", properties, RETENTION_SCHEDULE.RETENTION_ELIGIBLE_FIRST_EVENT); + + return doPostJsonRequest(user, password, SC_OK, requestParams, MessageFormat.format(DISPOSITION_ACTIONS_API, "{0}", catNodeRef)); + } + + /** + * Creates a retention schedule for a given category with added event + + * @param user + * @param password + * @param categoryName + * @param properties + * @param events + * @return The HTTP Response. + */ + public HttpResponse addDispositionScheduleSteps(String user, String password, String categoryName, Map properties, String events) + { + String catNodeRef = NODE_PREFIX + getItemNodeRef(user, password, "/" + categoryName); + + JSONObject requestParams = new JSONObject(); + addPropertyToRequest(requestParams, "name", properties, RETENTION_SCHEDULE.NAME); + addPropertyToRequest(requestParams, "description", properties, RETENTION_SCHEDULE.DESCRIPTION); + addPropertyToRequest(requestParams, "period", properties, RETENTION_SCHEDULE.RETENTION_PERIOD); + addPropertyToRequest(requestParams, "ghostOnDestroy", properties, RETENTION_SCHEDULE.RETENTION_GHOST); + addPropertyToRequest(requestParams, "periodProperty", properties, RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY); + requestParams.append("events", events); + addPropertyToRequest(requestParams, "combineDispositionStepConditions", properties, RETENTION_SCHEDULE.COMBINE_DISPOSITION_STEP_CONDITIONS); addPropertyToRequest(requestParams, "eligibleOnFirstCompleteEvent", properties, RETENTION_SCHEDULE.RETENTION_ELIGIBLE_FIRST_EVENT); return doPostJsonRequest(user, password, SC_OK, requestParams, MessageFormat.format(DISPOSITION_ACTIONS_API, "{0}", catNodeRef)); From fdfd6279bd9efac4cf77bba15e180473ad43e3c9 Mon Sep 17 00:00:00 2001 From: jcule Date: Wed, 16 May 2018 18:22:28 +0100 Subject: [PATCH 2/2] RM-6302: Add Edi tFunctionality To Disposition Schedule: automation tests --- .../alfresco/rest/v0/RecordCategoriesAPI.java | 34 +++---------------- 1 file changed, 5 insertions(+), 29 deletions(-) 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 57f2368f56..6a3caed2cc 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 @@ -35,7 +35,6 @@ import java.util.Map; import org.alfresco.rest.core.v0.BaseAPI; import org.apache.http.HttpResponse; import org.json.JSONObject; -import org.json.JSONArray; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -126,34 +125,11 @@ public class RecordCategoriesAPI extends BaseAPI addPropertyToRequest(requestParams, "period", properties, RETENTION_SCHEDULE.RETENTION_PERIOD); addPropertyToRequest(requestParams, "ghostOnDestroy", properties, RETENTION_SCHEDULE.RETENTION_GHOST); addPropertyToRequest(requestParams, "periodProperty", properties, RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY); - addPropertyToRequest(requestParams, "events", properties, RETENTION_SCHEDULE.RETENTION_EVENTS); - addPropertyToRequest(requestParams, "combineDispositionStepConditions", properties, RETENTION_SCHEDULE.COMBINE_DISPOSITION_STEP_CONDITIONS); - addPropertyToRequest(requestParams, "eligibleOnFirstCompleteEvent", properties, RETENTION_SCHEDULE.RETENTION_ELIGIBLE_FIRST_EVENT); - - return doPostJsonRequest(user, password, SC_OK, requestParams, MessageFormat.format(DISPOSITION_ACTIONS_API, "{0}", catNodeRef)); - } - - /** - * Creates a retention schedule for a given category with added event - - * @param user - * @param password - * @param categoryName - * @param properties - * @param events - * @return The HTTP Response. - */ - public HttpResponse addDispositionScheduleSteps(String user, String password, String categoryName, Map properties, String events) - { - String catNodeRef = NODE_PREFIX + getItemNodeRef(user, password, "/" + categoryName); - - JSONObject requestParams = new JSONObject(); - addPropertyToRequest(requestParams, "name", properties, RETENTION_SCHEDULE.NAME); - addPropertyToRequest(requestParams, "description", properties, RETENTION_SCHEDULE.DESCRIPTION); - addPropertyToRequest(requestParams, "period", properties, RETENTION_SCHEDULE.RETENTION_PERIOD); - addPropertyToRequest(requestParams, "ghostOnDestroy", properties, RETENTION_SCHEDULE.RETENTION_GHOST); - addPropertyToRequest(requestParams, "periodProperty", properties, RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY); - requestParams.append("events", events); + String events = getPropertyValue(properties, RETENTION_SCHEDULE.RETENTION_EVENTS); + if(!events.equals("")) + { + requestParams.append("events", events); + } addPropertyToRequest(requestParams, "combineDispositionStepConditions", properties, RETENTION_SCHEDULE.COMBINE_DISPOSITION_STEP_CONDITIONS); addPropertyToRequest(requestParams, "eligibleOnFirstCompleteEvent", properties, RETENTION_SCHEDULE.RETENTION_ELIGIBLE_FIRST_EVENT);