mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
124792 jvonka: RA-767: Queries API - min 3 alphanumeric chars in search 'term' (pending requirement review) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126586 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -66,6 +66,9 @@ public class QueriesImpl implements Queries, InitializingBean
|
||||
|
||||
private final static String QUERY_LIVE_SEARCH_NODES = "live-search-nodes";
|
||||
|
||||
private final static int TERM_MIN_LEN = 3; // review: should this be configurable system-wide (&/or per-tenant in the cloud) ?
|
||||
|
||||
|
||||
private final static Map<String,QName> MAP_PARAM_SORT_QNAME;
|
||||
static
|
||||
{
|
||||
@@ -112,12 +115,33 @@ public class QueriesImpl implements Queries, InitializingBean
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
// TODO check min length, excluding quotes etc
|
||||
String term = parameters.getParameter(PARAM_TERM);
|
||||
if (term == null)
|
||||
{
|
||||
throw new InvalidArgumentException("Query 'term' not specified");
|
||||
}
|
||||
else
|
||||
{
|
||||
String s = term.trim();
|
||||
int cnt = 0;
|
||||
for (int i = 0; i < s.length(); i++)
|
||||
{
|
||||
char c = s.charAt(i);
|
||||
if (Character.isLetterOrDigit(c))
|
||||
{
|
||||
cnt++;
|
||||
if (cnt == TERM_MIN_LEN)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cnt < TERM_MIN_LEN)
|
||||
{
|
||||
throw new InvalidArgumentException("Query 'term' is too short. Must have at least "+TERM_MIN_LEN+" alphanumeric chars");
|
||||
}
|
||||
}
|
||||
|
||||
String rootNodeId = parameters.getParameter(PARAM_ROOT_NODE_ID);
|
||||
if (rootNodeId != null)
|
||||
|
Reference in New Issue
Block a user