Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 13 additions & 28 deletions api/src/org/labkey/api/action/BaseApiAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import org.labkey.api.miniprofiler.MiniProfiler;
import org.labkey.api.miniprofiler.Timing;
import org.labkey.api.query.BatchValidationException;
import org.labkey.api.query.InvalidKeyException;
import org.labkey.api.query.QueryException;
Expand Down Expand Up @@ -200,19 +198,12 @@ public ModelAndView handlePost() throws Exception
}
else
{
Object response;
try (Timing ignored = MiniProfiler.step("execute"))
{
response = execute(form, errors);
}
Object response = execute(form, errors);

try (Timing ignored = MiniProfiler.step("render"))
{
if (isFailure(errors))
writeResponse((Errors) errors);
else if (null != response)
writeResponse(response);
}
if (isFailure(errors))
writeResponse((Errors) errors);
else if (null != response)
writeResponse(response);
}
}
catch (BindException e)
Expand Down Expand Up @@ -275,20 +266,17 @@ protected double getApiVersion()
@NotNull
private FormAndErrors<FORM> populateForm() throws Exception
{
try (Timing ignored = MiniProfiler.step("bind"))
String contentType = getViewContext().getRequest().getContentType();
if (null != contentType)
{
String contentType = getViewContext().getRequest().getContentType();
if (null != contentType)
if (MimeMap.DEFAULT.isJsonContentTypeHeader(contentType))
{
if (MimeMap.DEFAULT.isJsonContentTypeHeader(contentType))
{
_reqFormat = ApiResponseWriter.Format.JSON;
return populateJsonForm();
}
_reqFormat = ApiResponseWriter.Format.JSON;
return populateJsonForm();
}

return defaultPopulateForm();
}

return defaultPopulateForm();
}

// CONSIDER: Extract ApiRequestReader similar to the ApiResponseWriter
Expand Down Expand Up @@ -565,10 +553,7 @@ else if (value instanceof JSONObject)
@Override
public final void validate(@NotNull Object form, @NotNull Errors errors)
{
try (Timing ignored = MiniProfiler.step("validate"))
{
validateForm((FORM) form, errors);
}
validateForm((FORM) form, errors);
}

/**
Expand Down
34 changes: 10 additions & 24 deletions api/src/org/labkey/api/action/FormViewAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package org.labkey.api.action;

import org.jetbrains.annotations.NotNull;
import org.labkey.api.miniprofiler.MiniProfiler;
import org.labkey.api.miniprofiler.Timing;
import org.labkey.api.util.ExceptionUtil;
import org.labkey.api.util.URLHelper;
import org.labkey.api.view.HttpView;
Expand Down Expand Up @@ -62,11 +60,8 @@ public final ModelAndView handleRequest() throws Exception
{
FORM form;
BindException errors;
try (Timing ignored = MiniProfiler.step("bind"))
{
errors = bindParameters(getPropertyValues());
form = (errors.hasErrors() && getCommandClass().isRecord()) ? null : (FORM) errors.getTarget();
}
errors = bindParameters(getPropertyValues());
form = (errors.hasErrors() && getCommandClass().isRecord()) ? null : (FORM) errors.getTarget();

return handleRequest(form, errors);
}
Expand All @@ -79,34 +74,25 @@ public ModelAndView handleRequest(FORM form, BindException errors) throws Except
{
setReshow(true);

try (Timing ignored = MiniProfiler.step("validate"))
{
if (success && null != form)
validate(form, errors);
}
if (success && null != form)
validate(form, errors);
success = errors == null || !errors.hasErrors();

try (Timing ignored = MiniProfiler.step("handlePost"))
{
if (success)
success = handlePost(form, errors);
}
if (success)
success = handlePost(form, errors);

if (success)
{
URLHelper url = getSuccessURL(form);
if (null != url)
return HttpView.redirect(url);
try (Timing ignored = MiniProfiler.step("createView"))
{
ModelAndView successView = getSuccessView(form);
if (null != successView)
return successView;
}
ModelAndView successView = getSuccessView(form);
if (null != successView)
return successView;
}
}

try (Timing ignored = MiniProfiler.step("createView"))
try
{
return getView(form, getReshow(), errors);
}
Expand Down
33 changes: 11 additions & 22 deletions api/src/org/labkey/api/action/SimpleViewAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package org.labkey.api.action;

import org.jetbrains.annotations.NotNull;
import org.labkey.api.miniprofiler.MiniProfiler;
import org.labkey.api.miniprofiler.Timing;
import org.labkey.api.view.BadRequestException;
import org.labkey.api.view.ViewServlet;
import org.labkey.api.view.WebPartView;
Expand Down Expand Up @@ -47,31 +45,22 @@ protected SimpleViewAction(Class<? extends FORM> formClass)
public ModelAndView handleRequest() throws Exception
{
BindException errors;
try (Timing ignored = MiniProfiler.step("bind"))
{
// GET parameters have already been validated in ViewServlet
PropertyValues pvs = getPropertyValues();
if (!isGet())
validateUnicodePropertyValues(pvs);
errors = bindParameters(pvs);
}
// GET parameters have already been validated in ViewServlet
PropertyValues pvs = getPropertyValues();
if (!isGet())
validateUnicodePropertyValues(pvs);
errors = bindParameters(pvs);

FORM form;
try (Timing ignored = MiniProfiler.step("validate"))
{
form = (FORM) errors.getTarget();
validate(form, errors);
}
form = (FORM) errors.getTarget();
validate(form, errors);

ModelAndView v;

try (Timing ignored = MiniProfiler.step("createView"))
{
if (_print)
v = getPrintView(form, errors);
else
v = getView(form, errors);
}
if (_print)
v = getPrintView(form, errors);
else
v = getView(form, errors);

return v;
}
Expand Down
19 changes: 0 additions & 19 deletions api/src/org/labkey/api/action/SpringActionController.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
import org.labkey.api.data.Container;
import org.labkey.api.data.TransactionFilter;
import org.labkey.api.data.dialect.SqlDialect;
import org.labkey.api.miniprofiler.MiniProfiler;
import org.labkey.api.miniprofiler.RequestInfo;
import org.labkey.api.module.AllowedBeforeInitialUserIsSet;
import org.labkey.api.module.AllowedDuringUpgrade;
import org.labkey.api.module.Module;
Expand Down Expand Up @@ -95,7 +93,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -509,22 +506,6 @@ public ModelAndView handleRequest(HttpServletRequest request, @NotNull HttpServl
{
MemTracker.get().ignore();
}
else
{
// Don't send back mini-profiler id if the user won't be able to get the profiler info
if (MiniProfiler.isEnabled(context))
{
RequestInfo req = MemTracker.get().current();
if (req != null)
{
LinkedHashSet<Long> ids = new LinkedHashSet<>();
ids.add(req.getId());
ids.addAll(MemTracker.get().getUnviewed(context.getUser()));

response.setHeader("X-MiniProfiler-Ids", ids.toString());
}
}
}

// MULTIPART-FORMDATA handling (before permission check because permissionCheck needs CSRF parameter)
String contentType = request.getContentType();
Expand Down
10 changes: 4 additions & 6 deletions api/src/org/labkey/api/data/DataRegionSelection.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

package org.labkey.api.data;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.action.ApiSimpleResponse;
import org.labkey.api.collections.LongArrayList;
import org.labkey.api.collections.ResultSetRowMapFactory;
import org.labkey.api.miniprofiler.MiniProfiler;
import org.labkey.api.miniprofiler.Timing;
import org.labkey.api.query.QueryForm;
import org.labkey.api.query.QueryService;
import org.labkey.api.query.QueryView;
Expand All @@ -36,8 +36,6 @@
import org.labkey.api.view.NotFoundException;
import org.labkey.api.view.ViewContext;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
Expand Down Expand Up @@ -508,7 +506,7 @@ public static int setSelectionForAll(QueryView view, String key, boolean checked
var rgn = regionCtx.first;
var rc = regionCtx.second;

try (Timing ignored = MiniProfiler.step("selectAll"); ResultSet rs = rgn.getResults(rc))
try (ResultSet rs = rgn.getResults(rc))
{
var selection = createSelectionSet(rc, rgn, rs, null);
return setSelected(view.getViewContext(), key, selection, checked, false, true);
Expand Down Expand Up @@ -552,7 +550,7 @@ private static Set<String> getSelectedItems(QueryView view, @NotNull Collection<
ctx.setBaseFilter(new SimpleFilter(pkCol.getFieldKey(), pkCol.isNumericType() ? selectedValues.stream().map(Integer::parseInt).toList() : selectedValues, CompareType.IN));
}

try (Timing ignored = MiniProfiler.step("getSelected"); Results rs = rgn.getResults(ctx))
try (Results rs = rgn.getResults(ctx))
{
return createSelectionSet(ctx, rgn, rs, selectedValues);
}
Expand Down
Loading
Loading