diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/module-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/module-context.xml
index 04b7a32d05..f182740df2 100644
--- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/module-context.xml
+++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/module-context.xml
@@ -253,6 +253,10 @@
+
+
+
+
diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml
index 209626c3d7..7b7a037aa7 100644
--- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml
+++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-service-context.xml
@@ -46,6 +46,7 @@
+
@@ -870,9 +871,7 @@
-
-
-
+
@@ -1003,10 +1002,9 @@
-
-
+
-
diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml
index 66411b5569..c2806a8516 100644
--- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml
+++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml
@@ -633,7 +633,7 @@
-
+
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/BaseHold.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/BaseHold.java
index 2d4beae7f1..7a46004e3a 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/BaseHold.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/script/hold/BaseHold.java
@@ -37,7 +37,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.hold.HoldService;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService;
-import org.alfresco.service.cmr.dictionary.DictionaryService;
+import org.alfresco.module.org_alfresco_module_rm.util.NodeTypeUtility;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.json.JSONArray;
@@ -70,8 +70,8 @@ public abstract class BaseHold extends DeclarativeWebScript
/** node service */
private NodeService nodeService;
- /** Dictionary service */
- private DictionaryService dictionaryService;
+ /** Node type utility */
+ private NodeTypeUtility nodeTypeUtility;
/**
* Set the hold service
@@ -108,11 +108,11 @@ public abstract class BaseHold extends DeclarativeWebScript
}
/**
- * @param dictionaryService dictionary service
+ * @param nodeTypeUtility node type utility
*/
- public void setDictionaryService(DictionaryService dictionaryService)
+ public void setNodeTypeUtility(NodeTypeUtility nodeTypeUtility)
{
- this.dictionaryService = dictionaryService;
+ this.nodeTypeUtility = nodeTypeUtility;
}
/**
@@ -220,7 +220,7 @@ public abstract class BaseHold extends DeclarativeWebScript
// ensure that the node we are adding to the hold is a record or record folder or active content
if (!recordService.isRecord(nodeRef) && !recordFolderService.isRecordFolder(nodeRef) &&
- !dictionaryService.isSubClass(nodeService.getType(nodeRef), ContentModel.TYPE_CONTENT))
+ !nodeTypeUtility.instanceOf(nodeService.getType(nodeRef), ContentModel.TYPE_CONTENT))
{
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Items added to a hold must be either a record, a record folder or active content.");
}
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/NodeTypeUtility.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/NodeTypeUtility.java
new file mode 100644
index 0000000000..9db3acf0d0
--- /dev/null
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/NodeTypeUtility.java
@@ -0,0 +1,89 @@
+/*
+ * #%L
+ * Alfresco Records Management Module
+ * %%
+ * Copyright (C) 2005 - 2019 Alfresco Software Limited
+ * %%
+ * This file is part of the Alfresco software.
+ * -
+ * If the software was purchased under a paid Alfresco license, the terms of
+ * the paid license agreement will prevail. Otherwise, the software is
+ * provided under the following open source license terms:
+ * -
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * -
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ * -
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ * #L%
+ */
+package org.alfresco.module.org_alfresco_module_rm.util;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.alfresco.service.cmr.dictionary.DictionaryService;
+import org.alfresco.service.namespace.QName;
+import org.alfresco.util.ParameterCheck;
+
+/**
+ * Utility class to check if a node type is instance of another type
+ *
+ * @author Claudia Agache
+ * @since 3.2
+ */
+public class NodeTypeUtility
+{
+ /** Dictionary service */
+ private DictionaryService dictionaryService;
+
+ private static Map instanceOfCache = new WeakHashMap<>();
+
+ /**
+ * @param dictionaryService dictionary service
+ */
+ public void setDictionaryService(DictionaryService dictionaryService)
+ {
+ this.dictionaryService = dictionaryService;
+ }
+
+ /**
+ * Utility method to quickly determine whether one class is equal to or sub of another.
+ *
+ * @param className class name
+ * @param ofClassName class name to check against
+ * @return boolean true if equal to or sub, false otherwise
+ */
+ public boolean instanceOf(QName className, QName ofClassName)
+ {
+ ParameterCheck.mandatory("className", className);
+ ParameterCheck.mandatory("ofClassName", ofClassName);
+
+ boolean result = false;
+
+ String key = className.toString() + "|" + ofClassName.toString();
+ if (instanceOfCache.containsKey(key))
+ {
+ result = instanceOfCache.get(key);
+ }
+ else
+ {
+ if (ofClassName.equals(className) ||
+ dictionaryService.isSubClass(className, ofClassName))
+ {
+ result = true;
+ }
+
+ instanceOfCache.put(key, result);
+ }
+
+ return result;
+ }
+}
diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/ServiceBaseImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/ServiceBaseImpl.java
index f7a58ea1ff..a64179ccbc 100644
--- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/ServiceBaseImpl.java
+++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/ServiceBaseImpl.java
@@ -29,7 +29,6 @@ package org.alfresco.module.org_alfresco_module_rm.util;
import java.util.Map;
import java.util.Set;
-import java.util.WeakHashMap;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
@@ -80,6 +79,9 @@ public class ServiceBaseImpl implements RecordsManagementModel, ApplicationConte
/** Content service */
protected ContentService contentService;
+ /** Node type utility */
+ protected NodeTypeUtility nodeTypeUtility;
+
/**
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
*/
@@ -120,7 +122,15 @@ public class ServiceBaseImpl implements RecordsManagementModel, ApplicationConte
{
this.authenticationUtil = authenticationUtil;
}
-
+
+ /**
+ * @param nodeTypeUtility node type utility
+ */
+ public void setNodeTypeUtility(NodeTypeUtility nodeTypeUtility)
+ {
+ this.nodeTypeUtility = nodeTypeUtility;
+ }
+
/**
* @param transactionalResourceHelper transactional resource helper
*/
@@ -470,8 +480,6 @@ public class ServiceBaseImpl implements RecordsManagementModel, ApplicationConte
return instanceOf(className, ofClassName);
}
- private static Map instanceOfCache = new WeakHashMap<>();
-
/**
* Utility method to quickly determine whether one class is equal to or sub of another.
*
@@ -481,28 +489,7 @@ public class ServiceBaseImpl implements RecordsManagementModel, ApplicationConte
*/
protected boolean instanceOf(QName className, QName ofClassName)
{
- ParameterCheck.mandatory("className", className);
- ParameterCheck.mandatory("ofClassName", ofClassName);
-
- boolean result = false;
-
- String key = className.toString() + "|" + ofClassName.toString();
- if (instanceOfCache.containsKey(key))
- {
- result = instanceOfCache.get(key);
- }
- else
- {
- if (ofClassName.equals(className) ||
- dictionaryService.isSubClass(className, ofClassName))
- {
- result = true;
- }
-
- instanceOfCache.put(key, result);
- }
-
- return result;
+ return nodeTypeUtility.instanceOf(className, ofClassName);
}
/**
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java
index 05ae6f2606..d4d3183a06 100644
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java
@@ -114,7 +114,7 @@ public class HoldServiceImplUnitTest extends BaseUnitTest
activeContent = generateNodeRef();
QName contentSubtype = QName.createQName("contentSubtype", "contentSubtype");
when(mockedNodeService.getType(activeContent)).thenReturn(contentSubtype);
- when(mockedDictionaryService.isSubClass(contentSubtype, ContentModel.TYPE_CONTENT)).thenReturn(true);
+ when(mockedNodeTypeUtility.instanceOf(contentSubtype, ContentModel.TYPE_CONTENT)).thenReturn(true);
// setup interactions
doReturn(holdContainer).when(mockedFilePlanService).getHoldContainer(filePlan);
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FrozenAspectUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FrozenAspectUnitTest.java
index 0820c896a9..a6ca309f0a 100644
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FrozenAspectUnitTest.java
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/FrozenAspectUnitTest.java
@@ -34,7 +34,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.alfresco.model.ContentModel;
-import org.alfresco.service.cmr.dictionary.DictionaryService;
+import org.alfresco.module.org_alfresco_module_rm.util.NodeTypeUtility;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -62,7 +62,7 @@ public class FrozenAspectUnitTest
private ChildAssociationRef mockChildAssociationRef;
@Mock
- private DictionaryService mockDictionaryService;
+ private NodeTypeUtility mockedNodeTypeUtility;
@InjectMocks
private FrozenAspect frozenAspect;
@@ -103,6 +103,7 @@ public class FrozenAspectUnitTest
{
when(mockNodeService.hasAspect(content, ASPECT_RECORD)).thenReturn(false);
when(mockNodeService.getType(content)).thenReturn(ContentModel.TYPE_CONTENT);
+ when(mockedNodeTypeUtility.instanceOf(mockNodeService.getType(content), ContentModel.TYPE_CONTENT)).thenReturn(true);
when(mockNodeService.getPrimaryParent(content)).thenReturn(mockChildAssociationRef);
when(mockChildAssociationRef.getParentRef()).thenReturn(folder);
frozenAspect.onRemoveAspect(content, null);
@@ -117,7 +118,7 @@ public class FrozenAspectUnitTest
{
when(mockNodeService.hasAspect(content, ASPECT_RECORD)).thenReturn(false);
when(mockNodeService.getType(content)).thenReturn(ContentModel.TYPE_FOLDER);
- when(mockDictionaryService.isSubClass(ContentModel.TYPE_FOLDER, ContentModel.TYPE_CONTENT)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(ContentModel.TYPE_FOLDER, ContentModel.TYPE_CONTENT)).thenReturn(false);
frozenAspect.onRemoveAspect(content, null);
verify(mockNodeService, times(0)).setProperty(folder, PROP_HELD_CHILDREN_COUNT, 0);
}
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldContainerTypeUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldContainerTypeUnitTest.java
index 1cba7c83f9..83de6c90d7 100644
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldContainerTypeUnitTest.java
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/HoldContainerTypeUnitTest.java
@@ -57,7 +57,7 @@ public class HoldContainerTypeUnitTest extends BaseUnitTest
public void testAddNonHoldTypeToHoldContainer()
{
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_HOLD)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_HOLD)).thenReturn(false);
NodeRef nodeRef= AlfMock.generateNodeRef(mockedNodeService, type);
NodeRef holdContainer = generateNodeRef(TYPE_HOLD_CONTAINER, true);
@@ -75,7 +75,7 @@ public class HoldContainerTypeUnitTest extends BaseUnitTest
public void testAddHoldTypeToHoldContainer()
{
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_HOLD)).thenReturn(true);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_HOLD)).thenReturn(true);
NodeRef holdFolder= AlfMock.generateNodeRef(mockedNodeService, type);
NodeRef holdContainer = generateNodeRef(TYPE_HOLD_CONTAINER, true);
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderTypeUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderTypeUnitTest.java
index b50fcd0956..70e9562b4a 100644
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderTypeUnitTest.java
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordFolderTypeUnitTest.java
@@ -79,7 +79,7 @@ public class RecordFolderTypeUnitTest extends BaseUnitTest
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_TRANSFER)).thenReturn(true);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_TRANSFER)).thenReturn(true);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociation(childAssocRef, true);
@@ -94,7 +94,7 @@ public class RecordFolderTypeUnitTest extends BaseUnitTest
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_RECORD_FOLDER)).thenReturn(true);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_RECORD_FOLDER)).thenReturn(true);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociation(childAssocRef, true);
@@ -109,7 +109,7 @@ public class RecordFolderTypeUnitTest extends BaseUnitTest
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_RECORDS_MANAGEMENT_CONTAINER)).thenReturn(true);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_RECORDS_MANAGEMENT_CONTAINER)).thenReturn(true);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociation(childAssocRef, true);
@@ -124,7 +124,7 @@ public class RecordFolderTypeUnitTest extends BaseUnitTest
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_FOLDER)).thenReturn(true);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_FOLDER)).thenReturn(true);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociation(childAssocRef, true);
@@ -139,7 +139,7 @@ public class RecordFolderTypeUnitTest extends BaseUnitTest
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_FOLDER)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_FOLDER)).thenReturn(false);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociation(childAssocRef, true);
@@ -153,7 +153,7 @@ public class RecordFolderTypeUnitTest extends BaseUnitTest
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_CONTENT)).thenReturn(true);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_CONTENT)).thenReturn(true);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociation(childAssocRef, true);
@@ -168,8 +168,8 @@ public class RecordFolderTypeUnitTest extends BaseUnitTest
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_CONTENT)).thenReturn(false);
- when(mockedDictionaryService.isSubClass(type, TYPE_FOLDER)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_CONTENT)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_FOLDER)).thenReturn(false);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociation(childAssocRef, true);
@@ -184,7 +184,7 @@ public class RecordFolderTypeUnitTest extends BaseUnitTest
{
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_FOLDER)).thenReturn(true);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_FOLDER)).thenReturn(true);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociationOnCommit(childAssocRef, true);
@@ -201,7 +201,7 @@ public class RecordFolderTypeUnitTest extends BaseUnitTest
QName type = AlfMock.generateQName();
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
- when(mockedDictionaryService.isSubClass(type, TYPE_FOLDER)).thenReturn(true);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_FOLDER)).thenReturn(true);
when(mockedNodeService.hasAspect(nodeRef, ASPECT_HIDDEN)).thenReturn(true);
ChildAssociationRef mockedPrimaryParentAssoc = mock(ChildAssociationRef.class);
@@ -222,7 +222,7 @@ public class RecordFolderTypeUnitTest extends BaseUnitTest
QName type = AlfMock.generateQName();
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
- when(mockedDictionaryService.isSubClass(type, TYPE_FOLDER)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_FOLDER)).thenReturn(false);
ChildAssociationRef mockedPrimaryParentAssoc = mock(ChildAssociationRef.class);
when(mockedNodeService.getPrimaryParent(nodeRef)).thenReturn(mockedPrimaryParentAssoc);
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordContainerTypeUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordContainerTypeUnitTest.java
index f9a1dc7d7d..5841ef11a6 100644
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordContainerTypeUnitTest.java
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordContainerTypeUnitTest.java
@@ -59,9 +59,9 @@ public class UnfiledRecordContainerTypeUnitTest extends BaseUnitTest
public void testAddNonAcceptedTypeToUnfiledRecordContainer()
{
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
- when(mockedDictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
- when(mockedDictionaryService.isSubClass(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(false);
NodeRef nodeRef= AlfMock.generateNodeRef(mockedNodeService, type);
@@ -80,9 +80,9 @@ public class UnfiledRecordContainerTypeUnitTest extends BaseUnitTest
public void testAddUnfiledRecordFolderTypeToUnfiledRecordContainer()
{
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(true);
- when(mockedDictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
- when(mockedDictionaryService.isSubClass(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(true);
+ when(mockedNodeTypeUtility.instanceOf(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(false);
NodeRef nodeRef= AlfMock.generateNodeRef(mockedNodeService, type);
@@ -101,9 +101,9 @@ public class UnfiledRecordContainerTypeUnitTest extends BaseUnitTest
public void testAddContentTypeToUnfiledRecordContainer()
{
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
- when(mockedDictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)).thenReturn(true);
- when(mockedDictionaryService.isSubClass(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, ContentModel.TYPE_CONTENT)).thenReturn(true);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(false);
NodeRef nodeRef= AlfMock.generateNodeRef(mockedNodeService, type);
@@ -122,9 +122,9 @@ public class UnfiledRecordContainerTypeUnitTest extends BaseUnitTest
public void testNonElectronicDocumentTypeToUnfiledRecordContainer()
{
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
- when(mockedDictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
- when(mockedDictionaryService.isSubClass(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(true);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(true);
NodeRef nodeRef= AlfMock.generateNodeRef(mockedNodeService, type);
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordFolderTypeUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordFolderTypeUnitTest.java
index 10ffb83566..a4a5b230a3 100644
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordFolderTypeUnitTest.java
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/UnfiledRecordFolderTypeUnitTest.java
@@ -59,9 +59,9 @@ public class UnfiledRecordFolderTypeUnitTest extends BaseUnitTest
public void testAddNonAcceptedTypeToUnfiledRecordFolder()
{
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
- when(mockedDictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
- when(mockedDictionaryService.isSubClass(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(false);
NodeRef nodeRef= AlfMock.generateNodeRef(mockedNodeService, type);
@@ -80,9 +80,9 @@ public class UnfiledRecordFolderTypeUnitTest extends BaseUnitTest
public void testAddUnfiledRecordFolderTypeToUnfiledRecordFolder()
{
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(true);
- when(mockedDictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
- when(mockedDictionaryService.isSubClass(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(true);
+ when(mockedNodeTypeUtility.instanceOf(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(false);
NodeRef nodeRef= AlfMock.generateNodeRef(mockedNodeService, type);
@@ -101,9 +101,9 @@ public class UnfiledRecordFolderTypeUnitTest extends BaseUnitTest
public void testAddContentTypeToUnfiledRecordFolder()
{
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
- when(mockedDictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)).thenReturn(true);
- when(mockedDictionaryService.isSubClass(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, ContentModel.TYPE_CONTENT)).thenReturn(true);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(false);
NodeRef nodeRef= AlfMock.generateNodeRef(mockedNodeService, type);
@@ -122,9 +122,9 @@ public class UnfiledRecordFolderTypeUnitTest extends BaseUnitTest
public void testNonElectronicDocumentTypeToUnfiledRecordFolder()
{
QName type = AlfMock.generateQName();
- when(mockedDictionaryService.isSubClass(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
- when(mockedDictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
- when(mockedDictionaryService.isSubClass(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(true);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_UNFILED_RECORD_FOLDER)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, ContentModel.TYPE_CONTENT)).thenReturn(false);
+ when(mockedNodeTypeUtility.instanceOf(type, TYPE_NON_ELECTRONIC_DOCUMENT)).thenReturn(true);
NodeRef nodeRef= AlfMock.generateNodeRef(mockedNodeService, type);
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseUnitTest.java
index b8deb762b2..0b20db35a7 100644
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseUnitTest.java
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseUnitTest.java
@@ -58,6 +58,7 @@ import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
import org.alfresco.module.org_alfresco_module_rm.util.AlfrescoTransactionSupport;
import org.alfresco.module.org_alfresco_module_rm.util.AuthenticationUtil;
+import org.alfresco.module.org_alfresco_module_rm.util.NodeTypeUtility;
import org.alfresco.module.org_alfresco_module_rm.util.TransactionalResourceHelper;
import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService;
import org.alfresco.repo.policy.BehaviourFilter;
@@ -151,6 +152,8 @@ public class BaseUnitTest implements RecordsManagementModel, ContentModel
/** application context mock */
@Mock(name="applicationContext") protected ApplicationContext mockedApplicationContext;
+ @Mock protected NodeTypeUtility mockedNodeTypeUtility;
+
/** expected exception rule */
@Rule
public ExpectedException exception = ExpectedException.none();
@@ -313,6 +316,7 @@ public class BaseUnitTest implements RecordsManagementModel, ContentModel
if (type != null)
{
when(mockedNodeService.getType(eq(nodeRef))).thenReturn(type);
+ when(mockedNodeTypeUtility.instanceOf(type, type)).thenReturn(true);
}
return nodeRef;
}
diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/util/ServiceBaseImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/util/ServiceBaseImplUnitTest.java
index 3307cae8de..9a9d56f1d4 100644
--- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/util/ServiceBaseImplUnitTest.java
+++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/util/ServiceBaseImplUnitTest.java
@@ -35,7 +35,6 @@ import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
-import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.junit.Before;
@@ -55,10 +54,14 @@ public class ServiceBaseImplUnitTest
{
@InjectMocks private ServiceBaseImpl serviceBase;
- @Mock(name="nodeService") private NodeService mockedNodeService;
- @Mock(name="dictionaryService") private DictionaryService mockedDictionaryService;
- @Mock(name="transactionalResourceHelper") private TransactionalResourceHelper mockedTransactionalResourceHelper;
- @Mock(name="applicationContext") protected ApplicationContext mockedApplicationContext;
+ @Mock (name = "nodeService")
+ private NodeService mockedNodeService;
+ @Mock (name = "transactionalResourceHelper")
+ private TransactionalResourceHelper mockedTransactionalResourceHelper;
+ @Mock (name = "applicationContext")
+ protected ApplicationContext mockedApplicationContext;
+ @Mock (name = "nodeTypeUtility")
+ protected NodeTypeUtility mockedNodeTypeUtility;
@Mock private Map