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 68e37b76c3..977a7b4f17 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
@@ -662,4 +662,11 @@
parent="rmBaseWebscript">
+
+
+
+
+
\ No newline at end of file
diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.post.desc.xml
new file mode 100644
index 0000000000..24e1e2d8a9
--- /dev/null
+++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.post.desc.xml
@@ -0,0 +1,27 @@
+
+ Classifies a content
+
+
+ The body of the post should be in the form, e.g.
+ {
+ "nodeRef": "workspace://SpacesStore/aNodeRefId",
+ "classificationLevelId": "aLevelId",
+ "classificationAuthority": "anAuthority",
+ "classificationReasons": [
+ {
+ "id": "reason1Id"
+ },
+ {
+ "id": "reason2Id"
+ }
+ ]
+ }
+ ]]>
+
+ /api/node/{store_type}/{store_id}/{id}/classify
+ argument
+ user
+ required
+ internal
+
\ No newline at end of file
diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.post.json.ftl b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.post.json.ftl
new file mode 100644
index 0000000000..beda2de343
--- /dev/null
+++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.post.json.ftl
@@ -0,0 +1,5 @@
+<#escape x as jsonUtils.encodeJSONString(x)>
+{
+ "success": ${success?string}
+}
+#escape>
\ No newline at end of file
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPost.java
new file mode 100644
index 0000000000..d4666a405c
--- /dev/null
+++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPost.java
@@ -0,0 +1,113 @@
+/*
+ * 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 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 java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationService;
+import org.alfresco.module.org_alfresco_module_rm.script.AbstractRmWebScript;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.springframework.extensions.webscripts.Cache;
+import org.springframework.extensions.webscripts.Status;
+import org.springframework.extensions.webscripts.WebScriptRequest;
+
+/**
+ * Implementation for Java backed webscript to classify a content.
+ *
+ * @author Tuna Aksoy
+ * @since 3.0
+ */
+public class ClassifyContentPost extends AbstractRmWebScript
+{
+ /** Constants */
+ private static final String CLASSIFICATION_LEVEL_ID = "classificationLevelId";
+ private static final String CLASSIFICATION_AUTHORITY = "classificationAuthority";
+ private static final String CLASSIFICATION_REASONS = "classificationReasons";
+
+ /** Classification service */
+ private ClassificationService classificationService;
+
+ /**
+ * @return the classificationService
+ */
+ protected ClassificationService getClassificationService()
+ {
+ return this.classificationService;
+ }
+
+ /**
+ * @param classificationService the classificationService to set
+ */
+ public void setClassificationService(ClassificationService classificationService)
+ {
+ this.classificationService = classificationService;
+ }
+
+ /**
+ * @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 model = new HashMap(1);
+
+ JSONObject jsonObject = getRequestContentAsJsonObject(req);
+ String classificationLevelId = getStringValueFromJSONObject(jsonObject, CLASSIFICATION_LEVEL_ID);
+ String classificationAuthority = getStringValueFromJSONObject(jsonObject, CLASSIFICATION_AUTHORITY);
+ Set classificationReasonIds = getClassificationReasonIds(jsonObject);
+ NodeRef document = parseRequestForNodeRef(req);
+
+ getClassificationService().addClassificationToDocument(classificationLevelId, classificationAuthority, classificationReasonIds, document);
+ model.put(SUCCESS, true);
+
+ return model;
+ }
+
+ /**
+ * Helper method to get the classification reason ids
+ *
+ * @param jsonObject The json object representing the request body
+ * @return {@link Set}<{@link String}> classification ids
+ */
+ private Set getClassificationReasonIds(JSONObject jsonObject)
+ {
+ Set classificationReasonIds = new HashSet<>();
+
+ JSONArray classificationReasons = getJSONArrayFromJSONObject(jsonObject, CLASSIFICATION_REASONS);
+ for (int i = 0; i < classificationReasons.length(); i++)
+ {
+ JSONObject classificationReason = (JSONObject) getJSONArrayValue(classificationReasons, i);
+ classificationReasonIds.add(getStringValueFromJSONObject(classificationReason, ID));
+ }
+
+ return classificationReasonIds;
+ }
+}
\ No newline at end of file
diff --git a/rm-server/source/java/org/alfresco/util/WebScriptUtils.java b/rm-server/source/java/org/alfresco/util/WebScriptUtils.java
index 11eda01d30..d0a3e732b7 100644
--- a/rm-server/source/java/org/alfresco/util/WebScriptUtils.java
+++ b/rm-server/source/java/org/alfresco/util/WebScriptUtils.java
@@ -317,4 +317,30 @@ public final class WebScriptUtils
return jsonObject;
}
+
+ /**
+ * Gets the {@link JSONArray} value of a given key from a json object
+ *
+ * @param jsonObject The json object
+ * @param key The key
+ * @return The {@link JSONArray} value of the given key from the json object
+ */
+ public static JSONArray getJSONArrayFromJSONObject(JSONObject jsonObject, String key)
+ {
+ JSONArray jsonArray;
+
+ mandatory("jsonObject", jsonObject);
+ mandatory("key", key);
+
+ try
+ {
+ jsonArray = jsonObject.getJSONArray(key);
+ }
+ catch (JSONException error)
+ {
+ throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not get the json array for the key '" + key + "'.", error);
+ }
+
+ return jsonArray;
+ }
}