Skip to content

Commit

Permalink
Merge 23.11 to 24.2
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-teamcity committed Feb 6, 2024
2 parents ac1a5f3 + 00ea91d commit af898bd
Showing 1 changed file with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@
import org.labkey.api.util.URLHelper;
import org.labkey.api.view.ActionURL;
import org.labkey.api.view.HtmlView;
import org.labkey.api.view.HttpRedirectView;
import org.labkey.api.view.HttpView;
import org.labkey.api.view.JspView;
import org.labkey.api.view.NavTree;
import org.labkey.api.view.NotFoundException;
import org.labkey.api.view.RedirectException;
import org.labkey.api.view.UnauthorizedException;
import org.labkey.api.webdav.WebdavResource;
import org.labkey.api.webdav.WebdavService;
import org.labkey.skylinetoolsstore.model.Rating;
import org.labkey.skylinetoolsstore.model.SkylineTool;
import org.labkey.skylinetoolsstore.view.SkylineToolDetails;
Expand Down Expand Up @@ -105,6 +106,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -1101,9 +1103,28 @@ else if (toolLsid != null &&
"Path=/; Domain=;");
}

return new HttpRedirectView(
AppProps.getInstance().getContextPath() + "/files" + tool.lookupContainer().getPath()
+ "/" + tool.getZipName());
Container toolContainer = ContainerManager.getForId(tool.getContainerId());
if (toolContainer == null)
{
throw new NotFoundException("Tool container not found");
}

org.labkey.api.util.Path path = WebdavService.getPath().append(toolContainer.getParsedPath()).append(FileContentService.FILES_LINK).append(tool.getZipName());
WebdavResource resource = WebdavService.get().getResolver().lookup(path);
if (resource == null || !resource.isFile())
throw new NotFoundException("Resource could not be found: " + path.toString());

// Issue 49580: https://www.labkey.org/MacCoss/Issue%20Tracker/issues-details.view?issueId=49580
// Add our own 'Content-Disposition' header so that it overwrites the one set in
// ResponseHelper.setContentDisposition(HttpServletResponse response, ContentDispositionType type, @NotNull String filename)
// Skyline expects the 'Content-Disposition' header value to look like this: filename="MSstatsShiny.zip".
Map<String, String> headers = Collections.singletonMap("Content-Disposition", "filename=\""+ tool.getZipName() + "\"");
PageFlowUtil.streamFile(getViewContext().getResponse(),
headers,
resource.getName(),
resource.getInputStream(getUser()),
true);
return null;
}

protected boolean recordDownload(HttpServletRequest httpServletRequest, int toolId)
Expand Down

0 comments on commit af898bd

Please sign in to comment.