mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)
98999: Merged 5.0.N (5.0.2) to HEAD-BUG-FIX (5.1/Cloud) 98978: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.2) 98931: MNT-13562: Merged V4.1-BUG-FIX (4.1.10) to V4.2-BUG-FIX (4.2.5) 98757: Merged DEV to V4.1-BUG-FIX (4.1.10) 94378 : MNT-6400: Issue with versioning and comments - Ignore comments properties/aspects/children 96791 : MNT-6400: Issue with versioning and comments - Added a test git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@99002 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -31,6 +31,7 @@ import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.ForumModel;
|
||||
import org.alfresco.repo.policy.PolicyScope;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.version.VersionRevertCallback.RevertAspectAction;
|
||||
@@ -52,6 +53,7 @@ import org.alfresco.service.cmr.version.Version;
|
||||
import org.alfresco.service.cmr.version.VersionHistory;
|
||||
import org.alfresco.service.cmr.version.VersionService;
|
||||
import org.alfresco.service.cmr.version.VersionServiceException;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.util.Pair;
|
||||
@@ -1012,6 +1014,26 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
|
||||
// The frozen (which will become new) values
|
||||
// Get the node that represents the frozen state
|
||||
NodeRef versionNodeRef = version.getFrozenStateNodeRef();
|
||||
boolean needToRestoreDiscussion = !this.nodeService.hasAspect(versionNodeRef, ForumModel.ASPECT_DISCUSSABLE)
|
||||
&& this.nodeService.hasAspect(nodeRef, ForumModel.ASPECT_DISCUSSABLE);
|
||||
|
||||
Map<QName, Serializable> forumProps = null;
|
||||
|
||||
// Collect forum properties
|
||||
// only if previous version hasn't discussable aspect
|
||||
if (needToRestoreDiscussion)
|
||||
{
|
||||
Map<QName, Serializable> currentVersionProp = this.nodeService.getProperties(nodeRef);
|
||||
forumProps = new HashMap<QName, Serializable>();
|
||||
for (QName key : currentVersionProp.keySet())
|
||||
{
|
||||
if (key.getNamespaceURI().equals(NamespaceService.FORUMS_MODEL_1_0_URI))
|
||||
{
|
||||
forumProps.put(key, currentVersionProp.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<QName, Serializable> newProps = this.nodeService.getProperties(versionNodeRef);
|
||||
VersionUtil.convertFrozenToOriginalProps(newProps);
|
||||
Set<QName> newAspectQNames = this.nodeService.getAspects(versionNodeRef);
|
||||
@@ -1065,6 +1087,12 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
|
||||
}
|
||||
|
||||
this.nodeService.setProperties(nodeRef, newProps);
|
||||
|
||||
//Restore forum properties
|
||||
if (needToRestoreDiscussion)
|
||||
{
|
||||
this.nodeService.addProperties(nodeRef, forumProps);
|
||||
}
|
||||
|
||||
Set<QName> aspectsToRemove = new HashSet<QName>(oldAspectQNames);
|
||||
aspectsToRemove.removeAll(newAspectQNames);
|
||||
@@ -1079,6 +1107,19 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
|
||||
{
|
||||
this.nodeService.addAspect(nodeRef, aspect, null);
|
||||
}
|
||||
}
|
||||
// Don't remove forum aspects
|
||||
if (needToRestoreDiscussion)
|
||||
{
|
||||
Set<QName> ignoredAspects = new HashSet<QName>();
|
||||
for (QName aspectForCheck : aspectsToRemove)
|
||||
{
|
||||
if (aspectForCheck.getNamespaceURI().equals(NamespaceService.FORUMS_MODEL_1_0_URI))
|
||||
{
|
||||
ignoredAspects.add(aspectForCheck);
|
||||
}
|
||||
}
|
||||
aspectsToRemove.removeAll(ignoredAspects);
|
||||
}
|
||||
|
||||
// remove aspects that are not on the frozen node
|
||||
@@ -1175,6 +1216,19 @@ public class Version2ServiceImpl extends VersionServiceImpl implements VersionSe
|
||||
children.remove(versionedChild);
|
||||
}
|
||||
}
|
||||
// Don't remove forum children
|
||||
if (needToRestoreDiscussion)
|
||||
{
|
||||
List<ChildAssociationRef> ignoredChildren = new ArrayList<ChildAssociationRef>();
|
||||
for (ChildAssociationRef childForCheck : children)
|
||||
{
|
||||
if (childForCheck.getTypeQName().getNamespaceURI().equals(NamespaceService.FORUMS_MODEL_1_0_URI))
|
||||
{
|
||||
ignoredChildren.add(childForCheck);
|
||||
}
|
||||
}
|
||||
children.removeAll(ignoredChildren);
|
||||
}
|
||||
for (ChildAssociationRef ref : children)
|
||||
{
|
||||
if (!assocsToLeaveAlone.contains(ref.getTypeQName()))
|
||||
|
Reference in New Issue
Block a user