ref 11720: DataMiner - Update to StorageHUB
https://support.d4science.org/issues/11720 Updated to StorageHub getPublicLink and getProperties functions. git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@169410 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
40b10c8360
commit
321ecc3fb1
20
pom.xml
20
pom.xml
|
@ -109,6 +109,14 @@
|
|||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- StorageHub -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-client-library</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Authorization -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
|
@ -232,6 +240,12 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- StorageHub -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-client-library</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Information System Client IC-Client -->
|
||||
<dependency>
|
||||
|
@ -260,7 +274,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>workspace-explorer</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Workspace Uploader -->
|
||||
|
@ -360,8 +374,8 @@
|
|||
<runTarget>DataMinerManager.html</runTarget>
|
||||
<hostedWebapp>${webappDirectory}</hostedWebapp>
|
||||
<module>org.gcube.portlets.user.dataminermanager.dataminermanager</module>
|
||||
|
||||
</configuration>
|
||||
<!-- <style>DETAILED</style> -->
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public class PortalViewport extends SimpleContainer {
|
|||
}
|
||||
|
||||
int viewHeight = calculateHeight();
|
||||
Log.info("AM resize viewWidth: " + viewWidth + " viewHeight: "
|
||||
Log.info("DataMiner resize viewWidth: " + viewWidth + " viewHeight: "
|
||||
+ viewHeight + " clientWidth: " + Window.getClientWidth()
|
||||
+ " clientHeight: " + Window.getClientHeight());
|
||||
try {
|
||||
|
@ -127,7 +127,7 @@ public class PortalViewport extends SimpleContainer {
|
|||
protected void onWindowResize(int width, int height) {
|
||||
int viewWidth = calculateWidth();
|
||||
int viewHeight = calculateHeight();
|
||||
Log.trace("AM onWindowResize viewWidth: " + viewWidth
|
||||
Log.trace("DataMiner onWindowResize viewWidth: " + viewWidth
|
||||
+ " viewHeight: " + viewHeight + " clientWidth: "
|
||||
+ Window.getClientWidth() + " clientHeight: "
|
||||
+ Window.getClientHeight());
|
||||
|
@ -138,14 +138,14 @@ public class PortalViewport extends SimpleContainer {
|
|||
|
||||
protected int calculateWidth() {
|
||||
int leftBorder = getAbsoluteLeft();
|
||||
Log.info("AM width: "
|
||||
Log.info("DataMiner width: "
|
||||
+ String.valueOf(Window.getClientWidth() - 2 * leftBorder));
|
||||
return Window.getClientWidth() - 2 * leftBorder;
|
||||
}
|
||||
|
||||
protected int calculateHeight() {
|
||||
int topBorder = getAbsoluteTop();
|
||||
Log.info("AM height: "
|
||||
Log.info("DataMiner height: "
|
||||
+ String.valueOf(Window.getClientHeight() - topBorder - 34));
|
||||
return Window.getClientHeight() - topBorder - 34;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.ItemDescription;
|
||||
import org.gcube.portal.clientcontext.client.GCubeClientContext;
|
||||
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager;
|
||||
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
|
||||
|
@ -18,7 +19,6 @@ import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaEle
|
|||
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
|
||||
import org.gcube.portlets.user.dataminermanager.shared.Constants;
|
||||
import org.gcube.portlets.user.dataminermanager.shared.exception.SessionExpiredServiceException;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.ItemDescription;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload;
|
||||
|
@ -288,7 +288,9 @@ public class InputDataSetsPanel extends FramedPanel {
|
|||
};
|
||||
|
||||
dnd.addWorkspaceUploadNotificationListener(workspaceUploaderListener);
|
||||
|
||||
|
||||
|
||||
Log.debug("Create ToolBar for InputDataSetsPanel");
|
||||
// ToolBar
|
||||
btnDownload = new TextButton("Download");
|
||||
btnDownload.setIcon(DataMinerManager.resources.download());
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.ItemDescription;
|
||||
import org.gcube.portal.clientcontext.client.GCubeClientContext;
|
||||
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager;
|
||||
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
|
||||
|
@ -18,7 +19,6 @@ import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaEle
|
|||
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
|
||||
import org.gcube.portlets.user.dataminermanager.shared.Constants;
|
||||
import org.gcube.portlets.user.dataminermanager.shared.exception.SessionExpiredServiceException;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.ItemDescription;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload;
|
||||
|
@ -147,7 +147,7 @@ public class OutputDataSetsPanel extends FramedPanel {
|
|||
}
|
||||
switch (event.getDataMinerWorkAreaRegionType()) {
|
||||
case Computations:
|
||||
break;
|
||||
break;
|
||||
case DataSets:
|
||||
manageMyDataMinerWorkAreaEvents(event);
|
||||
break;
|
||||
|
@ -250,10 +250,10 @@ public class OutputDataSetsPanel extends FramedPanel {
|
|||
wsResourcesExplorerPanel.ensureDebugId("wsResourceExplorerPanelForOutput");
|
||||
wsResourcesExplorerPanel.setHeightToInternalScroll(300);
|
||||
|
||||
Log.debug("Define DND for InputDataSetsPanel");
|
||||
Log.debug("Define DND for OutputDataSetsPanel");
|
||||
|
||||
// DND
|
||||
|
||||
|
||||
dnd = new MultipleDNDUpload();
|
||||
dnd.setParameters(event.getDataMinerWorkArea().getOutputDataSets().getFolder().getId(), UPLOAD_TYPE.File);
|
||||
dnd.addUniqueContainer(wsResourcesExplorerPanel);
|
||||
|
@ -287,7 +287,8 @@ public class OutputDataSetsPanel extends FramedPanel {
|
|||
};
|
||||
|
||||
dnd.addWorkspaceUploadNotificationListener(workspaceUploaderListener);
|
||||
|
||||
|
||||
Log.debug("Create ToolBar for OutputDatasetsPanel");
|
||||
// ToolBar
|
||||
btnDownload = new TextButton("Download");
|
||||
btnDownload.setIcon(DataMinerManager.resources.download());
|
||||
|
@ -340,6 +341,7 @@ public class OutputDataSetsPanel extends FramedPanel {
|
|||
|
||||
v.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||
v.add(dnd, new VerticalLayoutData(1, 1, new Margins(0)));
|
||||
//v.add(wsResourcesExplorerPanel, new VerticalLayoutData(1, 1, new Margins(0)));
|
||||
add(v);
|
||||
|
||||
v.addResizeHandler(new ResizeHandler() {
|
||||
|
@ -429,7 +431,7 @@ public class OutputDataSetsPanel extends FramedPanel {
|
|||
if (caught instanceof SessionExpiredServiceException) {
|
||||
EventBusProvider.INSTANCE.fireEvent(new SessionExpiredEvent());
|
||||
} else {
|
||||
Log.error("Error open file: " + caught.getLocalizedMessage());
|
||||
Log.error("Error open file: " + caught.getLocalizedMessage(),caught);
|
||||
UtilsGXT3.alert("Error", caught.getLocalizedMessage());
|
||||
}
|
||||
caught.printStackTrace();
|
||||
|
|
|
@ -6,8 +6,10 @@
|
|||
<!-- <inherits name='com.google.gwt.user.theme.clean.Clean' /> -->
|
||||
<inherits name='com.sencha.gxt.ui.GXT' />
|
||||
<!-- <inherits name="com.extjs.gxt.ui.GXT" /> -->
|
||||
|
||||
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
|
||||
|
||||
<!--
|
||||
<inherits name="com.google.gwt.logging.Logging" />
|
||||
-->
|
||||
|
||||
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
|
||||
|
||||
|
@ -41,16 +43,21 @@
|
|||
<entry-point
|
||||
class='org.gcube.portlets.user.dataminermanager.client.DataMinerManager' />
|
||||
|
||||
<!-- <set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
|
||||
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
|
||||
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
|
||||
/> -->
|
||||
<!--
|
||||
<set-property name="log_ConsoleLogger" value="ENABLED" />
|
||||
<set-property name="log_DivLogger" value="ENABLED" />
|
||||
<set-property name="log_GWTLogger" value="ENABLED" />
|
||||
<set-property name="log_SystemLogger" value="ENABLED" />
|
||||
|
||||
<set-property name="log_ConsoleLogger" value="DISABLED" />
|
||||
<set-property name="log_DivLogger" value="DISABLED" />
|
||||
<set-property name="log_GWTLogger" value="DISABLED" />
|
||||
<set-property name="log_SystemLogger" value="DISABLED" />
|
||||
|
||||
<set-property name="gwt.logging.logLevel" value="SEVERE" />
|
||||
<set-property name="gwt.logging.enabled" value="TRUE" />
|
||||
<set-property name="gwt.logging.consoleHandler" value="ENABLED" /> -->
|
||||
|
||||
<set-property name="log_ConsoleLogger" value="DISABLED" /> <set-property
|
||||
name="log_DivLogger" value="DISABLED" /> <set-property name="log_GWTLogger"
|
||||
value="DISABLED" /> <set-property name="log_SystemLogger" value="DISABLED"
|
||||
/>
|
||||
|
||||
<source path='client' />
|
||||
<source path='shared' />
|
||||
|
|
|
@ -139,9 +139,10 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public ComputationId resubmit(ItemDescription itemDescription) throws ServiceException {
|
||||
try {
|
||||
StorageUtil storageUtil=new StorageUtil();
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
Map<String, String> properties = StorageUtil.getProperties(serviceCredentials.getUserName(),
|
||||
Map<String, String> properties = storageUtil.getProperties(serviceCredentials.getUserName(),
|
||||
itemDescription.getId());
|
||||
logger.debug("Properties: " + properties);
|
||||
|
||||
|
@ -182,7 +183,8 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
logger.debug("DeleteItem(): " + itemDescription);
|
||||
StorageUtil.deleteItem(serviceCredentials.getUserName(), itemDescription.getId());
|
||||
StorageUtil storageUtil=new StorageUtil();
|
||||
storageUtil.deleteItem(serviceCredentials.getUserName(), itemDescription.getId());
|
||||
return;
|
||||
|
||||
} catch (ServiceException e) {
|
||||
|
@ -236,7 +238,8 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
logger.debug("GetPublicLink(): " + itemDescription);
|
||||
String link = StorageUtil.getPublicLink(serviceCredentials.getUserName(), itemDescription.getId());
|
||||
StorageUtil storageUtil=new StorageUtil();
|
||||
String link = storageUtil.getPublicLink(serviceCredentials.getUserName(), itemDescription.getId());
|
||||
|
||||
return link;
|
||||
} catch (ServiceException e) {
|
||||
|
@ -293,7 +296,8 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
|
||||
logger.debug("OutputDataByComputationItemt(): " + itemDescription);
|
||||
Map<String, String> properties = StorageUtil.getProperties(serviceCredentials.getUserName(),
|
||||
StorageUtil storageUtil=new StorageUtil();
|
||||
Map<String, String> properties = storageUtil.getProperties(serviceCredentials.getUserName(),
|
||||
itemDescription.getId());
|
||||
|
||||
logger.debug("Properties: " + properties);
|
||||
|
|
|
@ -3,7 +3,11 @@ package org.gcube.portlets.user.dataminermanager.server;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
@ -106,15 +110,21 @@ public class DownloadFolderServlet extends HttpServlet {
|
|||
.getParameter(Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER);
|
||||
logger.debug("Request: [itemId=" + itemId + ", folderName="
|
||||
+ folderName + "]");
|
||||
|
||||
File tmpZip = StorageUtil.zipFolder(
|
||||
StorageUtil storageUtil=new StorageUtil();
|
||||
InputStream is = storageUtil.zipFolder(
|
||||
serviceCredentials.getUserName(), itemId);
|
||||
Path tempFile = Files.createTempFile("dataMinerDownload", ".zip");
|
||||
Files.copy(is, tempFile, StandardCopyOption.REPLACE_EXISTING);
|
||||
File tmpZip= tempFile.toFile();
|
||||
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\""
|
||||
+ folderName + ".zip\"");
|
||||
response.setContentType("application/zip");
|
||||
response.setHeader("Content-Length",
|
||||
String.valueOf(tmpZip.length()));
|
||||
|
||||
|
||||
|
||||
OutputStream out = response.getOutputStream();
|
||||
|
||||
FileInputStream fileTmpZip = new FileInputStream(tmpZip);
|
||||
|
@ -122,13 +132,12 @@ public class DownloadFolderServlet extends HttpServlet {
|
|||
out.flush();
|
||||
out.close();
|
||||
fileTmpZip.close();
|
||||
tmpZip.delete();
|
||||
Files.delete(tempFile);
|
||||
return;
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error in DownloadFolderServlet: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
+ e.getLocalizedMessage(),e);
|
||||
throw new ServletException("Error:" + e.getLocalizedMessage(), e);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,15 +1,24 @@
|
|||
package org.gcube.portlets.user.dataminermanager.server.storage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.workspace.Properties;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.homelibrary.util.zip.ZipUtil;
|
||||
import org.gcube.common.storagehub.client.StreamDescriptor;
|
||||
import org.gcube.common.storagehub.client.dsl.ItemContainer;
|
||||
import org.gcube.common.storagehub.client.dsl.OpenResolver;
|
||||
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||
import org.gcube.common.storagehub.model.Metadata;
|
||||
import org.gcube.common.storagehub.model.items.AbstractFileItem;
|
||||
import org.gcube.common.storagehub.model.items.FolderItem;
|
||||
import org.gcube.common.storagehub.model.items.GenericFileItem;
|
||||
import org.gcube.common.storagehub.model.items.ImageFile;
|
||||
import org.gcube.common.storagehub.model.items.Item;
|
||||
import org.gcube.common.storagehub.model.items.PDFFileItem;
|
||||
import org.gcube.portlets.user.dataminermanager.shared.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -34,19 +43,22 @@ public class StorageUtil {
|
|||
* @throws ServiceException
|
||||
* service exception
|
||||
*/
|
||||
public static Map<String, String> getProperties(String user, String itemId) throws ServiceException {
|
||||
public Map<String, String> getProperties(String user, String itemId) throws ServiceException {
|
||||
try {
|
||||
Workspace ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(itemId);
|
||||
Properties properties = workSpaceItem.getProperties();
|
||||
|
||||
return properties.getProperties();
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
Item item = shc.open(itemId).asItem().get();
|
||||
Metadata metadata = item.getPropertyMap();
|
||||
Map<String, String> itemMap = new HashMap<String, String>();
|
||||
Map<String, Object> metadataMap = metadata.getValues();
|
||||
for (String key : metadataMap.keySet()) {
|
||||
String s = String.valueOf(metadataMap.get(key));
|
||||
itemMap.put(key, s);
|
||||
}
|
||||
return itemMap;
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getLocalizedMessage());
|
||||
logger.error("Error retrieving properties: " +e.getLocalizedMessage(), e);
|
||||
throw new ServiceException(e.getLocalizedMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -61,50 +73,33 @@ public class StorageUtil {
|
|||
* @throws ServiceException
|
||||
* service exception
|
||||
*/
|
||||
public static InputStream getInputStreamForItemOnWorkspace(String user, String itemId) throws ServiceException {
|
||||
Workspace ws;
|
||||
public InputStream getInputStreamForItemOnWorkspace(String user, String itemId) throws ServiceException {
|
||||
try {
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
logger.debug("getInputStreamForItemOnWorkspace: [user="+user+", itemId="+itemId+"]");
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
ItemContainer<Item> itemContainer = shc.open(itemId).asItem();
|
||||
|
||||
Item item = itemContainer.get();
|
||||
if (item instanceof AbstractFileItem) {
|
||||
if (item instanceof GenericFileItem | item instanceof ImageFile | item instanceof PDFFileItem) {
|
||||
StreamDescriptor streamDescriptor = itemContainer.download();
|
||||
return streamDescriptor.getStream();
|
||||
} else {
|
||||
throw new ServiceException("Is not a valid file!");
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new ServiceException("Is not a valid file!");
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(itemId);
|
||||
if (workSpaceItem.isFolder()) {
|
||||
throw new ServiceException("Folder is not valid!");
|
||||
}
|
||||
|
||||
return getInputStream(user, workSpaceItem);
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getLocalizedMessage());
|
||||
logger.error("Error retrieving InputStream for Item: " +e.getLocalizedMessage(), e);
|
||||
throw new ServiceException(e.getLocalizedMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
* user
|
||||
* @param workspaceItem
|
||||
* workspace item
|
||||
* @return input stream
|
||||
* @throws ServiceException
|
||||
* service exception
|
||||
*/
|
||||
private static InputStream getInputStream(String user, WorkspaceItem workspaceItem) throws ServiceException {
|
||||
InputStream is = null;
|
||||
try {
|
||||
|
||||
org.gcube.common.homelibrary.home.workspace.folder.items.File gcubeItem = ((org.gcube.common.homelibrary.home.workspace.folder.items.File) workspaceItem);
|
||||
is = gcubeItem.getData();
|
||||
return is;
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error retrieving InputStream from storage", e);
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("Error retrieving file from storage: " + e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -116,23 +111,16 @@ public class StorageUtil {
|
|||
* @throws ServiceException
|
||||
* service exception
|
||||
*/
|
||||
public static String getPublicLink(String user, String itemId) throws ServiceException {
|
||||
Workspace ws;
|
||||
public String getPublicLink(String user, String itemId) throws ServiceException {
|
||||
try {
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(itemId);
|
||||
if (workSpaceItem.isFolder()) {
|
||||
throw new ServiceException("Attention this is a folder!");
|
||||
}
|
||||
|
||||
return workSpaceItem.getPublicLink(false);
|
||||
|
||||
logger.debug("getPublicLink: [user="+user+", itemId="+itemId+"]");
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
URL url = shc.open(itemId).asFile().getPublicLink();
|
||||
return url.toString();
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error retrieving public link: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getLocalizedMessage());
|
||||
|
||||
logger.error("Error retrieving public link: " + e.getLocalizedMessage(),e);
|
||||
throw new ServiceException(e.getLocalizedMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,30 +130,29 @@ public class StorageUtil {
|
|||
* user
|
||||
* @param folderId
|
||||
* folder id
|
||||
* @return zip folder
|
||||
* @return input stream
|
||||
* @throws ServiceException
|
||||
* service exception
|
||||
*/
|
||||
public static File zipFolder(String user, String folderId) throws ServiceException {
|
||||
Workspace ws;
|
||||
public InputStream zipFolder(String user, String folderId) throws ServiceException {
|
||||
try {
|
||||
logger.debug("zipFolder: [user=" + user + ", folderId=" + folderId + "]");
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
StorageHubClient shc = new StorageHubClient();
|
||||
OpenResolver openResolver = shc.open(folderId);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(folderId);
|
||||
if (!workSpaceItem.isFolder()) {
|
||||
throw new ServiceException("Item is not valid folder!");
|
||||
ItemContainer<Item> itemContainer = openResolver.asItem();
|
||||
Item item = itemContainer.get();
|
||||
if (item instanceof FolderItem) {
|
||||
StreamDescriptor streamDescriptor = openResolver.asFolder().download();
|
||||
InputStream is = streamDescriptor.getStream();
|
||||
return is;
|
||||
} else {
|
||||
throw new ServiceException("Is not a valid folder!");
|
||||
}
|
||||
|
||||
WorkspaceFolder folder = (WorkspaceFolder) workSpaceItem;
|
||||
|
||||
File fileZip = ZipUtil.zipFolder(folder);
|
||||
|
||||
return fileZip;
|
||||
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getLocalizedMessage());
|
||||
logger.error("Error in zip Folder: " +e.getLocalizedMessage(),e);
|
||||
throw new ServiceException(e.getLocalizedMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -180,9 +167,10 @@ public class StorageUtil {
|
|||
* @throws ServiceException
|
||||
* service exception
|
||||
*/
|
||||
public static WorkspaceItem getItemInRootFolderOnWorkspace(String user, String itemName) throws ServiceException {
|
||||
public WorkspaceItem getItemInRootFolderOnWorkspace(String user, String itemName) throws ServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
logger.debug("");
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem item = ws.find(itemName, ws.getRoot().getId());
|
||||
|
@ -190,7 +178,7 @@ public class StorageUtil {
|
|||
return item;
|
||||
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error in get Item in RootFolder: " +e.getLocalizedMessage(),e);
|
||||
throw new ServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +195,7 @@ public class StorageUtil {
|
|||
* @throws ServiceException
|
||||
* service exception
|
||||
*/
|
||||
public static WorkspaceItem getItemInFolderOnWorkspace(String user, String folderId, String itemName)
|
||||
public WorkspaceItem getItemInFolderOnWorkspace(String user, String folderId, String itemName)
|
||||
throws ServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
|
@ -218,7 +206,7 @@ public class StorageUtil {
|
|||
return item;
|
||||
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error in get Item in Folder: " +e.getLocalizedMessage(),e);
|
||||
throw new ServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
@ -232,7 +220,7 @@ public class StorageUtil {
|
|||
* @throws ServiceException
|
||||
* service exception
|
||||
*/
|
||||
public static void deleteItem(String user, String itemId) throws ServiceException {
|
||||
public void deleteItem(String user, String itemId) throws ServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
logger.debug("User: " + user + ", ItemId:" + itemId);
|
||||
|
@ -242,7 +230,7 @@ public class StorageUtil {
|
|||
|
||||
return;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error deleting Item: "+e.getLocalizedMessage(),e);
|
||||
throw new ServiceException(e.getLocalizedMessage());
|
||||
|
||||
}
|
||||
|
|
|
@ -36,8 +36,10 @@ public class DataMinerWorkAreaManager {
|
|||
|
||||
public DataMinerWorkArea getDataMinerWorkArea() throws ServiceException {
|
||||
DataMinerWorkArea dataMinerWorkArea = null;
|
||||
StorageUtil storageUtil=new StorageUtil();
|
||||
try {
|
||||
WorkspaceItem wiDataMinerFolder = StorageUtil
|
||||
|
||||
WorkspaceItem wiDataMinerFolder = storageUtil
|
||||
.getItemInRootFolderOnWorkspace(serviceCredentials.getUserName(),
|
||||
DATA_MINER_FOLDER);
|
||||
|
||||
|
@ -66,7 +68,7 @@ public class DataMinerWorkAreaManager {
|
|||
|
||||
InputDataSets inputDataSets = null;
|
||||
try {
|
||||
WorkspaceItem wiImportedDataFolder = StorageUtil
|
||||
WorkspaceItem wiImportedDataFolder = storageUtil
|
||||
.getItemInFolderOnWorkspace(serviceCredentials.getUserName(),
|
||||
dataMinerWorkArea.getDataMinerWorkAreaFolder()
|
||||
.getId(), IMPORTED_DATA_FOLDER);
|
||||
|
@ -88,7 +90,7 @@ public class DataMinerWorkAreaManager {
|
|||
|
||||
OutputDataSets outputDataSets = null;
|
||||
try {
|
||||
WorkspaceItem wiComputedDataFolder = StorageUtil
|
||||
WorkspaceItem wiComputedDataFolder = storageUtil
|
||||
.getItemInFolderOnWorkspace(serviceCredentials.getUserName(),
|
||||
dataMinerWorkArea.getDataMinerWorkAreaFolder()
|
||||
.getId(), COMPUTED_DATA_FOLDER);
|
||||
|
@ -109,7 +111,7 @@ public class DataMinerWorkAreaManager {
|
|||
|
||||
Computations computations = null;
|
||||
try {
|
||||
WorkspaceItem wiComputationsDataFolder = StorageUtil
|
||||
WorkspaceItem wiComputationsDataFolder = storageUtil
|
||||
.getItemInFolderOnWorkspace(serviceCredentials.getUserName(),
|
||||
dataMinerWorkArea.getDataMinerWorkAreaFolder()
|
||||
.getId(), COMPUTATIONS_FOLDER);
|
||||
|
|
|
@ -7,18 +7,17 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.csv4j.CSVReader;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.server.util.ServiceCredentials;
|
||||
import org.gcube.portlets.user.dataminermanager.server.storage.StorageUtil;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.ColumnItem;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.TableItemSimple;
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.ItemDescription;
|
||||
import org.gcube.portlets.user.dataminermanager.server.storage.StorageUtil;
|
||||
import org.gcube.portlets.user.dataminermanager.shared.exception.ServiceException;
|
||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.sf.csv4j.CSVReader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
|
@ -37,15 +36,15 @@ public class TableReader {
|
|||
}
|
||||
|
||||
public TableItemSimple getTableItemSimple() throws ServiceException {
|
||||
|
||||
InputStream is = StorageUtil.getInputStreamForItemOnWorkspace(
|
||||
StorageUtil storageUtil=new StorageUtil();
|
||||
InputStream is = storageUtil.getInputStreamForItemOnWorkspace(
|
||||
serviceCredentials.getUserName(), item.getId());
|
||||
Reader fileReader = new InputStreamReader(is);
|
||||
CSVReader csvReader = new CSVReader(fileReader);
|
||||
List<String> firstLine = getFirstLine(csvReader, false);
|
||||
ArrayList<String> columns = new ArrayList<String>(firstLine);
|
||||
|
||||
String publicLink=StorageUtil.getPublicLink(serviceCredentials.getUserName(), item.getId());
|
||||
String publicLink=storageUtil.getPublicLink(serviceCredentials.getUserName(), item.getId());
|
||||
|
||||
TableItemSimple tableItemSimple=new TableItemSimple(publicLink,item.getName(), item.getType());
|
||||
ArrayList<ColumnItem> columnItemList=new ArrayList<ColumnItem>();
|
||||
|
|
|
@ -6,8 +6,10 @@
|
|||
<!-- <inherits name='com.google.gwt.user.theme.clean.Clean' /> -->
|
||||
<inherits name='com.sencha.gxt.ui.GXT' />
|
||||
<!-- <inherits name="com.extjs.gxt.ui.GXT" /> -->
|
||||
|
||||
<!-- <inherits name="com.google.gwt.logging.Logging" /> -->
|
||||
|
||||
<!--
|
||||
<inherits name="com.google.gwt.logging.Logging" />
|
||||
-->
|
||||
|
||||
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
|
||||
|
||||
|
@ -41,15 +43,21 @@
|
|||
<entry-point
|
||||
class='org.gcube.portlets.user.dataminermanager.client.DataMinerManager' />
|
||||
|
||||
<!-- <set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
|
||||
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
|
||||
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
|
||||
/> -->
|
||||
<!--
|
||||
<set-property name="log_ConsoleLogger" value="ENABLED" />
|
||||
<set-property name="log_DivLogger" value="ENABLED" />
|
||||
<set-property name="log_GWTLogger" value="ENABLED" />
|
||||
<set-property name="log_SystemLogger" value="ENABLED" />
|
||||
|
||||
<set-property name="log_ConsoleLogger" value="DISABLED" />
|
||||
<set-property name="log_DivLogger" value="DISABLED" />
|
||||
<set-property name="log_GWTLogger" value="DISABLED" />
|
||||
<set-property name="log_SystemLogger" value="DISABLED" />
|
||||
|
||||
<set-property name="gwt.logging.logLevel" value="SEVERE" />
|
||||
<set-property name="gwt.logging.enabled" value="TRUE" />
|
||||
<set-property name="gwt.logging.consoleHandler" value="ENABLED" /> -->
|
||||
|
||||
<set-property name="log_ConsoleLogger" value="DISABLED" /> <set-property
|
||||
name="log_DivLogger" value="DISABLED" /> <set-property name="log_GWTLogger"
|
||||
value="DISABLED" /> <set-property name="log_SystemLogger" value="DISABLED"
|
||||
/>
|
||||
|
||||
<source path='client' />
|
||||
<source path='shared' />
|
||||
|
|
Loading…
Reference in New Issue