Skip to content

Commit 09bfc87

Browse files
committed
Merge remote-tracking branch 'origin/develop' into fb_delete_overlapping_indices
2 parents 6579ad1 + bfba15b commit 09bfc87

111 files changed

Lines changed: 484 additions & 563 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

announcements/src/org/labkey/announcements/AnnouncementsController.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@
107107
import org.labkey.api.util.DateUtil;
108108
import org.labkey.api.util.GUID;
109109
import org.labkey.api.util.HtmlString;
110+
import org.labkey.api.util.OptionBuilder;
110111
import org.labkey.api.util.PageFlowUtil;
111112
import org.labkey.api.util.Pair;
112-
import org.labkey.api.util.URLHelper;
113-
import org.labkey.api.util.OptionBuilder;
114113
import org.labkey.api.util.SelectBuilder;
114+
import org.labkey.api.util.URLHelper;
115115
import org.labkey.api.view.ActionURL;
116116
import org.labkey.api.view.AjaxCompletion;
117117
import org.labkey.api.view.AlwaysAvailableWebPartFactory;
@@ -137,7 +137,6 @@
137137
import org.springframework.web.servlet.ModelAndView;
138138

139139
import java.io.IOException;
140-
import java.io.PrintWriter;
141140
import java.util.ArrayList;
142141
import java.util.Arrays;
143142
import java.util.Calendar;

announcements/src/org/labkey/announcements/SendMessageAction.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.labkey.announcements;
1818

1919
import org.apache.commons.lang3.StringUtils;
20+
import org.apache.commons.lang3.Strings;
2021
import org.apache.logging.log4j.LogManager;
2122
import org.apache.logging.log4j.Logger;
2223
import org.jetbrains.annotations.NotNull;
@@ -224,11 +225,11 @@ private void addMsgRecipients(MailHelper.MultipartMessage msg, JSONArray recipie
224225
if (!_recipientMap.containsKey(type))
225226
_recipientMap.put(type, new HashSet<>());
226227

227-
if (StringUtils.equalsIgnoreCase(type, "TO"))
228+
if (Strings.CI.equals(type, "TO"))
228229
rtype = Message.RecipientType.TO;
229-
else if (StringUtils.equalsIgnoreCase(type, "CC"))
230+
else if (Strings.CI.equals(type, "CC"))
230231
rtype = Message.RecipientType.CC;
231-
else if (StringUtils.equalsIgnoreCase(type, "BCC"))
232+
else if (Strings.CI.equals(type, "BCC"))
232233
rtype = Message.RecipientType.BCC;
233234

234235
for (String email : resolveEmailAddress(recipient))

api/src/org/labkey/api/action/BaseApiAction.java

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.labkey.api.util.HttpUtil;
3838
import org.labkey.api.util.JsonUtil;
3939
import org.labkey.api.util.MimeMap;
40-
import org.labkey.api.util.Pair;
4140
import org.labkey.api.util.ResponseHelper;
4241
import org.labkey.api.util.StringUtilsLabKey;
4342
import org.labkey.api.view.BadRequestException;
@@ -91,13 +90,13 @@ private Marshaller findMarshaller()
9190
Marshal marshal = getClass().getAnnotation(Marshal.class);
9291
if (marshal == null)
9392
{
94-
Class superClass = getClass().getSuperclass();
93+
Class<?> superClass = getClass().getSuperclass();
9594
if (null != superClass)
9695
marshal = (Marshal) superClass.getAnnotation(Marshal.class);
9796
}
9897
if (marshal == null)
9998
{
100-
Class declaringClass = getClass().getDeclaringClass();
99+
Class<?> declaringClass = getClass().getDeclaringClass();
101100
if (declaringClass != null)
102101
marshal = (Marshal)declaringClass.getAnnotation(Marshal.class);
103102
}
@@ -123,17 +122,13 @@ protected String getCommandClassMethodName()
123122
@Override
124123
public ModelAndView handleRequest() throws Exception
125124
{
126-
switch (getViewContext().getMethod())
125+
return switch (getViewContext().getMethod())
127126
{
128-
case POST:
129-
case PUT:
130-
case DELETE:
131-
case PATCH:
132-
return handlePost();
133-
case GET:
134-
return handleGet();
135-
}
136-
throw new BadRequestException("Method Not Allowed: " + getViewContext().getRequest().getMethod(), null, HttpServletResponse.SC_METHOD_NOT_ALLOWED);
127+
case POST, PUT, DELETE, PATCH -> handlePost();
128+
case GET -> handleGet();
129+
default ->
130+
throw new BadRequestException("Method Not Allowed: " + getViewContext().getRequest().getMethod(), null, HttpServletResponse.SC_METHOD_NOT_ALLOWED);
131+
};
137132
}
138133

139134
@Override
@@ -176,7 +171,7 @@ public ModelAndView handlePost() throws Exception
176171

177172
try
178173
{
179-
Pair<FORM, BindException> pair;
174+
FormAndErrors<FORM> pair;
180175

181176
try
182177
{
@@ -188,8 +183,8 @@ public ModelAndView handlePost() throws Exception
188183
return null;
189184
}
190185

191-
FORM form = pair.first;
192-
BindException errors = pair.second;
186+
FORM form = pair.form;
187+
BindException errors = pair.errors;
193188

194189
if (form != null)
195190
{
@@ -309,7 +304,7 @@ protected double getApiVersion()
309304

310305

311306
@NotNull
312-
private Pair<FORM, BindException> populateForm() throws Exception
307+
private FormAndErrors<FORM> populateForm() throws Exception
313308
{
314309
try (Timing ignored = MiniProfiler.step("bind"))
315310
{
@@ -330,7 +325,7 @@ private Pair<FORM, BindException> populateForm() throws Exception
330325
// CONSIDER: Extract ApiRequestReader similar to the ApiResponseWriter
331326
// CONSIDER: Something like Jersey's MessageBodyReader? https://jax-rs-spec.java.net/nonav/2.0/apidocs/javax/ws/rs/ext/MessageBodyReader.html
332327
@NotNull
333-
private Pair<FORM, BindException> populateJsonForm() throws Exception
328+
private FormAndErrors<FORM> populateJsonForm() throws Exception
334329
{
335330
if (_marshaller == Marshaller.Jackson)
336331
return populateJacksonForm();
@@ -340,29 +335,33 @@ private Pair<FORM, BindException> populateJsonForm() throws Exception
340335

341336

342337
@NotNull
343-
private Pair<FORM, BindException> defaultPopulateForm() throws Exception
338+
private FormAndErrors<FORM> defaultPopulateForm() throws Exception
344339
{
345340
saveRequestedApiVersion(getViewContext().getRequest(), null);
346341

347342
BindException errors = defaultBindParameters(getCommand(), getPropertyValues());
348343
FORM form = (FORM)errors.getTarget();
349344

350-
return Pair.of(form, errors);
345+
return new FormAndErrors<>(form, errors);
346+
}
347+
348+
public record FormAndErrors<FORM>(FORM form, BindException errors)
349+
{
351350
}
352351

353352
/**
354353
* Use Jackson to parse POST body as JSON and instantiate the FORM class directly.
355354
*/
356355
@NotNull
357356
// Leave this protected; client-developed action classes override it. See #38307
358-
protected Pair<FORM, BindException> populateJacksonForm() throws Exception
357+
protected FormAndErrors<FORM> populateJacksonForm() throws Exception
359358
{
360359
FORM form = null;
361360
BindException errors;
362361

363362
try
364363
{
365-
Class c = getCommandClass();
364+
Class<?> c = getCommandClass();
366365
// Ideally, ObjectReader would handle the Object case as well, but currently readValue() throws with "end-of-input" exception
367366
if (Object.class != c)
368367
{
@@ -393,7 +392,7 @@ protected Pair<FORM, BindException> populateJacksonForm() throws Exception
393392
}
394393

395394
saveRequestedApiVersion(getViewContext().getRequest(), form);
396-
return Pair.of(form, errors);
395+
return new FormAndErrors<>(form, errors);
397396
}
398397

399398
private ObjectMapper getRequestObjectMapper()
@@ -431,7 +430,7 @@ protected ObjectMapper createResponseObjectMapper()
431430
return JsonUtil.DEFAULT_MAPPER;
432431
}
433432

434-
protected ObjectReader getObjectReader(Class c)
433+
protected ObjectReader getObjectReader(Class<?> c)
435434
{
436435
return getRequestObjectMapper().readerFor(c);
437436
}
@@ -440,7 +439,7 @@ protected ObjectReader getObjectReader(Class c)
440439
* Parse POST body as JSONObject then use either ApiJsonForm or spring form binding to populate the FORM instance.
441440
*/
442441
@NotNull
443-
private Pair<FORM, BindException> populateJSONObjectForm() throws Exception
442+
private FormAndErrors<FORM> populateJSONObjectForm() throws Exception
444443
{
445444
JSONObject jsonObj;
446445
try
@@ -460,7 +459,7 @@ private Pair<FORM, BindException> populateJSONObjectForm() throws Exception
460459

461460
FORM form = getCommand();
462461
BindException errors = populateForm(jsonObj, form);
463-
return Pair.of(form, errors);
462+
return new FormAndErrors<>(form, errors);
464463
}
465464

466465

@@ -652,15 +651,5 @@ public static <T> SimpleResponse<T> success(String message, T data)
652651
{
653652
return new SimpleResponse<>(true, message, data);
654653
}
655-
656-
void notFound() throws NotFoundException
657-
{
658-
throw new NotFoundException();
659-
}
660-
661-
void notFound(String message) throws NotFoundException
662-
{
663-
throw new NotFoundException(message);
664-
}
665654
}
666655

api/src/org/labkey/api/action/SpringActionController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ protected void handleException(Throwable x, ViewContext context, PageConfig page
593593
// THEN ask the caller to retry.
594594
if (x instanceof Exception && SqlDialect.isTransactionException((Exception)x) && "GET".equals(request.getMethod()) && !response.isCommitted())
595595
{
596-
if (!StringUtils.equals("1",getViewContext().getActionURL().getParameter("_retry_")))
596+
if (!"1".equals(getViewContext().getActionURL().getParameter("_retry_")))
597597
{
598598
ActionURL url = getViewContext().cloneActionURL().addParameter("_retry_", "1");
599599
ExceptionUtil.doErrorRedirect(response, url.getLocalURIString());

api/src/org/labkey/api/attachments/AttachmentService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ static AttachmentService get()
6262

6363
void download(HttpServletResponse response, AttachmentParent parent, String name, boolean inlineIfPossible) throws ServletException, IOException;
6464

65-
HttpView getHistoryView(ViewContext context, AttachmentParent parent);
65+
HttpView<?> getHistoryView(ViewContext context, AttachmentParent parent, BindException errors);
6666

67-
HttpView getErrorView(List<AttachmentFile> files, BindException errors, URLHelper returnUrl);
67+
HttpView<?> getErrorView(List<AttachmentFile> files, BindException errors, URLHelper returnUrl);
6868

6969
void addAttachments(AttachmentParent parent, List<AttachmentFile> files, @NotNull User user) throws IOException;
7070

@@ -132,9 +132,9 @@ static AttachmentService get()
132132

133133
void registerAttachmentType(AttachmentType type);
134134

135-
HttpView getAdminView(ActionURL currentUrl);
135+
HttpView<?> getAdminView(ActionURL currentUrl);
136136

137-
HttpView getFindAttachmentParentsView();
137+
HttpView<?> getFindAttachmentParentsView();
138138

139139
class DuplicateFilenameException extends IOException
140140
{
@@ -170,7 +170,7 @@ public String getMessage()
170170

171171
class FileTooLargeException extends IOException
172172
{
173-
private List<String> _errors = new ArrayList<>();
173+
private final List<String> _errors = new ArrayList<>();
174174

175175
public FileTooLargeException(Collection<AttachmentFile> files, int maxSize) throws IOException
176176
{

api/src/org/labkey/api/audit/provider/SiteSettingsAuditProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public TableInfo createTableInfo(UserSchema userSchema, ContainerFilter cf)
9696
List<FieldKey> defaultCols = new ArrayList<>(table.getDefaultVisibleColumns());
9797
defaultCols.add(FieldKey.fromParts("Changes"));
9898
table.setDefaultVisibleColumns(defaultCols);
99-
DetailsURL url = DetailsURL.fromString("audit/showSiteSettingsAuditDetails.view?id=${rowId}");
99+
DetailsURL url = DetailsURL.fromString("audit-showSiteSettingsAuditDetails.view?id=${rowId}");
100100
url.setStrictContainerContextEval(true);
101101
table.setDetailsURL(url);
102102

api/src/org/labkey/api/data/BaseColumnInfo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.apache.commons.collections4.MultiValuedMap;
2222
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
2323
import org.apache.commons.lang3.StringUtils;
24+
import org.apache.commons.lang3.Strings;
2425
import org.apache.logging.log4j.Logger;
2526
import org.jetbrains.annotations.NotNull;
2627
import org.jetbrains.annotations.Nullable;
@@ -1102,7 +1103,7 @@ public void loadFromXml(ColumnType xmlCol, boolean merge)
11021103
{
11031104
String conceptURI = xmlCol.getConceptURI();
11041105
// User can not set this concepturi, it only applies to exp.object.objectid
1105-
if (!StringUtils.equalsIgnoreCase(conceptURI,BuiltInColumnTypes.EXPOBJECTID_CONCEPT_URI))
1106+
if (!Strings.CI.equals(conceptURI,BuiltInColumnTypes.EXPOBJECTID_CONCEPT_URI))
11061107
setConceptURI(conceptURI);
11071108
}
11081109
if (xmlCol.isSetRangeURI())

api/src/org/labkey/api/data/ContainerTable.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.labkey.api.data;
1818

1919
import org.apache.commons.lang3.StringUtils;
20+
import org.apache.commons.lang3.Strings;
2021
import org.apache.logging.log4j.LogManager;
2122
import org.jetbrains.annotations.NotNull;
2223
import org.labkey.api.collections.NamedObjectList;
@@ -232,7 +233,7 @@ protected String transformValue(Integer rawValue)
232233
@Override
233234
protected ColumnInfo resolveColumn(String name)
234235
{
235-
if (StringUtils.equalsIgnoreCase("iconurl",name))
236+
if (Strings.CI.equals("iconurl",name))
236237
{
237238
var iconCol = new WrappedColumn(getColumn("entityid"), "iconurl");
238239
iconCol.setDisplayColumnFactory(IconDisplayColumn::new);

api/src/org/labkey/api/data/MaterializedQueryHelper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package org.labkey.api.data;
1717

1818
import org.apache.commons.lang3.StringUtils;
19+
import org.apache.commons.lang3.Strings;
1920
import org.jetbrains.annotations.NotNull;
2021
import org.jetbrains.annotations.Nullable;
2122
import org.junit.After;
@@ -225,7 +226,7 @@ public boolean stillValid(long createdTime)
225226
{
226227
String prevResult = result.get();
227228
String newResult = new SqlSelector(mqh._scope, mqh._uptodateQuery).getObject(String.class);
228-
if (StringUtils.equals(prevResult,newResult))
229+
if (Strings.CS.equals(prevResult,newResult))
229230
return true;
230231
result.set(newResult);
231232
return false;
@@ -265,7 +266,7 @@ public boolean stillValid(long createdTime)
265266
{
266267
String prevResult = _result.get();
267268
String newResult = _supplier.get();
268-
if (StringUtils.equals(prevResult,newResult))
269+
if (Strings.CS.equals(prevResult,newResult))
269270
return true;
270271
_result.set(newResult);
271272
return false;

api/src/org/labkey/api/data/PropertyManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.commons.collections4.map.UnmodifiableEntrySet;
2626
import org.apache.commons.collections4.set.UnmodifiableSet;
2727
import org.apache.commons.lang3.StringUtils;
28+
import org.apache.commons.lang3.Strings;
2829
import org.apache.logging.log4j.Logger;
2930
import org.jetbrains.annotations.NotNull;
3031
import org.jetbrains.annotations.Nullable;
@@ -449,7 +450,7 @@ public String put(String key, @Nullable String value)
449450
{
450451
if (null != _removedKeys)
451452
_removedKeys.remove(key);
452-
if (!StringUtils.equals(value, get(key)))
453+
if (!Strings.CS.equals(value, get(key)))
453454
_modified = true;
454455
return super.put(key, value);
455456
}

0 commit comments

Comments
 (0)