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.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||||
|
@ -501,18 +502,17 @@ public class FilesStorage {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
org.gcube.common.homelibrary.home.workspace.folder.items.File gcubeItem = ((org.gcube.common.homelibrary.home.workspace.folder.items.File) wi);
|
org.gcube.common.homelibrary.home.workspace.folder.items.File gcubeItem = ((org.gcube.common.homelibrary.home.workspace.folder.items.File) wi);
|
||||||
is=gcubeItem.getData();
|
is = gcubeItem.getData();
|
||||||
|
|
||||||
/*
|
|
||||||
SMPUrl smsHome = new SMPUrl(gcubeItem.getPublicLink());
|
|
||||||
|
|
||||||
logger.debug("smsHome: [host:" + smsHome.getHost() + " path:"
|
/*
|
||||||
+ smsHome.getPath() + " ref:" + smsHome.getRef()
|
* SMPUrl smsHome = new SMPUrl(gcubeItem.getPublicLink());
|
||||||
+ " userinfo:" + smsHome.getUserInfo() + " ]");
|
*
|
||||||
URLConnection uc = null;
|
* logger.debug("smsHome: [host:" + smsHome.getHost() + " path:" +
|
||||||
uc = (URLConnection) smsHome.openConnection();
|
* smsHome.getPath() + " ref:" + smsHome.getRef() + " userinfo:" +
|
||||||
is = uc.getInputStream();
|
* smsHome.getUserInfo() + " ]"); URLConnection uc = null; uc =
|
||||||
*/
|
* (URLConnection) smsHome.openConnection(); is =
|
||||||
|
* uc.getInputStream();
|
||||||
|
*/
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error retrieving file from storage", e);
|
logger.error("Error retrieving file from storage", e);
|
||||||
e.printStackTrace();
|
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)
|
public void downloadInputFile(String fileUrl, Path destination)
|
||||||
throws StatAlgoImporterServiceException {
|
throws StatAlgoImporterServiceException {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue