From 06cc11ae36ad19a8d2568812ef9ef7acbe3a593b Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Fri, 11 Mar 2016 22:25:32 +0000 Subject: [PATCH] Merged 5.1.N (5.1.1) to HEAD (5.2) 122216 rneamtu: Merged 5.0.N (5.0.4) to 5.1.N (5.1.1) 122101 cturlica: Merged V4.2-BUG-FIX (4.2.7) to 5.0.N (5.0.4) 122078 amukha: MNT-15654: Un-sharing updates the modified properties of a file - Disabled audit during unshare. - Added JUnit test. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@123657 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../quickshare/QuickShareServiceImpl.java | 18 +++++++--- .../QuickShareServiceIntegrationTest.java | 35 +++++++++++++++++-- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/source/java/org/alfresco/repo/quickshare/QuickShareServiceImpl.java b/source/java/org/alfresco/repo/quickshare/QuickShareServiceImpl.java index 34e714480c..b8a2c99f56 100644 --- a/source/java/org/alfresco/repo/quickshare/QuickShareServiceImpl.java +++ b/source/java/org/alfresco/repo/quickshare/QuickShareServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2014 Alfresco Software Limited. + * Copyright (C) 2005-2016 Alfresco Software Limited. * * This file is part of Alfresco * @@ -535,9 +535,19 @@ public class QuickShareServiceImpl implements QuickShareService, NodeServicePoli { logger.warn("SharedId mismatch: expected="+sharedId+",actual="+nodeSharedId); } - - nodeService.removeAspect(nodeRef, QuickShareModel.ASPECT_QSHARE); - + + // Disable audit to preserve modifier and modified date + // And not to create version + // see MNT-15654 + behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE); + try + { + nodeService.removeAspect(nodeRef, QuickShareModel.ASPECT_QSHARE); + } + finally + { + behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE); + } return null; } }, tenantDomain); diff --git a/source/test-java/org/alfresco/repo/quickshare/QuickShareServiceIntegrationTest.java b/source/test-java/org/alfresco/repo/quickshare/QuickShareServiceIntegrationTest.java index 6dcb1544fc..4dd57d10a5 100644 --- a/source/test-java/org/alfresco/repo/quickshare/QuickShareServiceIntegrationTest.java +++ b/source/test-java/org/alfresco/repo/quickshare/QuickShareServiceIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2014 Alfresco Software Limited. + * Copyright (C) 2005-2016 Alfresco Software Limited. * * This file is part of Alfresco * @@ -431,5 +431,36 @@ public class QuickShareServiceIntegrationTest } }); } - + + /** + * Test for MNT-15654 + *

The node is created and shared by user1. Then unshared by user2 + *

The modifier should not change to user2 after unsharing. + */ + @Test + public void testModifierAfterUnSharing() + { + AuthenticationUtil.runAs(new RunAsWork(){ + @Override + public Void doWork() throws Exception + { + permissionService.setPermission(testNode, user2.getUsername(), PermissionService.CONSUMER, true); + return null; + } + }, user1.getUsername()); + + QuickShareDTO dto = share(testNode, user1.getUsername()); + unshare(dto.getId(), user2.getUsername()); + + String modifier = AuthenticationUtil.runAsSystem(new RunAsWork(){ + @Override + public String doWork() throws Exception + { + return (String )nodeService.getProperty(testNode, ContentModel.PROP_MODIFIER); + } + }); + + assertEquals("The modifier has changed after sharing.", user1.getUsername(), modifier); + } + }