diff --git a/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java b/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java index b76059c..e1703ca 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/StorageHubClientService.java @@ -1,6 +1,5 @@ package org.gcube.common.storagehubwrapper.server; -import java.io.ByteArrayInputStream; import java.io.InputStream; import java.net.URL; import java.util.List; @@ -618,7 +617,7 @@ public class StorageHubClientService { * @return the thumbnail data * @throws Exception the exception */ - public StreamDescriptor getThumbnailData(String itemId) throws Exception{ + public byte[] getThumbnailData(String itemId) throws Exception{ Validate.notNull(itemId, "Bad request of getThumbnailData, the itemId is null"); setContextProviders(scope, authorizationToken); @@ -631,7 +630,7 @@ public class StorageHubClientService { if(thumbBytes==null || thumbBytes.length==0) throw new Exception("Thumbnail Data is not available for image: "+item.getName()); - return new StreamDescriptor(new ByteArrayInputStream(thumbBytes), item.getName()); + return thumbBytes; }else throw new Exception("Thumbnail Data is not available for type: "+item.getClass().getSimpleName()); } diff --git a/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java b/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java index fd0a9a8..623c2be 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/WorkspaceStorageHubClientService.java @@ -3,6 +3,7 @@ */ package org.gcube.common.storagehubwrapper.server; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; @@ -652,7 +653,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{ try { StreamDescriptor streamDesc = storageHubClientService.downloadFile(itemId, versionName, nodeIdsToExclude); - return new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(streamDesc.getStream(), streamDesc.getFileName()); + return new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(streamDesc.getStream(), streamDesc.getFileName(), null); } catch (Exception e) { logger.error("Error on downloading the file: "+fileName+ " with id: "+itemId, e); String error = e.getMessage()!=null?e.getMessage():""; @@ -676,7 +677,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{ try { StreamDescriptor streamDesc = storageHubClientService.downloadFolder(folderId, nodeIdsToExclude); - return new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(streamDesc.getStream(), streamDesc.getFileName()); + return new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(streamDesc.getStream(), streamDesc.getFileName(), null); } catch (Exception e) { logger.error("Error on downloading the folder: "+folderName+ " with id: "+folderId, e); String error = e.getMessage()!=null?e.getMessage():""; @@ -859,11 +860,16 @@ public final class WorkspaceStorageHubClientService implements Workspace{ } } - public StreamDescriptor getThumbnailData(String itemId) throws Exception{ + + /* (non-Javadoc) + * @see org.gcube.common.storagehubwrapper.server.tohl.Workspace#getThumbnailData(java.lang.String) + */ + public ItemStreamDescriptor getThumbnailData(String itemId) throws Exception{ try{ - return storageHubClientService.getThumbnailData(itemId); + byte[] thumbBytes = storageHubClientService.getThumbnailData(itemId); + return new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(new ByteArrayInputStream(thumbBytes), null, new Long(thumbBytes.length)); }catch(Exception e){ logger.error("Error on getThumbnailData for: "+itemId, e); diff --git a/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java b/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java index 847a1bb..6c45907 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/tohl/Workspace.java @@ -9,7 +9,6 @@ import java.net.URL; import java.util.List; import java.util.Map; -import org.gcube.common.storagehub.client.StreamDescriptor; import org.gcube.common.storagehub.model.items.Item; import org.gcube.common.storagehub.model.types.GenericItemType; import org.gcube.common.storagehubwrapper.shared.ACLType; @@ -302,7 +301,6 @@ public interface Workspace{ public List getListVersionsForFile(String fileItemId) throws Exception; - /** * Gets the thumbnail data. * @@ -310,7 +308,7 @@ public interface Workspace{ * @return the thumbnail data * @throws Exception the exception */ - public StreamDescriptor getThumbnailData(String itemId) throws Exception; + public ItemStreamDescriptor getThumbnailData(String itemId) throws Exception; diff --git a/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/impl/StreamDescriptor.java b/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/impl/StreamDescriptor.java index 1f0cacb..28ddee9 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/impl/StreamDescriptor.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/impl/StreamDescriptor.java @@ -63,6 +63,7 @@ public class StreamDescriptor implements ItemStreamDescriptor, Serializable{ private static final long serialVersionUID = -5482612709953553644L; private InputStream stream; private String itemName; + private Long size; }