From bf04115229f0f94e0c316959a30f0b47e91c94c4 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Mon, 20 Apr 2015 09:04:01 +0000 Subject: [PATCH] RM-2045 Fix references to "document" to refer to "content". We can use the same API to classify documents and records. +review RM-25 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@102160 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../classification/ClassificationService.java | 16 +++++----- .../ClassificationServiceImpl.java | 14 ++++----- .../classification/ClassifyContentPost.java | 2 +- .../ClassificationServiceImplUnitTest.java | 31 +++++++++---------- .../ClassifyContentPostTest.java | 2 +- 5 files changed, 31 insertions(+), 34 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationService.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationService.java index 47dc44837a..9b3d10d3a7 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationService.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationService.java @@ -52,18 +52,18 @@ public interface ClassificationService List getClassificationReasons(); /** - * Classify a document. + * Classify a piece of content. * - * @param classificationLevelId The security clearance needed to access the document. - * @param classificationAuthority The name of the authority responsible for the classification of this document. - * @param classificationReasonIds A non-empty set of ids of reasons for classifying the document in this way. - * @param document The node to classify. + * @param classificationLevelId The security clearance needed to access the content. + * @param classificationAuthority The name of the authority 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. * @throws LevelIdNotFound If the supplied level id is not found. * @throws ReasonIdNotFound If any of the supplied reason ids are not found. * @throws InvalidNodeRefException If the node could not be found. - * @throws InvalidNode If the supplied node is not a document node. + * @throws InvalidNode If the supplied node is not a content node. */ - void addClassificationToDocument(String classificationLevelId, String classificationAuthority, - Set classificationReasonIds, NodeRef document) throws LevelIdNotFound, ReasonIdNotFound, + void classifyContent(String classificationLevelId, String classificationAuthority, + Set classificationReasonIds, NodeRef content) throws LevelIdNotFound, ReasonIdNotFound, InvalidNodeRefException, InvalidNode; } diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceImpl.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceImpl.java index d625c6a776..b7d40c7dce 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceImpl.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceImpl.java @@ -218,24 +218,24 @@ public class ClassificationServiceImpl extends ServiceBaseImpl } @Override - public void addClassificationToDocument(String classificationLevelId, String classificationAuthority, - Set classificationReasonIds, NodeRef document) + public void classifyContent(String classificationLevelId, String classificationAuthority, + Set classificationReasonIds, NodeRef content) { mandatory("classificationLevelId", classificationLevelId); mandatory("classificationAuthority", classificationAuthority); mandatory("classificationReasonIds", classificationReasonIds); - mandatory("document", document); + mandatory("content", content); - if (!nodeService.getType(document).equals(ContentModel.TYPE_CONTENT)) + if (!nodeService.getType(content).equals(ContentModel.TYPE_CONTENT)) { - throw new InvalidNode(document, "The supplied node is not a content node."); + throw new InvalidNode(content, "The supplied node is not a content node."); } Map properties = new HashMap(); checkClassificationLevelId(classificationLevelId); // Initial classification id - if (nodeService.getProperty(document, PROP_INITIAL_CLASSIFICATION) == null) + if (nodeService.getProperty(content, PROP_INITIAL_CLASSIFICATION) == null) { properties.put(PROP_INITIAL_CLASSIFICATION, classificationLevelId); } @@ -256,7 +256,7 @@ public class ClassificationServiceImpl extends ServiceBaseImpl properties.put(PROP_CLASSIFICATION_REASONS, classificationReasons); // Add aspect - nodeService.addAspect(document, ASPECT_CLASSIFIED, properties); + nodeService.addAspect(content, ASPECT_CLASSIFIED, properties); } /** 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 4041f8d54e..dd8f423354 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 @@ -83,7 +83,7 @@ public class ClassifyContentPost extends AbstractRmWebScript Set classificationReasonIds = getClassificationReasonIds(jsonObject); NodeRef document = parseRequestForNodeRef(req); - getClassificationService().addClassificationToDocument(classificationLevelId, classificationAuthority, classificationReasonIds, document); + getClassificationService().classifyContent(classificationLevelId, classificationAuthority, classificationReasonIds, document); Map model = new HashMap(1); model.put(SUCCESS, true); diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceImplUnitTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceImplUnitTest.java index cc13b58611..889550631e 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceImplUnitTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/classification/ClassificationServiceImplUnitTest.java @@ -260,8 +260,8 @@ public class ClassificationServiceImplUnitTest assertEquals("Expected an empty list when the target level is not found.", 0, actual.size()); } - /** Classify a document with a couple of reasons and check the NodeService is called correctly. */ - @Test public void addClassificationToDocument_success() + /** Classify a piece of content with a couple of reasons and check the NodeService is called correctly. */ + @Test public void classifyContent_success() { // Create a level and two reasons. ClassificationLevel level = new ClassificationLevel("levelId1", "displayLabelKey"); @@ -271,15 +271,15 @@ public class ClassificationServiceImplUnitTest doReturn(level).when(mockLevelManager).findLevelById("levelId1"); doReturn(reason1).when(mockReasonManager).findReasonById("reasonId1"); doReturn(reason2).when(mockReasonManager).findReasonById("reasonId2"); - // Create a document node. - NodeRef document = new NodeRef("fake://document/"); - doReturn(ContentModel.TYPE_CONTENT).when(mockNodeService).getType(document); + // Create a content node. + NodeRef content = new NodeRef("fake://content/"); + doReturn(ContentModel.TYPE_CONTENT).when(mockNodeService).getType(content); // Call the method under test. - classificationServiceImpl.addClassificationToDocument("levelId1", "classificationAuthority", - Sets.newHashSet("reasonId1", "reasonId2"), document); + classificationServiceImpl.classifyContent("levelId1", "classificationAuthority", + Sets.newHashSet("reasonId1", "reasonId2"), content); - verify(mockNodeService).addAspect(eq(document), eq(ClassifiedContentModel.ASPECT_CLASSIFIED), + verify(mockNodeService).addAspect(eq(content), eq(ClassifiedContentModel.ASPECT_CLASSIFIED), propertiesCaptor.capture()); // Check the properties that were received. Map properties = propertiesCaptor.getValue(); @@ -295,19 +295,16 @@ public class ClassificationServiceImplUnitTest assertEquals("Unexpected set of reasons.", expectedReasonIds, properties.get(ClassifiedContentModel.PROP_CLASSIFICATION_REASONS)); } - /** - * Classify a folder using the addClassificationToDocument method and check that an exception is - * raised. - */ + /** Classify a folder using the classifyContent method and check that an exception is raised. */ @Test(expected = InvalidNode.class) - public void addClassificationToDocument_notDocument() + public void classifyContent_notContent() { // Create a folder node. - NodeRef notADocument = new NodeRef("not://a/document/"); - doReturn(ContentModel.TYPE_FOLDER).when(mockNodeService).getType(notADocument); + NodeRef notAPieceOfContent = new NodeRef("not://a/piece/of/content/"); + doReturn(ContentModel.TYPE_FOLDER).when(mockNodeService).getType(notAPieceOfContent); // Call the method under test. - classificationServiceImpl.addClassificationToDocument("levelId1", "classificationAuthority", - Sets.newHashSet("reasonId1", "reasonId2"), notADocument); + classificationServiceImpl.classifyContent("levelId1", "classificationAuthority", + Sets.newHashSet("reasonId1", "reasonId2"), notAPieceOfContent); } } diff --git a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPostTest.java b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPostTest.java index 0d7cee6bce..e3dbc979c8 100644 --- a/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPostTest.java +++ b/rm-server/unit-test/java/org/alfresco/module/org_alfresco_module_rm/script/classification/ClassifyContentPostTest.java @@ -116,7 +116,7 @@ public class ClassifyContentPostTest extends BaseWebScriptUnitTest assertEquals(getStringValueFromJSONObject(json, SUCCESS), Boolean.TRUE.toString()); // Verify that the classify content method was called - verify(mockedClassificationService, times(1)).addClassificationToDocument(LEVEL_ID, AUTHORITY, newHashSet(REASON1_ID, REASON2_ID), record); + verify(mockedClassificationService, times(1)).classifyContent(LEVEL_ID, AUTHORITY, newHashSet(REASON1_ID, REASON2_ID), record); } /**