ref 11720: DataMiner - Update to StorageHUB

https://support.d4science.org/issues/11720

Updated to StorageHub 

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@172017 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2018-10-08 09:50:17 +00:00
parent 45852ce7da
commit 95caa76d5d
1 changed files with 13 additions and 5 deletions

View File

@ -101,31 +101,39 @@ public class DownloadServlet extends HttpServlet {
String fileName;
if (itemDownload.getItemDescription() == null) {
fileName = "filename";
resp.setHeader("Content-Disposition:", "attachment;filename=\"" + fileName + "\"");
resp.setHeader("Content-Type", "application/force-download");
} else {
if (itemDownload.getItemDescription().getName() == null
|| itemDownload.getItemDescription().getName().isEmpty()) {
if (itemDownload.getItemDescription().getType() != null && itemDownload.getItemDescription()
.getType().compareTo(FolderItem.class.getSimpleName()) == 0) {
fileName = "folder.zip";
resp.setHeader("Content-Disposition:", "attachment;filename=\"" + fileName + "\"");
resp.setHeader("Content-Type", "application/zip");
} else {
fileName = "filename";
resp.setHeader("Content-Disposition:", "attachment;filename=\"" + fileName + "\"");
resp.setHeader("Content-Type", "application/force-download");
}
} else {
if (itemDownload.getItemDescription().getType() != null && itemDownload.getItemDescription()
.getType().compareTo(FolderItem.class.getSimpleName()) == 0) {
fileName = itemDownload.getItemDescription().getName() + ".zip";
resp.setHeader("Content-Disposition:", "attachment;filename=\"" + fileName + "\"");
resp.setHeader("Content-Type", "application/zip");
} else {
fileName = itemDownload.getItemDescription().getName();
resp.setHeader("Content-Disposition:", "attachment;filename=\"" + fileName + "\"");
resp.setHeader("Content-Type", "application/force-download");
}
}
}
logger.debug("DownloadServlet filename: " + fileName);
resp.setHeader("Content-Disposition:", "attachment;filename=\"" + fileName + "\"");
resp.setHeader("Content-Type", "application/force-download");
stream(itemDownload.getInputStream(), resp.getOutputStream());
}
}
} catch (ServiceException e) {
logger.error("DownloadServlet():" + e.getLocalizedMessage(), e);
throw new ServletException(e.getLocalizedMessage(), e);