added mimetype for thumbnail
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@173597 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ee44de36ad
commit
33a569977e
|
@ -23,6 +23,7 @@ import org.gcube.common.storagehub.model.items.FolderItem;
|
|||
import org.gcube.common.storagehub.model.items.Item;
|
||||
import org.gcube.common.storagehub.model.items.SharedFolder;
|
||||
import org.gcube.common.storagehub.model.items.VreFolder;
|
||||
import org.gcube.common.storagehub.model.items.nodes.ImageContent;
|
||||
import org.gcube.common.storagehub.model.service.Version;
|
||||
import org.gcube.common.storagehubwrapper.server.converter.ObjectMapper;
|
||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
|
||||
|
@ -609,15 +610,14 @@ public class StorageHubClientService {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the thumbnail data.
|
||||
* Gets the image content.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @return the thumbnail data
|
||||
* @return the image content
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public byte[] getThumbnailData(String itemId) throws Exception{
|
||||
public ImageContent getImageContent(String itemId) throws Exception{
|
||||
|
||||
Validate.notNull(itemId, "Bad request of getThumbnailData, the itemId is null");
|
||||
setContextProviders(scope, authorizationToken);
|
||||
|
@ -626,11 +626,7 @@ public class StorageHubClientService {
|
|||
if(item instanceof org.gcube.common.storagehub.model.items.ImageFile){
|
||||
|
||||
org.gcube.common.storagehub.model.items.ImageFile imgFI = (org.gcube.common.storagehub.model.items.ImageFile) item; //??
|
||||
byte[] thumbBytes = imgFI.getContent().getThumbnailData();
|
||||
if(thumbBytes==null || thumbBytes.length==0)
|
||||
throw new Exception("Thumbnail Data is not available for image: "+item.getName());
|
||||
|
||||
return thumbBytes;
|
||||
return imgFI.getContent();
|
||||
}else
|
||||
throw new Exception("Thumbnail Data is not available for type: "+item.getClass().getSimpleName());
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -18,6 +19,7 @@ import org.gcube.common.storagehub.client.dsl.FolderContainer;
|
|||
import org.gcube.common.storagehub.model.items.AbstractFileItem;
|
||||
import org.gcube.common.storagehub.model.items.FolderItem;
|
||||
import org.gcube.common.storagehub.model.items.Item;
|
||||
import org.gcube.common.storagehub.model.items.nodes.ImageContent;
|
||||
import org.gcube.common.storagehub.model.service.Version;
|
||||
import org.gcube.common.storagehub.model.types.GenericItemType;
|
||||
import org.gcube.common.storagehubwrapper.server.converter.HLMapper;
|
||||
|
@ -652,7 +654,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(), null);
|
||||
return new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(streamDesc.getStream(), streamDesc.getFileName(), null, 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 +678,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(), null);
|
||||
return new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(streamDesc.getStream(), streamDesc.getFileName(), null, null);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error on downloading the folder: "+folderName+ " with id: "+folderId, e);
|
||||
String error = e.getMessage()!=null?e.getMessage():"";
|
||||
|
@ -867,8 +869,12 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
|||
|
||||
try{
|
||||
|
||||
byte[] thumbBytes = storageHubClientService.getThumbnailData(itemId);
|
||||
return new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(WrapperUtility.toInputStream(thumbBytes), null, new Long(thumbBytes.length));
|
||||
ImageContent imgContent = storageHubClientService.getImageContent(itemId);
|
||||
byte[] thumbBytes = imgContent.getThumbnailData();
|
||||
if(thumbBytes==null || thumbBytes.length==0)
|
||||
throw new Exception("Thumbnail Data is not available for image with id: "+itemId);
|
||||
|
||||
return new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(new ByteArrayInputStream(thumbBytes), null, new Long(thumbBytes.length),imgContent.getThumbnailMimeType());
|
||||
|
||||
}catch(Exception e){
|
||||
logger.error("Error on getThumbnailData for: "+itemId, e);
|
||||
|
|
|
@ -64,6 +64,7 @@ public class StreamDescriptor implements ItemStreamDescriptor, Serializable{
|
|||
private InputStream stream;
|
||||
private String itemName;
|
||||
private Long size;
|
||||
private String mimeType;
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue