mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-2208 (Prevent classification of shared content)
+review RM @rwetherall git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@105284 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,6 +28,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.QuickShareModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.InvalidNode;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.LevelIdNotFound;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel;
|
||||
@@ -98,6 +99,10 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl implements
|
||||
throw new UnsupportedOperationException(
|
||||
"The content has already been classified. Reclassification is currently not supported.");
|
||||
}
|
||||
if (nodeService.hasAspect(content, QuickShareModel.ASPECT_QSHARE))
|
||||
{
|
||||
throw new IllegalStateException("A shared content cannot be classified.");
|
||||
}
|
||||
if (!securityClearanceService.isCurrentUserClearedForClassification(classificationLevelId))
|
||||
{
|
||||
throw new LevelIdNotFound(classificationLevelId);
|
||||
|
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.classification;
|
||||
|
||||
import static com.google.common.collect.Sets.newHashSet;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock.generateNodeRef;
|
||||
import static org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock.generateText;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -38,7 +39,9 @@ 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.QuickShareModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.InvalidNode;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.LevelIdNotFound;
|
||||
import org.alfresco.module.org_alfresco_module_rm.classification.model.ClassifiedContentModel;
|
||||
@@ -142,6 +145,18 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte
|
||||
Sets.newHashSet("reasonId1", "reasonId2"), classifiedContent);
|
||||
}
|
||||
|
||||
/** Classify a piece of content that has already been shared */
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void classifySharedContent()
|
||||
{
|
||||
NodeRef sharedContent = generateNodeRef(mockNodeService);
|
||||
when(mockDictionaryService.isSubClass(mockNodeService.getType(sharedContent), ContentModel.TYPE_CONTENT)).thenReturn(true);
|
||||
when(mockNodeService.hasAspect(sharedContent, QuickShareModel.ASPECT_QSHARE)).thenReturn(true);
|
||||
|
||||
// Call the method under test.
|
||||
contentClassificationServiceImpl.classifyContent(generateText(), generateText(), newHashSet(generateText(), generateText()), sharedContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that a user can't classify content with a level that either (a) doesn't exist, or (b) they don't have
|
||||
* clearance for. (Both cases are covered by the same flow through the code).
|
||||
|
Reference in New Issue
Block a user