use of io.arlas.server.core.exceptions.NotAllowedException in project ARLAS-server by gisaia.
the class JdbiFluidSearch method setOrder.
private void setOrder(Aggregation aggregationModel, MetricSelectClause metricAggregation, SelectClause sp) throws ArlasException {
Order order = aggregationModel.order;
OrderOn on = aggregationModel.on;
boolean isGeo = GEO_AGGREGATION_TYPE_ENUMS.contains(aggregationModel.type);
if (order == null && on == null && !isGeo) {
if (aggregationModel.type == AggregationTypeEnum.term) {
order = Order.desc;
on = OrderOn.count;
} else {
order = Order.asc;
on = OrderOn.field;
}
}
boolean orderAsc = order == Order.asc;
if (order != null && on != null) {
if (!isGeo) {
switch(on) {
case field:
req.addOrderClause(sp.asName, orderAsc);
break;
case count:
req.addOrderClause(((AggregationSelectClause) sp).asNameCount, orderAsc);
break;
case result:
if (metricAggregation != null) {
// ORDER ON RESULT IS NOT ALLOWED ON COORDINATES (CENTROID) OR BOUNDING BOX
if (!metricAggregation.isGeo()) {
req.addOrderClause(metricAggregation.asName, orderAsc);
} else {
throw new BadRequestException(ORDER_ON_GEO_RESULT_NOT_ALLOWED);
}
} else {
throw new BadRequestException(ORDER_ON_RESULT_NOT_ALLOWED);
}
break;
}
} else {
throw new NotAllowedException(ORDER_PARAM_NOT_ALLOWED);
}
} else if (order != null) {
if (isGeo)
throw new NotAllowedException(ORDER_PARAM_NOT_ALLOWED);
else
throw new BadRequestException(ON_NOT_SPECIFIED);
} else if (on != null) {
if (isGeo)
throw new NotAllowedException(ORDER_PARAM_NOT_ALLOWED);
else
throw new BadRequestException(ORDER_NOT_SPECIFIED);
}
}
use of io.arlas.server.core.exceptions.NotAllowedException in project ARLAS-server by gisaia.
the class CheckParams method checkExcludeField.
public static void checkExcludeField(List<String> excludeFields, List<String> fields) throws NotAllowedException {
ArrayList<Pattern> excludeFieldsPattern = new ArrayList<>();
excludeFields.forEach(field -> excludeFieldsPattern.add(Pattern.compile("^" + field.replace(".", "\\.").replace("*", ".*") + ".*$")));
boolean excludePath;
for (String field : fields) {
excludePath = excludeFieldsPattern.stream().anyMatch(pattern -> pattern.matcher(field).matches());
if (excludePath)
throw new NotAllowedException("Unable to exclude field " + field + " used for id, geometry, centroid or timestamp.");
}
}
Aggregations