use of datawave.webservice.query.exception.BadRequestQueryException in project datawave by NationalSecurityAgency.
the class GetAllMatches method initialize.
@Override
public void initialize(List<String> parameterList, int depth, QueryNode parent) throws IllegalArgumentException {
super.initialize(parameterList, depth, parent);
WildcardFieldedFilter.BooleanType type = WildcardFieldedFilter.BooleanType.AND;
int x = 0;
if (this.parameterList.size() % 2 == 1) {
try {
String firstArg = this.parameterList.get(0);
type = WildcardFieldedFilter.BooleanType.valueOf(firstArg.toUpperCase());
} catch (Exception e) {
BadRequestQueryException qe = new BadRequestQueryException(DatawaveErrorCode.INVALID_FUNCTION_ARGUMENTS, MessageFormat.format("{0}", e, this.name));
throw new IllegalArgumentException(qe);
}
x = 1;
}
this.fieldedFilter = new WildcardFieldedFilter(true, type);
while (x < parameterList.size()) {
String field = parameterList.get(x++);
String regex = parameterList.get(x++);
this.fieldedFilter.addCondition(field, regex);
}
}
use of datawave.webservice.query.exception.BadRequestQueryException in project datawave by NationalSecurityAgency.
the class DateFunction method validate.
@Override
public void validate() throws IllegalArgumentException {
if (this.parameterList.size() < 2) {
BadRequestQueryException qe = new BadRequestQueryException(DatawaveErrorCode.INVALID_FUNCTION_ARGUMENTS, MessageFormat.format("{0}", this.name));
throw new IllegalArgumentException(qe);
}
String type = this.parameterList.get(1).toLowerCase();
boolean knownType = COMMANDS.contains(type);
if (!knownType) {
// if the type is not specified, then we accept the between arguments
if (this.parameterList.size() < 3 || this.parameterList.size() > 5) {
BadRequestQueryException qe = new BadRequestQueryException(DatawaveErrorCode.INVALID_FUNCTION_ARGUMENTS, MessageFormat.format("{0}", this.name));
throw new IllegalArgumentException(qe);
}
} else if (type.equals("between")) {
if (this.parameterList.size() < 4 || this.parameterList.size() > 6) {
BadRequestQueryException qe = new BadRequestQueryException(DatawaveErrorCode.INVALID_FUNCTION_ARGUMENTS, MessageFormat.format("{0}", this.name));
throw new IllegalArgumentException(qe);
}
} else {
if (this.parameterList.size() < 3 || this.parameterList.size() > 5) {
BadRequestQueryException qe = new BadRequestQueryException(DatawaveErrorCode.INVALID_FUNCTION_ARGUMENTS, MessageFormat.format("{0}", this.name));
throw new IllegalArgumentException(qe);
}
}
}
use of datawave.webservice.query.exception.BadRequestQueryException in project datawave by NationalSecurityAgency.
the class EvaluationOnly method toString.
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("((_Eval_ = true) && (");
List<String> params = getParameterList();
if (params.size() != 1) {
BadRequestQueryException qe = new BadRequestQueryException(DatawaveErrorCode.INVALID_FUNCTION_ARGUMENTS, MessageFormat.format("{0}", this.name));
throw new IllegalArgumentException(qe);
} else {
try {
sb.append(parser.parse(params.get(0)).getOriginalQuery());
} catch (ParseException e) {
BadRequestQueryException qe = new BadRequestQueryException(DatawaveErrorCode.INVALID_FUNCTION_ARGUMENTS, MessageFormat.format("{0}", this.name));
throw new IllegalArgumentException(qe);
}
}
sb.append("))");
return sb.toString();
}
use of datawave.webservice.query.exception.BadRequestQueryException in project datawave by NationalSecurityAgency.
the class Occurrence method initialize.
@Override
public void initialize(List<String> parameterList, int depth, QueryNode parent) throws IllegalArgumentException {
super.initialize(parameterList, depth, parent);
WildcardFieldedFilter.BooleanType type = WildcardFieldedFilter.BooleanType.AND;
int x = 0;
if (this.parameterList.size() % 2 == 1) {
try {
String firstArg = this.parameterList.get(0);
type = WildcardFieldedFilter.BooleanType.valueOf(firstArg.toUpperCase());
} catch (Exception e) {
BadRequestQueryException qe = new BadRequestQueryException(DatawaveErrorCode.INVALID_FUNCTION_ARGUMENTS, MessageFormat.format("{0}", e, this.name));
throw new IllegalArgumentException(qe);
}
x = 1;
}
this.fieldedFilter = new WildcardFieldedFilter(true, type);
while (x < parameterList.size()) {
String field = parameterList.get(x++);
String regex = parameterList.get(x++);
this.fieldedFilter.addCondition(field, regex);
}
}
use of datawave.webservice.query.exception.BadRequestQueryException in project datawave by NationalSecurityAgency.
the class Loaded method validate.
@Override
public void validate() throws IllegalArgumentException {
if (this.parameterList.size() < 1) {
BadRequestQueryException qe = new BadRequestQueryException(DatawaveErrorCode.INVALID_FUNCTION_ARGUMENTS, MessageFormat.format("{0}", this.name));
throw new IllegalArgumentException(qe);
}
String type = this.parameterList.get(0).toLowerCase();
boolean knownType = COMMANDS.contains(type);
if (!knownType) {
// if the type is not specified, then we accept the between arguments
if (this.parameterList.size() < 1 || this.parameterList.size() > 3) {
BadRequestQueryException qe = new BadRequestQueryException(DatawaveErrorCode.INVALID_FUNCTION_ARGUMENTS, MessageFormat.format("{0}", this.name));
throw new IllegalArgumentException(qe);
}
} else if (type.equals("between")) {
if (this.parameterList.size() < 2 || this.parameterList.size() > 4) {
BadRequestQueryException qe = new BadRequestQueryException(DatawaveErrorCode.INVALID_FUNCTION_ARGUMENTS, MessageFormat.format("{0}", this.name));
throw new IllegalArgumentException(qe);
}
} else {
if (this.parameterList.size() < 1 || this.parameterList.size() > 3) {
BadRequestQueryException qe = new BadRequestQueryException(DatawaveErrorCode.INVALID_FUNCTION_ARGUMENTS, MessageFormat.format("{0}", this.name));
throw new IllegalArgumentException(qe);
}
}
}
Aggregations