use of doitincloud.commons.exceptions.BadRequestException in project rdbcache by rdbcache.
the class Request method processOptions.
private static void processOptions(Context context, HttpServletRequest request, KeyInfo keyInfo, String[] options) {
Map<String, String[]> params = request.getParameterMap();
if (keyInfo.getIsNew()) {
if (options[1] != null) {
keyInfo.setTable(options[1]);
}
if (options[0] != null) {
keyInfo.setExpire(options[0]);
}
if (params != null && params.size() > 0) {
QueryInfo queryInfo = new QueryInfo(keyInfo.getTable(), params);
keyInfo.setQuery(queryInfo);
}
} else {
if (options[0] != null && !options[0].equals(keyInfo.getExpire())) {
keyInfo.setExpire(options[0]);
keyInfo.setIsNew(true);
}
if (options[1] != null && !options[1].equals(keyInfo.getTable())) {
throw new BadRequestException(context, "can not change table name for an existing key");
}
if (params != null && params.size() > 0) {
QueryInfo queryInfo = new QueryInfo(keyInfo.getTable(), params);
if (keyInfo.getQueryKey() == null || !keyInfo.getQueryKey().equals(queryInfo.getKey())) {
throw new BadRequestException(context, "can not modify condition for an existing key");
}
}
}
}
Aggregations