REPO-2189: Service Pack: MNT-17239: Unexpected changes of cm:modified and cm:modifier

- IncompleteNodeTagger disables cm:auditable and cm:versionable when making changes

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@135891 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Cristian Turlica
2017-03-16 13:24:07 +00:00
parent 9eaffa8b04
commit 242cc5b406
3 changed files with 176 additions and 54 deletions

View File

@@ -1,28 +1,28 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.node.integrity;
import java.io.Serializable;
@@ -37,6 +37,7 @@ import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
@@ -85,6 +86,7 @@ public class IncompleteNodeTagger
private NodeService nodeService;
private List<String> storesToIgnore = new ArrayList<String>(0);
private Set<QName> propertiesToIgnore = new HashSet<QName>();
private BehaviourFilter behaviourFilter;
public IncompleteNodeTagger()
{
@@ -136,6 +138,11 @@ public class IncompleteNodeTagger
}
}
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
{
this.behaviourFilter = behaviourFilter;
}
/**
* Registers the system-level policy behaviours
*/
@@ -145,6 +152,7 @@ public class IncompleteNodeTagger
PropertyCheck.mandatory("IncompleteNodeTagger", "dictionaryService", dictionaryService);
PropertyCheck.mandatory("IncompleteNodeTagger", "nodeService", nodeService);
PropertyCheck.mandatory("IncompleteNodeTagger", "policyComponent", policyComponent);
PropertyCheck.mandatory("IncompleteNodeTagger", "behaviourFilter", behaviourFilter);
// register behaviour
policyComponent.bindClassBehaviour(
@@ -591,7 +599,19 @@ public class IncompleteNodeTagger
{
if (addTag && !isTagged)
{
nodeService.addAspect(nodeRef, ContentModel.ASPECT_INCOMPLETE, null);
// MNT-17239: Unexpected changes of cm:modified and cm:modifier
behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_VERSIONABLE);
try
{
nodeService.addAspect(nodeRef, ContentModel.ASPECT_INCOMPLETE, null);
}
finally
{
behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_VERSIONABLE);
behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
}
// done
if (logger.isDebugEnabled())
{
@@ -600,7 +620,19 @@ public class IncompleteNodeTagger
}
else if (!addTag && isTagged)
{
nodeService.removeAspect(nodeRef, ContentModel.ASPECT_INCOMPLETE);
// MNT-17239: Unexpected changes of cm:modified and cm:modifier
behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_VERSIONABLE);
try
{
nodeService.removeAspect(nodeRef, ContentModel.ASPECT_INCOMPLETE);
}
finally
{
behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_VERSIONABLE);
behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
}
// done
if (logger.isDebugEnabled())
{