1452: Implement a GUI for StatMan Algorithms Importer
Task-Url: https://support.d4science.org/issues/1452 Added ZipFolder with exclude item git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@122496 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b9bf1a758b
commit
a0ded9b2ba
|
@ -9,6 +9,7 @@ import java.io.InputStream;
|
|||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||
|
@ -501,18 +502,17 @@ public class FilesStorage {
|
|||
try {
|
||||
|
||||
org.gcube.common.homelibrary.home.workspace.folder.items.File gcubeItem = ((org.gcube.common.homelibrary.home.workspace.folder.items.File) wi);
|
||||
is=gcubeItem.getData();
|
||||
|
||||
/*
|
||||
SMPUrl smsHome = new SMPUrl(gcubeItem.getPublicLink());
|
||||
is = gcubeItem.getData();
|
||||
|
||||
logger.debug("smsHome: [host:" + smsHome.getHost() + " path:"
|
||||
+ smsHome.getPath() + " ref:" + smsHome.getRef()
|
||||
+ " userinfo:" + smsHome.getUserInfo() + " ]");
|
||||
URLConnection uc = null;
|
||||
uc = (URLConnection) smsHome.openConnection();
|
||||
is = uc.getInputStream();
|
||||
*/
|
||||
/*
|
||||
* SMPUrl smsHome = new SMPUrl(gcubeItem.getPublicLink());
|
||||
*
|
||||
* logger.debug("smsHome: [host:" + smsHome.getHost() + " path:" +
|
||||
* smsHome.getPath() + " ref:" + smsHome.getRef() + " userinfo:" +
|
||||
* smsHome.getUserInfo() + " ]"); URLConnection uc = null; uc =
|
||||
* (URLConnection) smsHome.openConnection(); is =
|
||||
* uc.getInputStream();
|
||||
*/
|
||||
} catch (Exception e) {
|
||||
logger.error("Error retrieving file from storage", e);
|
||||
e.printStackTrace();
|
||||
|
@ -596,6 +596,33 @@ public class FilesStorage {
|
|||
|
||||
}
|
||||
|
||||
public File zipFolder(String user, String folderId,
|
||||
List<String> idsToExclude) throws StatAlgoImporterServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(folderId);
|
||||
if (!workSpaceItem.isFolder()) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Item is not valid folder!");
|
||||
}
|
||||
|
||||
WorkspaceFolder folder = (WorkspaceFolder) workSpaceItem;
|
||||
|
||||
File fileZip = ZipUtil.zipFolder(folder, false, idsToExclude);
|
||||
|
||||
return fileZip;
|
||||
|
||||
} catch (IOException | InternalErrorException
|
||||
| WorkspaceFolderNotFoundException | HomeNotFoundException
|
||||
| ItemNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void downloadInputFile(String fileUrl, Path destination)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue