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
40 changes: 24 additions & 16 deletions api/src/org/labkey/api/data/ExpDataFileConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ private static DataType getDataType(@NotNull File file, @NotNull Collection<Assa
}

public static File convert(Object value)
{
return convert(value, true);
}

public static File convert(Object value, boolean tryResolutionByRowId)
{
if (value == null)
return null;
Expand All @@ -226,7 +231,7 @@ public static File convert(Object value)
{
try
{
return convert(value, fileRootPath, assayResultFileRoot, container, user);
return convert(value, fileRootPath, assayResultFileRoot, container, user, tryResolutionByRowId);
}
catch (ConvertHelper.FileConversionException e)
{
Expand All @@ -242,12 +247,12 @@ public static File convert(Object value)
}

// TODO, refactor more usages to call this method directly without using needing to set/getEnvironment
public static File convert(Object value, @Nullable String fileRootPath, @Nullable FileLike assayResultFileRoot, Container container, User user)
public static File convert(Object value, @Nullable String fileRootPath, @Nullable FileLike assayResultFileRoot, Container container, User user, boolean tryResolutionByRowId)
{
if (value == null)
return null;

File f = convertToFile(value, container, user, fileRootPath, assayResultFileRoot);
File f = convertToFile(value, container, user, fileRootPath, assayResultFileRoot, tryResolutionByRowId);

// If we have a file path, make sure it's supposed to be visible in the current container
if (f != null)
Expand Down Expand Up @@ -326,7 +331,7 @@ public static File convert(Object value, @Nullable String fileRootPath, @Nullabl
return null;
}

public static File convertToFile(Object value, @NotNull Container container, @NotNull User user, @Nullable String fileRootPath, @Nullable FileLike assayResultFileRoot)
public static File convertToFile(Object value, @NotNull Container container, @NotNull User user, @Nullable String fileRootPath, @Nullable FileLike assayResultFileRoot, boolean tryResolutionByRowId)
{
if (value instanceof File f)
{
Expand All @@ -344,27 +349,30 @@ public static File convertToFile(Object value, @NotNull Container container, @No
}

// Value specified as simple property, so we have to guess what it might be
// First, try looking it up as a RowId
try
if (tryResolutionByRowId)
{
int dataRowId = Integer.parseInt(value.toString());
ExpData data = ExperimentService.get().getExpData(dataRowId);
if (data != null)
// First, try looking it up as a RowId
try
{
File result = data.getFile();
if (result != null)
int dataRowId = Integer.parseInt(value.toString());
ExpData data = ExperimentService.get().getExpData(dataRowId);
if (data != null)
{
return result;
File result = data.getFile();
if (result != null)
{
return result;
}
}
}
}
catch (NumberFormatException ignored)
{
catch (NumberFormatException ignored)
{
}
}

// toss in here an additional check, if starts with HTTP then try to use _webdav to resolve it
// MAKE sure that the security is in place - figure out what container it is in
String rootSubstitutedPath = getFileRootSubstitutedFilePath(value.toString(), fileRootPath);;
String rootSubstitutedPath = getFileRootSubstitutedFilePath(value.toString(), fileRootPath);
if (null != StringUtils.trimToNull(rootSubstitutedPath))
{
if (assayResultFileRoot != null)
Expand Down
2 changes: 1 addition & 1 deletion experiment/src/org/labkey/experiment/ExpDataIterators.java
Original file line number Diff line number Diff line change
Expand Up @@ -2269,7 +2269,7 @@ public static class FileLinkDataIterator extends WrapperDataIterator
}
}

return ExpDataFileConverter.convert(value);
return ExpDataFileConverter.convert(value, false);
};
}
}
Expand Down