updated getThumbnailData

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@173559 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-10-17 10:32:22 +00:00
parent 701db13f41
commit 5feee8876e
4 changed files with 14 additions and 10 deletions

View File

@ -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());
}

View File

@ -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);

View File

@ -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<WorkspaceFileVersion> 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;

View File

@ -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;
}