mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Code cleanup while reviewing ALF-19860
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@54666 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -358,8 +358,8 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
|
|||||||
public void onAddAspect(NodeRef nodeRef, QName aspectTypeQName)
|
public void onAddAspect(NodeRef nodeRef, QName aspectTypeQName)
|
||||||
{
|
{
|
||||||
if (this.nodeService.exists(nodeRef) == true
|
if (this.nodeService.exists(nodeRef) == true
|
||||||
&& this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == true
|
&& this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == true
|
||||||
&& aspectTypeQName.equals(ContentModel.ASPECT_VERSIONABLE) == true)
|
&& aspectTypeQName.equals(ContentModel.ASPECT_VERSIONABLE) == true)
|
||||||
{
|
{
|
||||||
boolean initialVersion = true;
|
boolean initialVersion = true;
|
||||||
Boolean value = (Boolean)this.nodeService.getProperty(nodeRef, ContentModel.PROP_INITIAL_VERSION);
|
Boolean value = (Boolean)this.nodeService.getProperty(nodeRef, ContentModel.PROP_INITIAL_VERSION);
|
||||||
@@ -457,69 +457,69 @@ public class VersionableAspect implements ContentServicePolicies.OnContentUpdate
|
|||||||
(this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == true) &&
|
(this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == true) &&
|
||||||
(this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY) == false))
|
(this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TEMPORARY) == false))
|
||||||
{
|
{
|
||||||
onUpdatePropertiesBehaviour.disable();
|
onUpdatePropertiesBehaviour.disable();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Map<NodeRef, NodeRef> versionedNodeRefs = (Map)AlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS);
|
Map<NodeRef, NodeRef> versionedNodeRefs = (Map)AlfrescoTransactionSupport.getResource(KEY_VERSIONED_NODEREFS);
|
||||||
if (versionedNodeRefs == null || versionedNodeRefs.containsKey(nodeRef) == false)
|
if (versionedNodeRefs == null || versionedNodeRefs.containsKey(nodeRef) == false)
|
||||||
{
|
{
|
||||||
// Determine whether the node is auto versionable (for property only updates) or not
|
// Determine whether the node is auto versionable (for property only updates) or not
|
||||||
boolean autoVersion = false;
|
boolean autoVersion = false;
|
||||||
Boolean value = (Boolean)this.nodeService.getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION);
|
Boolean value = (Boolean)this.nodeService.getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION);
|
||||||
if (value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
// If the value is not null then
|
// If the value is not null then
|
||||||
autoVersion = value.booleanValue();
|
autoVersion = value.booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean autoVersionProps = false;
|
boolean autoVersionProps = false;
|
||||||
value = (Boolean)this.nodeService.getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION_PROPS);
|
value = (Boolean)this.nodeService.getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION_PROPS);
|
||||||
if (value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
// If the value is not null then
|
// If the value is not null then
|
||||||
autoVersionProps = value.booleanValue();
|
autoVersionProps = value.booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((autoVersion == true) && (autoVersionProps == true))
|
if ((autoVersion == true) && (autoVersionProps == true))
|
||||||
{
|
{
|
||||||
// Check for explicitly excluded props - if one or more excluded props changes then do not auto-version on this event (even if other props changed)
|
// Check for explicitly excluded props - if one or more excluded props changes then do not auto-version on this event (even if other props changed)
|
||||||
if (excludedOnUpdatePropQNames.size() > 0)
|
if (excludedOnUpdatePropQNames.size() > 0)
|
||||||
{
|
{
|
||||||
Set<QName> propNames = new HashSet<QName>(after.size() * 2);
|
Set<QName> propNames = new HashSet<QName>(after.size() * 2);
|
||||||
propNames.addAll(after.keySet());
|
propNames.addAll(after.keySet());
|
||||||
propNames.addAll(before.keySet());
|
propNames.addAll(before.keySet());
|
||||||
propNames.retainAll(excludedOnUpdatePropQNames);
|
propNames.retainAll(excludedOnUpdatePropQNames);
|
||||||
|
|
||||||
if (propNames.size() > 0)
|
if (propNames.size() > 0)
|
||||||
{
|
{
|
||||||
for (QName prop : propNames)
|
for (QName prop : propNames)
|
||||||
{
|
{
|
||||||
Serializable beforeValue = before.get(prop);
|
Serializable beforeValue = before.get(prop);
|
||||||
Serializable afterValue = after.get(prop);
|
Serializable afterValue = after.get(prop);
|
||||||
|
|
||||||
if (EqualsHelper.nullSafeEquals(beforeValue, afterValue) != true)
|
if (EqualsHelper.nullSafeEquals(beforeValue, afterValue) != true)
|
||||||
{
|
{
|
||||||
// excluded - do not version
|
// excluded - do not version
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// drop through and auto-version
|
// drop through and auto-version
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the auto-version
|
// Create the auto-version
|
||||||
Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(4);
|
Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(4);
|
||||||
versionProperties.put(Version.PROP_DESCRIPTION, I18NUtil.getMessage(MSG_AUTO_VERSION_PROPS));
|
versionProperties.put(Version.PROP_DESCRIPTION, I18NUtil.getMessage(MSG_AUTO_VERSION_PROPS));
|
||||||
versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR);
|
versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR);
|
||||||
|
|
||||||
createVersionImpl(nodeRef, versionProperties);
|
createVersionImpl(nodeRef, versionProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
onUpdatePropertiesBehaviour.enable();
|
onUpdatePropertiesBehaviour.enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user