From 2a2afa0589bd583fa5bbc337a32416f1c3ee27be Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Wed, 29 Jul 2015 20:11:28 +0000 Subject: [PATCH] RM-2402 (Extend classification REST API) +review RM-143 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@109184 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../classification/ClassifyContentBase.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentBase.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentBase.java index ebb0b1452e..a87a080c6b 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentBase.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentBase.java @@ -22,7 +22,6 @@ import static org.alfresco.util.WebScriptUtils.getJSONArrayFromJSONObject; import static org.alfresco.util.WebScriptUtils.getJSONArrayValue; import static org.alfresco.util.WebScriptUtils.getRequestContentAsJsonObject; import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject; -import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.apache.commons.lang3.time.DateFormatUtils.ISO_DATE_FORMAT; import static org.springframework.extensions.webscripts.Status.STATUS_BAD_REQUEST; @@ -110,10 +109,10 @@ public abstract class ClassifyContentBase extends AbstractRmWebScript String classifiedBy = getStringValueFromJSONObject(jsonObject, CLASSIFIED_BY); String classificationAgency = getStringValueFromJSONObject(jsonObject, CLASSIFICATION_AGENCY, false, false); Set classificationReasonIds = getClassificationReasonIds(jsonObject); - String downgradeDate = getStringValueFromJSONObject(jsonObject, DOWNGRADE_DATE, false, false); + Object downgradeDate = jsonObject.isNull(DOWNGRADE_DATE) ? null : getStringValueFromJSONObject(jsonObject, DOWNGRADE_DATE, false, false); String downgradeEvent = getStringValueFromJSONObject(jsonObject, DOWNGRADE_EVENT, false, false); String downgradeInstructions = getStringValueFromJSONObject(jsonObject, DOWNGRADE_INSTRUCTIONS, false, false); - String declassificationDate = getStringValueFromJSONObject(jsonObject, DECLASSIFICATION_DATE, false, false); + Object declassificationDate = jsonObject.isNull(DECLASSIFICATION_DATE) ? null : getStringValueFromJSONObject(jsonObject, DECLASSIFICATION_DATE, false, false); String declassificationEvent = getStringValueFromJSONObject(jsonObject, DECLASSIFICATION_EVENT, false, false); Set exemptionCategoryIds = getExemptionCategoryIds(jsonObject); @@ -190,21 +189,20 @@ public abstract class ClassifyContentBase extends AbstractRmWebScript } /** - * Parses the given string as date + * Parses the given date * - * @param date The {@link String} which will be parsed - * @return The parsed date, if the given date is blank then null will be returned. + * @param date The {@link Object} which will be parsed + * @return The parsed date. If the given date is null then null will be returned. */ - private Date parseDate(String date) + private Date parseDate(Object date) { Date parsedDate = null; - // FIXME: "null" check - if (isNotBlank(date) && !date.equalsIgnoreCase("null")) + if (date != null) { try { - parsedDate = DateUtils.parseDate(date, ISO_DATE_FORMAT.getPattern()); + parsedDate = DateUtils.parseDate((String) date, ISO_DATE_FORMAT.getPattern()); } catch (ParseException error) {