Merged 5.2.N (5.2.1) to HEAD (5.2)

130610 amorarasu: REPO-484: [REST API] 400 error for unsupported NOT operator in the 'where' predicate.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@132152 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-11-03 13:12:44 +00:00
parent dd91ce3629
commit 07fe704500
5 changed files with 85 additions and 77 deletions

View File

@@ -175,91 +175,94 @@ public class MapBasedQueryWalker extends WalkerCallbackAdapter
}
@Override
public void comparison(int type, String propertyName, String propertyValue)
public void comparison(int type, String propertyName, String propertyValue, boolean negated)
{
boolean throwError = false;
if (variablesEnabled && propertyName.startsWith("variables/"))
{
processVariable(propertyName, propertyValue, type);
}
else
processVariable(propertyName, propertyValue, type);
return;
}
boolean throwError = false;
if (type == WhereClauseParser.EQUALS)
{
if (type == WhereClauseParser.EQUALS)
if (supportedEqualsParameters != null && supportedEqualsParameters.contains(propertyName))
{
if (supportedEqualsParameters != null && supportedEqualsParameters.contains(propertyName))
{
equalsProperties.put(propertyName, propertyValue);
}
else
{
throwError = !handleUnmatchedComparison(type, propertyName, propertyValue);
}
}
else if (type == WhereClauseParser.MATCHES)
{
if (supportedMatchesParameters != null && supportedMatchesParameters.contains(propertyName))
{
matchesProperties.put(propertyName, propertyValue);
}
else
{
throwError = !handleUnmatchedComparison(type, propertyName, propertyValue);
}
}
else if (type == WhereClauseParser.GREATERTHAN)
{
if (supportedGreaterThanParameters != null && supportedGreaterThanParameters.contains(propertyName))
{
greaterThanProperties.put(propertyName, propertyValue);
}
else
{
throwError = !handleUnmatchedComparison(type, propertyName, propertyValue);
}
}
else if (type == WhereClauseParser.GREATERTHANOREQUALS)
{
if (supportedGreaterThanOrEqualParameters != null && supportedGreaterThanOrEqualParameters.contains(propertyName))
{
greaterThanOrEqualProperties.put(propertyName, propertyValue);
}
else
{
throwError = !handleUnmatchedComparison(type, propertyName, propertyValue);
}
}
else if (type == WhereClauseParser.LESSTHAN)
{
if (supportedLessThanParameters != null && supportedLessThanParameters.contains(propertyName))
{
lessThanProperties.put(propertyName, propertyValue);
}
else
{
throwError = !handleUnmatchedComparison(type, propertyName, propertyValue);
}
}
else if (type == WhereClauseParser.LESSTHANOREQUALS)
{
if (supportedLessThanOrEqualParameters != null && supportedLessThanOrEqualParameters.contains(propertyName))
{
lessThanOrEqualProperties.put(propertyName, propertyValue);
}
else
{
throwError = !handleUnmatchedComparison(type, propertyName, propertyValue);
}
equalsProperties.put(propertyName, propertyValue);
}
else
{
throwError = !handleUnmatchedComparison(type, propertyName, propertyValue);
throwError = !handleUnmatchedComparison(type, propertyName, propertyValue);
}
}
else if (type == WhereClauseParser.MATCHES)
{
if (supportedMatchesParameters != null && supportedMatchesParameters.contains(propertyName))
{
matchesProperties.put(propertyName, propertyValue);
}
else
{
throwError = !handleUnmatchedComparison(type, propertyName, propertyValue);
}
}
else if (type == WhereClauseParser.GREATERTHAN)
{
if (supportedGreaterThanParameters != null && supportedGreaterThanParameters.contains(propertyName))
{
greaterThanProperties.put(propertyName, propertyValue);
}
else
{
throwError = !handleUnmatchedComparison(type, propertyName, propertyValue);
}
}
else if (type == WhereClauseParser.GREATERTHANOREQUALS)
{
if (supportedGreaterThanOrEqualParameters != null && supportedGreaterThanOrEqualParameters.contains(propertyName))
{
greaterThanOrEqualProperties.put(propertyName, propertyValue);
}
else
{
throwError = !handleUnmatchedComparison(type, propertyName, propertyValue);
}
}
else if (type == WhereClauseParser.LESSTHAN)
{
if (supportedLessThanParameters != null && supportedLessThanParameters.contains(propertyName))
{
lessThanProperties.put(propertyName, propertyValue);
}
else
{
throwError = !handleUnmatchedComparison(type, propertyName, propertyValue);
}
}
else if (type == WhereClauseParser.LESSTHANOREQUALS)
{
if (supportedLessThanOrEqualParameters != null && supportedLessThanOrEqualParameters.contains(propertyName))
{
lessThanOrEqualProperties.put(propertyName, propertyValue);
}
else
{
throwError = !handleUnmatchedComparison(type, propertyName, propertyValue);
}
}
else
{
throwError = !handleUnmatchedComparison(type, propertyName, propertyValue);
}
if (throwError)
{
throw new InvalidArgumentException("framework.exception.InvalidProperty", new Object[] {propertyName, propertyValue, WhereClauseParser.tokenNames[type]});
}
else if (negated)
{
// Throw error for the unsupported NOT operator only if the property was valid for comparison, show the more meaningful error first.
throw new InvalidArgumentException("NOT operator is not supported for " + WhereClauseParser.tokenNames[type] + " comparison.");
}
}

View File

@@ -37,7 +37,7 @@ public class TaskVariablesWalkerCallback extends WalkerCallbackAdapter
private VariableScope scope = VariableScope.ANY;
@Override
public void comparison(int type, String propertyName, String propertyValue)
public void comparison(int type, String propertyName, String propertyValue, boolean negated)
{
if (PROPERTY_SCOPE.equals(propertyName))
{