mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
61345: Merged V4.2-BUG-FIX (4.2.2) to HEAD-BUG-FIX (Cloud/4.3) 61071: Merged DEV to V4.2-BUG-FIX (4.2.2) 60764: MNT-10533: Calls during the beforeDeleteNode phase of a group deletion may confuse the AuthorityDaoImpl cache - First delete authority and refresh cache only after that git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@62407 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -424,11 +424,12 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
|
|||||||
}
|
}
|
||||||
zoneAuthorityCache.remove(new Pair<String, String>(currentUserDomain, null));
|
zoneAuthorityCache.remove(new Pair<String, String>(currentUserDomain, null));
|
||||||
removeParentsFromChildAuthorityCache(nodeRef, false);
|
removeParentsFromChildAuthorityCache(nodeRef, false);
|
||||||
|
|
||||||
|
nodeService.deleteNode(nodeRef);
|
||||||
|
|
||||||
authorityLookupCache.remove(cacheKey(name));
|
authorityLookupCache.remove(cacheKey(name));
|
||||||
userAuthorityCache.clear();
|
userAuthorityCache.clear();
|
||||||
authorityBridgeTableCache.refresh();
|
authorityBridgeTableCache.refresh();
|
||||||
|
|
||||||
nodeService.deleteNode(nodeRef);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PagingResults<AuthorityInfo> getAuthoritiesInfo(AuthorityType type, String zoneName, String displayNameFilter, String sortBy, boolean sortAscending, PagingRequest pagingRequest)
|
public PagingResults<AuthorityInfo> getAuthoritiesInfo(AuthorityType type, String zoneName, String displayNameFilter, String sortBy, boolean sortAscending, PagingRequest pagingRequest)
|
||||||
|
@@ -39,7 +39,10 @@ import org.alfresco.model.ContentModel;
|
|||||||
import org.alfresco.query.PagingRequest;
|
import org.alfresco.query.PagingRequest;
|
||||||
import org.alfresco.query.PagingResults;
|
import org.alfresco.query.PagingResults;
|
||||||
import org.alfresco.repo.domain.permissions.AclDAO;
|
import org.alfresco.repo.domain.permissions.AclDAO;
|
||||||
|
import org.alfresco.repo.node.NodeServicePolicies;
|
||||||
import org.alfresco.repo.node.archive.NodeArchiveService;
|
import org.alfresco.repo.node.archive.NodeArchiveService;
|
||||||
|
import org.alfresco.repo.policy.JavaBehaviour;
|
||||||
|
import org.alfresco.repo.policy.PolicyComponent;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
||||||
@@ -57,6 +60,7 @@ import org.alfresco.service.cmr.security.MutableAuthenticationService;
|
|||||||
import org.alfresco.service.cmr.security.PermissionService;
|
import org.alfresco.service.cmr.security.PermissionService;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
import org.alfresco.service.cmr.site.SiteService;
|
import org.alfresco.service.cmr.site.SiteService;
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
@@ -81,6 +85,8 @@ public class AuthorityServiceTest extends TestCase
|
|||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private AuthorityBridgeTableAsynchronouslyRefreshedCache authorityBridgeTableCache;
|
private AuthorityBridgeTableAsynchronouslyRefreshedCache authorityBridgeTableCache;
|
||||||
private NodeArchiveService nodeArchiveService;
|
private NodeArchiveService nodeArchiveService;
|
||||||
|
private PolicyComponent policyComponent;
|
||||||
|
private TransactionService transactionService;
|
||||||
|
|
||||||
public AuthorityServiceTest()
|
public AuthorityServiceTest()
|
||||||
{
|
{
|
||||||
@@ -114,6 +120,8 @@ public class AuthorityServiceTest extends TestCase
|
|||||||
nodeService = (NodeService) ctx.getBean("nodeService");
|
nodeService = (NodeService) ctx.getBean("nodeService");
|
||||||
authorityBridgeTableCache = (AuthorityBridgeTableAsynchronouslyRefreshedCache) ctx.getBean("authorityBridgeTableCache");
|
authorityBridgeTableCache = (AuthorityBridgeTableAsynchronouslyRefreshedCache) ctx.getBean("authorityBridgeTableCache");
|
||||||
nodeArchiveService = (NodeArchiveService) ctx.getBean("nodeArchiveService");
|
nodeArchiveService = (NodeArchiveService) ctx.getBean("nodeArchiveService");
|
||||||
|
policyComponent = (PolicyComponent) ctx.getBean("policyComponent");
|
||||||
|
transactionService = (TransactionService) ctx.getBean(ServiceRegistry.TRANSACTION_SERVICE.getLocalName());
|
||||||
|
|
||||||
String defaultAdminUser = AuthenticationUtil.getAdminUserName();
|
String defaultAdminUser = AuthenticationUtil.getAdminUserName();
|
||||||
AuthenticationUtil.setFullyAuthenticatedUser(defaultAdminUser);
|
AuthenticationUtil.setFullyAuthenticatedUser(defaultAdminUser);
|
||||||
@@ -127,7 +135,6 @@ public class AuthorityServiceTest extends TestCase
|
|||||||
GRP_CNT = DEFAULT_GRP_CNT + (DEFAULT_SITE_GRP_CNT * SITE_CNT);
|
GRP_CNT = DEFAULT_GRP_CNT + (DEFAULT_SITE_GRP_CNT * SITE_CNT);
|
||||||
ROOT_GRP_CNT = DEFAULT_GRP_CNT + (DEFAULT_SITE_ROOT_GRP_CNT * SITE_CNT);
|
ROOT_GRP_CNT = DEFAULT_GRP_CNT + (DEFAULT_SITE_ROOT_GRP_CNT * SITE_CNT);
|
||||||
|
|
||||||
TransactionService transactionService = (TransactionService) ctx.getBean(ServiceRegistry.TRANSACTION_SERVICE.getLocalName());
|
|
||||||
tx = transactionService.getUserTransaction();
|
tx = transactionService.getUserTransaction();
|
||||||
tx.begin();
|
tx.begin();
|
||||||
for (String user : getAllAuthorities(AuthorityType.USER))
|
for (String user : getAllAuthorities(AuthorityType.USER))
|
||||||
@@ -193,6 +200,45 @@ public class AuthorityServiceTest extends TestCase
|
|||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testMNT10533() throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
String GROUP_NAME = "testMNT10533";
|
||||||
|
String GROUP_FULL_NAME = "GROUP_" + GROUP_NAME;
|
||||||
|
|
||||||
|
policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"), ContentModel.TYPE_AUTHORITY_CONTAINER, new JavaBehaviour(
|
||||||
|
new GroupBehaviour(), "beforeDeleteNode"));
|
||||||
|
|
||||||
|
UserTransaction transaction = null;
|
||||||
|
|
||||||
|
transaction = transactionService.getUserTransaction();
|
||||||
|
transaction.begin();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
authorityService.createAuthority(AuthorityType.GROUP, GROUP_NAME);
|
||||||
|
|
||||||
|
assertNotNull(authorityService.getAuthorityNodeRef(GROUP_FULL_NAME));
|
||||||
|
authorityService.deleteAuthority(GROUP_FULL_NAME);
|
||||||
|
assertNull(authorityService.getAuthorityNodeRef(GROUP_FULL_NAME));
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
transaction.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GroupBehaviour implements NodeServicePolicies.BeforeDeleteNodePolicy
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeDeleteNode(NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_AUTHORITY_NAME);
|
||||||
|
// this call refills the authority cache
|
||||||
|
System.out.println("removing " + authorityService.getAuthorityNodeRef(name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testZones()
|
public void testZones()
|
||||||
{
|
{
|
||||||
assertNull(pubAuthorityService.getAuthorityZones("GROUP_DEFAULT"));
|
assertNull(pubAuthorityService.getAuthorityZones("GROUP_DEFAULT"));
|
||||||
|
Reference in New Issue
Block a user