From 1f479a1c88a2cf5b5996ca7d565e25e6e8ef71f7 Mon Sep 17 00:00:00 2001 From: Natalia Smintanca Date: Mon, 14 Dec 2015 12:08:27 +0000 Subject: [PATCH] =?UTF-8?q?Merged=205.0.N=20(5.0.4)=20to=205.1.N=20(5.1.1)?= =?UTF-8?q?=20=20=20=20120041=20gjames:=20Merged=20MNT-15211=20(5.0.4)=20t?= =?UTF-8?q?o=205.0.N=20(5.0.4)=20=20=20=20=20=20=20119608=20gjames:=20MNT-?= =?UTF-8?q?15211=20Restoring=20data=20from=20Trashcan=20with=20MySQL=20Clu?= =?UTF-8?q?ster=20NDB=20backend=20doesn=E2=80=99t=20work?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@120101 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/domain/node/AbstractNodeDAOImpl.java | 48 ++++++++++++++----- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/source/java/org/alfresco/repo/domain/node/AbstractNodeDAOImpl.java b/source/java/org/alfresco/repo/domain/node/AbstractNodeDAOImpl.java index 1ecef48015..fa53346011 100644 --- a/source/java/org/alfresco/repo/domain/node/AbstractNodeDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/node/AbstractNodeDAOImpl.java @@ -1490,26 +1490,48 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO // Store 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 - Set 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 + + // Create a new node newChildNode = newNodeImpl( newParentStore, childNode.getUuid(), childNode.getTypeQNameId(), childNode.getLocaleId(), childNode.getAclId(), - auditableProps); + null); Long newChildNodeId = newChildNode.getId(); - moveNodeData( - childNode.getId(), - newChildNodeId); + + QName nodeTypeQName = qnameDAO.getQName(childNode.getTypeQNameId()).getSecond(); + 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 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 invalidateNodeCaches(newChildNodeId); invalidateNodeChildrenCaches(newChildNodeId, true, true);