Skip to content

Commit 3475cd5

Browse files
committed
Merge remote-tracking branch 'origin/develop' into fb_angus_mail
2 parents 4ddc7ed + 9cdee5b commit 3475cd5

File tree

10 files changed

+73
-35
lines changed

10 files changed

+73
-35
lines changed

api/src/org/labkey/api/collections/ResultSetRowMapFactory.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@
1919
import org.labkey.api.data.ConvertHelper;
2020
import org.labkey.api.util.ResultSetUtil;
2121

22-
import java.beans.Introspector;
2322
import java.io.Serializable;
2423
import java.math.BigDecimal;
2524
import java.sql.Clob;
2625
import java.sql.ResultSet;
2726
import java.sql.ResultSetMetaData;
2827
import java.sql.SQLException;
2928
import java.util.List;
30-
import java.util.Map;
3129

3230
public class ResultSetRowMapFactory extends RowMapFactory<Object> implements Serializable
3331
{
@@ -64,22 +62,9 @@ private ResultSetRowMapFactory(ResultSetMetaData md) throws SQLException
6462
{
6563
super(md.getColumnCount() + 1);
6664

67-
int count = md.getColumnCount();
68-
Map<String, Integer> findMap = getFindMap();
69-
findMap.put("_row", 0); // We're going to stuff the current row index at index 0
70-
71-
for (int i = 1; i <= count; i++)
72-
{
73-
String propName = md.getColumnLabel(i);
74-
75-
if (!propName.isEmpty() && Character.isUpperCase(propName.charAt(0)))
76-
propName = Introspector.decapitalize(propName);
77-
78-
findMap.put(propName, i);
79-
}
65+
ResultSetUtil.populateFindMap(md, getFindMap());
8066
}
8167

82-
8368
public void setConvertBigDecimalToDouble(boolean b)
8469
{
8570
_convertBigDecimalToDouble = b;

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public void renderGridCellContents(RenderContext ctx, Writer out) throws IOExcep
6262
/** @return the short name of the file (not including full path) */
6363
protected abstract String getFileName(RenderContext ctx, Object value);
6464

65+
protected String getFileName(RenderContext ctx, Object value, boolean isDisplay)
66+
{
67+
return getFileName(ctx, value);
68+
}
69+
6570
protected abstract InputStream getFileContents(RenderContext ctx, Object value) throws FileNotFoundException;
6671

6772
protected void renderIconAndFilename(RenderContext ctx, Writer out, String filename, boolean link, boolean thumbnail) throws IOException
@@ -103,7 +108,7 @@ protected void renderIconAndFilename(RenderContext ctx, Writer out, String filen
103108
}
104109
}
105110

106-
String displayName = getFileName(ctx, filename);
111+
String displayName = getFileName(ctx, filename, true);
107112
boolean isImage = isImage(filename);
108113

109114
FileImageRenderHelper renderHelper = createRenderHelper(ctx, url, filename, displayName, fileIconUrl, popupIconUrl, thumbnail, isImage);

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
import org.labkey.api.util.Path;
9090
import org.labkey.api.util.QuietCloser;
9191
import org.labkey.api.util.ReentrantLockWithName;
92+
import org.labkey.api.util.ResultSetUtil;
9293
import org.labkey.api.util.TestContext;
9394
import org.labkey.api.util.logging.LogHelper;
9495
import org.labkey.api.view.ActionURL;
@@ -3103,8 +3104,13 @@ public Container handle(ResultSet rs) throws SQLException
31033104
LockState lockState = null != lockStateString ? Enums.getIfPresent(LockState.class, lockStateString).or(LockState.Unlocked) : LockState.Unlocked;
31043105

31053106
LocalDate expirationDate = rs.getObject("ExpirationDate", LocalDate.class);
3106-
Long fileRootSize = (Long)rs.getObject("FileRootSize"); // getObject() and cast because getLong() returns 0 for null
3107-
LocalDateTime fileRootLastCrawled = rs.getObject("FileRootLastCrawled", LocalDateTime.class);
3107+
3108+
// Could be running upgrade code before these recent columns have been added to the table. Use a find map
3109+
// to determine if they are present. Issue 51692. These checks could be removed after creation of these
3110+
// columns is incorporated into the bootstrap scripts.
3111+
Map<String, Integer> findMap = ResultSetUtil.getFindMap(rs.getMetaData());
3112+
Long fileRootSize = findMap.containsKey("FileRootSize") ? (Long)rs.getObject("FileRootSize") : null; // getObject() and cast because getLong() returns 0 for null
3113+
LocalDateTime fileRootLastCrawled = findMap.containsKey("FileRootLastCrawled") ? rs.getObject("FileRootLastCrawled", LocalDateTime.class) : null;
31083114

31093115
Container dirParent = null;
31103116
if (null != parentId)

api/src/org/labkey/api/study/assay/FileLinkDisplayColumn.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.io.InputStream;
5050
import java.io.Writer;
5151
import java.net.URI;
52+
import java.net.URISyntaxException;
5253
import java.util.List;
5354
import java.util.Map;
5455
import java.util.Set;
@@ -247,15 +248,26 @@ protected String getFileName(RenderContext ctx, Object value)
247248
return getFileName(ctx, value, false);
248249
}
249250

251+
@Override
250252
protected String getFileName(RenderContext ctx, Object value, boolean isDisplay)
251253
{
252254
String result = value == null ? null : StringUtils.trimToNull(value.toString());
253255
if (result != null)
254256
{
255-
File f;
257+
File f = null;
256258
if (result.startsWith("file:"))
257-
f = new File(URI.create(result));
258-
else
259+
{
260+
try
261+
{
262+
f = new File(new URI(result));
263+
}
264+
catch (URISyntaxException x)
265+
{
266+
// try to recover
267+
result = result.substring("file:".length());
268+
}
269+
}
270+
if (null == f)
259271
f = FileUtil.getAbsoluteCaseSensitiveFile(new File(result));
260272
NetworkDrive.ensureDrive(f.getPath());
261273
List<FileContentService.ContentType> fileRootTypes = List.of(FileContentService.ContentType.files, FileContentService.ContentType.pipeline, FileContentService.ContentType.assayfiles);
@@ -270,7 +282,7 @@ protected String getFileName(RenderContext ctx, Object value, boolean isDisplay)
270282
result = f.getName();
271283
}
272284

273-
if (isDisplay && !f.exists())
285+
if (isDisplay && !f.exists() && !result.endsWith("(unavailable)"))
274286
result += " (unavailable)";
275287
}
276288
return result;
@@ -339,7 +351,7 @@ else if (f.isDirectory())
339351
else
340352
{
341353
// It's not on the file system anymore, so don't offer a link and tell the user it's unavailable
342-
super.renderIconAndFilename(ctx, out, filename + " (unavailable)", Attachment.getFileIcon(filename), null, false, false);
354+
super.renderIconAndFilename(ctx, out, filename, Attachment.getFileIcon(filename), null, false, false);
343355
}
344356
}
345357
else

api/src/org/labkey/api/util/ResultSetUtil.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import org.jetbrains.annotations.Nullable;
2121
import org.junit.Assert;
2222
import org.junit.Test;
23+
import org.labkey.api.collections.ArrayListMap;
24+
import org.labkey.api.collections.CaseInsensitiveHashMap;
2325
import org.labkey.api.collections.ResultSetRowMapFactory;
2426
import org.labkey.api.data.CachedResultSet;
2527
import org.labkey.api.data.CachedResultSets;
@@ -28,6 +30,7 @@
2830
import org.labkey.api.query.AliasManager;
2931
import org.labkey.api.util.logging.LogHelper;
3032

33+
import java.beans.Introspector;
3134
import java.io.IOException;
3235
import java.io.StringWriter;
3336
import java.io.Writer;
@@ -108,6 +111,27 @@ public static Map<String, Object> mapRow(ResultSet rs) throws SQLException
108111
return factory.getRowMap(rs);
109112
}
110113

114+
public static Map<String, Integer> populateFindMap(ResultSetMetaData md, Map<String, Integer> findMap) throws SQLException
115+
{
116+
findMap.put("_row", 0); // We're going to stuff the current row index at index 0
117+
118+
for (int i = 1; i <= md.getColumnCount(); i++)
119+
{
120+
String propName = md.getColumnLabel(i);
121+
122+
if (!propName.isEmpty() && Character.isUpperCase(propName.charAt(0)))
123+
propName = Introspector.decapitalize(propName);
124+
125+
findMap.put(propName, i);
126+
}
127+
128+
return findMap;
129+
}
130+
131+
public static Map<String, Integer> getFindMap(ResultSetMetaData md) throws SQLException
132+
{
133+
return populateFindMap(md, new ArrayListMap.FindMap<>(new CaseInsensitiveHashMap<>()));
134+
}
111135

112136
// Just for testing purposes... splats ResultSet metadata to log
113137
@SuppressWarnings("unused")

core/src/org/labkey/core/webdav/DavController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5369,7 +5369,7 @@ private StringBuilder determineMethodsAllowed(WebdavResource resource)
53695369
methodsAllowed.append(", GET, HEAD, COPY");
53705370
if (delete)
53715371
methodsAllowed.append(", DELETE");
5372-
if (delete && read)
5372+
if (delete && read && resource.canRename(user,false))
53735373
methodsAllowed.append(", MOVE");
53745374
if (_locking)
53755375
methodsAllowed.append(", LOCK, UNLOCK");

experiment/src/org/labkey/experiment/ExperimentModule.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -889,10 +889,10 @@ public Collection<String> getSummary(Container c)
889889
columns.add(ExpDataClassTable.Column.Name.name());
890890
columns.add(ExpDataClassTable.Column.DataCount.name());
891891

892-
Map<String, Long> results = new TableSelector(table, columns).getValueMap();
892+
Map<String, Integer> results = new TableSelector(table, columns).getValueMap();
893893
for (var entry : results.entrySet())
894894
{
895-
long count = entry.getValue();
895+
int count = entry.getValue();
896896
if (count > 0)
897897
summaries.add(new Summary(count, entry.getKey()));
898898
}
@@ -917,10 +917,10 @@ public Collection<String> getSummary(Container c)
917917
columns.add(ExpSampleTypeTable.Column.Name.name());
918918
columns.add(ExpSampleTypeTable.Column.SampleCount.name());
919919

920-
Map<String, Long> results = new TableSelector(table, columns).getValueMap();
920+
Map<String, Integer> results = new TableSelector(table, columns).getValueMap();
921921
for (var entry : results.entrySet())
922922
{
923-
long count = entry.getValue();
923+
int count = entry.getValue();
924924
if (count > 0)
925925
{
926926
String name = entry.getKey();

filecontent/src/org/labkey/filecontent/FileContentController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,8 +1259,7 @@ public ApiResponse execute(CustomPropertiesForm form, BindException errors)
12591259
Map<FieldKey, Object> data = result.getFieldKeyRowMap();
12601260
Map<String, Object> row = new HashMap<>();
12611261

1262-
java.nio.file.Path dataFilePath = FileUtil.stringToPath(getContainer(), (String) data.get(dataFileURLFieldKey));
1263-
row.put("dataFileUrl", null != dataFilePath ? FileUtil.pathToString(dataFilePath) : null);
1262+
row.put("dataFileUrl", data.get(dataFileURLFieldKey));
12641263
row.put("rowId", data.get(rowIdFieldKey));
12651264
row.put("name", data.get(nameFieldKey));
12661265

issues/src/org/labkey/issue/model/IssueManager.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -954,9 +954,16 @@ public static void indexIssues(@Nullable Container container, User user, IndexTa
954954

955955
for (Integer id : ids)
956956
{
957-
IssueObject issue = IssueManager.getIssue(container, user, id);
958-
if (issue != null)
959-
queueIssue(task, id, issue.getProperties(), issue.getCommentObjects());
957+
try
958+
{
959+
IssueObject issue = IssueManager.getIssue(container, user, id);
960+
if (issue != null)
961+
queueIssue(task, id, issue.getProperties(), issue.getCommentObjects());
962+
}
963+
catch (UnauthorizedException e)
964+
{
965+
// Issue 51607 ignore restricted issue failures
966+
}
960967
}
961968
}
962969

pipeline/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ jugVersion=2.0.0
88
# external repositories
99
muleModuleBuildersVersion=1.4.4e
1010

11-
xstreamVersion=1.4.20
11+
xstreamVersion=1.4.21

0 commit comments

Comments
 (0)