From fa3f1230a440eb47c4ba251e6a904721a906f482 Mon Sep 17 00:00:00 2001 From: Neil McErlean Date: Tue, 30 Jun 2015 15:32:47 +0000 Subject: [PATCH] RM-2333, RM-2341, RM-2342, RM-2343, RM-2344, RM-2346. Changed Classification Agency to optional throughtout the stack and added a new mandatory property Classified By throughout the stack. Addressing the fallout in the existing tests due to these changes. Also enhanced some existing tests to validate the classified by value persistence. Still to do: need to initialise the Classified By field in the Classify dialog to the current user's full name (not as easy as I'd thought) and add additional AC tests. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@107433 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../classified-content-context.xml | 1 + .../model/classifiedContentModel.xml | 8 ++++++++ .../classifycontent.post.desc.xml | 1 + .../ContentClassificationService.java | 4 +++- .../ContentClassificationServiceImpl.java | 10 ++++++---- .../model/ClassifiedContentModel.java | 1 + .../classification/ClassifyContentPost.java | 7 +++++-- .../classification/ClassifyTest.java | 12 ++++++++---- ...entBrowseClassificationEnforcementTest.java | 10 +++++----- ...entSearchClassificationEnforcementTest.java | 10 +++++----- ...ordBrowseClassificationEnforcementTest.java | 10 +++++----- ...ordSearchClassificationEnforcementTest.java | 10 +++++----- ...ationshipClassificationEnforcementTest.java | 2 +- ...vedSearchClassificationEnforcementTest.java | 6 +++--- .../test/integration/issue/RM2260Test.java | 2 +- .../jscript/JSONConversionComponentTest.java | 8 ++++---- ...ntentClassificationServiceImplUnitTest.java | 18 +++++++++++------- .../ClassifyContentPostUnitTest.java | 5 ++++- 18 files changed, 77 insertions(+), 48 deletions(-) diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/classified-content-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/classified-content-context.xml index 60876950c6..570ec94695 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/classified-content-context.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/classified-content-context.xml @@ -145,6 +145,7 @@ class="org.alfresco.module.org_alfresco_module_rm.classification.SecurityClearanceServiceImpl" parent="baseService" init-method="init"> + diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/classifiedContentModel.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/classifiedContentModel.xml index f1f50a3100..54e2cb2b9d 100644 --- a/rm-server/config/alfresco/module/org_alfresco_module_rm/model/classifiedContentModel.xml +++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/model/classifiedContentModel.xml @@ -64,6 +64,14 @@ Classification Agency The classification agency d:text + false + + + + Classified By + Name of whoever has applied the classification + d:text + true Classification Reasons diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.post.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.post.desc.xml index 19f9625163..2e43613aa1 100644 --- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.post.desc.xml +++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/rma/classification/classifycontent.post.desc.xml @@ -6,6 +6,7 @@ The body of the post should be in the form, e.g.
{
"classificationLevelId": "aLevelId",
+ "classifiedBy": "some person or entity",
"classificationAgency": "anAgency",
"classificationReasons": [
{
diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationService.java index 7cb6fb16e2..dc708c9164 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationService.java @@ -45,6 +45,7 @@ public interface ContentClassificationService * Classify a piece of content. * * @param classificationLevelId The security clearance needed to access the content. + * @param classifiedBy Free-form text identifying who classified the content. * @param classificationAgency The name of the agency responsible for the classification of this content. * @param classificationReasonIds A non-empty set of ids of reasons for classifying the content in this way. * @param content The node to classify. @@ -53,7 +54,8 @@ public interface ContentClassificationService * @throws InvalidNodeRefException If the node could not be found. * @throws InvalidNode If the supplied node is not a content node. */ - void classifyContent(String classificationLevelId, String classificationAgency, Set classificationReasonIds, NodeRef content) + void classifyContent(String classificationLevelId, String classifiedBy, String classificationAgency, + Set classificationReasonIds, NodeRef content) throws LevelIdNotFound, ReasonIdNotFound, InvalidNodeRefException, InvalidNode; /** diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImpl.java index 8d9f857e37..ccea4dd79a 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImpl.java @@ -85,11 +85,11 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl implements }; @Override - public void classifyContent(String classificationLevelId, String classificationAgency, - Set classificationReasonIds, final NodeRef content) + public void classifyContent(String classificationLevelId, String classifiedBy, String classificationAgency, + Set classificationReasonIds, final NodeRef content) { checkNotBlank("classificationLevelId", classificationLevelId); - checkNotBlank("classificationAgency", classificationAgency); + mandatory("classifiedBy", classifiedBy); mandatory("classificationReasonIds", classificationReasonIds); mandatory("content", content); @@ -111,7 +111,7 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl implements throw new LevelIdNotFound(classificationLevelId); } - final Map properties = new HashMap(); + final Map properties = new HashMap<>(); // Initial classification id if (nodeService.getProperty(content, PROP_INITIAL_CLASSIFICATION) == null) { @@ -124,6 +124,8 @@ public class ContentClassificationServiceImpl extends ServiceBaseImpl implements // Classification agency properties.put(PROP_CLASSIFICATION_AGENCY, classificationAgency); + properties.put(PROP_CLASSIFIED_BY, classifiedBy); + // Classification reason ids HashSet classificationReasons = new HashSet<>(); for (String classificationReasonId : classificationReasonIds) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/model/ClassifiedContentModel.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/model/ClassifiedContentModel.java index 466d3072e9..641bea8ad7 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/model/ClassifiedContentModel.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/model/ClassifiedContentModel.java @@ -45,6 +45,7 @@ public interface ClassifiedContentModel QName PROP_INITIAL_CLASSIFICATION = QName.createQName(CLF_URI, "initialClassification"); QName PROP_CURRENT_CLASSIFICATION = QName.createQName(CLF_URI, "currentClassification"); QName PROP_CLASSIFICATION_AGENCY = QName.createQName(CLF_URI, "classificationAgency"); + QName PROP_CLASSIFIED_BY = QName.createQName(CLF_URI, "classifiedBy"); QName PROP_CLASSIFICATION_REASONS = QName.createQName(CLF_URI, "classificationReasons"); /** Security Clearance aspect. */ diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPost.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPost.java index 2d6fd40b13..284be8e853 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPost.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPost.java @@ -47,6 +47,7 @@ public class ClassifyContentPost extends AbstractRmWebScript { /** Constants */ public static final String CLASSIFICATION_LEVEL_ID = "classificationLevelId"; + public static final String CLASSIFIED_BY = "classifiedBy"; public static final String CLASSIFICATION_AGENCY = "classificationAgency"; public static final String CLASSIFICATION_REASONS = "classificationReasons"; @@ -73,11 +74,13 @@ public class ClassifyContentPost extends AbstractRmWebScript { JSONObject jsonObject = getRequestContentAsJsonObject(req); String classificationLevelId = getStringValueFromJSONObject(jsonObject, CLASSIFICATION_LEVEL_ID); - String classificationAgency = getStringValueFromJSONObject(jsonObject, CLASSIFICATION_AGENCY); + String classifiedBy = getStringValueFromJSONObject(jsonObject, CLASSIFIED_BY); + String classificationAgency = getStringValueFromJSONObject(jsonObject, CLASSIFICATION_AGENCY, false, false); Set classificationReasonIds = getClassificationReasonIds(jsonObject); NodeRef document = parseRequestForNodeRef(req); - contentClassificationService.classifyContent(classificationLevelId, classificationAgency, classificationReasonIds, document); + contentClassificationService.classifyContent(classificationLevelId, classifiedBy, classificationAgency, + classificationReasonIds, document); Map model = new HashMap<>(1); model.put(SUCCESS, true); diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ClassifyTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ClassifyTest.java index d8c1a09efd..e12349ed74 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ClassifyTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/ClassifyTest.java @@ -43,6 +43,7 @@ public class ClassifyTest extends BaseRMTestCase private static final String LOWER_CLASSIFICATION_LEVEL = "level2"; private static final String CLASSIFICATION_REASON = "Test Reason 1"; private static final String CLASSIFICATION_AGENCY = "classification agency"; + private static final String CLASSIFIED_BY = "classified by text"; private static final String RECORD_NAME = "recordname.txt"; /** @@ -69,6 +70,7 @@ public class ClassifyTest extends BaseRMTestCase { contentClassificationService.classifyContent( CLASSIFICATION_LEVEL, + CLASSIFIED_BY, CLASSIFICATION_AGENCY, Collections.singleton(CLASSIFICATION_REASON), record); @@ -97,6 +99,7 @@ public class ClassifyTest extends BaseRMTestCase { contentClassificationService.classifyContent( CLASSIFICATION_LEVEL, + CLASSIFIED_BY, CLASSIFICATION_AGENCY, Collections.singleton(CLASSIFICATION_REASON), record); @@ -106,10 +109,11 @@ public class ClassifyTest extends BaseRMTestCase public void then() throws Exception { assertTrue(nodeService.hasAspect(record, ClassifiedContentModel.ASPECT_CLASSIFIED)); - assertEquals(CLASSIFICATION_LEVEL, (String)nodeService.getProperty(record, ClassifiedContentModel.PROP_INITIAL_CLASSIFICATION)); + assertEquals(CLASSIFICATION_LEVEL, (String) nodeService.getProperty(record, ClassifiedContentModel.PROP_INITIAL_CLASSIFICATION)); assertEquals(CLASSIFICATION_LEVEL, (String)nodeService.getProperty(record, ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION)); assertEquals(CLASSIFICATION_AGENCY, (String)nodeService.getProperty(record, ClassifiedContentModel.PROP_CLASSIFICATION_AGENCY)); - assertEquals(Collections.singletonList(CLASSIFICATION_REASON), (List)nodeService.getProperty(record, ClassifiedContentModel.PROP_CLASSIFICATION_REASONS)); + assertEquals(CLASSIFIED_BY, (String)nodeService.getProperty(record, ClassifiedContentModel.PROP_CLASSIFIED_BY)); + assertEquals(Collections.singletonList(CLASSIFICATION_REASON), nodeService.getProperty(record, ClassifiedContentModel.PROP_CLASSIFICATION_REASONS)); } }); } @@ -148,7 +152,7 @@ public class ClassifyTest extends BaseRMTestCase @Override public Void run() { - contentClassificationService.classifyContent(CLASSIFICATION_LEVEL, CLASSIFICATION_AGENCY, + contentClassificationService.classifyContent(CLASSIFICATION_LEVEL, CLASSIFIED_BY, CLASSIFICATION_AGENCY, Sets.newHashSet(CLASSIFICATION_REASON), record); return null; } @@ -199,7 +203,7 @@ public class ClassifyTest extends BaseRMTestCase @Override public Void run() { - contentClassificationService.classifyContent(CLASSIFICATION_LEVEL, CLASSIFICATION_AGENCY, + contentClassificationService.classifyContent(CLASSIFICATION_LEVEL, CLASSIFIED_BY, CLASSIFICATION_AGENCY, Sets.newHashSet(CLASSIFICATION_REASON), record); return null; } diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/DocumentBrowseClassificationEnforcementTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/DocumentBrowseClassificationEnforcementTest.java index b7c8b364e7..68379b9765 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/DocumentBrowseClassificationEnforcementTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/DocumentBrowseClassificationEnforcementTest.java @@ -80,7 +80,7 @@ public class DocumentBrowseClassificationEnforcementTest extends BrowseClassific doc1 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); doc2 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1); } /** @@ -172,8 +172,8 @@ public class DocumentBrowseClassificationEnforcementTest extends BrowseClassific doc2 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); doc3 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1); - contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), doc2); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1); + contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), doc2); } /** @@ -267,8 +267,8 @@ public class DocumentBrowseClassificationEnforcementTest extends BrowseClassific doc2 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); doc3 = fileFolderService.create(folder, generate(), TYPE_CONTENT).getNodeRef(); - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1); - contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), doc2); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1); + contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), doc2); } /** diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/DocumentSearchClassificationEnforcementTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/DocumentSearchClassificationEnforcementTest.java index 0a56a158d4..b7f626faf9 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/DocumentSearchClassificationEnforcementTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/DocumentSearchClassificationEnforcementTest.java @@ -83,7 +83,7 @@ public class DocumentSearchClassificationEnforcementTest extends SearchClassific doc1 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef(); doc2 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef(); - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1); } /** @@ -174,8 +174,8 @@ public class DocumentSearchClassificationEnforcementTest extends SearchClassific doc2 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef(); doc3 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef(); - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1); - contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), doc2); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1); + contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), doc2); } /** @@ -266,8 +266,8 @@ public class DocumentSearchClassificationEnforcementTest extends SearchClassific doc2 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef(); doc3 = fileFolderService.create(folder, searchQuery + generate(), TYPE_CONTENT).getNodeRef(); - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), doc1); - contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), doc2); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), doc1); + contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), doc2); } /** diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RecordBrowseClassificationEnforcementTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RecordBrowseClassificationEnforcementTest.java index 29fb0fd92a..0d0eb747f8 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RecordBrowseClassificationEnforcementTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RecordBrowseClassificationEnforcementTest.java @@ -74,7 +74,7 @@ public class RecordBrowseClassificationEnforcementTest extends BrowseClassificat record1 = utils.createRecord(folder, generate()); record2 = utils.createRecord(folder, generate()); - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1); } /** @@ -169,8 +169,8 @@ public class RecordBrowseClassificationEnforcementTest extends BrowseClassificat record2 = utils.createRecord(folder, generate()); record3 = utils.createRecord(folder, generate()); - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1); - contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), record2); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1); + contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), record2); } /** @@ -267,8 +267,8 @@ public class RecordBrowseClassificationEnforcementTest extends BrowseClassificat record2 = utils.createRecord(folder, generate()); record3 = utils.createRecord(folder, generate()); - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1); - contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), record2); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1); + contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), record2); } /** diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RecordSearchClassificationEnforcementTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RecordSearchClassificationEnforcementTest.java index 5e158eeb63..3d83f9462f 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RecordSearchClassificationEnforcementTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RecordSearchClassificationEnforcementTest.java @@ -76,7 +76,7 @@ public class RecordSearchClassificationEnforcementTest extends SearchClassificat record1 = utils.createRecord(folder, searchQuery + generate()); record2 = utils.createRecord(folder, searchQuery + generate()); - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1); } /** @@ -170,8 +170,8 @@ public class RecordSearchClassificationEnforcementTest extends SearchClassificat record2 = utils.createRecord(folder, searchQuery + generate()); record3 = utils.createRecord(folder, searchQuery + generate()); - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1); - contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), record2); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1); + contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), record2); } /** @@ -265,8 +265,8 @@ public class RecordSearchClassificationEnforcementTest extends SearchClassificat record2 = utils.createRecord(folder, searchQuery + generate()); record3 = utils.createRecord(folder, searchQuery + generate()); - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1); - contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), record2); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1); + contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), record2); } /** diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RelationshipClassificationEnforcementTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RelationshipClassificationEnforcementTest.java index f852c78172..ee5356c075 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RelationshipClassificationEnforcementTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/RelationshipClassificationEnforcementTest.java @@ -94,7 +94,7 @@ public class RelationshipClassificationEnforcementTest extends BaseRMTestCase { filePlanPermissionService.setPermission(category, myUser, FILING); securityClearanceService.setUserSecurityClearance(myUser, LEVEL3); - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1); relationshipService.addRelationship(CUSTOM_REF_RENDITION.getLocalName(), record1, record2); } diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/SavedSearchClassificationEnforcementTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/SavedSearchClassificationEnforcementTest.java index e8c3c514aa..dfdf377a8a 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/SavedSearchClassificationEnforcementTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/classification/interceptor/SavedSearchClassificationEnforcementTest.java @@ -96,9 +96,9 @@ public class SavedSearchClassificationEnforcementTest extends SearchClassificati searchParameters.setIncludeUndeclaredRecords(true); rmSearchService.saveSearch(siteId, savedSearchName, generate(), searchQuery + "*", searchParameters, true); - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record1); - contentClassificationService.classifyContent(LEVEL2, generate(), newHashSet(REASON), record3); - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON), record5); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record1); + contentClassificationService.classifyContent(LEVEL2, generate(), generate(), newHashSet(REASON), record3); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON), record5); } /** diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2260Test.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2260Test.java index 81290a7221..4af4153e22 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2260Test.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM2260Test.java @@ -86,7 +86,7 @@ public class RM2260Test extends BaseRMTestCase @Override public Void run() { - contentClassificationService.classifyContent(LEVEL, generate(), newHashSet(REASON), record); + contentClassificationService.classifyContent(LEVEL, generate(), generate(), newHashSet(REASON), record); return null; } }, myUser); diff --git a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JSONConversionComponentTest.java b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JSONConversionComponentTest.java index e9cd9edf69..adb4b3337d 100644 --- a/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JSONConversionComponentTest.java +++ b/rm-server/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/jscript/JSONConversionComponentTest.java @@ -92,7 +92,7 @@ public class JSONConversionComponentTest extends BaseRMTestCase @Override public void when() throws Exception { - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON1), record); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON1), record); jsonString = converter.toJSON(record, true); } @@ -131,7 +131,7 @@ public class JSONConversionComponentTest extends BaseRMTestCase @Override public void when() throws Exception { - contentClassificationService.classifyContent(UNCLASSIFIED_ID, generate(), newHashSet(REASON1), record); + contentClassificationService.classifyContent(UNCLASSIFIED_ID, generate(), generate(), newHashSet(REASON1), record); jsonString = converter.toJSON(record, true); } @@ -206,7 +206,7 @@ public class JSONConversionComponentTest extends BaseRMTestCase @Override public void when() throws Exception { - contentClassificationService.classifyContent(LEVEL1, generate(), newHashSet(REASON1), file); + contentClassificationService.classifyContent(LEVEL1, generate(), generate(), newHashSet(REASON1), file); jsonString = converter.toJSON(file, true); } @@ -243,7 +243,7 @@ public class JSONConversionComponentTest extends BaseRMTestCase @Override public void when() throws Exception { - contentClassificationService.classifyContent(UNCLASSIFIED_ID, generate(), newHashSet(REASON1), file); + contentClassificationService.classifyContent(UNCLASSIFIED_ID, generate(), generate(), newHashSet(REASON1), file); jsonString = converter.toJSON(file, true); } diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImplUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImplUnitTest.java index 4ceacc72ce..02d5c28d7f 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImplUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ContentClassificationServiceImplUnitTest.java @@ -83,6 +83,7 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte { MockitoAnnotations.initMocks(this); MockAuthenticationUtilHelper.setup(mockAuthenticationUtil); + contentClassificationServiceImpl.setAuthenticationUtil(mockAuthenticationUtil); } /** Classify a piece of content with a couple of reasons and check the NodeService is called correctly. */ @@ -102,9 +103,9 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte when(mockNodeService.hasAspect(content, ClassifiedContentModel.ASPECT_CLASSIFIED)).thenReturn(false); when(mockSecurityClearanceService.isCurrentUserClearedForClassification("levelId1")).thenReturn(true); - // Call the method under test. - contentClassificationServiceImpl.classifyContent("levelId1", "classificationAgency", - Sets.newHashSet("reasonId1", "reasonId2"), content); + // Call the method under test + contentClassificationServiceImpl.classifyContent("levelId1", "classifiedBy", "classificationAgency", + Sets.newHashSet("reasonId1", "reasonId2"), content); verify(mockNodeService).addAspect(eq(content), eq(ClassifiedContentModel.ASPECT_CLASSIFIED), propertiesCaptor.capture()); @@ -113,10 +114,12 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte HashSet expectedPropertyKeys = Sets.newHashSet(ClassifiedContentModel.PROP_INITIAL_CLASSIFICATION, ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION, ClassifiedContentModel.PROP_CLASSIFICATION_AGENCY, + ClassifiedContentModel.PROP_CLASSIFIED_BY, ClassifiedContentModel.PROP_CLASSIFICATION_REASONS); assertEquals("Aspect created with unexpected set of keys.", expectedPropertyKeys, properties.keySet()); assertEquals("Unexpected initial classification.", level.getId(), properties.get(ClassifiedContentModel.PROP_INITIAL_CLASSIFICATION)); assertEquals("Unexpected current classification.", level.getId(), properties.get(ClassifiedContentModel.PROP_CURRENT_CLASSIFICATION)); + assertEquals("Unexpected classifiedBy.", "classifiedBy", properties.get(ClassifiedContentModel.PROP_CLASSIFIED_BY)); assertEquals("Unexpected agency.", "classificationAgency", properties.get(ClassifiedContentModel.PROP_CLASSIFICATION_AGENCY)); Set expectedReasonIds = Sets.newHashSet("reasonId1", "reasonId2"); assertEquals("Unexpected set of reasons.", expectedReasonIds, properties.get(ClassifiedContentModel.PROP_CLASSIFICATION_REASONS)); @@ -131,7 +134,7 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte when(mockNodeService.getType(notAPieceOfContent)).thenReturn(ContentModel.TYPE_FOLDER); // Call the method under test. - contentClassificationServiceImpl.classifyContent("levelId1", "classificationAgency", + contentClassificationServiceImpl.classifyContent("levelId1", "classifiedBy", "classificationAgency", Sets.newHashSet("reasonId1", "reasonId2"), notAPieceOfContent); } @@ -145,7 +148,7 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte when(mockNodeService.hasAspect(classifiedContent, ClassifiedContentModel.ASPECT_CLASSIFIED)).thenReturn(true); // Call the method under test. - contentClassificationServiceImpl.classifyContent("levelId1", "classificationAgency", + contentClassificationServiceImpl.classifyContent("levelId1", "classifiedBy", "classificationAgency", Sets.newHashSet("reasonId1", "reasonId2"), classifiedContent); } @@ -158,7 +161,8 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte when(mockNodeService.hasAspect(sharedContent, QuickShareModel.ASPECT_QSHARE)).thenReturn(true); // Call the method under test. - contentClassificationServiceImpl.classifyContent(generateText(), generateText(), newHashSet(generateText(), generateText()), sharedContent); + contentClassificationServiceImpl.classifyContent(generateText(), generateText(), generateText(), + newHashSet(generateText(), generateText()), sharedContent); } /** @@ -175,7 +179,7 @@ public class ContentClassificationServiceImplUnitTest implements ClassifiedConte when(mockSecurityClearanceService.isCurrentUserClearedForClassification("levelId1")).thenReturn(false); // Call the method under test. - contentClassificationServiceImpl.classifyContent("levelId1", "classificationAgency", + contentClassificationServiceImpl.classifyContent("levelId1", "classifiedBy","classificationAgency", Sets.newHashSet("reasonId1", "reasonId2"), classifiedContent); } diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPostUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPostUnitTest.java index e6c8ef9952..08e8c3ff73 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPostUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPostUnitTest.java @@ -22,6 +22,7 @@ import static com.google.common.collect.Sets.newHashSet; import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentPost.CLASSIFICATION_AGENCY; import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentPost.CLASSIFICATION_LEVEL_ID; import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentPost.CLASSIFICATION_REASONS; +import static org.alfresco.module.org_alfresco_module_rm.script.classification.ClassifyContentPost.CLASSIFIED_BY; import static org.alfresco.util.WebScriptUtils.getStringValueFromJSONObject; import static org.alfresco.util.WebScriptUtils.putValuetoJSONObject; import static org.junit.Assert.assertEquals; @@ -61,6 +62,7 @@ public class ClassifyContentPostUnitTest extends BaseWebScriptUnitTest private static final String ID = "id"; private static final String SUCCESS = "success"; private static final String LEVEL_ID = "aLevelId"; + private static final String BY = "bySomeone"; private static final String AGENCY = "anAgency"; private static final String REASON1_ID = "reason1Id"; private static final String REASON2_ID = "reason2Id"; @@ -116,7 +118,7 @@ public class ClassifyContentPostUnitTest extends BaseWebScriptUnitTest assertEquals(getStringValueFromJSONObject(json, SUCCESS), Boolean.TRUE.toString()); // Verify that the classify content method was called - verify(mockedContentClassificationService, times(1)).classifyContent(LEVEL_ID, AGENCY, newHashSet(REASON1_ID, REASON2_ID), record); + verify(mockedContentClassificationService, times(1)).classifyContent(LEVEL_ID, BY, AGENCY, newHashSet(REASON1_ID, REASON2_ID), record); } /** @@ -128,6 +130,7 @@ public class ClassifyContentPostUnitTest extends BaseWebScriptUnitTest { JSONObject content = new JSONObject(); putValuetoJSONObject(content, CLASSIFICATION_LEVEL_ID, LEVEL_ID); + putValuetoJSONObject(content, CLASSIFIED_BY, BY); putValuetoJSONObject(content, CLASSIFICATION_AGENCY, AGENCY); JSONObject classificationReason1 = new JSONObject();