|
67 | 67 | import org.labkey.api.util.URLHelper; |
68 | 68 | import org.labkey.api.view.ActionURL; |
69 | 69 | import org.labkey.api.view.HtmlView; |
70 | | -import org.labkey.api.view.HttpRedirectView; |
71 | 70 | import org.labkey.api.view.HttpView; |
72 | 71 | import org.labkey.api.view.JspView; |
73 | 72 | import org.labkey.api.view.NavTree; |
74 | 73 | import org.labkey.api.view.NotFoundException; |
75 | 74 | import org.labkey.api.view.RedirectException; |
76 | 75 | import org.labkey.api.view.UnauthorizedException; |
| 76 | +import org.labkey.api.webdav.WebdavResource; |
| 77 | +import org.labkey.api.webdav.WebdavService; |
77 | 78 | import org.labkey.skylinetoolsstore.model.Rating; |
78 | 79 | import org.labkey.skylinetoolsstore.model.SkylineTool; |
79 | 80 | import org.labkey.skylinetoolsstore.view.SkylineToolDetails; |
|
105 | 106 | import java.util.ArrayList; |
106 | 107 | import java.util.Arrays; |
107 | 108 | import java.util.Calendar; |
| 109 | +import java.util.Collections; |
108 | 110 | import java.util.Enumeration; |
109 | 111 | import java.util.HashMap; |
110 | 112 | import java.util.HashSet; |
@@ -1101,9 +1103,28 @@ else if (toolLsid != null && |
1101 | 1103 | "Path=/; Domain=;"); |
1102 | 1104 | } |
1103 | 1105 |
|
1104 | | - return new HttpRedirectView( |
1105 | | - AppProps.getInstance().getContextPath() + "/files" + tool.lookupContainer().getPath() |
1106 | | - + "/" + tool.getZipName()); |
| 1106 | + Container toolContainer = ContainerManager.getForId(tool.getContainerId()); |
| 1107 | + if (toolContainer == null) |
| 1108 | + { |
| 1109 | + throw new NotFoundException("Tool container not found"); |
| 1110 | + } |
| 1111 | + |
| 1112 | + org.labkey.api.util.Path path = WebdavService.getPath().append(toolContainer.getParsedPath()).append(FileContentService.FILES_LINK).append(tool.getZipName()); |
| 1113 | + WebdavResource resource = WebdavService.get().getResolver().lookup(path); |
| 1114 | + if (resource == null || !resource.isFile()) |
| 1115 | + throw new NotFoundException("Resource could not be found: " + path.toString()); |
| 1116 | + |
| 1117 | + // Issue 49580: https://www.labkey.org/MacCoss/Issue%20Tracker/issues-details.view?issueId=49580 |
| 1118 | + // Add our own 'Content-Disposition' header so that it overwrites the one set in |
| 1119 | + // ResponseHelper.setContentDisposition(HttpServletResponse response, ContentDispositionType type, @NotNull String filename) |
| 1120 | + // Skyline expects the 'Content-Disposition' header value to look like this: filename="MSstatsShiny.zip". |
| 1121 | + Map<String, String> headers = Collections.singletonMap("Content-Disposition", "filename=\""+ tool.getZipName() + "\""); |
| 1122 | + PageFlowUtil.streamFile(getViewContext().getResponse(), |
| 1123 | + headers, |
| 1124 | + resource.getName(), |
| 1125 | + resource.getInputStream(getUser()), |
| 1126 | + true); |
| 1127 | + return null; |
1107 | 1128 | } |
1108 | 1129 |
|
1109 | 1130 | protected boolean recordDownload(HttpServletRequest httpServletRequest, int toolId) |
|
0 commit comments