mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix for ALF-3142: CLONE - patch.updateDmPermissions takes too long to complete
- final improvements and fix progress report git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22040 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -354,6 +354,13 @@
|
||||
</isGreaterThan>
|
||||
</update>
|
||||
|
||||
<update id="update_NodePatchAcl" parameterClass="NodeUpdate">
|
||||
update alf_node set
|
||||
<isEqual property="updateAclId" compareValue="true" > acl_id = #aclId#</isEqual>
|
||||
where
|
||||
id = #id#
|
||||
</update>
|
||||
|
||||
<update id="update_ChildAssocsUniqueName" parameterClass="ChildAssoc">
|
||||
update alf_child_assoc set
|
||||
child_node_name_crc = #childNodeNameCrc#,
|
||||
|
@@ -298,7 +298,7 @@
|
||||
</select>
|
||||
|
||||
<!-- for patch -->
|
||||
<select id="select_DmNodeCount">
|
||||
<select id="select_DmNodeCount" resultClass="long">
|
||||
select
|
||||
count(*)
|
||||
from
|
||||
@@ -306,7 +306,7 @@
|
||||
</select>
|
||||
|
||||
<!-- for patch -->
|
||||
<select id="select_DmNodeCountWherePermissionsHaveChanged" parameterMap="parameter_IdMap">
|
||||
<select id="select_DmNodeCountWherePermissionsHaveChanged" parameterMap="parameter_IdMap" resultClass="long">
|
||||
select
|
||||
count(*)
|
||||
from
|
||||
|
@@ -1418,6 +1418,17 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
||||
invalidateCachesByNodeId(primaryParentNodeId, null, nodesCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNodeDefiningAclId(Long nodeId, long aclId)
|
||||
{
|
||||
NodeUpdateEntity nodeUpdateEntity = new NodeUpdateEntity();
|
||||
nodeUpdateEntity.setId(nodeId);
|
||||
nodeUpdateEntity.setAclId(aclId);
|
||||
nodeUpdateEntity.setUpdateAclId(true);
|
||||
updateNodePatchAcl(nodeUpdateEntity);
|
||||
invalidateCachesByNodeId(null, nodeId, nodesCache);
|
||||
}
|
||||
|
||||
public void deleteNode(Long nodeId)
|
||||
{
|
||||
Node node = getNodeNotNull(nodeId);
|
||||
@@ -3161,6 +3172,7 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
|
||||
protected abstract int updateStoreRoot(StoreEntity store);
|
||||
protected abstract Long insertNode(NodeEntity node);
|
||||
protected abstract int updateNode(NodeUpdateEntity nodeUpdate);
|
||||
protected abstract int updateNodePatchAcl(NodeUpdateEntity nodeUpdate);
|
||||
protected abstract void updatePrimaryChildrenSharedAclId(
|
||||
Long primaryParentNodeId,
|
||||
Long optionalOldSharedAlcIdInAdditionToNull,
|
||||
|
@@ -630,4 +630,12 @@ public interface NodeDAO extends NodeBulkLoader
|
||||
Serializable nodeValue,
|
||||
ChildAssocRefQueryCallback resultsCallback);
|
||||
|
||||
/**
|
||||
* Used in ACL upgrade only to set the acl id with mimimal overhead
|
||||
*
|
||||
* @param nodeId
|
||||
* @param id
|
||||
*/
|
||||
public void setNodeDefiningAclId(Long nodeId, long id);
|
||||
|
||||
}
|
||||
|
@@ -85,6 +85,7 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl
|
||||
private static final String SELECT_STORE_ROOT_NODE_BY_REF = "alfresco.node.select_StoreRootNodeByRef";
|
||||
private static final String INSERT_NODE = "alfresco.node.insert_Node";
|
||||
private static final String UPDATE_NODE = "alfresco.node.update_Node";
|
||||
private static final String UPDATE_NODE_PATCH_ACL = "alfresco.node.update_NodePatchAcl";
|
||||
private static final String DELETE_NODE_BY_ID = "alfresco.node.delete_NodeById";
|
||||
private static final String SELECT_NODE_BY_ID = "alfresco.node.select_NodeById";
|
||||
private static final String SELECT_NODE_BY_NODEREF = "alfresco.node.select_NodeByNodeRef";
|
||||
@@ -284,6 +285,12 @@ public class NodeDAOImpl extends AbstractNodeDAOImpl
|
||||
return template.update(UPDATE_NODE, nodeUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int updateNodePatchAcl(NodeUpdateEntity nodeUpdate)
|
||||
{
|
||||
return template.update(UPDATE_NODE_PATCH_ACL, nodeUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updatePrimaryChildrenSharedAclId(
|
||||
Long primaryParentNodeId,
|
||||
|
@@ -133,7 +133,8 @@ public class ADMAccessControlListDAO implements AccessControlListDAO
|
||||
if (!pair.getSecond().getProtocol().equals(StoreRef.PROTOCOL_AVM))
|
||||
{
|
||||
CounterSet update;
|
||||
update = fixOldDmAcls(nodeDAO.getRootNode(pair.getSecond()).getFirst(), (Long)null, true);
|
||||
Long rootNodeId = nodeDAO.getRootNode(pair.getSecond()).getFirst();
|
||||
update = fixOldDmAcls(rootNodeId, nodeDAO.getNodeAclId(rootNodeId), (Long)null, true);
|
||||
result.add(update);
|
||||
}
|
||||
}
|
||||
@@ -148,91 +149,92 @@ public class ADMAccessControlListDAO implements AccessControlListDAO
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private CounterSet fixOldDmAcls(Long nodeId, Long inherited, boolean isRoot)
|
||||
{
|
||||
return fixOldDmAclsImpl(nodeId, inherited, isRoot);
|
||||
}
|
||||
|
||||
private CounterSet fixOldDmAclsImpl(Long nodeId, Long inherited, boolean isRoot)
|
||||
private CounterSet fixOldDmAcls(Long nodeId, Long existingNodeAclId, Long inheritedAclId, boolean isRoot)
|
||||
{
|
||||
CounterSet result = new CounterSet();
|
||||
// Do the children first
|
||||
|
||||
Acl existingAcl = null;
|
||||
Long aclId = nodeDAO.getNodeAclId(nodeId);
|
||||
if (aclId != null)
|
||||
// If existingNodeAclId is not null and equal to inheritedAclId then we know we have hit a shared ACL we have bulk set
|
||||
// - just carry on in this case - we do not need to get the acl
|
||||
|
||||
Long newDefiningAcl = null;
|
||||
|
||||
if((existingNodeAclId != null) && (existingNodeAclId == inheritedAclId))
|
||||
{
|
||||
existingAcl = aclDaoComponent.getAcl(aclId);
|
||||
}
|
||||
|
||||
Long toInherit = null;
|
||||
Long idToInheritFrom = null;
|
||||
|
||||
if (existingAcl != null)
|
||||
{
|
||||
if (existingAcl.getAclType() == ACLType.OLD)
|
||||
{
|
||||
result.increment(ACLType.DEFINING);
|
||||
SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties(aclDaoComponent.getDefaultProperties());
|
||||
properties.setInherits(existingAcl.getInherits());
|
||||
AccessControlList existing = aclDaoComponent.getAccessControlList(existingAcl.getId());
|
||||
Long actuallyInherited = null;
|
||||
if (existingAcl.getInherits())
|
||||
{
|
||||
if (inherited != null)
|
||||
{
|
||||
actuallyInherited = inherited;
|
||||
}
|
||||
}
|
||||
Acl newAcl = aclDaoComponent.createAccessControlList(properties, existing.getEntries(), actuallyInherited);
|
||||
idToInheritFrom = newAcl.getId();
|
||||
nodeDAO.setNodeAclId(nodeId, idToInheritFrom);
|
||||
}
|
||||
else if (existingAcl.getAclType() == ACLType.SHARED)
|
||||
{
|
||||
// nothing to do just cascade into the children - we most likely did a bulk set above.
|
||||
}
|
||||
else
|
||||
{
|
||||
// Already fixed up
|
||||
return result;
|
||||
}
|
||||
// nothing to do except move into the children
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set default ACL on roots with no settings
|
||||
if (isRoot)
|
||||
AccessControlList existing = null;
|
||||
if (existingNodeAclId != null)
|
||||
{
|
||||
result.increment(ACLType.DEFINING);
|
||||
existing = aclDaoComponent.getAccessControlList(existingNodeAclId);
|
||||
}
|
||||
|
||||
AccessControlListProperties properties = aclDaoComponent.getDefaultProperties();
|
||||
Acl newAcl = aclDaoComponent.createAccessControlList(properties);
|
||||
long id = newAcl.getId();
|
||||
if (existing != null)
|
||||
{
|
||||
if (existing.getProperties().getAclType() == ACLType.OLD)
|
||||
{
|
||||
result.increment(ACLType.DEFINING);
|
||||
SimpleAccessControlListProperties properties = new SimpleAccessControlListProperties(aclDaoComponent.getDefaultProperties());
|
||||
properties.setInherits(existing.getProperties().getInherits());
|
||||
|
||||
idToInheritFrom = id;
|
||||
nodeDAO.setNodeAclId(nodeId, id);
|
||||
Long actuallyInherited = null;
|
||||
if (existing.getProperties().getInherits())
|
||||
{
|
||||
if (inheritedAclId != null)
|
||||
{
|
||||
actuallyInherited = inheritedAclId;
|
||||
}
|
||||
}
|
||||
Acl newAcl = aclDaoComponent.createAccessControlList(properties, existing.getEntries(), actuallyInherited);
|
||||
newDefiningAcl = newAcl.getId();
|
||||
nodeDAO.setNodeDefiningAclId(nodeId, newDefiningAcl);
|
||||
}
|
||||
else if (existing.getProperties().getAclType() == ACLType.SHARED)
|
||||
{
|
||||
// nothing to do just cascade into the children - we most likely did a bulk set above.
|
||||
// TODO: Check shared ACL set is correct
|
||||
}
|
||||
else
|
||||
{
|
||||
// Already fixed up
|
||||
// TODO: Keep going to check
|
||||
// Check inheritance is correct
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unset - simple inherit
|
||||
nodeDAO.setNodeAclId(nodeId, inherited);
|
||||
// Set default ACL on roots with no settings
|
||||
if (isRoot)
|
||||
{
|
||||
result.increment(ACLType.DEFINING);
|
||||
|
||||
AccessControlListProperties properties = aclDaoComponent.getDefaultProperties();
|
||||
Acl newAcl = aclDaoComponent.createAccessControlList(properties);
|
||||
newDefiningAcl = newAcl.getId();
|
||||
nodeDAO.setNodeDefiningAclId(nodeId, newDefiningAcl);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unset - simple inherit
|
||||
nodeDAO.setNodeDefiningAclId(nodeId, inheritedAclId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Long toInherit = null;
|
||||
List<NodeIdAndAclId> children = nodeDAO.getPrimaryChildrenAcls(nodeId);
|
||||
if (children.size() > 0)
|
||||
{
|
||||
// Only make inherited if required
|
||||
if (toInherit == null)
|
||||
if (newDefiningAcl == null)
|
||||
{
|
||||
if (idToInheritFrom == null)
|
||||
{
|
||||
toInherit = inherited;
|
||||
}
|
||||
else
|
||||
{
|
||||
toInherit = aclDaoComponent.getInheritedAccessControlList(idToInheritFrom);
|
||||
}
|
||||
toInherit = inheritedAclId;
|
||||
}
|
||||
else
|
||||
{
|
||||
toInherit = aclDaoComponent.getInheritedAccessControlList(newDefiningAcl);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -244,7 +246,7 @@ public class ADMAccessControlListDAO implements AccessControlListDAO
|
||||
|
||||
for (NodeIdAndAclId child : children)
|
||||
{
|
||||
CounterSet update = fixOldDmAcls(child.getId(), toInherit, false);
|
||||
CounterSet update = fixOldDmAcls(child.getId(), child.getAclId(), toInherit, false);
|
||||
result.add(update);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user