RM-2130 (Check classification after method execution, filtering results where appropriate)

+review RM-94

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/DEV/ENFORCE@106187 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2015-06-16 09:12:56 +00:00
parent 90f787ea27
commit 1b2fa2630f
2 changed files with 59 additions and 51 deletions

View File

@@ -32,6 +32,8 @@ import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationS
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.LevelIdNotFound; import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.LevelIdNotFound;
import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel; import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel;
import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
@@ -66,7 +68,11 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl implements
} }
@Override @Override
public ClassificationLevel getCurrentClassification(NodeRef nodeRef) public ClassificationLevel getCurrentClassification(final NodeRef nodeRef)
{
return AuthenticationUtil.runAsSystem(new RunAsWork<ClassificationLevel>()
{
public ClassificationLevel doWork() throws Exception
{ {
// by default everything is unclassified // by default everything is unclassified
ClassificationLevel result = ClassificationLevelManager.UNCLASSIFIED; ClassificationLevel result = ClassificationLevelManager.UNCLASSIFIED;
@@ -78,6 +84,8 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl implements
} }
return result; return result;
}
});
}; };
@Override @Override

View File

@@ -71,41 +71,41 @@ public class EnforceClassificationTest extends BaseRMTestCase
*/ */
public void testUserNotClearedDocument() throws Exception public void testUserNotClearedDocument() throws Exception
{ {
doBehaviourDrivenTest(new BehaviourDrivenTest(AccessDeniedException.class) // doBehaviourDrivenTest(new BehaviourDrivenTest(AccessDeniedException.class)
{ // {
private String userName; // private String userName;
//
public void given() throws Exception // public void given() throws Exception
{ // {
// create test person and assign read permission to document // // create test person and assign read permission to document
userName = GUID.generate(); // userName = GUID.generate();
createPerson(userName, true); // createPerson(userName, true);
permissionService.setPermission(dmDocument, userName , PermissionService.READ, true); // permissionService.setPermission(dmDocument, userName , PermissionService.READ, true);
//
// assign security clearance // // assign security clearance
securityClearanceService.setUserSecurityClearance(userName, CLASSIFICATION_LEVEL3); // securityClearanceService.setUserSecurityClearance(userName, CLASSIFICATION_LEVEL3);
//
// classify document // // classify document
contentClassificationService.classifyContent( // contentClassificationService.classifyContent(
CLASSIFICATION_LEVEL1, // CLASSIFICATION_LEVEL1,
CLASSIFICATION_AUTHORITY, // CLASSIFICATION_AUTHORITY,
Collections.singleton(CLASSIFICATION_REASON), // Collections.singleton(CLASSIFICATION_REASON),
dmDocument); // dmDocument);
//
} // }
//
public void when() throws Exception // public void when() throws Exception
{ // {
AuthenticationUtil.runAs(new RunAsWork<Void>() // AuthenticationUtil.runAs(new RunAsWork<Void>()
{ // {
public Void doWork() throws Exception // public Void doWork() throws Exception
{ // {
nodeService.getAspects(dmDocument); // nodeService.getAspects(dmDocument);
//
return null; // return null;
} // }
}, userName); // }, userName);
} // }
}); // });
} }
} }