Implemented Feature #5028 with WebSockets

Workspace enhancements: avoid http timeout during folder compression plus fix for servlet not exposing absute paths file download

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace@131621 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-09-22 10:31:54 +00:00
parent 4928d1e554
commit 9fb3aee05e
1 changed files with 13 additions and 5 deletions

View File

@ -14,6 +14,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import javax.websocket.OnClose;
import javax.websocket.OnMessage;
@ -126,13 +127,20 @@ public class DownloadFolderWebSocketServer {
try {
File tmpZip = ZipUtil.zipFolder((WorkspaceFolder) item);
Path tmpDir = Files.createTempDirectory("workspace_temp");
File toCopy = new File(tmpDir.toAbsolutePath()+File.separator+item.getName());
String tmpSys = System.getProperty("java.io.tmpdir");
String randomDirName = UUID.randomUUID().toString();
String toReturn = randomDirName + File.separator + item.getName();
_log.debug("Copying in " + tmpSys + File.separator + toReturn);
String path = tmpSys + File.separator + randomDirName;
File thePath = new File (path);
thePath.mkdirs();
File toCopy = new File(tmpSys + File.separator + toReturn);
if (!toCopy.exists())
toCopy.createNewFile();
copyFileUsingFileChannels(tmpZip, toCopy);
_log.info("Zipped folder in="+toCopy.getAbsolutePath());
_log.info("Zipped folder in="+toCopy.getAbsolutePath() + ", returning="+toReturn);
tmpZip.deleteOnExit();
return toCopy.getAbsolutePath();
return toReturn;
} catch (Exception e) {
_log.error("Error during folder compression "+itemId,e);
peer.getAsyncRemote().sendText(ConstantsExplorer.DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_ERROR_DURING_COMPRESSION);