mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-22 06:58:45 +00:00
Move handleQueryNullLimit to utils class
This commit is contained in:
@ -1366,7 +1366,7 @@ public class QJavalinImplementation
|
||||
|
||||
if(queryInput.getFilter() == null || queryInput.getFilter().getLimit() == null)
|
||||
{
|
||||
handleQueryNullLimit(context, queryInput);
|
||||
QJavalinUtils.handleQueryNullLimit(javalinMetaData, queryInput, context);
|
||||
}
|
||||
|
||||
List<QueryJoin> queryJoins = processQueryJoinsParam(context);
|
||||
@ -1389,28 +1389,6 @@ public class QJavalinImplementation
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
**
|
||||
***************************************************************************/
|
||||
private static void handleQueryNullLimit(Context context, QueryInput queryInput)
|
||||
{
|
||||
boolean allowed = javalinMetaData.getQueryWithoutLimitAllowed();
|
||||
if(!allowed)
|
||||
{
|
||||
if(queryInput.getFilter() == null)
|
||||
{
|
||||
queryInput.setFilter(new QQueryFilter());
|
||||
}
|
||||
|
||||
queryInput.getFilter().setLimit(javalinMetaData.getQueryWithoutLimitDefault());
|
||||
LOG.log(javalinMetaData.getQueryWithoutLimitLogLevel(), "Query request did not specify a limit, which is not allowed. Using default instead", null,
|
||||
logPair("defaultLimit", javalinMetaData.getQueryWithoutLimitDefault()),
|
||||
logPair("path", context.path()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
@ -31,12 +31,15 @@ import com.kingsrook.qqq.backend.core.exceptions.QPermissionDeniedException;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QUserFacingException;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QValueException;
|
||||
import com.kingsrook.qqq.backend.core.logging.QLogger;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput;
|
||||
import com.kingsrook.qqq.backend.core.utils.ExceptionUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.JsonUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.ValueUtils;
|
||||
import io.javalin.http.Context;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import static com.kingsrook.qqq.backend.core.logging.LogUtils.logPair;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -48,7 +51,6 @@ public class QJavalinUtils
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Returns Integer if context has a valid int query parameter by the given name,
|
||||
** Returns null if no param (or empty value).
|
||||
@ -252,4 +254,32 @@ public class QJavalinUtils
|
||||
context.status(statusCode.getCode());
|
||||
context.result(JsonUtils.toJson(Map.of("error", errorMessage)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
**
|
||||
***************************************************************************/
|
||||
public static void handleQueryNullLimit(QJavalinMetaData javalinMetaData, QueryInput queryInput, Context context)
|
||||
{
|
||||
if(javalinMetaData == null)
|
||||
{
|
||||
javalinMetaData = new QJavalinMetaData();
|
||||
}
|
||||
|
||||
boolean allowed = javalinMetaData.getQueryWithoutLimitAllowed();
|
||||
if(!allowed)
|
||||
{
|
||||
if(queryInput.getFilter() == null)
|
||||
{
|
||||
queryInput.setFilter(new QQueryFilter());
|
||||
}
|
||||
|
||||
queryInput.getFilter().setLimit(javalinMetaData.getQueryWithoutLimitDefault());
|
||||
LOG.log(javalinMetaData.getQueryWithoutLimitLogLevel(), "Query request did not specify a limit, which is not allowed. Using default instead", null,
|
||||
logPair("defaultLimit", javalinMetaData.getQueryWithoutLimitDefault()),
|
||||
logPair("path", context == null ? null : context.path()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user