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:
Andrew Hind
2009-10-22 10:54:25 +00:00
parent f62a7a886a
commit ca1de03f8b
7 changed files with 570 additions and 143 deletions

View File

@@ -276,7 +276,18 @@
</property> </property>
</bean> </bean>
<bean id="aclDaoComponent" class="org.alfresco.repo.domain.hibernate.AclDaoComponentImpl"> <bean id="aclDaoComponent" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target">
<ref bean="aclDaoComponentImpl" />
</property>
<property name="interceptorNames">
<list>
<value>daoServiceDirtySessionInterceptor</value>
</list>
</property>
</bean>
<bean id="aclDaoComponentImpl" class="org.alfresco.repo.domain.hibernate.AclDaoComponentImpl">
<property name="sessionFactory"> <property name="sessionFactory">
<ref bean="sessionFactory" /> <ref bean="sessionFactory" />
</property> </property>

View File

@@ -31,6 +31,7 @@ import org.alfresco.repo.admin.patch.AbstractPatch;
import org.alfresco.repo.domain.AccessControlListDAO; import org.alfresco.repo.domain.AccessControlListDAO;
import org.alfresco.repo.domain.hibernate.AclDaoComponentImpl; import org.alfresco.repo.domain.hibernate.AclDaoComponentImpl;
import org.alfresco.repo.security.permissions.ACLType; 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;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
@@ -44,7 +45,7 @@ public class DmPermissionsPatch extends AbstractPatch
private AccessControlListDAO accessControlListDao; private AccessControlListDAO accessControlListDao;
private AclDaoComponentImpl aclDaoComponent; private AclDaoComponent aclDaoComponent;
@Override @Override
protected String applyInternal() throws Exception protected String applyInternal() throws Exception
@@ -85,7 +86,7 @@ public class DmPermissionsPatch extends AbstractPatch
* *
* @param aclDaoComponent * @param aclDaoComponent
*/ */
public void setAclDaoComponent(AclDaoComponentImpl aclDaoComponent) public void setAclDaoComponent(AclDaoComponent aclDaoComponent)
{ {
this.aclDaoComponent = aclDaoComponent; this.aclDaoComponent = aclDaoComponent;
} }

View File

@@ -29,9 +29,9 @@ import java.util.List;
import org.alfresco.i18n.I18NUtil; import org.alfresco.i18n.I18NUtil;
import org.alfresco.repo.admin.patch.AbstractPatch; 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.AVMSnapShotTriggeredIndexingMethodInterceptor;
import org.alfresco.repo.search.impl.lucene.AVMLuceneIndexer; 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.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor; import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
@@ -48,7 +48,7 @@ public class WCMPostPermissionSnapshotPatch extends AbstractPatch
AVMService avmService; AVMService avmService;
AclDaoComponentImpl aclDaoComponent; AclDaoComponent aclDaoComponent;
public void setAvmService(AVMService avmService) public void setAvmService(AVMService avmService)
{ {
@@ -60,7 +60,7 @@ public class WCMPostPermissionSnapshotPatch extends AbstractPatch
this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor; this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor;
} }
public void setAclDaoComponent(AclDaoComponentImpl aclDaoComponent) public void setAclDaoComponent(AclDaoComponent aclDaoComponent)
{ {
this.aclDaoComponent = aclDaoComponent; this.aclDaoComponent = aclDaoComponent;
} }

View File

@@ -110,7 +110,7 @@ public class DMAccessControlListDAO implements AccessControlListDAO
{ {
// Nothing to do // Nothing to do
} }
private Node getNodeNotNull(NodeRef nodeRef) private Node getNodeNotNull(NodeRef nodeRef)
{ {
Pair<Long, NodeRef> nodePair = nodeDaoService.getNodePair(nodeRef); Pair<Long, NodeRef> nodePair = nodeDaoService.getNodePair(nodeRef);
@@ -215,25 +215,18 @@ public class DMAccessControlListDAO implements AccessControlListDAO
result.increment(ACLType.DEFINING); result.increment(ACLType.DEFINING);
SimpleAccessControlListProperties properties = DMPermissionsDaoComponentImpl.getDefaultProperties(); SimpleAccessControlListProperties properties = DMPermissionsDaoComponentImpl.getDefaultProperties();
properties.setInherits(existingAcl.getInherits()); properties.setInherits(existingAcl.getInherits());
Long id = aclDaoComponent.createAccessControlList(properties);
DbAccessControlList newAcl = aclDaoComponent.getDbAccessControlList(id);
AccessControlList existing = aclDaoComponent.getAccessControlList(existingAcl.getId()); AccessControlList existing = aclDaoComponent.getAccessControlList(existingAcl.getId());
for (AccessControlEntry entry : existing.getEntries()) Long actuallyInherited = null;
{
if (entry.getPosition() == 0)
{
aclDaoComponent.setAccessControlEntry(id, entry);
}
}
if (existingAcl.getInherits()) if (existingAcl.getInherits())
{ {
if (inherited != null) if (inherited != null)
{ {
aclDaoComponent.enableInheritance(id, inherited); actuallyInherited = inherited;
} }
} }
Long id = aclDaoComponent.createAccessControlList(properties, existing.getEntries(), actuallyInherited);
DbAccessControlList newAcl = aclDaoComponent.getDbAccessControlList(id);
idToInheritFrom = 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 // Only make inherited if required
if(toInherit == null) if (toInherit == null)
{ {
if(idToInheritFrom == null) if (idToInheritFrom == null)
{ {
toInherit = inherited; toInherit = inherited;
} }
@@ -282,6 +278,10 @@ public class DMAccessControlListDAO implements AccessControlListDAO
toInherit = aclDaoComponent.getInheritedAccessControlList(idToInheritFrom); toInherit = aclDaoComponent.getInheritedAccessControlList(idToInheritFrom);
} }
} }
}
for (ChildAssociationRef child : children)
{
if (child.isPrimary()) if (child.isPrimary())
{ {

View File

@@ -39,6 +39,7 @@ import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation; import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.hibernate.Criteria;
import org.hibernate.FlushMode; import org.hibernate.FlushMode;
import org.hibernate.Query; import org.hibernate.Query;
import org.hibernate.Session; import org.hibernate.Session;
@@ -262,6 +263,43 @@ public class DirtySessionMethodInterceptor implements MethodInterceptor
query.setFlushMode(FlushMode.MANUAL); 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. * Manually mark the session as dirty.
*/ */

View File

@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import org.alfresco.repo.domain.DbAccessControlList; 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.domain.hibernate.AclDaoComponentImpl.Indirection;
import org.alfresco.repo.security.permissions.ACLCopyMode; import org.alfresco.repo.security.permissions.ACLCopyMode;
import org.alfresco.repo.security.permissions.AccessControlEntry; import org.alfresco.repo.security.permissions.AccessControlEntry;
@@ -48,6 +49,7 @@ public interface AclDaoComponent extends TransactionalDao
* @param id * @param id
* @return * @return
*/ */
@DirtySessionAnnotation(markDirty=false)
DbAccessControlList getDbAccessControlList(Long id); DbAccessControlList getDbAccessControlList(Long id);
@@ -57,6 +59,7 @@ public interface AclDaoComponent extends TransactionalDao
* @param id * @param id
* @return * @return
*/ */
@DirtySessionAnnotation(markDirty=false)
public AccessControlList getAccessControlList(Long id); public AccessControlList getAccessControlList(Long id);
/** /**
@@ -65,6 +68,7 @@ public interface AclDaoComponent extends TransactionalDao
* @param id * @param id
* @return - the id of all ACLs affected * @return - the id of all ACLs affected
*/ */
@DirtySessionAnnotation(markDirty=false)
public List<AclChange> deleteAccessControlList(Long id); public List<AclChange> deleteAccessControlList(Long id);
/** /**
@@ -73,6 +77,7 @@ public interface AclDaoComponent extends TransactionalDao
* @param id * @param id
* @return - the id of all ACLs affected * @return - the id of all ACLs affected
*/ */
@DirtySessionAnnotation(markDirty=false)
public List<AclChange> deleteLocalAccessControlEntries(Long id); public List<AclChange> deleteLocalAccessControlEntries(Long id);
/** /**
@@ -81,6 +86,7 @@ public interface AclDaoComponent extends TransactionalDao
* @param id * @param id
* @return - the id of all ACLs affected * @return - the id of all ACLs affected
*/ */
@DirtySessionAnnotation(markDirty=false)
public List<AclChange> deleteInheritedAccessControlEntries(Long id); public List<AclChange> deleteInheritedAccessControlEntries(Long id);
/** /**
@@ -89,6 +95,7 @@ public interface AclDaoComponent extends TransactionalDao
* @param authority * @param authority
* @return - the id of all ACLs affected * @return - the id of all ACLs affected
*/ */
@DirtySessionAnnotation(markDirty=false)
public List<AclChange> invalidateAccessControlEntries(String authority); public List<AclChange> invalidateAccessControlEntries(String authority);
/** /**
@@ -97,6 +104,7 @@ public interface AclDaoComponent extends TransactionalDao
* @param authority * @param authority
* @return - the id of all ACLs affected * @return - the id of all ACLs affected
*/ */
@DirtySessionAnnotation(markDirty=false)
public List<AclChange> deleteAccessControlEntries(String authority); public List<AclChange> deleteAccessControlEntries(String authority);
/** /**
@@ -107,6 +115,7 @@ public interface AclDaoComponent extends TransactionalDao
* non null elements are used for the match * non null elements are used for the match
* @return - the id of all ACLs affected * @return - the id of all ACLs affected
*/ */
@DirtySessionAnnotation(markDirty=false)
public List<AclChange> deleteAccessControlEntries(Long id, AccessControlEntry pattern); public List<AclChange> deleteAccessControlEntries(Long id, AccessControlEntry pattern);
/** /**
@@ -116,7 +125,18 @@ public interface AclDaoComponent extends TransactionalDao
* @param ace * @param ace
* @return - the id of all ACLs affected * @return - the id of all ACLs affected
*/ */
@DirtySessionAnnotation(markDirty=false)
public List<AclChange> setAccessControlEntry(Long id, AccessControlEntry ace); 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 * Enable inheritance
@@ -125,6 +145,7 @@ public interface AclDaoComponent extends TransactionalDao
* @param parent * @param parent
* @return * @return
*/ */
@DirtySessionAnnotation(markDirty=false)
public List<AclChange> enableInheritance(Long id, Long parent); public List<AclChange> enableInheritance(Long id, Long parent);
/** /**
@@ -134,6 +155,7 @@ public interface AclDaoComponent extends TransactionalDao
* @param setInheritedOnAcl * @param setInheritedOnAcl
* @return * @return
*/ */
@DirtySessionAnnotation(markDirty=false)
public List<AclChange> disableInheritance(Long id, boolean setInheritedOnAcl); public List<AclChange> disableInheritance(Long id, boolean setInheritedOnAcl);
/** /**
@@ -142,16 +164,21 @@ public interface AclDaoComponent extends TransactionalDao
* @param id * @param id
* @return - the id of all ACLs affected * @return - the id of all ACLs affected
*/ */
@DirtySessionAnnotation(markDirty=false)
public AccessControlListProperties getAccessControlListProperties(Long id); 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 * @param properties
* @return * @return
*/ */
@DirtySessionAnnotation(markDirty=false)
public Long createAccessControlList(AccessControlListProperties properties); 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 * 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 * 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 * @param id
* @return * @return
*/ */
@DirtySessionAnnotation(markDirty=false)
public Long getInheritedAccessControlList(Long id); public Long getInheritedAccessControlList(Long id);
/** /**
@@ -168,23 +196,67 @@ public interface AclDaoComponent extends TransactionalDao
* @param target * @param target
* @return * @return
*/ */
@DirtySessionAnnotation(markDirty=false)
public List<AclChange> mergeInheritedAccessControlList(Long inherited, Long target); public List<AclChange> mergeInheritedAccessControlList(Long inherited, Long target);
@DirtySessionAnnotation(markDirty=false)
public DbAccessControlList getDbAccessControlListCopy(Long toCopy, Long toInheritFrom, ACLCopyMode mode); public DbAccessControlList getDbAccessControlListCopy(Long toCopy, Long toInheritFrom, ACLCopyMode mode);
@DirtySessionAnnotation(markDirty=false)
public Long getCopy(Long toCopy, Long toInheritFrom, ACLCopyMode mode); public Long getCopy(Long toCopy, Long toInheritFrom, ACLCopyMode mode);
@DirtySessionAnnotation(markDirty=false)
public List<Long> getAvmNodesByACL(Long id); public List<Long> getAvmNodesByACL(Long id);
@DirtySessionAnnotation(markDirty=false)
public List<Indirection> getAvmIndirections(); public List<Indirection> getAvmIndirections();
/** /**
* hibernate lifecycle support * hibernate lifecycle support
* @param id * @param id
*/ */
@DirtySessionAnnotation(markDirty=false)
public void onDeleteAccessControlList(final long id); public void onDeleteAccessControlList(final long id);
@DirtySessionAnnotation(markDirty=false)
public void updateAuthority(String before, String after); public void updateAuthority(String before, String after);
@DirtySessionAnnotation(markDirty=false)
public void createAuthority(String authority); 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();
} }