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:
parent
4928d1e554
commit
9fb3aee05e
|
@ -14,6 +14,7 @@ import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.websocket.OnClose;
|
import javax.websocket.OnClose;
|
||||||
import javax.websocket.OnMessage;
|
import javax.websocket.OnMessage;
|
||||||
|
@ -126,13 +127,20 @@ public class DownloadFolderWebSocketServer {
|
||||||
try {
|
try {
|
||||||
File tmpZip = ZipUtil.zipFolder((WorkspaceFolder) item);
|
File tmpZip = ZipUtil.zipFolder((WorkspaceFolder) item);
|
||||||
|
|
||||||
Path tmpDir = Files.createTempDirectory("workspace_temp");
|
String tmpSys = System.getProperty("java.io.tmpdir");
|
||||||
|
String randomDirName = UUID.randomUUID().toString();
|
||||||
File toCopy = new File(tmpDir.toAbsolutePath()+File.separator+item.getName());
|
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);
|
copyFileUsingFileChannels(tmpZip, toCopy);
|
||||||
_log.info("Zipped folder in="+toCopy.getAbsolutePath());
|
_log.info("Zipped folder in="+toCopy.getAbsolutePath() + ", returning="+toReturn);
|
||||||
tmpZip.deleteOnExit();
|
tmpZip.deleteOnExit();
|
||||||
return toCopy.getAbsolutePath();
|
return toReturn;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
_log.error("Error during folder compression "+itemId,e);
|
_log.error("Error during folder compression "+itemId,e);
|
||||||
peer.getAsyncRemote().sendText(ConstantsExplorer.DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_ERROR_DURING_COMPRESSION);
|
peer.getAsyncRemote().sendText(ConstantsExplorer.DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_ERROR_DURING_COMPRESSION);
|
||||||
|
|
Loading…
Reference in New Issue