diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/classification/rm-classification-reasons.json b/rm-server/config/alfresco/module/org_alfresco_module_rm/classification/rm-classification-reasons.json index 9535c91e4c..a8918f3880 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/classification/rm-classification-reasons.json +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/classification/rm-classification-reasons.json @@ -9,6 +9,6 @@ }, { "id" : "1.4(c)", - "displayLabel" : "rm.classification.intelligenceActivities" + "displayLabel" : "rm.classification-reason.intelligenceActivities" } ] diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml index 7a31fd1b76..b7bbd7baba 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml @@ -648,4 +648,11 @@ parent="rmBaseWebscript"> + + + + + \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/reasons.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/reasons.get.desc.xml new file mode 100644 index 0000000000..60797f9d1f --- /dev/null +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/reasons.get.desc.xml @@ -0,0 +1,8 @@ + + Records Management Classification Reasons + Gets the list of classification reasons. + /api/classification/reasons + + user + required + \ No newline at end of file diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/reasons.get.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/reasons.get.json.ftl new file mode 100644 index 0000000000..6c8aed741b --- /dev/null +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/reasons.get.json.ftl @@ -0,0 +1,16 @@ +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "data": + { + "items": + [ + <#list reasons as reason> + { + "id": "<#noescape>${reason.id}", + "displayLabel": "<#noescape>${reason.displayLabel}" + }<#if reason_has_next>, + + ] + } +} + \ No newline at end of file diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationReason.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationReason.java index d704eb246d..48af4f45ea 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationReason.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationReason.java @@ -44,6 +44,7 @@ public final class ClassificationReason implements Serializable public ClassificationReason(final String id, final String displayLabelKey) { if (id == null || id.trim().equals("")) { throw new IllegalArgumentException("Illegal id: '" + id + "'"); } + if (displayLabelKey == null || displayLabelKey.trim().equals("")) { throw new IllegalArgumentException("Illegal displayLabelKey: '" + displayLabelKey + "'"); } this.id = id; this.displayLabelKey = displayLabelKey; } @@ -57,11 +58,13 @@ public final class ClassificationReason implements Serializable } /** - * Returns the localised (current locale) display label for this classification reason. + * Returns the localised (current locale) display label for this classification reason. If no translation is found + * then return the key instead. */ public String getDisplayLabel() { - return I18NUtil.getMessage(displayLabelKey); + String message = I18NUtil.getMessage(displayLabelKey); + return (message != null ? message : displayLabelKey); } @Override diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ReasonsGet.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ReasonsGet.java new file mode 100644 index 0000000000..ff90ca8e49 --- /dev/null +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ReasonsGet.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2005-2014 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * 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 . + */ +package org.alfresco.module.org_alfresco_module_rm.script.classification; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationService; +import org.alfresco.module.org_alfresco_module_rm.jscript.app.JSONConversionComponent; +import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript; +import org.springframework.extensions.webscripts.Cache; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Implementation for Java backed webscript to get the classification reasons. + * + * @author tpage + * @since 3.0 + */ +public class ReasonsGet extends AbstractRmWebScript +{ + /** Constants */ + private static final String REASONS = "reasons"; + + /** Classification service */ + private ClassificationService classificationService; + + /** JSON conversion component */ + private JSONConversionComponent jsonConversionComponent; + + /** + * Gets the JSON conversion component + * + * @return The JSON conversion component + */ + protected JSONConversionComponent getJsonConversionComponent() + { + return this.jsonConversionComponent; + } + + /** + * Sets the classification service + * + * @param classificatonService The classification service + */ + public void setClassificationService(ClassificationService classificationService) + { + this.classificationService = classificationService; + } + + /** + * Sets the JSON conversion component + * + * @param jsonConversionComponent The JSON conversion component + */ + public void setJsonConversionComponent(JSONConversionComponent jsonConversionComponent) + { + this.jsonConversionComponent = jsonConversionComponent; + } + + /** + * @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, + * org.springframework.extensions.webscripts.Status, + * org.springframework.extensions.webscripts.Cache) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status, Cache cache) + { + Map result = new HashMap(); + result.put(REASONS, classificationService.getClassificationReasons()); + return result; + } +}