Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)

59269: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3)
      59268: Merged V4.1-BUG-FIX (4.1.8) to V4.2-BUG-FIX (4.2.1)
         59264: MNT-10237: Merged V4.1.6 (4.1.6.4) to V4.1-BUG-FIX (4.1.8) AGAIN!
            58707: MNT-10109: Merged DEV to PATCHES/V4.1.6 (4.1.6.4)
               58676: MNT-10109: Permissions are not restored when a deleted site is recovered from the trashcan
                  - Delete associated groups on callback when archived site is purged. Add unit test for case.
            58895: MNT-10109: Merged DEV to PATCHES/V4.1.6 (4.1.6.4)
               58855: MNT-10109: Permissions are not restored when a deleted site is recovered from the trashcan
                  - Fix unit tests failure by purging archived sites. Forbid new site creation if site group already exists.
               58871: MNT-10109: Permissions are not restored when a deleted site is recovered from the trashcan
                  - Return beforePurgeNode callback binding to Site class.
            58947: MNT-10109: PATCHES/V4.1.6 (4.1.6.4)
               58946: MNT-10109: Permissions are not restored when a deleted site is recovered from the trashcan
                  - Fix test failures by purging deleted sites from trashcan so that sitename can be reused. Change SiteServiceImplTest to avoid database deadlock.
            58949: MNT-10109: PATCHES/V4.1.6 (4.1.6.4)
               58948: MNT-10109: Permissions are not restored when a deleted site is recovered from the trashcan
                  - Fix test failures by purging deleted sites from trashcan so that sitename can be reused.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@62125 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2014-02-12 01:24:08 +00:00
parent dd04a7ebfa
commit 0144810a6d
16 changed files with 339 additions and 81 deletions

View File

@@ -21,7 +21,9 @@ package org.alfresco.repo.node.archive;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
@@ -35,7 +37,11 @@ import org.alfresco.repo.batch.BatchProcessor;
import org.alfresco.repo.batch.BatchProcessor.BatchProcessWorker;
import org.alfresco.repo.lock.JobLockService;
import org.alfresco.repo.lock.LockAcquisitionException;
import org.alfresco.repo.node.NodeArchiveServicePolicies;
import org.alfresco.repo.node.NodeArchiveServicePolicies.BeforePurgeNodePolicy;
import org.alfresco.repo.node.archive.RestoreNodeReport.RestoreStatus;
import org.alfresco.repo.policy.ClassPolicyDelegate;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.security.permissions.AccessDeniedException;
@@ -86,6 +92,15 @@ public class NodeArchiveServiceImpl implements NodeArchiveService
private TenantService tenantService;
private boolean userNamesAreCaseSensitive = false;
/** controls policy delegates */
private PolicyComponent policyComponent;
private ClassPolicyDelegate<BeforePurgeNodePolicy> beforePurgeNodeDelegate;
public void setPolicyComponent(PolicyComponent policyComponent)
{
this.policyComponent = policyComponent;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
@@ -110,7 +125,13 @@ public class NodeArchiveServiceImpl implements NodeArchiveService
{
this.jobLockService = jobLockService;
}
public void init()
{
// Register the various policies
beforePurgeNodeDelegate = policyComponent.registerClassPolicy(NodeArchiveServicePolicies.BeforePurgeNodePolicy.class);
}
public void setAuthorityService(AuthorityService authorityService)
{
this.authorityService = authorityService;
@@ -474,6 +495,7 @@ public class NodeArchiveServiceImpl implements NodeArchiveService
{
try
{
invokeBeforePurgeNode(archivedNodeRef);
nodeService.deleteNode(archivedNodeRef);
}
catch (InvalidNodeRefException e)
@@ -524,6 +546,7 @@ public class NodeArchiveServiceImpl implements NodeArchiveService
AuthenticationUtil.setFullyAuthenticatedUser(user);
if (nodeService.exists(nodeRef))
{
invokeBeforePurgeNode(nodeRef);
nodeService.deleteNode(nodeRef);
}
}
@@ -748,4 +771,52 @@ public class NodeArchiveServiceImpl implements NodeArchiveService
}
return currentUser;
}
protected void invokeBeforePurgeNode(NodeRef nodeRef)
{
if (ignorePolicy(nodeRef))
{
return;
}
// get qnames to invoke against
Set<QName> qnames = getTypeAndAspectQNames(nodeRef);
// execute policy for node type and aspects
NodeArchiveServicePolicies.BeforePurgeNodePolicy policy = beforePurgeNodeDelegate.get(nodeRef, qnames);
policy.beforePurgeNode(nodeRef);
}
/**
* Get all aspect and node type qualified names
*
* @param nodeRef
* the node we are interested in
* @return Returns a set of qualified names containing the node type and all
* the node aspects, or null if the node no longer exists
*/
protected Set<QName> getTypeAndAspectQNames(NodeRef nodeRef)
{
Set<QName> qnames = null;
try
{
Set<QName> aspectQNames = nodeService.getAspects(nodeRef);
QName typeQName = nodeService.getType(nodeRef);
qnames = new HashSet<QName>(aspectQNames.size() + 1);
qnames.addAll(aspectQNames);
qnames.add(typeQName);
}
catch (InvalidNodeRefException e)
{
qnames = Collections.emptySet();
}
// done
return qnames;
}
private boolean ignorePolicy(NodeRef nodeRef)
{
return false;
}
}