use of org.alfresco.rest.framework.resource.parameters.InvalidSelectException in project alfresco-remote-api by Alfresco.
the class RecognizedParamsExtractor method getClause.
/**
* Gets the clause specificed in paramName
*
* @param param
* @param paramName
* @return bean property names potentially using JSON Pointer syntax
*/
default List<String> getClause(String param, String paramName) {
if (param == null)
return Collections.emptyList();
try {
CommonTree selectedPropsTree = WhereCompiler.compileSelectClause(param);
if (selectedPropsTree instanceof CommonErrorNode) {
rpeLogger().debug("Error parsing the " + paramName + " clause " + selectedPropsTree);
throw new InvalidSelectException(paramName, selectedPropsTree);
}
if (selectedPropsTree.getChildCount() == 0 && !selectedPropsTree.getText().isEmpty()) {
return Arrays.asList(selectedPropsTree.getText());
}
List<Tree> children = (List<Tree>) selectedPropsTree.getChildren();
if (children != null && !children.isEmpty()) {
List<String> properties = new ArrayList<String>(children.size());
for (Tree child : children) {
properties.add(child.getText());
}
return properties;
}
} catch (RewriteCardinalityException re) {
// Catch any error so it doesn't get thrown up the stack
rpeLogger().debug("Unhandled Error parsing the " + paramName + " clause: " + re);
} catch (RecognitionException e) {
rpeLogger().debug("Error parsing the \"+paramName+\" clause: " + param);
} catch (InvalidQueryException iqe) {
throw new InvalidSelectException(paramName, iqe.getQueryParam());
}
// Default to throw out an invalid query
throw new InvalidSelectException(paramName, param);
}
Aggregations