Fix the failed test tomorrow

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@137719 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Martin Muller
2017-06-20 18:51:14 +00:00
parent fc391b7839
commit cf2240d301
2 changed files with 48 additions and 154 deletions

View File

@@ -613,18 +613,17 @@ public class CommentServiceImpl extends AbstractLifecycleBean implements Comment
NodeRef discussableNodeRef = getDiscussableAncestor(commentNodeRef);
if (discussableNodeRef.equals(discussableNode))
{
if (!isWorkingCopyOrLocked(discussableNode)
|| isLockOwner(discussableNode))
if (!isWorkingCopyOrLocked(discussableNode))
{
canEdit = canEditPermission(commentNodeRef);
canDelete = canDeletePermission(commentNodeRef);
}
}
Map<String, Boolean> map = new HashMap<>(2);
map.put(CommentService.CAN_EDIT, canEdit);
map.put(CommentService.CAN_DELETE, canDelete);
return map;
}
@@ -638,17 +637,12 @@ public class CommentServiceImpl extends AbstractLifecycleBean implements Comment
boolean isCoordinator = permissionService.hasPermission(commentNodeRef, PermissionService.COORDINATOR) == (AccessStatus.ALLOWED);
return (isSiteManager || isCoordinator || currentUser.equals(creator) || currentUser.equals(owner));
}
private boolean canDeletePermission(NodeRef commentNodeRef)
{
return permissionService.hasPermission(commentNodeRef, PermissionService.DELETE) == AccessStatus.ALLOWED;
}
private boolean isLockOwner(NodeRef nodeRef)
{
return lockService.getLockStatus(nodeRef) == LockStatus.LOCK_OWNER?true:false;
}
private boolean isWorkingCopyOrLocked(NodeRef nodeRef)
{
boolean isWorkingCopy = false;
@@ -673,7 +667,7 @@ public class CommentServiceImpl extends AbstractLifecycleBean implements Comment
}
return (isWorkingCopy || isLocked);
}
@Override
public void onUpdateProperties(NodeRef commentNodeRef, Map<QName, Serializable> before, Map<QName, Serializable> after)
{
@@ -681,11 +675,10 @@ public class CommentServiceImpl extends AbstractLifecycleBean implements Comment
if (discussableNodeRef != null)
{
if (behaviourFilter.isEnabled(ContentModel.ASPECT_LOCKABLE)
&& isWorkingCopyOrLocked(discussableNodeRef)
&& !isLockOwner(discussableNodeRef))
&& isWorkingCopyOrLocked(discussableNodeRef))
{
List<QName> changedProperties = getChangedProperties(before, after);
// check if comment updated (rather than some other change, eg. addition of lockable aspect only)
boolean commentUpdated = false;
for (QName changedProperty : changedProperties)
@@ -700,7 +693,7 @@ public class CommentServiceImpl extends AbstractLifecycleBean implements Comment
}
}
}
if (commentUpdated)
{
throw new NodeLockedException(discussableNodeRef);
@@ -748,22 +741,20 @@ public class CommentServiceImpl extends AbstractLifecycleBean implements Comment
return results;
}
@Override
public void beforeDeleteNode(final NodeRef commentNodeRef)
{
NodeRef discussableNodeRef = getDiscussableAncestor(commentNodeRef);
if (discussableNodeRef != null)
{
boolean canDelete = canDeletePermission(commentNodeRef);
if (behaviourFilter.isEnabled(ContentModel.ASPECT_LOCKABLE) // eg. delete site (MNT-14671)
&& isWorkingCopyOrLocked(discussableNodeRef)
&& !isLockOwner(discussableNodeRef)
&& !canDelete)
&& isWorkingCopyOrLocked(discussableNodeRef))
{
throw new NodeLockedException(discussableNodeRef);
}
boolean canDelete = canDeletePermission(commentNodeRef);
if (! canDelete)
{
throw new AccessDeniedException("Cannot delete comment");