mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged 5.2.N (5.2.1) to HEAD (5.2)
131385 idanea: ACE-5453: 500 error: GET /nodes/{nodeId}/ratings?skipCount=XXX - implemented fix and added new unit test git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@132255 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -108,14 +108,16 @@ public class NodeRatingsImpl implements NodeRatings
|
|||||||
|
|
||||||
int skipCount = paging.getSkipCount();
|
int skipCount = paging.getSkipCount();
|
||||||
int maxItems = paging.getMaxItems();
|
int maxItems = paging.getMaxItems();
|
||||||
|
int totalSize = schemes.size();
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
int end = skipCount + maxItems;
|
int end = skipCount + maxItems;
|
||||||
if(end < 0)
|
if(end < 0)
|
||||||
{
|
{
|
||||||
// overflow
|
// overflow
|
||||||
end = Integer.MAX_VALUE;
|
end = Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
int count = Math.min(maxItems, schemes.size() - skipCount);
|
List<NodeRating> ratings = new ArrayList<NodeRating>(totalSize);
|
||||||
List<NodeRating> ratings = new ArrayList<NodeRating>(count);
|
|
||||||
|
|
||||||
for(int i = 0; i < end && it.hasNext(); i++)
|
for(int i = 0; i < end && it.hasNext(); i++)
|
||||||
{
|
{
|
||||||
@@ -124,13 +126,12 @@ public class NodeRatingsImpl implements NodeRatings
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
count++;
|
||||||
RatingScheme ratingScheme = validateRatingScheme(schemeName);
|
RatingScheme ratingScheme = validateRatingScheme(schemeName);
|
||||||
NodeRating nodeRating = ratingScheme.getNodeRating(nodeRef);
|
NodeRating nodeRating = ratingScheme.getNodeRating(nodeRef);
|
||||||
ratings.add(nodeRating);
|
ratings.add(nodeRating);
|
||||||
}
|
}
|
||||||
|
|
||||||
int totalSize = schemes.size();
|
|
||||||
boolean hasMoreItems = (skipCount + count < totalSize);
|
boolean hasMoreItems = (skipCount + count < totalSize);
|
||||||
|
|
||||||
return CollectionWithPagingInfo.asPaged(paging, ratings, hasMoreItems, totalSize);
|
return CollectionWithPagingInfo.asPaged(paging, ratings, hasMoreItems, totalSize);
|
||||||
|
@@ -534,6 +534,28 @@ public class TestNodeRatings extends AbstractBaseApiTest
|
|||||||
assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
|
assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test case ACE-5453
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
testSkipCountLargeValue(person11, network1, nodeRef1, nodesProxy);
|
||||||
|
}
|
||||||
|
catch (PublicApiException e)
|
||||||
|
{
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// test for retrieving the list of ratings with high value of skipCount(e.g. 10)
|
||||||
|
public void testSkipCountLargeValue(TestPerson person11, TestNetwork network1, NodeRef nodeRef1, Nodes nodesProxy) throws PublicApiException
|
||||||
|
{
|
||||||
|
List<NodeRating> expectedRatings = repoService.getNodeRatings(person11.getId(), network1.getId(), nodeRef1);
|
||||||
|
int skipCount = 10;
|
||||||
|
int maxItems = Integer.MAX_VALUE;
|
||||||
|
Paging paging = getPaging(skipCount, maxItems, expectedRatings.size(), expectedRatings.size());
|
||||||
|
nodesProxy.getNodeRatings(nodeRef1.getId(), createParams(paging, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user