diff --git a/source/java/org/alfresco/repo/domain/node/AbstractNodeDAOImpl.java b/source/java/org/alfresco/repo/domain/node/AbstractNodeDAOImpl.java index 645fc5bef4..9ead92c233 100644 --- a/source/java/org/alfresco/repo/domain/node/AbstractNodeDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/node/AbstractNodeDAOImpl.java @@ -913,15 +913,13 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO TransactionEntity txn = getCurrentTransaction(); node.setTransaction(txn); - Set nodeAspects = null; - // Audit + boolean addAuditableAspect = false; if (auditableProps != null) { // Client-supplied cm:auditable values node.setAuditableProperties(auditableProps); - - nodeAspects = Collections.singleton(ContentModel.ASPECT_AUDITABLE); + addAuditableAspect = true; } else if (AuditablePropertiesEntity.hasAuditableAspect(nodeTypeQName, dictionaryService)) { @@ -929,12 +927,7 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO auditableProps = new AuditablePropertiesEntity(); auditableProps.setAuditValues(null, null, true, 0L); node.setAuditableProperties(auditableProps); - - nodeAspects = Collections.singleton(ContentModel.ASPECT_AUDITABLE); - } - else - { - nodeAspects = Collections.emptySet(); + addAuditableAspect = true; } Long id = null; @@ -962,6 +955,18 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO } node.setId(id); + Set nodeAspects = null; + if (addAuditableAspect) + { + Long auditableAspectQNameId = qnameDAO.getOrCreateQName(ContentModel.ASPECT_AUDITABLE).getFirst(); + insertNodeAspect(id, auditableAspectQNameId); + nodeAspects = Collections.singleton(ContentModel.ASPECT_AUDITABLE); + } + else + { + nodeAspects = Collections.emptySet(); + } + // Lock the node and cache node.lock(); nodesCache.setValue(id, node); @@ -1551,6 +1556,11 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO Map newProps, boolean isAddOnly) { + if (isAddOnly && newProps.size() == 0) + { + return false; // No point adding nothing + } + Node node = getNodeNotNull(nodeId); // Copy inbound values newProps = new HashMap(newProps); @@ -1888,6 +1898,10 @@ public abstract class AbstractNodeDAOImpl implements NodeDAO, BatchingDAO public boolean addNodeAspects(Long nodeId, Set aspectQNames) { + if (aspectQNames.size() == 0) + { + return false; + } // Copy the inbound set Set aspectQNamesToAdd = new HashSet(aspectQNames); // Get existing