mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
REPO-1059: REST API: Invalid orderBy field is ignored
- additional fix + test case git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@130593 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -313,13 +313,18 @@ public interface RecognizedParamsExtractor
|
||||
}
|
||||
else
|
||||
{
|
||||
rpeLogger().debug("Invalid sort order definition (" + sortDef + "). Valid values are " + SortColumn.ASCENDING + " or "
|
||||
rpeLogger().debug("Invalid sort order direction (" + sortDef + "). Valid values are " + SortColumn.ASCENDING + " or "
|
||||
+ SortColumn.DESCENDING + ".");
|
||||
throw new InvalidArgumentException("Unknown sort order direction: "+sortDef+" expected: asc or desc");
|
||||
throw new InvalidArgumentException("Unknown sort order direction '"+sortDef+"', expected asc or desc");
|
||||
}
|
||||
}
|
||||
sortedColumns.add(new SortColumn(columnName, SortColumn.ASCENDING.equals(sortOrder)));
|
||||
}
|
||||
else
|
||||
{
|
||||
rpeLogger().debug("Invalid sort order definition (" + token + ")");
|
||||
throw new InvalidArgumentException("Unknown sort order definition '" + token + "', expected 'field1,field2' or 'field1 asc,field2 desc' or similar");
|
||||
}
|
||||
// filteredProperties.add();
|
||||
}
|
||||
// logger.debug("Filtering using the following properties: " + filteredProperties);
|
||||
|
@@ -148,22 +148,32 @@ public class RecognizedParamsExtractorTest implements RecognizedParamsExtractor
|
||||
assertEquals("name", theSort.get(1).column);
|
||||
assertTrue(theSort.get(1).asc);
|
||||
|
||||
theSort = getSort("name asc,"); // ok for now, trailing comma is ignored
|
||||
assertNotNull(theSort);
|
||||
assertTrue("Must have a value for column: NAME", !theSort.isEmpty());
|
||||
assertTrue(theSort.size() == 1);
|
||||
assertEquals("name", theSort.get(0).column);
|
||||
assertTrue(theSort.get(0).asc);
|
||||
|
||||
try
|
||||
{
|
||||
getSort("age asc, name des"); // nvalid, should be desc
|
||||
fail("Should throw an InvalidSelectException");
|
||||
getSort("age asc, name des"); // invalid, should be desc
|
||||
fail("Should throw an InvalidArgumentException");
|
||||
}
|
||||
catch (InvalidArgumentException error)
|
||||
{
|
||||
// this is correct
|
||||
}
|
||||
|
||||
theSort = getSort("name asc,"); // trailing comma is ignored
|
||||
assertNotNull(theSort);
|
||||
assertTrue("Must have a value for column: NAME", !theSort.isEmpty());
|
||||
assertTrue(theSort.size() == 1);
|
||||
assertEquals("name", theSort.get(0).column);
|
||||
assertTrue(theSort.get(0).asc);
|
||||
try
|
||||
{
|
||||
getSort("age asc name"); // invalid, missing comma
|
||||
fail("Should throw an InvalidArgumentException");
|
||||
}
|
||||
catch (InvalidArgumentException error)
|
||||
{
|
||||
// this is correct
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user