mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged DEV to HEAD
51998: Deleting a store is now functionally the same as deleting a node but without any option of archival - ALF-19153: CLOUD-1685, CLOUD-1827 and CLOUD-1828 - While cleaning Cloud test data tenants are deleted, which leads to their stores being deleted. - NodeService.deleteStore was not firing policies for every node in the store; several bits of pre- and post-delete code were therefore not being called, which lead to secondary data (caches, attributes, etc) being left lying around. - A side effect of this fix was that the sys:undeletable aspect has to be disabled during account deletion git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@52007 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -263,7 +263,16 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
{
|
||||
// Delete the index
|
||||
nodeIndexer.indexDeleteStore(storeRef);
|
||||
// Rename the store
|
||||
// Cannot delete the root node but we can delete, without archive, all immediate children
|
||||
NodeRef rootNodeRef = nodeDAO.getRootNode(storeRef).getSecond();
|
||||
List<ChildAssociationRef> childAssocRefs = getChildAssocs(rootNodeRef);
|
||||
for (ChildAssociationRef childAssocRef : childAssocRefs)
|
||||
{
|
||||
NodeRef childNodeRef = childAssocRef.getChildRef();
|
||||
// We do NOT want to archive these, so mark them as temporary
|
||||
deleteNode(childNodeRef, false);
|
||||
}
|
||||
// Rename the store. This takes all the nodes with it.
|
||||
StoreRef deletedStoreRef = new StoreRef(StoreRef.PROTOCOL_DELETED, GUID.generate());
|
||||
nodeDAO.moveStore(storeRef, deletedStoreRef);
|
||||
|
||||
@@ -1044,7 +1053,20 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
/**
|
||||
* Delete Node
|
||||
*/
|
||||
@Override
|
||||
public void deleteNode(NodeRef nodeRef)
|
||||
{
|
||||
deleteNode(nodeRef, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a node
|
||||
*
|
||||
* @param nodeRef the node to delete
|
||||
* @param allowArchival <tt>true</tt> if normal archival may occur or
|
||||
* <tt>false</tt> if the node must be forcibly deleted
|
||||
*/
|
||||
private void deleteNode(NodeRef nodeRef, boolean allowArchival)
|
||||
{
|
||||
// The node(s) involved may not be pending deletion
|
||||
checkPendingDelete(nodeRef);
|
||||
@@ -1055,13 +1077,21 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
|
||||
Boolean requiresDelete = null;
|
||||
|
||||
// get the primary parent-child relationship before it is gone
|
||||
Pair<Long, ChildAssociationRef> childAssocPair = nodeDAO.getPrimaryParentAssoc(nodeId);
|
||||
ChildAssociationRef childAssocRef = childAssocPair.getSecond();
|
||||
// get type and aspect QNames as they will be unavailable after the delete
|
||||
QName nodeTypeQName = nodeDAO.getNodeType(nodeId);
|
||||
Set<QName> nodeAspectQNames = nodeDAO.getNodeAspects(nodeId);
|
||||
|
||||
// Have we been asked to delete a store?
|
||||
if (nodeTypeQName.equals(ContentModel.TYPE_STOREROOT))
|
||||
{
|
||||
throw new IllegalArgumentException("A store root node cannot be deleted: " + nodeRef);
|
||||
}
|
||||
|
||||
// get the primary parent-child relationship before it is gone
|
||||
Pair<Long, ChildAssociationRef> childAssocPair = nodeDAO.getPrimaryParentAssoc(nodeId);
|
||||
ChildAssociationRef childAssocRef = childAssocPair.getSecond();
|
||||
|
||||
// Is this store
|
||||
StoreRef storeRef = nodeRef.getStoreRef();
|
||||
StoreRef archiveStoreRef = storeArchiveMap.get(storeRef);
|
||||
|
||||
@@ -1079,7 +1109,12 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
nodesPendingDeleteTxn.addAll(nodesPendingDelete); // We need to remove these later, again
|
||||
|
||||
// Work out whether we need to archive or delete the node.
|
||||
if (archiveStoreRef == null)
|
||||
if (!allowArchival)
|
||||
{
|
||||
// No archival allowed
|
||||
requiresDelete = true;
|
||||
}
|
||||
else if (archiveStoreRef == null)
|
||||
{
|
||||
// The store does not specify archiving
|
||||
requiresDelete = true;
|
||||
@@ -1162,6 +1197,7 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl
|
||||
}
|
||||
invokeBeforeDeleteChildAssociation(secondaryParentAssocPair.getSecond());
|
||||
}
|
||||
|
||||
// Primary child associations
|
||||
if (archive)
|
||||
{
|
||||
|
Reference in New Issue
Block a user