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:
Alan Davis
2014-04-02 21:46:59 +00:00
parent 080827166a
commit 3913fde282
3 changed files with 37 additions and 1 deletions

View File

@@ -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;
@@ -215,6 +217,14 @@ public class CommentsImpl implements Comments
public CollectionWithPagingInfo<Comment> getComments(String nodeId, Paging paging)
{
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);