From 1d30c027ad7967c496f22ef75c07d0d591e85035 Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Sat, 31 Jan 2015 11:52:55 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud) 92529: Merged 5.0.N (5.0.1) to HEAD-BUG-FIX (5.1/Cloud) 92463: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.1) 92370: Merged V4.1-BUG-FIX (4.1.10) to V4.2-BUG-FIX (4.2.5) 92314: Merged DEV to V4.1-BUG-FIX (4.1.10) 92170 : MNT-2118 : Share inconsistencies when displaying locked files with tags - Ignore working copies at search for tags 92132 : MNT-2118 : Share inconsistencies when displaying locked files with tags - Restore number of tag at check out 92146 : MNT-2118 : Share inconsistencies when displaying locked files with tags - Test failure fixed git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@94888 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/tagging/TaggingServiceImpl.java | 17 ++++++++++++++++- .../repo/tagging/TaggingServiceImplTest.java | 4 ++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/source/java/org/alfresco/repo/tagging/TaggingServiceImpl.java b/source/java/org/alfresco/repo/tagging/TaggingServiceImpl.java index fe910eb224..a5994d1782 100644 --- a/source/java/org/alfresco/repo/tagging/TaggingServiceImpl.java +++ b/source/java/org/alfresco/repo/tagging/TaggingServiceImpl.java @@ -42,6 +42,7 @@ import org.alfresco.query.EmptyPagingResults; import org.alfresco.query.PagingRequest; import org.alfresco.query.PagingResults; import org.alfresco.repo.audit.AuditComponent; +import org.alfresco.repo.coci.CheckOutCheckInServicePolicies; import org.alfresco.repo.copy.CopyServicePolicies; import org.alfresco.repo.copy.CopyServicePolicies.BeforeCopyPolicy; import org.alfresco.repo.copy.CopyServicePolicies.OnCopyCompletePolicy; @@ -238,6 +239,11 @@ public class TaggingServiceImpl implements TaggingService, OnCopyCompletePolicy.QNAME, ContentModel.ASPECT_TAGGABLE, new JavaBehaviour(this, "onCopyComplete", NotificationFrequency.EVERY_EVENT)); + + this.policyComponent.bindClassBehaviour( + CheckOutCheckInServicePolicies.OnCheckOut.QNAME, + ContentModel.ASPECT_TAGGABLE, + new JavaBehaviour(this, "afterCheckOut", NotificationFrequency.EVERY_EVENT)); } /** @@ -298,7 +304,7 @@ public class TaggingServiceImpl implements TaggingService, public void beforeDeleteNode(NodeRef nodeRef) { if (this.nodeService.exists(nodeRef) == true && - this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TAGGABLE) == true) + this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TAGGABLE) == true && !this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) { updateAllScopeTags(nodeRef, Boolean.FALSE); } @@ -1507,5 +1513,14 @@ public class TaggingServiceImpl implements TaggingService, public void flush() { } + + public void afterCheckOut(NodeRef workingCopy) + { + if (this.nodeService.exists(workingCopy) == true && this.nodeService.hasAspect(workingCopy, ContentModel.ASPECT_TAGGABLE) == true + && this.nodeService.hasAspect(workingCopy, ContentModel.ASPECT_WORKING_COPY)) + { + updateAllScopeTags(workingCopy, Boolean.FALSE); + } + } } diff --git a/source/test-java/org/alfresco/repo/tagging/TaggingServiceImplTest.java b/source/test-java/org/alfresco/repo/tagging/TaggingServiceImplTest.java index 2d5f5379e3..c6bcc589a2 100644 --- a/source/test-java/org/alfresco/repo/tagging/TaggingServiceImplTest.java +++ b/source/test-java/org/alfresco/repo/tagging/TaggingServiceImplTest.java @@ -1175,8 +1175,8 @@ public class TaggingServiceImplTest extends TestCase assertEquals(3, taggingService.findTagScope(testData.container1).getTags().size()); assertEquals(0, taggingService.findTagScope(testData.container2).getTags().size()); - assertEquals(3, taggingService.findTagScope(testData.container1).getTag("foo1").getCount()); - assertEquals(2, taggingService.findTagScope(testData.container1).getTag("foo2").getCount()); + assertEquals(2, taggingService.findTagScope(testData.container1).getTag("foo1").getCount()); + assertEquals(1, taggingService.findTagScope(testData.container1).getTag("foo2").getCount()); assertEquals(1, taggingService.findTagScope(testData.container1).getTag("foo3").getCount()); assertEquals(1, nodeService.getChildAssocs(testData.container1).size());