mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
65590: Merged V4.2-BUG-FIX (4.2.2) to HEAD-BUG-FIX (4.3/Cloud) 65433: Merged DEV to V4.2-BUG-FIX (4.2.2) 63225 : MNT-10536 : Public API > GET nodes/<nodeId>/comments. - Throw InvalidArgumentException (status 400) if detected node is not a content or a folder 65046 : MNT-10536 : Public API > GET nodes/<nodeId>/comments. - Test for the fix git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@66245 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -38,6 +38,8 @@ package org.alfresco.rest.api.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.AbstractList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -216,6 +218,14 @@ public class CommentsImpl implements Comments
|
||||
{
|
||||
final NodeRef nodeRef = nodes.validateNode(nodeId);
|
||||
|
||||
/* MNT-10536 : fix */
|
||||
final Set<QName> contentAndFolders =
|
||||
new HashSet<QName>(Arrays.asList(ContentModel.TYPE_FOLDER, ContentModel.TYPE_CONTENT));
|
||||
if (!nodes.nodeMatches(nodeRef, contentAndFolders, null))
|
||||
{
|
||||
throw new InvalidArgumentException("NodeId of folder or content is expected");
|
||||
}
|
||||
|
||||
PagingRequest pagingRequest = Util.getPagingRequest(paging);
|
||||
final PagingResults<NodeRef> pagingResults = commentService.listComments(nodeRef, pagingRequest);
|
||||
|
||||
|
@@ -1028,6 +1028,14 @@ public class RepoService
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
public NodeRef createCmObject(final NodeRef parentNodeRef, final String name)
|
||||
{
|
||||
QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(name));
|
||||
NodeRef nodeRef = nodeService.createNode(parentNodeRef, ContentModel.ASSOC_CONTAINS, assocQName, ContentModel.TYPE_CMOBJECT).getChildRef();
|
||||
|
||||
return nodeRef;
|
||||
}
|
||||
|
||||
public Visibility getVisibility(Client client, NodeRef nodeRef)
|
||||
{
|
||||
return hiddenAspect.getVisibility(client, nodeRef);
|
||||
|
@@ -56,6 +56,7 @@ public class TestNodeComments extends EnterpriseTestApi
|
||||
private NodeRef nodeRef2;
|
||||
private NodeRef nodeRef3;
|
||||
private NodeRef nodeRef4;
|
||||
private NodeRef cmObjectNodeRef;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception
|
||||
@@ -129,6 +130,8 @@ public class TestNodeComments extends EnterpriseTestApi
|
||||
nodes.add(nodeRef);
|
||||
nodeRef = repoService.createDocument(site1.getContainerNodeRef("documentLibrary"), "Test Doc 3", "Test Content 3");
|
||||
nodes.add(nodeRef);
|
||||
nodeRef = repoService.createCmObject(site1.getContainerNodeRef("documentLibrary"), "CM Object");
|
||||
nodes.add(nodeRef);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -139,6 +142,7 @@ public class TestNodeComments extends EnterpriseTestApi
|
||||
this.nodeRef2 = nodes.get(2);
|
||||
this.nodeRef3 = nodes.get(3);
|
||||
this.nodeRef4 = nodes.get(4);
|
||||
this.cmObjectNodeRef = nodes.get(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -196,6 +200,20 @@ public class TestNodeComments extends EnterpriseTestApi
|
||||
createdComments.put(ret.getId(), ret);
|
||||
}
|
||||
|
||||
// get comments of the non-folder/non-document nodeRef
|
||||
try
|
||||
{
|
||||
int skipCount = 0;
|
||||
int maxItems = 2;
|
||||
Paging paging = getPaging(skipCount, maxItems);
|
||||
commentsProxy.getNodeComments(cmObjectNodeRef.getId(), createParams(paging, null));
|
||||
fail();
|
||||
}
|
||||
catch(PublicApiException e)
|
||||
{
|
||||
assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
|
||||
}
|
||||
|
||||
int skipCount = 0;
|
||||
int maxItems = 2;
|
||||
Paging paging = getPaging(skipCount, maxItems);
|
||||
|
Reference in New Issue
Block a user