From 83d102d92f9745ab575d99c026429bfc2d8b03c1 Mon Sep 17 00:00:00 2001 From: tiagos Date: Tue, 8 Sep 2020 18:17:55 +0100 Subject: [PATCH 01/15] [MNT-21818] Added cache to records management root, preventing the query from being executed multiple times --- .../rm-service-context.xml | 3 ++ .../fileplan/FilePlanServiceImpl.java | 51 ++++++++++++++----- 2 files changed, 42 insertions(+), 12 deletions(-) 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 00e1ccddaf..757e7649dd 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 @@ -393,10 +393,13 @@ + + + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java index 1194805168..e9e4f18566 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java @@ -89,6 +89,9 @@ public class FilePlanServiceImpl extends ServiceBaseImpl /** root container cache */ private SimpleCache, NodeRef> rootContainerCache; + /** root records management cache */ + private SimpleCache, Set> rootRecordsManagementCache; + /** File plan role service */ private FilePlanRoleService filePlanRoleService; @@ -174,6 +177,14 @@ public class FilePlanServiceImpl extends ServiceBaseImpl this.rootContainerCache = rootContainerCache; } + /** + * @param rootRecordsManagementCache root records management node cache + */ + public void setRootRecordsManagementCache(SimpleCache, Set> rootRecordsManagementCache) + { + this.rootRecordsManagementCache = rootRecordsManagementCache; + } + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#getFilePlans(org.alfresco.service.cmr.repository.StoreRef) */ @@ -185,20 +196,36 @@ public class FilePlanServiceImpl extends ServiceBaseImpl final Set results = new HashSet<>(); Set aspects = new HashSet<>(1); aspects.add(ASPECT_RECORDS_MANAGEMENT_ROOT); - getNodeDAO().getNodesWithAspects(aspects, Long.MIN_VALUE, Long.MAX_VALUE, new NodeDAO.NodeRefQueryCallback() - { - @Override - public boolean handle(Pair nodePair) - { - NodeRef nodeRef = nodePair.getSecond(); - if (storeRef.equals(nodeRef.getStoreRef())) - { - results.add(nodeRef); - } - return true; + Pair key = new Pair<>(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString()); + + if (!rootRecordsManagementCache.contains(key)) + { + getNodeDAO().getNodesWithAspects(aspects, Long.MIN_VALUE, Long.MAX_VALUE, new NodeDAO.NodeRefQueryCallback() + { + @Override + public boolean handle(Pair nodePair) + { + NodeRef nodeRef = nodePair.getSecond(); + if (storeRef.equals(nodeRef.getStoreRef())) + { + results.add(nodeRef); + } + + return true; + } + }); + + if (results.size() > 0) + { + rootRecordsManagementCache.put(key, results); } - }); + } + else + { + return rootRecordsManagementCache.get(key); + } + return results; } From 3955b2735085fb3608c46a300eafb31a8a9deecc Mon Sep 17 00:00:00 2001 From: tiagos Date: Thu, 10 Sep 2020 11:43:13 +0100 Subject: [PATCH 02/15] [MNT-21818] Added pair key type --- .../org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java index e9e4f18566..9c2379c302 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java @@ -197,7 +197,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl Set aspects = new HashSet<>(1); aspects.add(ASPECT_RECORDS_MANAGEMENT_ROOT); - Pair key = new Pair<>(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString()); + Pair key = new Pair(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString()); if (!rootRecordsManagementCache.contains(key)) { From 45ce884d018c15f2cce82f993828a17e36ce986d Mon Sep 17 00:00:00 2001 From: tiagos Date: Fri, 11 Sep 2020 01:39:29 +0100 Subject: [PATCH 03/15] [MNT-21818] Perform cache cleaning after each test is run --- .../org_alfresco_module_rm/fileplan/FilePlanService.java | 5 +++++ .../fileplan/FilePlanServiceImpl.java | 8 ++++++++ .../org_alfresco_module_rm/test/util/BaseRMTestCase.java | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java index f8b784d342..ca09908ef2 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java @@ -346,4 +346,9 @@ public interface FilePlanService */ NodeRef createRecordCategory(NodeRef parent, String name, Map properties); + /** + * Clears the records management root node cache + */ + void clearRootRecordsManagementCache(); + } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java index 9c2379c302..eb66b1961b 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java @@ -177,6 +177,14 @@ public class FilePlanServiceImpl extends ServiceBaseImpl this.rootContainerCache = rootContainerCache; } + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#clearRootRecordsManagementCache() + */ + public void clearRootRecordsManagementCache() + { + this.rootContainerCache.clear(); + } + /** * @param rootRecordsManagementCache root records management node cache */ diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java index a8b31ff55e..3f3b899bd6 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java @@ -458,6 +458,11 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase filter.disableBehaviour(); try { + if (filePlanService != null) + { + filePlanService.clearRootRecordsManagementCache(); + } + if (filePlan != null && nodeService.exists(filePlan)) { List holds = holdService.getHolds(filePlan); From 3c38823b48bf6ea834a2aadad8e315da2a21f3a9 Mon Sep 17 00:00:00 2001 From: tiagos Date: Fri, 11 Sep 2020 12:47:32 +0100 Subject: [PATCH 04/15] [MNT-21818] Fixed cache variable name --- .../org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java index eb66b1961b..f32d905daf 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java @@ -182,7 +182,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl */ public void clearRootRecordsManagementCache() { - this.rootContainerCache.clear(); + this.rootRecordsManagementCache.clear(); } /** From 67225447d5a2dae349db3d34d1f1380e87fdcdf6 Mon Sep 17 00:00:00 2001 From: tiagos Date: Mon, 14 Sep 2020 22:00:02 +0100 Subject: [PATCH 05/15] [MNT-21818] Added behavior to update cache. Changed clear method. --- .../org_alfresco_module_rm/module-context.xml | 7 + .../CleanRecordsManagementRootCache.java | 135 ++++++++++++++++++ .../fileplan/FilePlanService.java | 12 +- .../fileplan/FilePlanServiceImpl.java | 17 ++- .../test/util/BaseRMTestCase.java | 19 ++- 5 files changed, 177 insertions(+), 13 deletions(-) create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/behaviour/CleanRecordsManagementRootCache.java 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 4ccba8a2a0..9f279987b2 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 @@ -125,6 +125,13 @@ + + + + + + + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/behaviour/CleanRecordsManagementRootCache.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/behaviour/CleanRecordsManagementRootCache.java new file mode 100644 index 0000000000..2f311e4adb --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/behaviour/CleanRecordsManagementRootCache.java @@ -0,0 +1,135 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2020 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.behaviour; + +import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.node.NodeServicePolicies.OnDeleteNodePolicy; +import org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy; +import org.alfresco.repo.policy.JavaBehaviour; +import org.alfresco.repo.policy.PolicyComponent; +import org.alfresco.service.cmr.repository.ChildAssociationRef; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.alfresco.util.PropertyCheck; + +public class CleanRecordsManagementRootCache implements RecordsManagementModel, OnDeleteNodePolicy, OnRemoveAspectPolicy +{ + + private PolicyComponent policyComponent; + + private NodeService nodeService; + + private FilePlanService filePlanService; + + /** + * + * @param policyComponent + */ + public void setPolicyComponent(PolicyComponent policyComponent) + { + this.policyComponent = policyComponent; + } + + /** + * @param nodeService + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * + * @param filePlanService + */ + public void setFilePlanService(FilePlanService filePlanService) + { + this.filePlanService = filePlanService; + } + + /** + * Performs the initialization operations for this behavior + */ + public void init() + { + // check that required properties have been set + PropertyCheck.mandatory("CleanRecordsManagementRootCache", "policyComponent", policyComponent); + PropertyCheck.mandatory("CleanRecordsManagementRootCache", "nodeService", nodeService); + PropertyCheck.mandatory("CleanRecordsManagementRootCache", "filePlanService", filePlanService); + + // register behaviour + policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveAspect"), + this, + new JavaBehaviour(this, "onRemoveAspect")); + policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"), + this, + new JavaBehaviour(this, "onDeleteNode")); + } + + /** + * On remove aspect, performs the records management root cache clean operation but only + * if the removed aspects matches {@link RecordsManagementModel#ASPECT_RECORDS_MANAGEMENT_ROOT} + */ + @Override + public void onRemoveAspect(NodeRef nodeRef, QName aspectTypeQName) + { + if (nodeRef != null && ASPECT_RECORDS_MANAGEMENT_ROOT.isMatch(aspectTypeQName)) + { + clearRootRecordsManagementCache(nodeRef); + } + } + + /** + * On delete node, performs the records management root cache clean operation + */ + @Override + public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived) + { + if (childAssocRef != null) + { + clearRootRecordsManagementCache(childAssocRef.getParentRef()); + clearRootRecordsManagementCache(childAssocRef.getChildRef()); + } + } + + /** + * Cleans the records managements root cache in case of supplied nodeRef has {@link RecordsManagementModel#ASPECT_RECORDS_MANAGEMENT_ROOT} aspect + * + * @param nodeRef + */ + private void clearRootRecordsManagementCache(NodeRef nodeRef) { + if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT)) + { + filePlanService.clearRootRecordsManagementCache(nodeRef.getStoreRef()); + } + } +} \ No newline at end of file diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java index ca09908ef2..f5c6ee4c88 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java @@ -346,9 +346,11 @@ public interface FilePlanService */ NodeRef createRecordCategory(NodeRef parent, String name, Map properties); - /** - * Clears the records management root node cache - */ - void clearRootRecordsManagementCache(); + /** + * Clears the records management root node cache + * + * @param storeRef + */ + void clearRootRecordsManagementCache(StoreRef storeRef); -} +} \ No newline at end of file diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java index f32d905daf..fe70233cf4 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java @@ -178,11 +178,22 @@ public class FilePlanServiceImpl extends ServiceBaseImpl } /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#clearRootRecordsManagementCache() + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#clearRootRecordsManagementCache(StoreRef) */ - public void clearRootRecordsManagementCache() + public void clearRootRecordsManagementCache(StoreRef storeRef) { - this.rootRecordsManagementCache.clear(); + if (storeRef != null) + { + Pair key = new Pair(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString()); + if (rootRecordsManagementCache.contains(key)) + { + this.rootRecordsManagementCache.remove(key); + } + } + else + { + this.rootRecordsManagementCache.clear(); + } } /** diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java index 3f3b899bd6..180d85954c 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java @@ -458,11 +458,6 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase filter.disableBehaviour(); try { - if (filePlanService != null) - { - filePlanService.clearRootRecordsManagementCache(); - } - if (filePlan != null && nodeService.exists(filePlan)) { List holds = holdService.getHolds(filePlan); @@ -489,6 +484,11 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase { siteService.deleteSite(collabSiteId); } + + if (filePlanService != null) + { + filePlanService.clearRootRecordsManagementCache(null); + } } finally { @@ -941,6 +941,15 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase public void then() throws Exception { /** empty implementation */ } public void after() throws Exception { /** empty implementation */ } + + public void mAfter() throws Exception + { + this.after(); + if (filePlanService != null) + { + filePlanService.clearRootRecordsManagementCache(null); + } + } public void run() throws Exception { From 913658e4d68f5814ad6ad8b357d802d3578eacd3 Mon Sep 17 00:00:00 2001 From: tiagos Date: Mon, 14 Sep 2020 23:15:59 +0100 Subject: [PATCH 06/15] [MNT-21818] BehaviourDrivenTest after method --- .../org_alfresco_module_rm/test/util/BaseRMTestCase.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java index 180d85954c..0313b21efa 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java @@ -1020,13 +1020,13 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase @Override public void runImpl() throws Exception { - after(); + mAfter(); } }, runAsUser); } else { - after(); + mAfter(); } } } From d54f5365094feaf8011026fdf516311374e825f3 Mon Sep 17 00:00:00 2001 From: tiagos Date: Tue, 15 Sep 2020 03:51:06 +0100 Subject: [PATCH 07/15] [MNT-21818] Added onCreateNode and onAddAspect policies --- .../org_alfresco_module_rm/module-context.xml | 2 +- ... => UpdateRecordsManagementRootCache.java} | 69 +++++++++++++++++-- .../fileplan/FilePlanService.java | 7 ++ .../fileplan/FilePlanServiceImpl.java | 30 +++++++- .../test/util/BaseRMTestCase.java | 17 ++--- 5 files changed, 105 insertions(+), 20 deletions(-) rename rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/behaviour/{CleanRecordsManagementRootCache.java => UpdateRecordsManagementRootCache.java} (65%) 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 9f279987b2..90a38c871d 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 @@ -126,7 +126,7 @@ - + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/behaviour/CleanRecordsManagementRootCache.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/behaviour/UpdateRecordsManagementRootCache.java similarity index 65% rename from rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/behaviour/CleanRecordsManagementRootCache.java rename to rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/behaviour/UpdateRecordsManagementRootCache.java index 2f311e4adb..f76a121f4a 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/behaviour/CleanRecordsManagementRootCache.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/behaviour/UpdateRecordsManagementRootCache.java @@ -28,6 +28,8 @@ package org.alfresco.module.org_alfresco_module_rm.behaviour; import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy; +import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy; import org.alfresco.repo.node.NodeServicePolicies.OnDeleteNodePolicy; import org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy; import org.alfresco.repo.policy.JavaBehaviour; @@ -39,7 +41,18 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; import org.alfresco.util.PropertyCheck; -public class CleanRecordsManagementRootCache implements RecordsManagementModel, OnDeleteNodePolicy, OnRemoveAspectPolicy +/** + * Updates the records management root nodes cache from {@link FilePlanService} + * + * @author Tiago Salvado + * + * @see RecordsManagementModel + * @see OnCreateNodePolicy + * @see OnDeleteNodePolicy + * @see OnAddAspectPolicy + * @see OnRemoveAspectPolicy + */ +public class UpdateRecordsManagementRootCache implements RecordsManagementModel, OnCreateNodePolicy, OnDeleteNodePolicy, OnAddAspectPolicy, OnRemoveAspectPolicy { private PolicyComponent policyComponent; @@ -85,10 +98,18 @@ public class CleanRecordsManagementRootCache implements RecordsManagementModel, PropertyCheck.mandatory("CleanRecordsManagementRootCache", "filePlanService", filePlanService); // register behaviour + policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), + this, + new JavaBehaviour(this, "onAddAspect")); policyComponent.bindClassBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveAspect"), this, new JavaBehaviour(this, "onRemoveAspect")); + policyComponent.bindClassBehaviour( + QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), + this, + new JavaBehaviour(this, "onCreateNode")); policyComponent.bindClassBehaviour( QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"), this, @@ -96,8 +117,19 @@ public class CleanRecordsManagementRootCache implements RecordsManagementModel, } /** - * On remove aspect, performs the records management root cache clean operation but only - * if the removed aspects matches {@link RecordsManagementModel#ASPECT_RECORDS_MANAGEMENT_ROOT} + * Updates the root records management cache when adding an aspect + */ + @Override + public void onAddAspect(NodeRef nodeRef, QName aspectTypeQName) + { + if (nodeRef != null && ASPECT_RECORDS_MANAGEMENT_ROOT.isMatch(aspectTypeQName)) + { + addToRootRecordsManagementCache(nodeRef); + } + } + + /** + * Updates the root records management cache on aspect removal */ @Override public void onRemoveAspect(NodeRef nodeRef, QName aspectTypeQName) @@ -105,11 +137,24 @@ public class CleanRecordsManagementRootCache implements RecordsManagementModel, if (nodeRef != null && ASPECT_RECORDS_MANAGEMENT_ROOT.isMatch(aspectTypeQName)) { clearRootRecordsManagementCache(nodeRef); - } + } } + /** + * Updates the root records management cache on node creation + */ + @Override + public void onCreateNode(ChildAssociationRef childAssocRef) + { + if (childAssocRef != null) + { + addToRootRecordsManagementCache(childAssocRef.getParentRef()); + addToRootRecordsManagementCache(childAssocRef.getChildRef()); + } + } + /** - * On delete node, performs the records management root cache clean operation + * Updates the root records management cache on node removal */ @Override public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived) @@ -122,7 +167,19 @@ public class CleanRecordsManagementRootCache implements RecordsManagementModel, } /** - * Cleans the records managements root cache in case of supplied nodeRef has {@link RecordsManagementModel#ASPECT_RECORDS_MANAGEMENT_ROOT} aspect + * Adds a node to the records managements root node cache + * + * @param nodeRef + */ + private void addToRootRecordsManagementCache(NodeRef nodeRef) { + if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT)) + { + filePlanService.addToRootRecordsManagementCache(nodeRef); + } + } + + /** + * Cleans the records managements root node cache * * @param nodeRef */ diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java index f5c6ee4c88..6e6965caaf 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java @@ -346,6 +346,13 @@ public interface FilePlanService */ NodeRef createRecordCategory(NodeRef parent, String name, Map properties); + /** + * Adds a node to records management root node cache + * + * @param nodeRef + */ + void addToRootRecordsManagementCache(NodeRef nodeRef); + /** * Clears the records management root node cache * diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java index fe70233cf4..d83abef335 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java @@ -177,6 +177,34 @@ public class FilePlanServiceImpl extends ServiceBaseImpl this.rootContainerCache = rootContainerCache; } + /** + * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#addToRootRecordsManagementCache(NodeRef) + */ + public void addToRootRecordsManagementCache(NodeRef nodeRef) + { + if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT)) + { + Set roots; + StoreRef storeRef = nodeRef.getStoreRef(); + Pair key = new Pair(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString()); + + if (rootRecordsManagementCache.contains(key)) + { + roots = this.rootRecordsManagementCache.get(key); + } + else + { + roots = new HashSet<>(); + } + + if (!roots.contains(nodeRef)) { + roots.add(nodeRef); + } + + rootRecordsManagementCache.put(key, roots); + } + } + /** * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#clearRootRecordsManagementCache(StoreRef) */ @@ -230,7 +258,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl { results.add(nodeRef); } - + return true; } }); diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java index 0313b21efa..78b551a339 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java @@ -27,7 +27,9 @@ package org.alfresco.module.org_alfresco_module_rm.test.util; +import java.io.PrintWriter; import java.io.Serializable; +import java.io.StringWriter; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -487,7 +489,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase if (filePlanService != null) { - filePlanService.clearRootRecordsManagementCache(null); + filePlanService.clearRootRecordsManagementCache(null); } } finally @@ -942,15 +944,6 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase public void after() throws Exception { /** empty implementation */ } - public void mAfter() throws Exception - { - this.after(); - if (filePlanService != null) - { - filePlanService.clearRootRecordsManagementCache(null); - } - } - public void run() throws Exception { try @@ -1020,13 +1013,13 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase @Override public void runImpl() throws Exception { - mAfter(); + after(); } }, runAsUser); } else { - mAfter(); + after(); } } } From 4c59680881ff29af95764a8035267d99c3212526 Mon Sep 17 00:00:00 2001 From: tiagos Date: Tue, 15 Sep 2020 16:23:34 +0100 Subject: [PATCH 08/15] [MNT-21818] Created RMContainerCacheManager to isolate the new cache. Updated BaseRMTestCase and FilePlanService interface and implementation according to the new manager --- .../org_alfresco_module_rm/module-context.xml | 7 - .../rm-model-context.xml | 1 + .../rm-service-context.xml | 12 +- .../UpdateRecordsManagementRootCache.java | 192 ------------------ .../fileplan/FilePlanService.java | 14 -- .../fileplan/FilePlanServiceImpl.java | 75 ++----- .../type/RecordsManagementContainerType.java | 51 ++++- .../util/RMContainerCacheManager.java | 157 ++++++++++++++ .../test/util/BaseRMTestCase.java | 13 +- 9 files changed, 237 insertions(+), 285 deletions(-) delete mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/behaviour/UpdateRecordsManagementRootCache.java create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java 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 90a38c871d..4ccba8a2a0 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 @@ -125,13 +125,6 @@ - - - - - - - diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml index 932d24c525..826f06b1b1 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml @@ -71,6 +71,7 @@ + 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 757e7649dd..321fb2aba6 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 @@ -389,17 +389,23 @@ + + + + + + + + - - - + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/behaviour/UpdateRecordsManagementRootCache.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/behaviour/UpdateRecordsManagementRootCache.java deleted file mode 100644 index f76a121f4a..0000000000 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/behaviour/UpdateRecordsManagementRootCache.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * #%L - * Alfresco Records Management Module - * %% - * Copyright (C) 2005 - 2020 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.behaviour; - -import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService; -import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; -import org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy; -import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy; -import org.alfresco.repo.node.NodeServicePolicies.OnDeleteNodePolicy; -import org.alfresco.repo.node.NodeServicePolicies.OnRemoveAspectPolicy; -import org.alfresco.repo.policy.JavaBehaviour; -import org.alfresco.repo.policy.PolicyComponent; -import org.alfresco.service.cmr.repository.ChildAssociationRef; -import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; -import org.alfresco.service.namespace.NamespaceService; -import org.alfresco.service.namespace.QName; -import org.alfresco.util.PropertyCheck; - -/** - * Updates the records management root nodes cache from {@link FilePlanService} - * - * @author Tiago Salvado - * - * @see RecordsManagementModel - * @see OnCreateNodePolicy - * @see OnDeleteNodePolicy - * @see OnAddAspectPolicy - * @see OnRemoveAspectPolicy - */ -public class UpdateRecordsManagementRootCache implements RecordsManagementModel, OnCreateNodePolicy, OnDeleteNodePolicy, OnAddAspectPolicy, OnRemoveAspectPolicy -{ - - private PolicyComponent policyComponent; - - private NodeService nodeService; - - private FilePlanService filePlanService; - - /** - * - * @param policyComponent - */ - public void setPolicyComponent(PolicyComponent policyComponent) - { - this.policyComponent = policyComponent; - } - - /** - * @param nodeService - */ - public void setNodeService(NodeService nodeService) - { - this.nodeService = nodeService; - } - - /** - * - * @param filePlanService - */ - public void setFilePlanService(FilePlanService filePlanService) - { - this.filePlanService = filePlanService; - } - - /** - * Performs the initialization operations for this behavior - */ - public void init() - { - // check that required properties have been set - PropertyCheck.mandatory("CleanRecordsManagementRootCache", "policyComponent", policyComponent); - PropertyCheck.mandatory("CleanRecordsManagementRootCache", "nodeService", nodeService); - PropertyCheck.mandatory("CleanRecordsManagementRootCache", "filePlanService", filePlanService); - - // register behaviour - policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onAddAspect"), - this, - new JavaBehaviour(this, "onAddAspect")); - policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onRemoveAspect"), - this, - new JavaBehaviour(this, "onRemoveAspect")); - policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), - this, - new JavaBehaviour(this, "onCreateNode")); - policyComponent.bindClassBehaviour( - QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"), - this, - new JavaBehaviour(this, "onDeleteNode")); - } - - /** - * Updates the root records management cache when adding an aspect - */ - @Override - public void onAddAspect(NodeRef nodeRef, QName aspectTypeQName) - { - if (nodeRef != null && ASPECT_RECORDS_MANAGEMENT_ROOT.isMatch(aspectTypeQName)) - { - addToRootRecordsManagementCache(nodeRef); - } - } - - /** - * Updates the root records management cache on aspect removal - */ - @Override - public void onRemoveAspect(NodeRef nodeRef, QName aspectTypeQName) - { - if (nodeRef != null && ASPECT_RECORDS_MANAGEMENT_ROOT.isMatch(aspectTypeQName)) - { - clearRootRecordsManagementCache(nodeRef); - } - } - - /** - * Updates the root records management cache on node creation - */ - @Override - public void onCreateNode(ChildAssociationRef childAssocRef) - { - if (childAssocRef != null) - { - addToRootRecordsManagementCache(childAssocRef.getParentRef()); - addToRootRecordsManagementCache(childAssocRef.getChildRef()); - } - } - - /** - * Updates the root records management cache on node removal - */ - @Override - public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived) - { - if (childAssocRef != null) - { - clearRootRecordsManagementCache(childAssocRef.getParentRef()); - clearRootRecordsManagementCache(childAssocRef.getChildRef()); - } - } - - /** - * Adds a node to the records managements root node cache - * - * @param nodeRef - */ - private void addToRootRecordsManagementCache(NodeRef nodeRef) { - if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT)) - { - filePlanService.addToRootRecordsManagementCache(nodeRef); - } - } - - /** - * Cleans the records managements root node cache - * - * @param nodeRef - */ - private void clearRootRecordsManagementCache(NodeRef nodeRef) { - if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT)) - { - filePlanService.clearRootRecordsManagementCache(nodeRef.getStoreRef()); - } - } -} \ No newline at end of file diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java index 6e6965caaf..41bb9576b8 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanService.java @@ -346,18 +346,4 @@ public interface FilePlanService */ NodeRef createRecordCategory(NodeRef parent, String name, Map properties); - /** - * Adds a node to records management root node cache - * - * @param nodeRef - */ - void addToRootRecordsManagementCache(NodeRef nodeRef); - - /** - * Clears the records management root node cache - * - * @param storeRef - */ - void clearRootRecordsManagementCache(StoreRef storeRef); - } \ No newline at end of file diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java index d83abef335..a700b9dce9 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/fileplan/FilePlanServiceImpl.java @@ -42,6 +42,7 @@ import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; +import org.alfresco.module.org_alfresco_module_rm.util.RMContainerCacheManager; import org.alfresco.module.org_alfresco_module_rm.util.ServiceBaseImpl; import org.alfresco.repo.cache.SimpleCache; import org.alfresco.repo.domain.node.NodeDAO; @@ -89,9 +90,6 @@ public class FilePlanServiceImpl extends ServiceBaseImpl /** root container cache */ private SimpleCache, NodeRef> rootContainerCache; - /** root records management cache */ - private SimpleCache, Set> rootRecordsManagementCache; - /** File plan role service */ private FilePlanRoleService filePlanRoleService; @@ -104,6 +102,9 @@ public class FilePlanServiceImpl extends ServiceBaseImpl /** Site service */ private SiteService siteService; + /** RM container cache manager **/ + private RMContainerCacheManager rmContainerCacheManager; + /** * Gets the file plan role service * @@ -178,58 +179,12 @@ public class FilePlanServiceImpl extends ServiceBaseImpl } /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#addToRootRecordsManagementCache(NodeRef) + * @param rmContainerCacheManager RM container cache manager + * */ - public void addToRootRecordsManagementCache(NodeRef nodeRef) + public void setRmContainerCacheManager(RMContainerCacheManager rmContainerCacheManager) { - if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT)) - { - Set roots; - StoreRef storeRef = nodeRef.getStoreRef(); - Pair key = new Pair(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString()); - - if (rootRecordsManagementCache.contains(key)) - { - roots = this.rootRecordsManagementCache.get(key); - } - else - { - roots = new HashSet<>(); - } - - if (!roots.contains(nodeRef)) { - roots.add(nodeRef); - } - - rootRecordsManagementCache.put(key, roots); - } - } - - /** - * @see org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService#clearRootRecordsManagementCache(StoreRef) - */ - public void clearRootRecordsManagementCache(StoreRef storeRef) - { - if (storeRef != null) - { - Pair key = new Pair(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString()); - if (rootRecordsManagementCache.contains(key)) - { - this.rootRecordsManagementCache.remove(key); - } - } - else - { - this.rootRecordsManagementCache.clear(); - } - } - - /** - * @param rootRecordsManagementCache root records management node cache - */ - public void setRootRecordsManagementCache(SimpleCache, Set> rootRecordsManagementCache) - { - this.rootRecordsManagementCache = rootRecordsManagementCache; + this.rmContainerCacheManager = rmContainerCacheManager; } /** @@ -244,9 +199,7 @@ public class FilePlanServiceImpl extends ServiceBaseImpl Set aspects = new HashSet<>(1); aspects.add(ASPECT_RECORDS_MANAGEMENT_ROOT); - Pair key = new Pair(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString()); - - if (!rootRecordsManagementCache.contains(key)) + if (!rmContainerCacheManager.isCached(storeRef)) { getNodeDAO().getNodesWithAspects(aspects, Long.MIN_VALUE, Long.MAX_VALUE, new NodeDAO.NodeRefQueryCallback() { @@ -257,20 +210,16 @@ public class FilePlanServiceImpl extends ServiceBaseImpl if (storeRef.equals(nodeRef.getStoreRef())) { results.add(nodeRef); + rmContainerCacheManager.add(nodeRef); } - + return true; } }); - - if (results.size() > 0) - { - rootRecordsManagementCache.put(key, results); - } } else { - return rootRecordsManagementCache.get(key); + return rmContainerCacheManager.get(storeRef); } return results; diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java index 72a7894901..633f7cc71a 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java @@ -33,6 +33,7 @@ import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.record.RecordService; import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService; +import org.alfresco.module.org_alfresco_module_rm.util.RMContainerCacheManager; import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.annotation.Behaviour; @@ -55,7 +56,8 @@ import org.alfresco.service.namespace.QName; defaultType = "rma:recordsManagementContainer" ) public class RecordsManagementContainerType extends BaseBehaviourBean - implements NodeServicePolicies.OnCreateChildAssociationPolicy + implements NodeServicePolicies.OnCreateChildAssociationPolicy, + NodeServicePolicies.OnDeleteChildAssociationPolicy { /** behaviour name */ private static final String BEHAVIOUR_NAME = "onCreateContainerType"; @@ -69,9 +71,21 @@ public class RecordsManagementContainerType extends BaseBehaviourBean /** record folder service */ protected RecordFolderService recordFolderService; + /** RM container cache manager **/ + private RMContainerCacheManager rmContainerCacheManager; + /** I18N */ private static final String MSG_CANNOT_CAST_TO_RM_TYPE = "rm.action.cast-to-rm-type"; + /** + * @param rmContainerCacheManager RM container cache manager + * + */ + public void setRmContainerCacheManager(RMContainerCacheManager rmContainerCacheManager) + { + this.rmContainerCacheManager = rmContainerCacheManager; + } + /** * @param identifierService identifier service */ @@ -194,15 +208,48 @@ public class RecordsManagementContainerType extends BaseBehaviourBean setIdenifierProperty(child); } } + + if (rmContainerCacheManager != null) + { + rmContainerCacheManager.add(child); + } } return null; } }); - } /** + * + */ + @Override + @Behaviour + ( + kind = BehaviourKind.ASSOCIATION + ) + public void onDeleteChildAssociation(ChildAssociationRef childAssocRef) + { + + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // Get the elements of the deleted association + final NodeRef child = childAssocRef.getChildRef(); + + if (rmContainerCacheManager != null) + { + rmContainerCacheManager.remove(child); + } + + return null; + } + }); + } + + /** * Set the identifier property * * @param nodeRef node reference diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java new file mode 100644 index 0000000000..500db5f7a4 --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java @@ -0,0 +1,157 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2020 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.HashSet; +import java.util.Set; + +import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; +import org.alfresco.repo.cache.SimpleCache; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.util.Pair; + +/** + * Provides operations to manipulate the records management root cache + * + * @author Tiago Salvado + * + * @see RecordsManagementModel + */ +public class RMContainerCacheManager implements RecordsManagementModel +{ + /** node service */ + private NodeService nodeService; + + /** root records management cache */ + private SimpleCache, Set> cache; + + /** + * @param nodeService node service + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } + + /** + * @param cache + */ + public void setCache(SimpleCache, Set> cache) + { + this.cache = cache; + } + + /** + * Verifies if there is cached nodes for supplied storeRef + * @param storeRef + * @return true if there are cached nodes, false otherwise + */ + public boolean isCached(StoreRef storeRef) + { + Pair key = new Pair(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString()); + return cache.contains(key); + } + + /** + * Obtains the cached nodes for supplied storeRef + * + * @param storeRef + * @return a set containing the cached nodes + */ + public Set get(StoreRef storeRef) + { + return cache.get(getKey(storeRef)); + } + + /** + * Caches the supplied node + * + * @param nodeRef + */ + public void add(NodeRef nodeRef) + { + if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT)) + { + Set entries; + Pair key = getKey(nodeRef.getStoreRef()); + + if (cache.contains(key)) + { + entries = this.cache.get(key); + } + else + { + entries = new HashSet<>(); + } + + if (!entries.contains(nodeRef)) + { + entries.add(nodeRef); + } + + cache.put(key, entries); + } + } + + /** + * Removes the supplied entry from the cache + * + * @param nodeRef + */ + public void remove(NodeRef nodeRef) + { + if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT)) + { + Pair key = getKey(nodeRef.getStoreRef()); + if (cache.contains(key)) + { + cache.get(key).remove(nodeRef); + } + } + } + + /** + * Resets the cache entries + */ + public void reset() + { + this.cache.clear(); + } + + /** + * Builds the cache key using the supplied storeRef + * + * @param storeRef + * @return a pair corresponding to the cache key + */ + private Pair getKey(StoreRef storeRef) + { + return new Pair(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString()); + } +} \ No newline at end of file diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java index 78b551a339..1d81ab517c 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/util/BaseRMTestCase.java @@ -27,9 +27,7 @@ package org.alfresco.module.org_alfresco_module_rm.test.util; -import java.io.PrintWriter; import java.io.Serializable; -import java.io.StringWriter; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -59,6 +57,7 @@ import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService; import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService; import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService; +import org.alfresco.module.org_alfresco_module_rm.util.RMContainerCacheManager; import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordService; import org.alfresco.repo.policy.BehaviourFilter; import org.alfresco.repo.policy.PolicyComponent; @@ -175,6 +174,9 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase protected InplaceRecordService inplaceRecordService; protected RelationshipService relationshipService; + /** RM Container Cache Manager */ + protected RMContainerCacheManager rmContainerCacheManager; + /** test utils */ protected UserAndGroupsUtils userAndGroupsUtils; @@ -426,6 +428,9 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase holdService = (HoldService) applicationContext.getBean("HoldService"); inplaceRecordService = (InplaceRecordService) applicationContext.getBean("InplaceRecordService"); relationshipService = (RelationshipService) applicationContext.getBean("RelationshipService"); + + // RM Container Cache Manager + rmContainerCacheManager = (RMContainerCacheManager) applicationContext.getBean("rmContainerCacheManager"); } /** @@ -487,9 +492,9 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase siteService.deleteSite(collabSiteId); } - if (filePlanService != null) + if (rmContainerCacheManager != null) { - filePlanService.clearRootRecordsManagementCache(null); + rmContainerCacheManager.reset(); } } finally From bc4e41b4a7168a45480cf946e7c12b41658bc93a Mon Sep 17 00:00:00 2001 From: tiagos Date: Tue, 15 Sep 2020 17:17:10 +0100 Subject: [PATCH 09/15] [MNT-21818] applied code formatter --- .../util/RMContainerCacheManager.java | 171 +++++++++--------- 1 file changed, 86 insertions(+), 85 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java index 500db5f7a4..6eed0291c0 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java @@ -37,7 +37,7 @@ import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.util.Pair; /** - * Provides operations to manipulate the records management root cache + * Provides operations to manipulate the records management root cache * * @author Tiago Salvado * @@ -45,14 +45,15 @@ import org.alfresco.util.Pair; */ public class RMContainerCacheManager implements RecordsManagementModel { - /** node service */ + /** node service */ private NodeService nodeService; - + /** root records management cache */ - private SimpleCache, Set> cache; - + private SimpleCache, Set> cache; + /** - * @param nodeService node service + * @param nodeService + * node service */ public void setNodeService(NodeService nodeService) { @@ -67,91 +68,91 @@ public class RMContainerCacheManager implements RecordsManagementModel this.cache = cache; } - /** - * Verifies if there is cached nodes for supplied storeRef - * @param storeRef - * @return true if there are cached nodes, false otherwise - */ - public boolean isCached(StoreRef storeRef) - { - Pair key = new Pair(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString()); - return cache.contains(key); - } - - /** - * Obtains the cached nodes for supplied storeRef - * - * @param storeRef - * @return a set containing the cached nodes - */ - public Set get(StoreRef storeRef) - { + /** + * Verifies if there is cached nodes for supplied storeRef + * + * @param storeRef + * @return true if there are cached nodes, false otherwise + */ + public boolean isCached(StoreRef storeRef) + { + return cache.contains(getKey(storeRef)); + } + + /** + * Obtains the cached nodes for supplied storeRef + * + * @param storeRef + * @return a set containing the cached nodes + */ + public Set get(StoreRef storeRef) + { return cache.get(getKey(storeRef)); - } + } - /** - * Caches the supplied node - * - * @param nodeRef - */ - public void add(NodeRef nodeRef) - { - if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT)) - { - Set entries; - Pair key = getKey(nodeRef.getStoreRef()); + /** + * Caches the supplied node + * + * @param nodeRef + */ + public void add(NodeRef nodeRef) + { + if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT)) + { + Set entries; + Pair key = getKey(nodeRef.getStoreRef()); - if (cache.contains(key)) - { - entries = this.cache.get(key); - } - else - { - entries = new HashSet<>(); - } + if (cache.contains(key)) + { + entries = this.cache.get(key); + } + else + { + entries = new HashSet<>(); + } - if (!entries.contains(nodeRef)) - { - entries.add(nodeRef); - } + if (!entries.contains(nodeRef)) + { + entries.add(nodeRef); + } - cache.put(key, entries); - } - } + cache.put(key, entries); + } + } - /** - * Removes the supplied entry from the cache - * - * @param nodeRef - */ - public void remove(NodeRef nodeRef) - { - if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT)) - { - Pair key = getKey(nodeRef.getStoreRef()); - if (cache.contains(key)) - { - cache.get(key).remove(nodeRef); - } - } - } + /** + * Removes the supplied entry from the cache + * + * @param nodeRef + */ + public void remove(NodeRef nodeRef) + { + if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT)) + { + Pair key = getKey(nodeRef.getStoreRef()); + if (cache.contains(key)) + { + cache.get(key).remove(nodeRef); + } + } + } - /** - * Resets the cache entries - */ - public void reset() - { - this.cache.clear(); - } + /** + * Resets the cache entries + */ + public void reset() + { + this.cache.clear(); + } - /** - * Builds the cache key using the supplied storeRef - * - * @param storeRef - * @return a pair corresponding to the cache key - */ - private Pair getKey(StoreRef storeRef) - { - return new Pair(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString()); - } + /** + * Builds the cache key using the supplied storeRef + * + * @param storeRef + * @return a pair corresponding to the cache key + */ + private Pair getKey(StoreRef storeRef) + { + return new Pair(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString()); + } } \ No newline at end of file From 80150e5a8d2158d8bfd8e6b059652af8fc915bac Mon Sep 17 00:00:00 2001 From: tiagos Date: Tue, 15 Sep 2020 22:13:50 +0100 Subject: [PATCH 10/15] [MNT-21818] Clear cache if site node is deleted --- .../util/RMContainerCacheManager.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java index 6eed0291c0..ac44c661db 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java @@ -127,12 +127,20 @@ public class RMContainerCacheManager implements RecordsManagementModel */ public void remove(NodeRef nodeRef) { - if (nodeRef != null && nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT)) + if (nodeRef != null) { - Pair key = getKey(nodeRef.getStoreRef()); - if (cache.contains(key)) + if (nodeService.hasAspect(nodeRef, ASPECT_RECORDS_MANAGEMENT_ROOT)) { - cache.get(key).remove(nodeRef); + Pair key = getKey(nodeRef.getStoreRef()); + if (cache.contains(key)) + { + cache.get(key).remove(nodeRef); + } + } + + if (TYPE_RM_SITE.equals(nodeService.getType(nodeRef))) + { + reset(); } } } From 62ae83a3b6c82118245bfd6913a1dfa226a5597a Mon Sep 17 00:00:00 2001 From: tiagos Date: Wed, 16 Sep 2020 01:10:53 +0100 Subject: [PATCH 11/15] [MNT-21818] Clear cache if site node is deleted (added to RmSiteType behaviour as well) --- .../rm-model-context.xml | 1 + .../type/RecordsManagementContainerType.java | 3 +- .../model/rma/type/RmSiteType.java | 50 ++++++++++++++++++- .../util/RMContainerCacheManager.java | 4 +- 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml index 826f06b1b1..30ce99ce9e 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-model-context.xml @@ -124,6 +124,7 @@ + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java index 633f7cc71a..eb457f3600 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java @@ -226,7 +226,8 @@ public class RecordsManagementContainerType extends BaseBehaviourBean @Override @Behaviour ( - kind = BehaviourKind.ASSOCIATION + kind = BehaviourKind.ASSOCIATION, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT ) public void onDeleteChildAssociation(ChildAssociationRef childAssocRef) { diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java index 76b31f5250..7a0e16a263 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java @@ -39,6 +39,7 @@ import org.alfresco.model.ContentModel; import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService; import org.alfresco.module.org_alfresco_module_rm.model.BaseBehaviourBean; import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService; +import org.alfresco.module.org_alfresco_module_rm.util.RMContainerCacheManager; import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.annotation.Behaviour; @@ -73,7 +74,8 @@ public class RmSiteType extends BaseBehaviourBean implements NodeServicePolicies.OnCreateNodePolicy, NodeServicePolicies.OnUpdatePropertiesPolicy, NodeServicePolicies.BeforeDeleteNodePolicy, - NodeServicePolicies.OnCreateChildAssociationPolicy + NodeServicePolicies.OnCreateChildAssociationPolicy, + NodeServicePolicies.OnDeleteChildAssociationPolicy { /** Constant values */ public static final String COMPONENT_DOCUMENT_LIBRARY = "documentLibrary"; @@ -95,6 +97,9 @@ public class RmSiteType extends BaseBehaviourBean private FilePlanType filePlanType; + /** RM container cache manager **/ + private RMContainerCacheManager rmContainerCacheManager; + /** Map of file plan type's key'ed by corresponding site types */ protected Map mapFilePlanType = new HashMap<>(3); @@ -105,7 +110,7 @@ public class RmSiteType extends BaseBehaviourBean public void setSiteService(SiteService siteService) { this.siteService = siteService; - } + } /** * @param recordsManagementSearchService records management search service @@ -136,6 +141,15 @@ public class RmSiteType extends BaseBehaviourBean this.filePlanType = filePlanType; } + /** + * @param rmContainerCacheManager RM container cache manager + * + */ + public void setRmContainerCacheManager(RMContainerCacheManager rmContainerCacheManager) + { + this.rmContainerCacheManager = rmContainerCacheManager; + } + /** * Registers a file plan type for a specific site type. * @@ -310,6 +324,32 @@ public class RmSiteType extends BaseBehaviourBean } } + /** + * + */ + @Override + @Behaviour + ( + kind = BehaviourKind.ASSOCIATION + ) + public void onDeleteChildAssociation(ChildAssociationRef childAssocRef) + { + AuthenticationUtil.runAsSystem(new RunAsWork() + { + @Override + public Void doWork() + { + // Resets RM Container Cache Manager + if (rmContainerCacheManager != null) + { + rmContainerCacheManager.reset(); + } + + return null; + } + }); + } + /** * Add the limitation of creating only one rma:filePlan or one dod:filePlan depending on the type of rm site. * Let multiple cm:folder type be created under rm site. @@ -347,6 +387,12 @@ public class RmSiteType extends BaseBehaviourBean ) public void onDeleteNodeOnCommit(ChildAssociationRef childAssocRef, boolean isNodeArchived) { + // Resets RM Container Cache Manager + if (rmContainerCacheManager != null) + { + rmContainerCacheManager.reset(); + } + filePlanType.enable(); } } diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java index ac44c661db..62e64e9e31 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java @@ -34,6 +34,7 @@ import org.alfresco.repo.cache.SimpleCache; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.namespace.QName; import org.alfresco.util.Pair; /** @@ -138,7 +139,8 @@ public class RMContainerCacheManager implements RecordsManagementModel } } - if (TYPE_RM_SITE.equals(nodeService.getType(nodeRef))) + QName nodeType = nodeService.getType(nodeRef); + if (TYPE_RM_SITE.isMatch(nodeType) || TYPE_RECORDS_MANAGEMENT_CONTAINER.isMatch(nodeType) || TYPE_FILE_PLAN.isMatch(nodeType)) { reset(); } From 968a50a64055489565c8146de1a23e1f66263f8f Mon Sep 17 00:00:00 2001 From: tiagosalvado10 <9038083+tiagosalvado10@users.noreply.github.com> Date: Wed, 16 Sep 2020 10:32:35 +0100 Subject: [PATCH 12/15] Update RMContainerCacheManager.java Removed unnecessary IF statement logic in RMContainerCacheManager.remove method --- .../util/RMContainerCacheManager.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java index 62e64e9e31..2517198e02 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/util/RMContainerCacheManager.java @@ -138,12 +138,6 @@ public class RMContainerCacheManager implements RecordsManagementModel cache.get(key).remove(nodeRef); } } - - QName nodeType = nodeService.getType(nodeRef); - if (TYPE_RM_SITE.isMatch(nodeType) || TYPE_RECORDS_MANAGEMENT_CONTAINER.isMatch(nodeType) || TYPE_FILE_PLAN.isMatch(nodeType)) - { - reset(); - } } } @@ -165,4 +159,4 @@ public class RMContainerCacheManager implements RecordsManagementModel { return new Pair(storeRef, ASPECT_RECORDS_MANAGEMENT_ROOT.toString()); } -} \ No newline at end of file +} From a6bf69cb7b4a4841bd5983d6154031d3e72141f3 Mon Sep 17 00:00:00 2001 From: tiagos Date: Wed, 16 Sep 2020 11:16:41 +0100 Subject: [PATCH 13/15] [MNT-21818] Added javadoc --- .../rma/type/RecordsManagementContainerType.java | 6 ++++-- .../model/rma/type/RmSiteType.java | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java index eb457f3600..582c6ec1d6 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RecordsManagementContainerType.java @@ -221,7 +221,9 @@ public class RecordsManagementContainerType extends BaseBehaviourBean } /** + * Attempts to remove a deleted node from records management root cache * + * @see org.alfresco.repo.node.NodeServicePolicies.OnDeleteAssociationPolicy#onDeleteAssociation(org.alfresco.service.cmr.repository.AssociationRef) */ @Override @Behaviour @@ -248,9 +250,9 @@ public class RecordsManagementContainerType extends BaseBehaviourBean return null; } }); - } + } - /** + /** * Set the identifier property * * @param nodeRef node reference diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java index 7a0e16a263..c9f6e22ef4 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/type/RmSiteType.java @@ -325,7 +325,11 @@ public class RmSiteType extends BaseBehaviourBean } /** + * Handles site deletion in order to reset the records management root cache * + * @param childAssocRef + * + * @see org.alfresco.repo.node.NodeServicePolicies.OnDeleteAssociationPolicy#onDeleteAssociation(org.alfresco.service.cmr.repository.AssociationRef) */ @Override @Behaviour @@ -379,6 +383,13 @@ public class RmSiteType extends BaseBehaviourBean }); } + /** + * Handles the deletion node policy (alf:onDeleteNode), resetting the records management root cache + * and enabling file plan behavior as well + * + * @param childAssocRef + * @param isNodeArchived + */ @Behaviour ( kind = BehaviourKind.CLASS, From 250a922534de903267ac8a171f3e556d308f0f4e Mon Sep 17 00:00:00 2001 From: alfresco-build Date: Wed, 16 Sep 2020 17:27:23 +0100 Subject: [PATCH 14/15] [maven-release-plugin] prepare release V3.2.0.9 --- pom.xml | 4 ++-- rm-automation/pom.xml | 2 +- rm-automation/rm-automation-community-rest-api/pom.xml | 2 +- rm-community/pom.xml | 2 +- rm-community/rm-community-repo/pom.xml | 2 +- rm-community/rm-community-rest-api-explorer/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 84e0678a2a..e0a1831ad3 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-governance-services pom - 3.2.0.9-SNAPSHOT + 3.2.0.9 Alfresco Governance Services http://www.alfresco.org/ @@ -18,7 +18,7 @@ scm:git:ssh://git@github.com/Alfresco/governance-services.git scm:git:ssh://git@github.com/Alfresco/governance-services.git scm:git:ssh://git@github.com/Alfresco/governance-services.git - HEAD + V3.2.0.9 diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index db98abcbf6..87d3ec5714 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-governance-services - 3.2.0.9-SNAPSHOT + 3.2.0.9 diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index 18173a7c42..baf8bb2977 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-governance-services-automation - 3.2.0.9-SNAPSHOT + 3.2.0.9 diff --git a/rm-community/pom.xml b/rm-community/pom.xml index db9a430ef7..0fda9ff13e 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-governance-services - 3.2.0.9-SNAPSHOT + 3.2.0.9 diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index b56ad58164..d9d2f353aa 100644 --- a/rm-community/rm-community-repo/pom.xml +++ b/rm-community/rm-community-repo/pom.xml @@ -9,7 +9,7 @@ org.alfresco alfresco-governance-services-community - 3.2.0.9-SNAPSHOT + 3.2.0.9 diff --git a/rm-community/rm-community-rest-api-explorer/pom.xml b/rm-community/rm-community-rest-api-explorer/pom.xml index 0446ad2dbb..3414d3eef5 100644 --- a/rm-community/rm-community-rest-api-explorer/pom.xml +++ b/rm-community/rm-community-rest-api-explorer/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-governance-services-community - 3.2.0.9-SNAPSHOT + 3.2.0.9 From 234d1713d365497752fc6571564f60476ff3b92f Mon Sep 17 00:00:00 2001 From: alfresco-build Date: Wed, 16 Sep 2020 17:27:34 +0100 Subject: [PATCH 15/15] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- rm-automation/pom.xml | 2 +- rm-automation/rm-automation-community-rest-api/pom.xml | 2 +- rm-community/pom.xml | 2 +- rm-community/rm-community-repo/pom.xml | 2 +- rm-community/rm-community-rest-api-explorer/pom.xml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index e0a1831ad3..765af0fccd 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.alfresco alfresco-governance-services pom - 3.2.0.9 + 3.2.0.10-SNAPSHOT Alfresco Governance Services http://www.alfresco.org/ @@ -18,7 +18,7 @@ scm:git:ssh://git@github.com/Alfresco/governance-services.git scm:git:ssh://git@github.com/Alfresco/governance-services.git scm:git:ssh://git@github.com/Alfresco/governance-services.git - V3.2.0.9 + HEAD diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index 87d3ec5714..e9c53b055d 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-governance-services - 3.2.0.9 + 3.2.0.10-SNAPSHOT diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index baf8bb2977..55fc702819 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-governance-services-automation - 3.2.0.9 + 3.2.0.10-SNAPSHOT diff --git a/rm-community/pom.xml b/rm-community/pom.xml index 0fda9ff13e..65445490a3 100644 --- a/rm-community/pom.xml +++ b/rm-community/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-governance-services - 3.2.0.9 + 3.2.0.10-SNAPSHOT diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index d9d2f353aa..12788ad0bf 100644 --- a/rm-community/rm-community-repo/pom.xml +++ b/rm-community/rm-community-repo/pom.xml @@ -9,7 +9,7 @@ org.alfresco alfresco-governance-services-community - 3.2.0.9 + 3.2.0.10-SNAPSHOT diff --git a/rm-community/rm-community-rest-api-explorer/pom.xml b/rm-community/rm-community-rest-api-explorer/pom.xml index 3414d3eef5..0661c2ce80 100644 --- a/rm-community/rm-community-rest-api-explorer/pom.xml +++ b/rm-community/rm-community-rest-api-explorer/pom.xml @@ -7,7 +7,7 @@ org.alfresco alfresco-governance-services-community - 3.2.0.9 + 3.2.0.10-SNAPSHOT