From 14a1c9f9bc90ab9aa02e2ccc7d2d955f83ecaf78 Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Mon, 8 Jun 2015 11:03:19 +0000 Subject: [PATCH] RM-2280 (Move the code for checking if the content is classified to the service layer) +review RM git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@105735 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../jscript/app/JSONConversionComponent.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java index e33a052f81..ed13840379 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/jscript/app/JSONConversionComponent.java @@ -18,6 +18,10 @@ */ package org.alfresco.module.org_alfresco_module_rm.jscript.app; +import static org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevelManager.UNCLASSIFIED_ID; +import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.ASPECT_CLASSIFIED; +import static org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -65,6 +69,7 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS private static final String IS_RM_SITE_CREATED = "isRmSiteCreated"; private static final String IS_RECORD_CONTRIBUTOR_GROUP_ENABLED = "isRecordContributorGroupEnabled"; private static final String RECORD_CONTRIBUTOR_GROUP_NAME = "recordContributorGroupName"; + private static final String IS_CLASSIFIED = "isClassified"; /** true if record contributor group is enabled, false otherwise */ private boolean isRecordContributorsGroupEnabled = false; @@ -241,6 +246,9 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS // Get the node reference for convenience NodeRef nodeRef = nodeInfo.getNodeRef(); + // Is the node classified + rootJSONObject.put(IS_CLASSIFIED, isClassified(nodeRef)); + if (AccessStatus.ALLOWED.equals(capabilityService.getCapabilityAccessState(nodeRef, ViewRecordsCapability.NAME))) { // Indicate whether the node is a RM object or not @@ -258,6 +266,28 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS } } + /** + * Checks if the node is classified or not. A node classified + * as "Unclassified" will be treated as not classified. + * + * @param nodeRef Node reference + * @return true if the node is classified, false otherwise + */ + private boolean isClassified(NodeRef nodeRef) + { + boolean isClassified = false; + + String currentClassification = (String) nodeService.getProperty(nodeRef, PROP_CURRENT_CLASSIFICATION); + + if (nodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED) && + !(UNCLASSIFIED_ID).equals(currentClassification)) + { + isClassified = true; + } + + return isClassified; + } + /** * Checks for the existance of the RM site *