From 899cf5fad113bf68392c52fc206b12c24b59d748 Mon Sep 17 00:00:00 2001 From: Tuna Aksoy Date: Sun, 26 Apr 2015 20:02:30 +0000 Subject: [PATCH] RM-2193 (Cannot classify non electronic document) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@102702 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../classification/ClassificationServiceImpl.java | 7 ++++--- .../classification/ClassificationServiceImplUnitTest.java | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) 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 d807ad264d..536937ac6a 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 @@ -18,6 +18,7 @@ */ package org.alfresco.module.org_alfresco_module_rm.classification; +import static org.alfresco.module.org_alfresco_module_rm.util.RMParameterCheck.checkNotBlank; import static org.alfresco.util.ParameterCheck.mandatory; import java.io.Serializable; @@ -221,12 +222,12 @@ public class ClassificationServiceImpl extends ServiceBaseImpl public void classifyContent(String classificationLevelId, String classificationAuthority, Set classificationReasonIds, NodeRef content) { - mandatory("classificationLevelId", classificationLevelId); - mandatory("classificationAuthority", classificationAuthority); + checkNotBlank("classificationLevelId", classificationLevelId); + checkNotBlank("classificationAuthority", classificationAuthority); mandatory("classificationReasonIds", classificationReasonIds); mandatory("content", content); - if (!nodeService.getType(content).equals(ContentModel.TYPE_CONTENT)) + if (!dictionaryService.isSubClass(nodeService.getType(content), ContentModel.TYPE_CONTENT)) { throw new InvalidNode(content, "The supplied node is not a content node."); } 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 7e4834c23d..17c8867f52 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 @@ -37,6 +37,7 @@ import java.util.Set; import java.util.stream.Stream; import com.google.common.collect.Sets; + import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.InvalidNode; import org.alfresco.module.org_alfresco_module_rm.classification.ClassificationServiceException.MissingConfiguration; @@ -45,6 +46,7 @@ import org.alfresco.module.org_alfresco_module_rm.test.util.ExceptionUtils; import org.alfresco.module.org_alfresco_module_rm.test.util.MockAuthenticationUtilHelper; import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil; import org.alfresco.service.cmr.attributes.AttributeService; +import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.QName; @@ -110,6 +112,7 @@ public class ClassificationServiceImplUnitTest @Mock private AuthenticationUtil mockedAuthenticationUtil; @Mock private ClassificationServiceDAO mockClassificationServiceDAO; @Mock private NodeService mockNodeService; + @Mock private DictionaryService mockDictionaryService; /** Using a mock appender in the class logger so that we can verify some of the logging requirements. */ @Mock private Appender mockAppender; @Mock private ClassificationLevelManager mockLevelManager; @@ -272,7 +275,7 @@ public class ClassificationServiceImplUnitTest when(mockReasonManager.findReasonById("reasonId2")).thenReturn(reason2); // Create a content node. NodeRef content = new NodeRef("fake://content/"); - when(mockNodeService.getType(content)).thenReturn(ContentModel.TYPE_CONTENT); + when(mockDictionaryService.isSubClass(mockNodeService.getType(content), ContentModel.TYPE_CONTENT)).thenReturn(true); when(mockNodeService.hasAspect(content, ClassifiedContentModel.ASPECT_CLASSIFIED)).thenReturn(false); // Call the method under test. @@ -314,7 +317,7 @@ public class ClassificationServiceImplUnitTest { // Create a classified piece of content. NodeRef classifiedContent = new NodeRef("classified://content/"); - when(mockNodeService.getType(classifiedContent)).thenReturn(ContentModel.TYPE_CONTENT); + when(mockDictionaryService.isSubClass(mockNodeService.getType(classifiedContent), ContentModel.TYPE_CONTENT)).thenReturn(true); when(mockNodeService.hasAspect(classifiedContent, ClassifiedContentModel.ASPECT_CLASSIFIED)).thenReturn(true); // Call the method under test.