Merged 5.2.N (5.2.1) to HEAD (5.2)

129826 jvonka: REPO-164 / REPO-1150: fix minor regress (eg. if recursively locking nodes via includeChildren)
   -  MNT-16446, MNT-14945


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@130233 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-09-06 14:43:54 +00:00
parent caf1c1c8ca
commit ca6e13d532
2 changed files with 79 additions and 11 deletions

View File

@@ -365,14 +365,27 @@ public class RepoService
nodeService.deleteNode(nodeRef); nodeService.deleteNode(nodeRef);
} }
//
// TODO replace with V1 REST API to Lock/Unlock - except calls to includeChildren (which may not be exposed, initially
//
public void lockNode(NodeRef nodeRef) public void lockNode(NodeRef nodeRef)
{ {
lockService.lock(nodeRef, LockType.NODE_LOCK); lockNode(nodeRef, LockType.NODE_LOCK, 0, false);
}
public void lockNode(NodeRef nodeRef, LockType lockType, int timeToExpire, boolean includeChildren)
{
lockService.lock(nodeRef, lockType, timeToExpire, includeChildren);
} }
public void unlockNode(NodeRef nodeRef) public void unlockNode(NodeRef nodeRef)
{ {
lockService.unlock(nodeRef); unlockNode(nodeRef, false);
}
public void unlockNode(NodeRef nodeRef, boolean includeChildren)
{
lockService.unlock(nodeRef, true, false);
} }
public NodeRef addUserDescription(final String personId, final TestNetwork network, final String personDescription) public NodeRef addUserDescription(final String personId, final TestNetwork network, final String personDescription)

View File

@@ -57,6 +57,7 @@ import org.alfresco.rest.api.tests.client.data.Activity;
import org.alfresco.rest.api.tests.client.data.Comment; import org.alfresco.rest.api.tests.client.data.Comment;
import org.alfresco.rest.api.tests.client.data.SiteRole; import org.alfresco.rest.api.tests.client.data.SiteRole;
import org.alfresco.rest.api.tests.client.data.Tag; import org.alfresco.rest.api.tests.client.data.Tag;
import org.alfresco.service.cmr.lock.LockType;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.site.SiteVisibility; import org.alfresco.service.cmr.site.SiteVisibility;
import org.alfresco.util.GUID; import org.alfresco.util.GUID;
@@ -91,6 +92,7 @@ public class TestNodeComments extends EnterpriseTestApi
private NodeRef nodeRef4; private NodeRef nodeRef4;
private NodeRef cmObjectNodeRef; private NodeRef cmObjectNodeRef;
private NodeRef customTypeObject; private NodeRef customTypeObject;
private NodeRef nodeRef5;
@Override @Override
@Before @Before
@@ -170,7 +172,8 @@ public class TestNodeComments extends EnterpriseTestApi
{ {
NodeRef nodeRef = repoService.createDocument(site1.getContainerNodeRef("documentLibrary"), "Test Doc", "Test Content"); NodeRef nodeRef = repoService.createDocument(site1.getContainerNodeRef("documentLibrary"), "Test Doc", "Test Content");
nodes.add(nodeRef); nodes.add(nodeRef);
nodeRef = repoService.createFolder(site1.getContainerNodeRef("documentLibrary"), "Test Folder"); NodeRef folderNodeRef = repoService.createFolder(site1.getContainerNodeRef("documentLibrary"), "Test Folder");
nodeRef = folderNodeRef;
nodes.add(nodeRef); nodes.add(nodeRef);
nodeRef = repoService.createDocument(site1.getContainerNodeRef("documentLibrary"), "Test Doc 1", "Test Content 1"); nodeRef = repoService.createDocument(site1.getContainerNodeRef("documentLibrary"), "Test Doc 1", "Test Content 1");
nodes.add(nodeRef); nodes.add(nodeRef);
@@ -182,6 +185,8 @@ public class TestNodeComments extends EnterpriseTestApi
nodes.add(nodeRef); nodes.add(nodeRef);
nodeRef = repoService.createObjectOfCustomType(site1.getContainerNodeRef("documentLibrary"), "Custom type object", "{custom.model}sop"); nodeRef = repoService.createObjectOfCustomType(site1.getContainerNodeRef("documentLibrary"), "Custom type object", "{custom.model}sop");
nodes.add(nodeRef); nodes.add(nodeRef);
nodeRef = repoService.createDocument(folderNodeRef, "Test Doc 4", "Test Content 4 - in Test Folder");
nodes.add(nodeRef);
return null; return null;
} }
@@ -194,6 +199,7 @@ public class TestNodeComments extends EnterpriseTestApi
this.nodeRef4 = nodes.get(4); this.nodeRef4 = nodes.get(4);
this.cmObjectNodeRef = nodes.get(5); this.cmObjectNodeRef = nodes.get(5);
this.customTypeObject = nodes.get(6); this.customTypeObject = nodes.get(6);
this.nodeRef5 = nodes.get(7);
} }
@Test @Test
@@ -771,8 +777,15 @@ public class TestNodeComments extends EnterpriseTestApi
{ {
assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode()); assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
} }
}
@Test
public void testNodeCommentsAndLocking() throws Exception
{
Comments commentsProxy = publicApiClient.comments();
// locked node - cannot add/edit/delete comments (MNT-14945, MNT-16446) // locked node - cannot add/edit/delete comments (MNT-14945, MNT-16446)
try try
{ {
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person11.getId())); publicApiClient.setRequestContext(new RequestContext(network1.getId(), person11.getId()));
@@ -797,7 +810,7 @@ public class TestNodeComments extends EnterpriseTestApi
int skipCount = 0; int skipCount = 0;
int maxItems = Integer.MAX_VALUE; int maxItems = Integer.MAX_VALUE;
Paging paging = getPaging(skipCount, maxItems, expectedComments.size(), expectedComments.size()); Paging paging = getPaging(skipCount, maxItems);
commentsProxy.getNodeComments(nodeRef1.getId(), createParams(paging, null)); commentsProxy.getNodeComments(nodeRef1.getId(), createParams(paging, null));
// test POST for a locked node // test POST for a locked node
@@ -809,7 +822,7 @@ public class TestNodeComments extends EnterpriseTestApi
fail(""); fail("");
} }
catch(PublicApiException e) catch (PublicApiException e)
{ {
assertEquals(HttpStatus.SC_CONFLICT, e.getHttpResponse().getStatusCode()); assertEquals(HttpStatus.SC_CONFLICT, e.getHttpResponse().getStatusCode());
} }
@@ -823,7 +836,7 @@ public class TestNodeComments extends EnterpriseTestApi
fail(""); fail("");
} }
catch(PublicApiException e) catch (PublicApiException e)
{ {
assertEquals(HttpStatus.SC_CONFLICT, e.getHttpResponse().getStatusCode()); assertEquals(HttpStatus.SC_CONFLICT, e.getHttpResponse().getStatusCode());
} }
@@ -835,7 +848,7 @@ public class TestNodeComments extends EnterpriseTestApi
fail(""); fail("");
} }
catch(PublicApiException e) catch (PublicApiException e)
{ {
assertEquals(HttpStatus.SC_CONFLICT, e.getHttpResponse().getStatusCode()); assertEquals(HttpStatus.SC_CONFLICT, e.getHttpResponse().getStatusCode());
} }
@@ -854,6 +867,48 @@ public class TestNodeComments extends EnterpriseTestApi
} }
} }
// lock recursively (MNT-14945, MNT-16446, REPO-1150)
@Test
public void testNodeCommentsAndLockingIncludingChildren() throws Exception
{
Comments commentsProxy = publicApiClient.comments();
// TODO push-down to future CommentServiceImplTest (see ACE-5437) - since includeChildren is via LockService api only
try
{
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person11.getId()));
Comment comment = new Comment();
comment.setContent("my comment");
Comment createdComment = commentsProxy.createNodeComment(nodeRef5.getId(), comment);
// recursive lock (folderRef1, nodeRef5)
TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
repoService.lockNode(folderNodeRef1, LockType.WRITE_LOCK, 0, true);
return null;
}
}, person11.getId(), network1.getId());
}
finally
{
TenantUtil.runAsSystemTenant(new TenantRunAsWork<Void>()
{
@Override
public Void doWork() throws Exception
{
repoService.unlockNode(folderNodeRef1, true);
return null;
}
}, network1.getId());
}
}
@Test @Test
public void test_MNT_16446() throws Exception public void test_MNT_16446() throws Exception
{ {