Search in sources :

Example 26 with BadRequestQueryException

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);
    }
}
Also used : BadRequestQueryException(datawave.webservice.query.exception.BadRequestQueryException) WildcardFieldedFilter(datawave.query.search.WildcardFieldedFilter) BadRequestQueryException(datawave.webservice.query.exception.BadRequestQueryException)

Example 27 with BadRequestQueryException

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);
        }
    }
}
Also used : BadRequestQueryException(datawave.webservice.query.exception.BadRequestQueryException)

Example 28 with BadRequestQueryException

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();
}
Also used : BadRequestQueryException(datawave.webservice.query.exception.BadRequestQueryException) ParseException(datawave.query.language.parser.ParseException)

Example 29 with BadRequestQueryException

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);
    }
}
Also used : BadRequestQueryException(datawave.webservice.query.exception.BadRequestQueryException) WildcardFieldedFilter(datawave.query.search.WildcardFieldedFilter) BadRequestQueryException(datawave.webservice.query.exception.BadRequestQueryException)

Example 30 with BadRequestQueryException

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);
        }
    }
}
Also used : BadRequestQueryException(datawave.webservice.query.exception.BadRequestQueryException)

Aggregations

BadRequestQueryException (datawave.webservice.query.exception.BadRequestQueryException)30 BadRequestException (datawave.webservice.common.exception.BadRequestException)12 QueryException (datawave.webservice.query.exception.QueryException)12 NotFoundQueryException (datawave.webservice.query.exception.NotFoundQueryException)11 DatawaveWebApplicationException (datawave.webservice.common.exception.DatawaveWebApplicationException)10 UnauthorizedException (datawave.webservice.common.exception.UnauthorizedException)10 PreConditionFailedQueryException (datawave.webservice.query.exception.PreConditionFailedQueryException)10 UnauthorizedQueryException (datawave.webservice.query.exception.UnauthorizedQueryException)10 IOException (java.io.IOException)10 Produces (javax.ws.rs.Produces)10 WebApplicationException (javax.ws.rs.WebApplicationException)8 NoResultsException (datawave.webservice.common.exception.NoResultsException)7 NoResultsQueryException (datawave.webservice.query.exception.NoResultsQueryException)7 Path (javax.ws.rs.Path)7 GZIP (org.jboss.resteasy.annotations.GZIP)7 DatawavePrincipal (datawave.security.authorization.DatawavePrincipal)6 GenericResponse (datawave.webservice.result.GenericResponse)6 CancellationException (java.util.concurrent.CancellationException)6 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)6 Interceptors (javax.interceptor.Interceptors)6