Merged 5.1.N (5.1.1) to HEAD (5.1)

120101 nsmintanca: Merged 5.0.N (5.0.4) to 5.1.N (5.1.1)
      120041 gjames: Merged MNT-15211 (5.0.4) to 5.0.N (5.0.4)
         119608 gjames: MNT-15211 Restoring data from Trashcan with MySQL Cluster NDB backend doesn't work


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@123607 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-03-11 21:34:04 +00:00
parent 11cf39ec0f
commit d77c2c456a

View File

@@ -1490,26 +1490,48 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO
// Store // Store
if (!childStore.getId().equals(newParentStore.getId())) if (!childStore.getId().equals(newParentStore.getId()))
{ {
// Remove the cm:auditable aspect from the source node
// Remove the cm:auditable aspect from the old node as the new one will get new values as required // Create a new node
Set<Long> aspectIdsToDelete = qnameDAO.convertQNamesToIds(
Collections.singleton(ContentModel.ASPECT_AUDITABLE),
true);
deleteNodeAspects(childNodeId, aspectIdsToDelete);
// ... but make sure we copy over the cm:auditable data from the originating node
AuditablePropertiesEntity auditableProps = childNode.getAuditableProperties();
// Create a new node and copy all the data over to it
newChildNode = newNodeImpl( newChildNode = newNodeImpl(
newParentStore, newParentStore,
childNode.getUuid(), childNode.getUuid(),
childNode.getTypeQNameId(), childNode.getTypeQNameId(),
childNode.getLocaleId(), childNode.getLocaleId(),
childNode.getAclId(), childNode.getAclId(),
auditableProps); null);
Long newChildNodeId = newChildNode.getId(); Long newChildNodeId = newChildNode.getId();
moveNodeData(
childNode.getId(), QName nodeTypeQName = qnameDAO.getQName(childNode.getTypeQNameId()).getSecond();
newChildNodeId); boolean isAuditable = AuditablePropertiesEntity.hasAuditableAspect(nodeTypeQName, dictionaryService);
AuditablePropertiesEntity auditableProps = null;
if (isAuditable)
{
//Delete the ASPECT_AUDITABLE from the source node so it doesn't get copied across
//A new aspect would have already been created in the newNodeImpl method.
// ... make sure we have the cm:auditable data from the originating node
auditableProps = childNode.getAuditableProperties();
Set<Long> aspectIdsToDelete = qnameDAO.convertQNamesToIds(
Collections.singleton(ContentModel.ASPECT_AUDITABLE),
true);
deleteNodeAspects(childNodeId, aspectIdsToDelete);
}
//copy all the data over to new node
moveNodeData(childNode.getId(), newChildNodeId);
if (isAuditable && auditableProps != null)
{
Node node = getNodeNotNull(newChildNodeId, false);
NodeUpdateEntity nodeUpdate = new NodeUpdateEntity();
nodeUpdate.setId(newChildNodeId);
nodeUpdate.setAuditableProperties(auditableProps);
nodeUpdate.setUpdateAuditableProperties(true);
nodeUpdate.setVersion(node.getVersion());
updateNode(nodeUpdate);
}
// The new node will have new data not present in the cache, yet // The new node will have new data not present in the cache, yet
invalidateNodeCaches(newChildNodeId); invalidateNodeCaches(newChildNodeId);
invalidateNodeChildrenCaches(newChildNodeId, true, true); invalidateNodeChildrenCaches(newChildNodeId, true, true);