Fix the api-explorer version, there is no 5.2.2-SNAPSHOT version yet.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@137776 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ancuta Morarasu
2017-06-23 07:34:24 +00:00
parent df009a5e27
commit 05af878987
2 changed files with 110 additions and 71 deletions

View File

@@ -759,7 +759,7 @@ public class CommentServiceImpl extends AbstractLifecycleBean implements Comment
if (behaviourFilter.isEnabled(ContentModel.ASPECT_LOCKABLE) // eg. delete site (MNT-14671) if (behaviourFilter.isEnabled(ContentModel.ASPECT_LOCKABLE) // eg. delete site (MNT-14671)
&& isWorkingCopyOrLocked(discussableNodeRef) && isWorkingCopyOrLocked(discussableNodeRef)
&& !isLockOwner(discussableNodeRef) && !isLockOwner(discussableNodeRef)
&& !canDelete) && canDelete)
{ {
throw new NodeLockedException(discussableNodeRef); throw new NodeLockedException(discussableNodeRef);
} }

View File

@@ -409,6 +409,10 @@ public class CommentsTest
* REPO-2557, ALF-21907 * REPO-2557, ALF-21907
*/ */
@Test public void testAddingCommentOnLockedNode() @Test public void testAddingCommentOnLockedNode()
{
String user = authenticationComponent.getCurrentUserName();
final NodeRef testDoc = testDocs.get(0);
try
{ {
// create user 2 and 3 // create user 2 and 3
transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
@@ -429,7 +433,6 @@ public class CommentsTest
authenticationComponent.setCurrentUser(USER_ONE_NAME); authenticationComponent.setCurrentUser(USER_ONE_NAME);
// create some comments // create some comments
final NodeRef testDoc = testDocs.get(0);
transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{ {
@Override @Override
@@ -474,6 +477,26 @@ public class CommentsTest
// Fails because is not the lock owner // Fails because is not the lock owner
} }
authenticationComponent.setCurrentUser(USER_ONE_NAME);
try
{
transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
applyComment(testDoc, "Hello 3");
return null;
}
});
fail("NodeLockedException not thrown");
}
catch (NodeLockedException e)
{
// Fails because is not the lock owner
}
// change to lock owner // change to lock owner
authenticationComponent.setCurrentUser(USER_TWO_NAME); authenticationComponent.setCurrentUser(USER_TWO_NAME);
@@ -488,8 +511,24 @@ public class CommentsTest
}); });
assertCommentCountIs(testDoc, 3); assertCommentCountIs(testDoc, 3);
}
finally
{
authenticationComponent.setCurrentUser(USER_ONE_NAME);
authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName()); // unlock node
transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
lockService.unlock(testDoc);
return null;
}
});
authenticationComponent.setCurrentUser(user);
}
} }
/** /**