RM-2280 (Move the code for checking if the content is classified to the service layer)

* moved the check to content classification service
   
+review RM-87

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@106090 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2015-06-12 20:39:33 +00:00
parent ac56441fc3
commit f2010a9f2f
5 changed files with 91 additions and 29 deletions

View File

@@ -56,6 +56,15 @@ public interface ContentClassificationService
void classifyContent(String classificationLevelId, String classificationAuthority, Set<String> classificationReasonIds, NodeRef content)
throws LevelIdNotFound, ReasonIdNotFound, InvalidNodeRefException, InvalidNode;
/**
* Checks if the node is classified or not. A node classified
* as "Unclassified" will be treated as not classified.
*
* @param nodeRef Node reference
* @return <code>true</code> if the node is classified, <code>false</code> otherwise
*/
boolean isClassified(NodeRef nodeRef);
/**
* Indicates whether the currently authenticated user has clearance to see the
* provided node.

View File

@@ -18,6 +18,7 @@
*/
package org.alfresco.module.org_alfresco_module_rm.classification;
import static org.alfresco.module.org_alfresco_module_rm.classification.ClassificationLevelManager.UNCLASSIFIED_ID;
import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
import static org.alfresco.util.ParameterCheck.mandatory;
@@ -144,4 +145,24 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl implements
ClassificationLevel currentClassification = getCurrentClassification(nodeRef);
return securityClearanceService.isCurrentUserClearedForClassification(currentClassification.getId());
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService#isClassified(org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public boolean isClassified(NodeRef nodeRef)
{
mandatory("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;
}
}

View File

@@ -19,9 +19,6 @@
package org.alfresco.module.org_alfresco_module_rm.jscript.app;
import static org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel.READ_RECORDS;
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 static org.alfresco.service.cmr.security.AccessStatus.ALLOWED;
import java.util.ArrayList;
@@ -32,6 +29,7 @@ import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
import org.alfresco.module.org_alfresco_module_rm.capability.impl.ViewRecordsCapability;
import org.alfresco.module.org_alfresco_module_rm.classification.ContentClassificationService;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
@@ -94,6 +92,9 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS
/** site service */
private SiteService siteService;
/** Content classification service */
private ContentClassificationService contentClassificationService;
/** Indicators */
private List<BaseEvaluator> indicators = new ArrayList<BaseEvaluator>();
@@ -165,6 +166,14 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS
this.siteService = siteService;
}
/**
* @param contentClassificationService the contentClassificationService to set
*/
public void setContentClassificationService(ContentClassificationService contentClassificationService)
{
this.contentClassificationService = contentClassificationService;
}
/**
* @param indicator registered indicator
*/
@@ -249,7 +258,7 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS
NodeRef nodeRef = nodeInfo.getNodeRef();
// Is the node classified
rootJSONObject.put(IS_CLASSIFIED, isClassified(nodeRef));
rootJSONObject.put(IS_CLASSIFIED, contentClassificationService.isClassified(nodeRef));
if (AccessStatus.ALLOWED.equals(capabilityService.getCapabilityAccessState(nodeRef, ViewRecordsCapability.NAME)))
{
@@ -268,28 +277,6 @@ 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 <code>true</code> if the node is classified, <code>false</code> 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
*