refs 2521: Explore the possibility to port the StatMan interface onto Dataminer

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

Fixed Image Download

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@129040 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-06-09 14:58:32 +00:00
parent 3efd9dcd1d
commit 0bdd12db00
3 changed files with 1 additions and 67 deletions

View File

@ -1,58 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.dataminermanager.server;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.gcube.portlets.user.dataminermanager.server.storage.StorageUtil;
/**
*
* @author Giancarlo Panichi
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DownloadServlet extends HttpServlet{
private static final long serialVersionUID = -8423345575690165644L;
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String requestType = (String)req.getParameter("type");
String smpUrl = (String)req.getParameter("url");
String fileName = req.getParameter("name");
System.out.println("DOWNLOAD SERVLET");
System.out.println("SMP URL: "+smpUrl);
System.out.println("File name: "+fileName);
try{
if (requestType==null || !requestType.toUpperCase().contentEquals("IMAGES"))
resp.setHeader( "Content-Disposition", "attachment; filename=\"" + fileName + "\"" );
InputStream inputStream = StorageUtil.getStorageClientInputStream(smpUrl);
OutputStream out = resp.getOutputStream();
IOUtils.copy(inputStream, resp.getOutputStream());
out.close();
} catch (Exception e) {
System.out.println("Error during external item sending "+smpUrl);
// e.printStackTrace();
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error during data retrieving: "+e.getMessage());
return;
}
}
}

View File

@ -159,7 +159,7 @@
margin: 0px 5px 5px 10px; /* top right bottom left*/
padding: 5px;
overflow: hidden;
height: 64px;
height: 78px;
}
.operatorPanel-selected {

View File

@ -11,10 +11,6 @@
<servlet-name>jUnitHostImpl</servlet-name>
<servlet-class>com.google.gwt.junit.server.JUnitHostImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>DownloadService</servlet-name>
<servlet-class>org.gcube.portlets.user.dataminermanager.server.DownloadServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>DownloadFolderServlet</servlet-name>
<servlet-class>org.gcube.portlets.user.dataminermanager.server.DownloadFolderServlet</servlet-class>
@ -47,10 +43,6 @@
<servlet-name>jUnitHostImpl</servlet-name>
<url-pattern>/dataminermanager/junithost/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>DownloadService</servlet-name>
<url-pattern>/dataminermanager/DownloadService</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>DownloadFolderServlet</servlet-name>
<url-pattern>/dataminermanager/DownloadFolderServlet</url-pattern>