Merged V3.1 to HEAD

14955: Merged V2.2 to V3.1
      14352: Fixed ETWOTWO-1113: Creation date / modification date reset to current date during import
   14956: Fix for ETHREEOH-2198 and ALFCOM-2972
           - Thumbnail Service now allows creation of system managed thumbnails nodes by Consumer users or on Locked items
           - Explicit permission check to ensure user must at least be able to Read the original doc
           - Now correctly ensures that the 'modifier' properties are not updated on the original doc due to thumbnail generation

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14957 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2009-06-26 12:47:58 +00:00
parent 8139b17300
commit 6763cfabc1
7 changed files with 408 additions and 138 deletions

View File

@@ -73,6 +73,7 @@ import org.alfresco.repo.domain.hibernate.SessionSizeResourceManager;
import org.alfresco.repo.domain.hibernate.StoreImpl;
import org.alfresco.repo.domain.hibernate.TransactionImpl;
import org.alfresco.repo.node.db.NodeDaoService;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.permissions.ACLType;
import org.alfresco.repo.security.permissions.AccessControlListProperties;
@@ -191,6 +192,7 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
private DictionaryService dictionaryService;
private boolean enableTimestampPropagation;
private RetryingTransactionHelper auditableTransactionHelper;
private BehaviourFilter behaviourFilter;
/** A cache mapping StoreRef and NodeRef instances to the entity IDs (primary key) */
private SimpleCache<EntityRef, Long> storeAndNodeIdCache;
/** A cache for more performant lookups of the parent associations */
@@ -311,6 +313,16 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
this.auditableTransactionHelper = auditableTransactionHelper;
}
/**
* Set the component to determine the correct aspect behaviours. This applies
* particularly to the <b>cm:auditable</b> case, where the setting of values
* is done automatically except when the behaviour is disabled.
*/
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
{
this.behaviourFilter = behaviourFilter;
}
/**
* Ste the transaction-aware cache to store Store and Root Node IDs by Store Reference
*
@@ -839,21 +851,56 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
}
}
/**
* Record the node update, setting the node's <b>cm:auditable</b> properties.
* The <b>cm:auditable</b> properties set implicity if the automatic behaviour
* {@link BehaviourFilter#isEnabled(NodeRef, QName) behaviour} is enabled.
*
* @see #recordNodeUpdate(Node, Map)
*/
private void recordNodeUpdate(Node node)
{
recordNodeUpdate(node, null);
}
/**
* Record the node update, setting the node's <b>cm:auditable</b> properties.
* The <b>cm:auditable</b> properties set implicity if the automatic behaviour
* {@link BehaviourFilter#isEnabled(NodeRef, QName) behaviour} is enabled,
* otherwise the properties are extracted from the properties passed in.
*
* @param node the node to operate on
* @param properties the node properties from which <b>cm:auditable</b> properties
* may be extracted
*/
private void recordNodeUpdate(Node node, Map<QName, Serializable> properties)
{
updateNodeStatus(node, false);
// Handle cm:auditable
if (hasNodeAspect(node, ContentModel.ASPECT_AUDITABLE))
{
String currentUser = getCurrentUser();
Date currentDate = new Date();
NodeRef nodeRef = node.getNodeRef();
AuditableProperties auditableProperties = node.getAuditableProperties();
if (auditableProperties == null)
{
auditableProperties = new AuditableProperties();
node.setAuditableProperties(auditableProperties);
}
auditableProperties.setAuditValues(currentUser, currentDate, false);
String currentUser = getCurrentUser();
Date currentDate = new Date();
// Check if the cm:auditable aspect behaviour is enabled
if (behaviourFilter.isEnabled(nodeRef, ContentModel.ASPECT_AUDITABLE))
{
// Automatic cm:auditable behaviour
auditableProperties.setAuditValues(currentUser, currentDate, false);
}
else if (properties != null)
{
// Manual cm:auditable behaviour
node.getAuditableProperties().setAuditValues(currentUser, currentDate, properties);
}
// else
// there are no properties, so there is nothing to set
}
// Propagate timestamps
propagateTimestamps(node);
@@ -1398,7 +1445,9 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
addNodePropertyImpl(node, qname, propertyValue, localeId);
// Record change ID
recordNodeUpdate(node);
recordNodeUpdate(
node,
Collections.singletonMap(qname, propertyValue));
}
@SuppressWarnings("unchecked")
@@ -1410,12 +1459,16 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
for (Map.Entry<QName, Serializable> entry : properties.entrySet())
{
QName qname = entry.getKey();
if (AuditableProperties.isAuditableProperty(qname))
{
continue;
}
Serializable value = entry.getValue();
addNodePropertyImpl(node, qname, value, localeId);
}
// Record change ID
recordNodeUpdate(node);
recordNodeUpdate(node, properties);
}
public void setNodeProperties(Long nodeId, Map<QName, Serializable> propertiesIncl)
@@ -1477,7 +1530,7 @@ public class HibernateNodeDaoServiceImpl extends HibernateDaoSupport implements
}
// Record change ID
recordNodeUpdate(node);
recordNodeUpdate(node, propertiesIncl);
}
public void removeNodeProperties(Long nodeId, Set<QName> propertyQNamesIncl)