From a612271e6b3b115dc928e90649d639b3364e22c7 Mon Sep 17 00:00:00 2001 From: Jan Vonka Date: Wed, 7 Jul 2010 12:54:55 +0000 Subject: [PATCH] SAIL-373 (SAIL-294): Fix ACL update entity - fix PersonTest.testCreateMissingPeople after r20931 (which enabled the shared ACL entity cache) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@20979 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../ResetWCMToGroupBasedPermissionsPatch.java | 5 +-- .../permissions/AbstractAclCrudDAOImpl.java | 6 ++-- .../repo/domain/permissions/AclCrudDAO.java | 4 +-- .../repo/domain/permissions/AclDAOImpl.java | 24 ++++++------- .../domain/permissions/AclUpdateEntity.java | 36 +++++++++++++++++++ 5 files changed, 56 insertions(+), 19 deletions(-) create mode 100644 source/java/org/alfresco/repo/domain/permissions/AclUpdateEntity.java diff --git a/source/java/org/alfresco/repo/admin/patch/impl/ResetWCMToGroupBasedPermissionsPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/ResetWCMToGroupBasedPermissionsPatch.java index 330df372c9..3f5cefbc71 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/ResetWCMToGroupBasedPermissionsPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/ResetWCMToGroupBasedPermissionsPatch.java @@ -35,6 +35,7 @@ import org.alfresco.repo.domain.avm.AVMStoreDAO; import org.alfresco.repo.domain.patch.PatchDAO; import org.alfresco.repo.domain.permissions.AclCrudDAO; import org.alfresco.repo.domain.permissions.AclEntity; +import org.alfresco.repo.domain.permissions.AclUpdateEntity; import org.alfresco.repo.domain.permissions.Authority; import org.alfresco.repo.domain.permissions.Permission; import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor.StoreType; @@ -1058,14 +1059,14 @@ public class ResetWCMToGroupBasedPermissionsPatch extends MoveWCMToGroupBasedPer private void updateAclInheritsFrom(final long aclId, final long inheritsFromId) throws Exception { - AclEntity aclEntity = aclCrudDAO.getAclForUpdate(aclId); + AclUpdateEntity aclEntity = aclCrudDAO.getAclForUpdate(aclId); aclEntity.setInheritsFrom(inheritsFromId); aclCrudDAO.updateAcl(aclEntity); } private void updateAclInherited(final long aclId, final long inheritedAclId) throws Exception { - AclEntity aclEntity = aclCrudDAO.getAclForUpdate(aclId); + AclUpdateEntity aclEntity = aclCrudDAO.getAclForUpdate(aclId); aclEntity.setInheritedAcl(inheritedAclId); aclCrudDAO.updateAcl(aclEntity); } diff --git a/source/java/org/alfresco/repo/domain/permissions/AbstractAclCrudDAOImpl.java b/source/java/org/alfresco/repo/domain/permissions/AbstractAclCrudDAOImpl.java index 1732c99a05..a50aafb146 100644 --- a/source/java/org/alfresco/repo/domain/permissions/AbstractAclCrudDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/permissions/AbstractAclCrudDAOImpl.java @@ -206,7 +206,7 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO return entityPair.getSecond(); } - public AclEntity getAclForUpdate(long id) + public AclUpdateEntity getAclForUpdate(long id) { AclEntity acl = getAclImpl(id); if (acl == null) @@ -215,7 +215,7 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO } // copy for update - AclEntity aclEntity = new AclEntity(); + AclUpdateEntity aclEntity = new AclUpdateEntity(); aclEntity.setId(acl.getId()); aclEntity.setVersion(acl.getVersion()); aclEntity.setAclChangeSetId(acl.getAclChangeSetId()); @@ -254,7 +254,7 @@ public abstract class AbstractAclCrudDAOImpl implements AclCrudDAO return getAVMNodeEntityIdsByAcl(aclEntityId, maxResults); } - public void updateAcl(AclEntity entity) + public void updateAcl(AclUpdateEntity entity) { ParameterCheck.mandatory("entity", entity); ParameterCheck.mandatory("entity.id", entity.getId()); diff --git a/source/java/org/alfresco/repo/domain/permissions/AclCrudDAO.java b/source/java/org/alfresco/repo/domain/permissions/AclCrudDAO.java index 802c6602cc..8aebe9943f 100644 --- a/source/java/org/alfresco/repo/domain/permissions/AclCrudDAO.java +++ b/source/java/org/alfresco/repo/domain/permissions/AclCrudDAO.java @@ -57,10 +57,10 @@ public interface AclCrudDAO public Acl createAcl(AclEntity entity); public Acl getAcl(long aclEntityId); - public AclEntity getAclForUpdate(long aclEntityId); + public AclUpdateEntity getAclForUpdate(long aclEntityId); public List getAclsThatInheritFromAcl(long aclEntityId); public Long getLatestAclByGuid(String aclGuid); - public void updateAcl(AclEntity entity); + public void updateAcl(AclUpdateEntity entity); public void deleteAcl(long aclEntityId); public List getADMNodesByAcl(long aclEntityId, int maxResults); public List getAVMNodesByAcl(long aclEntityId, int maxResults); diff --git a/source/java/org/alfresco/repo/domain/permissions/AclDAOImpl.java b/source/java/org/alfresco/repo/domain/permissions/AclDAOImpl.java index 79dd20b897..f94b322f3c 100644 --- a/source/java/org/alfresco/repo/domain/permissions/AclDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/permissions/AclDAOImpl.java @@ -423,7 +423,7 @@ public class AclDAOImpl implements AclDAO private AclChange getWritable(final Long id, final Long parent, List exclude, List acesToAdd, Long inheritsFrom, List inherited, List positions, int depth, WriteMode mode, boolean requiresVersion) { - AclEntity acl = (AclEntity)aclCrudDAO.getAcl(id); + AclUpdateEntity acl = aclCrudDAO.getAclForUpdate(id); if (!acl.isLatest()) { aclCache.remove(id); @@ -590,7 +590,7 @@ public class AclDAOImpl implements AclDAO if (parent != null) { Long writableParentAcl = getWritable(parent, null, null, null, null, null, null, 0, WriteMode.COPY_ONLY, false).getAfter(); - AclEntity parentAcl = aclCrudDAO.getAclForUpdate(writableParentAcl); + AclUpdateEntity parentAcl = aclCrudDAO.getAclForUpdate(writableParentAcl); parentAcl.setInheritedAcl(created); aclCrudDAO.updateAcl(parentAcl); } @@ -851,7 +851,7 @@ public class AclDAOImpl implements AclDAO List acls = new ArrayList(); - final AclEntity acl = aclCrudDAO.getAclForUpdate(id); + final AclUpdateEntity acl = aclCrudDAO.getAclForUpdate(id); if (!acl.isLatest()) { throw new UnsupportedOperationException("Old ACL versions can not be updated"); @@ -894,7 +894,7 @@ public class AclDAOImpl implements AclDAO if (inherited.isVersioned()) { - AclEntity inheritedForUpdate = aclCrudDAO.getAclForUpdate(inherited.getId()); + AclUpdateEntity inheritedForUpdate = aclCrudDAO.getAclForUpdate(inherited.getId()); if (inheritedForUpdate != null) { inheritedForUpdate.setLatest(Boolean.FALSE); @@ -1075,7 +1075,7 @@ public class AclDAOImpl implements AclDAO */ public Long getInheritedAccessControlList(Long id) { - AclEntity acl = aclCrudDAO.getAclForUpdate(id); + AclUpdateEntity acl = aclCrudDAO.getAclForUpdate(id); if (acl.getAclType() == ACLType.OLD) { return null; @@ -1260,7 +1260,7 @@ public class AclDAOImpl implements AclDAO { List changes = new ArrayList(); - AclEntity acl = aclCrudDAO.getAclForUpdate(id); + AclUpdateEntity acl = aclCrudDAO.getAclForUpdate(id); switch (acl.getAclType()) { @@ -1305,7 +1305,7 @@ public class AclDAOImpl implements AclDAO */ public List disableInheritance(Long id, boolean setInheritedOnAcl) { - AclEntity acl = aclCrudDAO.getAclForUpdate(id); + AclUpdateEntity acl = aclCrudDAO.getAclForUpdate(id); List changes = new ArrayList(1); switch (acl.getAclType()) { @@ -1330,7 +1330,7 @@ public class AclDAOImpl implements AclDAO private Long getCopy(Long toCopy, Long toInheritFrom, ACLCopyMode mode) { - AclEntity aclToCopy; + AclUpdateEntity aclToCopy; Long inheritedId; Acl aclToInheritFrom; switch (mode) @@ -1352,7 +1352,7 @@ public class AclDAOImpl implements AclDAO inheritedId = getInheritedAccessControlList(toCopy); if ((inheritedId != null) && (!inheritedId.equals(toCopy))) { - AclEntity inheritedAcl = aclCrudDAO.getAclForUpdate(inheritedId); + AclUpdateEntity inheritedAcl = aclCrudDAO.getAclForUpdate(inheritedId); inheritedAcl.setRequiresVersion(true); aclCrudDAO.updateAcl(inheritedAcl); aclCache.remove(inheritedId); @@ -1502,18 +1502,18 @@ public class AclDAOImpl implements AclDAO return acl; } - private List disableInheritanceImpl(Long id, boolean setInheritedOnAcl, AclEntity acl) + private List disableInheritanceImpl(Long id, boolean setInheritedOnAcl, AclEntity aclIn) { List changes = new ArrayList(); - if (!acl.getInherits()) + if (!aclIn.getInherits()) { return Collections. emptyList(); } // Manages caching getWritable(id, null, null, null, null, false, changes, WriteMode.COPY_ONLY); - acl = aclCrudDAO.getAclForUpdate(changes.get(0).getAfter()); + AclUpdateEntity acl = aclCrudDAO.getAclForUpdate(changes.get(0).getAfter()); final Long inheritsFrom = acl.getInheritsFrom(); acl.setInherits(Boolean.FALSE); aclCrudDAO.updateAcl(acl); diff --git a/source/java/org/alfresco/repo/domain/permissions/AclUpdateEntity.java b/source/java/org/alfresco/repo/domain/permissions/AclUpdateEntity.java new file mode 100644 index 0000000000..3fd600b281 --- /dev/null +++ b/source/java/org/alfresco/repo/domain/permissions/AclUpdateEntity.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2005-2010 Alfresco Software Limited. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * aLong with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + * As a special exception to the terms and conditions of version 2.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * and Open Source Software ("FLOSS") applications as described in Alfresco's + * FLOSS exception. You should have recieved a copy of the text describing + * the FLOSS exception, and it is also available here: + * http://www.alfresco.com/legal/licensing" + */ +package org.alfresco.repo.domain.permissions; + + +/** + * Entity for alf_acess_control_list persistence. + * + * @author janv + * @since 3.4 + */ +public class AclUpdateEntity extends AclEntity +{ +}