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());