mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.2 to HEAD
17076: Improvements for ETHREEOH-2153: patch.updateDmPermissions takes too long to complete git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17082 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -31,6 +31,7 @@ import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.domain.AccessControlListDAO;
|
||||
import org.alfresco.repo.domain.hibernate.AclDaoComponentImpl;
|
||||
import org.alfresco.repo.security.permissions.ACLType;
|
||||
import org.alfresco.repo.security.permissions.impl.AclDaoComponent;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
|
||||
@@ -44,7 +45,7 @@ public class DmPermissionsPatch extends AbstractPatch
|
||||
|
||||
private AccessControlListDAO accessControlListDao;
|
||||
|
||||
private AclDaoComponentImpl aclDaoComponent;
|
||||
private AclDaoComponent aclDaoComponent;
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
@@ -85,7 +86,7 @@ public class DmPermissionsPatch extends AbstractPatch
|
||||
*
|
||||
* @param aclDaoComponent
|
||||
*/
|
||||
public void setAclDaoComponent(AclDaoComponentImpl aclDaoComponent)
|
||||
public void setAclDaoComponent(AclDaoComponent aclDaoComponent)
|
||||
{
|
||||
this.aclDaoComponent = aclDaoComponent;
|
||||
}
|
||||
|
@@ -29,9 +29,9 @@ import java.util.List;
|
||||
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.domain.hibernate.AclDaoComponentImpl;
|
||||
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor;
|
||||
import org.alfresco.repo.search.impl.lucene.AVMLuceneIndexer;
|
||||
import org.alfresco.repo.security.permissions.impl.AclDaoComponent;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class WCMPostPermissionSnapshotPatch extends AbstractPatch
|
||||
|
||||
AVMService avmService;
|
||||
|
||||
AclDaoComponentImpl aclDaoComponent;
|
||||
AclDaoComponent aclDaoComponent;
|
||||
|
||||
public void setAvmService(AVMService avmService)
|
||||
{
|
||||
@@ -60,7 +60,7 @@ public class WCMPostPermissionSnapshotPatch extends AbstractPatch
|
||||
this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor;
|
||||
}
|
||||
|
||||
public void setAclDaoComponent(AclDaoComponentImpl aclDaoComponent)
|
||||
public void setAclDaoComponent(AclDaoComponent aclDaoComponent)
|
||||
{
|
||||
this.aclDaoComponent = aclDaoComponent;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -110,7 +110,7 @@ public class DMAccessControlListDAO implements AccessControlListDAO
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
|
||||
private Node getNodeNotNull(NodeRef nodeRef)
|
||||
{
|
||||
Pair<Long, NodeRef> nodePair = nodeDaoService.getNodePair(nodeRef);
|
||||
@@ -215,25 +215,18 @@ public class DMAccessControlListDAO implements AccessControlListDAO
|
||||
result.increment(ACLType.DEFINING);
|
||||
SimpleAccessControlListProperties properties = DMPermissionsDaoComponentImpl.getDefaultProperties();
|
||||
properties.setInherits(existingAcl.getInherits());
|
||||
Long id = aclDaoComponent.createAccessControlList(properties);
|
||||
|
||||
DbAccessControlList newAcl = aclDaoComponent.getDbAccessControlList(id);
|
||||
|
||||
AccessControlList existing = aclDaoComponent.getAccessControlList(existingAcl.getId());
|
||||
for (AccessControlEntry entry : existing.getEntries())
|
||||
{
|
||||
if (entry.getPosition() == 0)
|
||||
{
|
||||
aclDaoComponent.setAccessControlEntry(id, entry);
|
||||
}
|
||||
}
|
||||
Long actuallyInherited = null;
|
||||
if (existingAcl.getInherits())
|
||||
{
|
||||
if (inherited != null)
|
||||
{
|
||||
aclDaoComponent.enableInheritance(id, inherited);
|
||||
actuallyInherited = inherited;
|
||||
}
|
||||
}
|
||||
Long id = aclDaoComponent.createAccessControlList(properties, existing.getEntries(), actuallyInherited);
|
||||
|
||||
DbAccessControlList newAcl = aclDaoComponent.getDbAccessControlList(id);
|
||||
|
||||
idToInheritFrom = id;
|
||||
|
||||
@@ -268,12 +261,15 @@ public class DMAccessControlListDAO implements AccessControlListDAO
|
||||
}
|
||||
}
|
||||
|
||||
for (ChildAssociationRef child : nodeService.getChildAssocs(nodeRef))
|
||||
List<ChildAssociationRef> children = nodeService.getChildAssocs(nodeRef);
|
||||
if (children.size() > 0)
|
||||
{
|
||||
hibernateSessionHelper.reset();
|
||||
|
||||
// Only make inherited if required
|
||||
if(toInherit == null)
|
||||
if (toInherit == null)
|
||||
{
|
||||
if(idToInheritFrom == null)
|
||||
if (idToInheritFrom == null)
|
||||
{
|
||||
toInherit = inherited;
|
||||
}
|
||||
@@ -282,6 +278,10 @@ public class DMAccessControlListDAO implements AccessControlListDAO
|
||||
toInherit = aclDaoComponent.getInheritedAccessControlList(idToInheritFrom);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for (ChildAssociationRef child : children)
|
||||
{
|
||||
|
||||
if (child.isPrimary())
|
||||
{
|
||||
|
@@ -39,6 +39,7 @@ import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
@@ -262,6 +263,43 @@ public class DirtySessionMethodInterceptor implements MethodInterceptor
|
||||
query.setFlushMode(FlushMode.MANUAL);
|
||||
}
|
||||
|
||||
public static void setCriteriaFlushMode(Session session, Criteria criteria)
|
||||
{
|
||||
FlushData flushData = DirtySessionMethodInterceptor.getFlushData();
|
||||
|
||||
// If all the methods in the method stack are annotated, then we can adjust the query and
|
||||
// play with the session
|
||||
if (!flushData.isStackAnnotated())
|
||||
{
|
||||
if (loggerDebugEnabled)
|
||||
{
|
||||
logger.debug(
|
||||
"Method stack is not annotated. Not setting query flush mode: \n" +
|
||||
" Flush Data: " + flushData);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// The stack is fully annotated, so flush if required and set the flush mode on the query
|
||||
if (loggerDebugEnabled)
|
||||
{
|
||||
logger.debug(
|
||||
"Setting query flush mode: \n" +
|
||||
" Criteria: " + criteria.toString() + "\n" +
|
||||
" Dirty: " + flushData);
|
||||
}
|
||||
|
||||
if (flushData.isDirty())
|
||||
{
|
||||
// Flush the session
|
||||
session.flush();
|
||||
// Reset the dirty state
|
||||
flushData.resetDirtyCount();
|
||||
}
|
||||
// Adjust the query flush mode
|
||||
criteria.setFlushMode(FlushMode.MANUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually mark the session as dirty.
|
||||
*/
|
||||
|
@@ -28,6 +28,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.domain.DbAccessControlList;
|
||||
import org.alfresco.repo.domain.hibernate.DirtySessionAnnotation;
|
||||
import org.alfresco.repo.domain.hibernate.AclDaoComponentImpl.Indirection;
|
||||
import org.alfresco.repo.security.permissions.ACLCopyMode;
|
||||
import org.alfresco.repo.security.permissions.AccessControlEntry;
|
||||
@@ -48,6 +49,7 @@ public interface AclDaoComponent extends TransactionalDao
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
DbAccessControlList getDbAccessControlList(Long id);
|
||||
|
||||
|
||||
@@ -57,6 +59,7 @@ public interface AclDaoComponent extends TransactionalDao
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public AccessControlList getAccessControlList(Long id);
|
||||
|
||||
/**
|
||||
@@ -65,6 +68,7 @@ public interface AclDaoComponent extends TransactionalDao
|
||||
* @param id
|
||||
* @return - the id of all ACLs affected
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public List<AclChange> deleteAccessControlList(Long id);
|
||||
|
||||
/**
|
||||
@@ -73,6 +77,7 @@ public interface AclDaoComponent extends TransactionalDao
|
||||
* @param id
|
||||
* @return - the id of all ACLs affected
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public List<AclChange> deleteLocalAccessControlEntries(Long id);
|
||||
|
||||
/**
|
||||
@@ -81,6 +86,7 @@ public interface AclDaoComponent extends TransactionalDao
|
||||
* @param id
|
||||
* @return - the id of all ACLs affected
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public List<AclChange> deleteInheritedAccessControlEntries(Long id);
|
||||
|
||||
/**
|
||||
@@ -89,6 +95,7 @@ public interface AclDaoComponent extends TransactionalDao
|
||||
* @param authority
|
||||
* @return - the id of all ACLs affected
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public List<AclChange> invalidateAccessControlEntries(String authority);
|
||||
|
||||
/**
|
||||
@@ -97,6 +104,7 @@ public interface AclDaoComponent extends TransactionalDao
|
||||
* @param authority
|
||||
* @return - the id of all ACLs affected
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public List<AclChange> deleteAccessControlEntries(String authority);
|
||||
|
||||
/**
|
||||
@@ -107,6 +115,7 @@ public interface AclDaoComponent extends TransactionalDao
|
||||
* non null elements are used for the match
|
||||
* @return - the id of all ACLs affected
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public List<AclChange> deleteAccessControlEntries(Long id, AccessControlEntry pattern);
|
||||
|
||||
/**
|
||||
@@ -116,7 +125,18 @@ public interface AclDaoComponent extends TransactionalDao
|
||||
* @param ace
|
||||
* @return - the id of all ACLs affected
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public List<AclChange> setAccessControlEntry(Long id, AccessControlEntry ace);
|
||||
|
||||
/**
|
||||
* Add an access control entry
|
||||
*
|
||||
* @param id
|
||||
* @param ace
|
||||
* @return - the id of all ACLs affected
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public List<AclChange> setAccessControlEntries(Long id, List<AccessControlEntry> aces);
|
||||
|
||||
/**
|
||||
* Enable inheritance
|
||||
@@ -125,6 +145,7 @@ public interface AclDaoComponent extends TransactionalDao
|
||||
* @param parent
|
||||
* @return
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public List<AclChange> enableInheritance(Long id, Long parent);
|
||||
|
||||
/**
|
||||
@@ -134,6 +155,7 @@ public interface AclDaoComponent extends TransactionalDao
|
||||
* @param setInheritedOnAcl
|
||||
* @return
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public List<AclChange> disableInheritance(Long id, boolean setInheritedOnAcl);
|
||||
|
||||
/**
|
||||
@@ -142,16 +164,21 @@ public interface AclDaoComponent extends TransactionalDao
|
||||
* @param id
|
||||
* @return - the id of all ACLs affected
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public AccessControlListProperties getAccessControlListProperties(Long id);
|
||||
|
||||
/**
|
||||
* Create a bew ACL with teh given properties. Unset ones are assigned defaults.
|
||||
* Create a new ACL with the given properties. Unset properties are assigned defaults.
|
||||
*
|
||||
* @param properties
|
||||
* @return
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public Long createAccessControlList(AccessControlListProperties properties);
|
||||
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public Long createAccessControlList(AccessControlListProperties properties, List<AccessControlEntry> aces, Long inherited);
|
||||
|
||||
/**
|
||||
* Get the id of the ACL inherited from the one given
|
||||
* May return null if there is nothing to inherit -> OLD world where nodes have thier own ACL and we wlak the parent chain
|
||||
@@ -159,6 +186,7 @@ public interface AclDaoComponent extends TransactionalDao
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public Long getInheritedAccessControlList(Long id);
|
||||
|
||||
/**
|
||||
@@ -168,23 +196,67 @@ public interface AclDaoComponent extends TransactionalDao
|
||||
* @param target
|
||||
* @return
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public List<AclChange> mergeInheritedAccessControlList(Long inherited, Long target);
|
||||
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public DbAccessControlList getDbAccessControlListCopy(Long toCopy, Long toInheritFrom, ACLCopyMode mode);
|
||||
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public Long getCopy(Long toCopy, Long toInheritFrom, ACLCopyMode mode);
|
||||
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public List<Long> getAvmNodesByACL(Long id);
|
||||
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public List<Indirection> getAvmIndirections();
|
||||
|
||||
/**
|
||||
* hibernate lifecycle support
|
||||
* @param id
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public void onDeleteAccessControlList(final long id);
|
||||
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public void updateAuthority(String before, String after);
|
||||
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
public void createAuthority(String authority);
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
boolean supportsProgressTracking();
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
Long getDmNodeCount();
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
Long getMaxAclId();
|
||||
|
||||
|
||||
/**
|
||||
* @param max
|
||||
* @return
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
Long getDmNodeCountWithNewACLS(Long max);
|
||||
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@DirtySessionAnnotation(markDirty=false)
|
||||
Long getNewInStore();
|
||||
}
|
||||
|
Reference in New Issue
Block a user