mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
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:
@@ -17,6 +17,7 @@
|
|||||||
<property name="capabilityService" ref="CapabilityService"/>
|
<property name="capabilityService" ref="CapabilityService"/>
|
||||||
<property name="dictionaryService" ref="DictionaryService" />
|
<property name="dictionaryService" ref="DictionaryService" />
|
||||||
<property name="siteService" ref="SiteService" />
|
<property name="siteService" ref="SiteService" />
|
||||||
|
<property name="contentClassificationService" ref="contentClassificationService"/>
|
||||||
<property name="policyComponent" ref="policyComponent" />
|
<property name="policyComponent" ref="policyComponent" />
|
||||||
<property name="jsonConversionComponentCache" ref="jsonConversionComponentCache" />
|
<property name="jsonConversionComponentCache" ref="jsonConversionComponentCache" />
|
||||||
</bean>
|
</bean>
|
||||||
|
@@ -56,6 +56,15 @@ public interface ContentClassificationService
|
|||||||
void classifyContent(String classificationLevelId, String classificationAuthority, Set<String> classificationReasonIds, NodeRef content)
|
void classifyContent(String classificationLevelId, String classificationAuthority, Set<String> classificationReasonIds, NodeRef content)
|
||||||
throws LevelIdNotFound, ReasonIdNotFound, InvalidNodeRefException, InvalidNode;
|
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
|
* Indicates whether the currently authenticated user has clearance to see the
|
||||||
* provided node.
|
* provided node.
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.classification;
|
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.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank;
|
||||||
import static org.alfresco.util.ParameterCheck.mandatory;
|
import static org.alfresco.util.ParameterCheck.mandatory;
|
||||||
|
|
||||||
@@ -144,4 +145,24 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl implements
|
|||||||
ClassificationLevel currentClassification = getCurrentClassification(nodeRef);
|
ClassificationLevel currentClassification = getCurrentClassification(nodeRef);
|
||||||
return securityClearanceService.isCurrentUserClearedForClassification(currentClassification.getId());
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,9 +19,6 @@
|
|||||||
package org.alfresco.module.org_alfresco_module_rm.jscript.app;
|
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.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 static org.alfresco.service.cmr.security.AccessStatus.ALLOWED;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -32,6 +29,7 @@ import java.util.Map;
|
|||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
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.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.FilePlanComponentKind;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
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 */
|
/** site service */
|
||||||
private SiteService siteService;
|
private SiteService siteService;
|
||||||
|
|
||||||
|
/** Content classification service */
|
||||||
|
private ContentClassificationService contentClassificationService;
|
||||||
|
|
||||||
/** Indicators */
|
/** Indicators */
|
||||||
private List<BaseEvaluator> indicators = new ArrayList<BaseEvaluator>();
|
private List<BaseEvaluator> indicators = new ArrayList<BaseEvaluator>();
|
||||||
|
|
||||||
@@ -165,6 +166,14 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS
|
|||||||
this.siteService = siteService;
|
this.siteService = siteService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param contentClassificationService the contentClassificationService to set
|
||||||
|
*/
|
||||||
|
public void setContentClassificationService(ContentClassificationService contentClassificationService)
|
||||||
|
{
|
||||||
|
this.contentClassificationService = contentClassificationService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param indicator registered indicator
|
* @param indicator registered indicator
|
||||||
*/
|
*/
|
||||||
@@ -249,7 +258,7 @@ public class JSONConversionComponent extends org.alfresco.repo.jscript.app.JS
|
|||||||
NodeRef nodeRef = nodeInfo.getNodeRef();
|
NodeRef nodeRef = nodeInfo.getNodeRef();
|
||||||
|
|
||||||
// Is the node classified
|
// 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)))
|
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
|
* Checks for the existance of the RM site
|
||||||
*
|
*
|
||||||
|
@@ -37,9 +37,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.model.QuickShareModel;
|
import org.alfresco.model.QuickShareModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.InvalidNode;
|
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationException.InvalidNode;
|
||||||
@@ -60,6 +57,9 @@ import org.mockito.InjectMocks;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for {@link ContentClassificationServiceImpl}.
|
* Unit tests for {@link ContentClassificationServiceImpl}.
|
||||||
*
|
*
|
||||||
@@ -301,4 +301,48 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
|
|||||||
|
|
||||||
assertFalse(contentClassificationServiceImpl.hasClearance(nodeRef));
|
assertFalse(contentClassificationServiceImpl.hasClearance(nodeRef));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given that I classify a node with a level not equal to "Unclassified"
|
||||||
|
* When I ask if the node is classified
|
||||||
|
* Then return true
|
||||||
|
*/
|
||||||
|
@Test public void contentClassified_levelNotUnclassified()
|
||||||
|
{
|
||||||
|
NodeRef nodeRef = generateNodeRef(mockNodeService);
|
||||||
|
|
||||||
|
when(mockNodeService.getProperty(nodeRef, PROP_CURRENT_CLASSIFICATION)).thenReturn("level1");
|
||||||
|
when(mockNodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED)).thenReturn(true);
|
||||||
|
|
||||||
|
assertTrue(contentClassificationServiceImpl.isClassified(nodeRef));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given that I classify a node with level "Unclassified"
|
||||||
|
* When I ask if the node is classified
|
||||||
|
* Then return false
|
||||||
|
*/
|
||||||
|
@Test public void contentClassified_levelUnclassified()
|
||||||
|
{
|
||||||
|
NodeRef nodeRef = generateNodeRef(mockNodeService);
|
||||||
|
|
||||||
|
when(mockNodeService.getProperty(nodeRef, PROP_CURRENT_CLASSIFICATION)).thenReturn(ClassificationLevelManager.UNCLASSIFIED_ID);
|
||||||
|
when(mockNodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED)).thenReturn(true);
|
||||||
|
|
||||||
|
assertFalse(contentClassificationServiceImpl.isClassified(nodeRef));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given that a node is not classified
|
||||||
|
* When I ask if the node is classified
|
||||||
|
* Then return false
|
||||||
|
*/
|
||||||
|
@Test public void contentNotClassified()
|
||||||
|
{
|
||||||
|
NodeRef nodeRef = generateNodeRef(mockNodeService);
|
||||||
|
|
||||||
|
when(mockNodeService.hasAspect(nodeRef, ASPECT_CLASSIFIED)).thenReturn(false);
|
||||||
|
|
||||||
|
assertFalse(contentClassificationServiceImpl.isClassified(nodeRef));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user