mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix for ALF-10080. Can't delete site discussion topics that you do not own but have permissions to delete.
This problem was caused by the deletion of a discussion topic leading to the update (property changes) on parent nodes. Whilst the site manager mentioned in the bug has permission to delete the topic node, they do not have permission to update the properties further up the containment hierarchy. Those updates should have been run as system and not they are. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30751 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -32,6 +32,8 @@ import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy;
|
||||
import org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -175,15 +177,31 @@ public class ForumPostBehaviours implements NodeServicePolicies.OnCreateNodePoli
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateNode(ChildAssociationRef childAssocRef)
|
||||
public void onCreateNode(final ChildAssociationRef childAssocRef)
|
||||
{
|
||||
adjustCommentCount(childAssocRef.getChildRef(), true);
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
adjustCommentCount(childAssocRef.getChildRef(), true);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeDeleteNode(NodeRef nodeRef)
|
||||
public void beforeDeleteNode(final NodeRef nodeRef)
|
||||
{
|
||||
adjustCommentCount(nodeRef, false);
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
adjustCommentCount(nodeRef, false);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,6 +225,7 @@ public class ForumPostBehaviours implements NodeServicePolicies.OnCreateNodePoli
|
||||
if (recount != null)
|
||||
{
|
||||
nodeService.addAspect(discussableAncestor, ForumModel.ASPECT_COMMENTS_ROLLUP, null);
|
||||
|
||||
int newCountValue = recount;
|
||||
// If the node is being deleted then the above node-count will include the to-be-deleted node.
|
||||
// This is because the policies are onCreateNode and *before*DeleteNode
|
||||
@@ -221,6 +240,7 @@ public class ForumPostBehaviours implements NodeServicePolicies.OnCreateNodePoli
|
||||
}
|
||||
|
||||
nodeService.setProperty(discussableAncestor, ForumModel.PROP_COMMENT_COUNT, newCountValue);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user