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

120108 nsmintanca: Merged 5.0.N (5.0.4) to 5.1.N (5.1.1)
      120075 rmunteanu: Merged V4.2-BUG-FIX (4.2.6) to 5.0.N (5.0.4)
         120039 amukha: Merged V4.2-BUG-FIX-MNT-14688 (4.2.6) to V4.2-BUG-FIX (4.2.6)
            120019 amukha: MNT-14688: version revert on first version failure if type has aspect
               - Restoring a version now restores the node's type.
               - Added JUnit test.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@123613 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-03-11 21:34:50 +00:00
parent e39037672c
commit 096c5871d8
4 changed files with 107 additions and 16 deletions

View File

@@ -1056,27 +1056,36 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
Map<QName, Serializable> newProps = this.nodeService.getProperties(versionNodeRef);
VersionUtil.convertFrozenToOriginalProps(newProps);
Set<QName> newAspectQNames = this.nodeService.getAspects(versionNodeRef);
QName newNodeTypeQName = nodeService.getType(versionNodeRef);
// RevertDetails - given to policy behaviours
VersionRevertDetailsImpl revertDetails = new VersionRevertDetailsImpl();
revertDetails.setNodeRef(nodeRef);
revertDetails.setNodeType(oldNodeTypeQName);
revertDetails.setNodeType(newNodeTypeQName);
// Do we want to maintain any existing property values?
Collection<QName> propsToLeaveAlone = new ArrayList<QName>();
Collection<QName> assocsToLeaveAlone = new ArrayList<QName>();
TypeDefinition typeDef = dictionaryService.getType(oldNodeTypeQName);
if(typeDef != null)
{
for(QName assocName : typeDef.getAssociations().keySet())
{
if(getRevertAssocAction(oldNodeTypeQName, assocName, revertDetails) == RevertAssocAction.IGNORE)
{
assocsToLeaveAlone.add(assocName);
}
}
}
// The VersionRevertCallback was added in r50122 on HEAD-QA branch in ACE-1001
// If it is required to preserve this callback when the type is changed,
// this part should be reimplemented.
// see MNT-14688
if (newNodeTypeQName.equals(oldNodeTypeQName))
{
// The node did not change the type, check the associations
TypeDefinition typeDef = dictionaryService.getType(oldNodeTypeQName);
if(typeDef != null)
{
for(QName assocName : typeDef.getAssociations().keySet())
{
if(getRevertAssocAction(oldNodeTypeQName, assocName, revertDetails) == RevertAssocAction.IGNORE)
{
assocsToLeaveAlone.add(assocName);
}
}
}
}
for (QName aspect : oldAspectQNames)
{
@@ -1110,6 +1119,9 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
//Restore forum properties
this.nodeService.addProperties(nodeRef, forumProps);
// Restore the type
this.nodeService.setType(nodeRef, newNodeTypeQName);
Set<QName> aspectsToRemove = new HashSet<QName>(oldAspectQNames);
aspectsToRemove.removeAll(newAspectQNames);