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:
parent
701db13f41
commit
5feee8876e
|
@ -1,6 +1,5 @@
|
||||||
package org.gcube.common.storagehubwrapper.server;
|
package org.gcube.common.storagehubwrapper.server;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -618,7 +617,7 @@ public class StorageHubClientService {
|
||||||
* @return the thumbnail data
|
* @return the thumbnail data
|
||||||
* @throws Exception the exception
|
* @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");
|
Validate.notNull(itemId, "Bad request of getThumbnailData, the itemId is null");
|
||||||
setContextProviders(scope, authorizationToken);
|
setContextProviders(scope, authorizationToken);
|
||||||
|
@ -631,7 +630,7 @@ public class StorageHubClientService {
|
||||||
if(thumbBytes==null || thumbBytes.length==0)
|
if(thumbBytes==null || thumbBytes.length==0)
|
||||||
throw new Exception("Thumbnail Data is not available for image: "+item.getName());
|
throw new Exception("Thumbnail Data is not available for image: "+item.getName());
|
||||||
|
|
||||||
return new StreamDescriptor(new ByteArrayInputStream(thumbBytes), item.getName());
|
return thumbBytes;
|
||||||
}else
|
}else
|
||||||
throw new Exception("Thumbnail Data is not available for type: "+item.getClass().getSimpleName());
|
throw new Exception("Thumbnail Data is not available for type: "+item.getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.common.storagehubwrapper.server;
|
package org.gcube.common.storagehubwrapper.server;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -652,7 +653,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
StreamDescriptor streamDesc = storageHubClientService.downloadFile(itemId, versionName, nodeIdsToExclude);
|
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) {
|
} catch (Exception e) {
|
||||||
logger.error("Error on downloading the file: "+fileName+ " with id: "+itemId, e);
|
logger.error("Error on downloading the file: "+fileName+ " with id: "+itemId, e);
|
||||||
String error = e.getMessage()!=null?e.getMessage():"";
|
String error = e.getMessage()!=null?e.getMessage():"";
|
||||||
|
@ -676,7 +677,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
StreamDescriptor streamDesc = storageHubClientService.downloadFolder(folderId, nodeIdsToExclude);
|
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) {
|
} catch (Exception e) {
|
||||||
logger.error("Error on downloading the folder: "+folderName+ " with id: "+folderId, e);
|
logger.error("Error on downloading the folder: "+folderName+ " with id: "+folderId, e);
|
||||||
String error = e.getMessage()!=null?e.getMessage():"";
|
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{
|
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){
|
}catch(Exception e){
|
||||||
logger.error("Error on getThumbnailData for: "+itemId, e);
|
logger.error("Error on getThumbnailData for: "+itemId, e);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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.items.Item;
|
||||||
import org.gcube.common.storagehub.model.types.GenericItemType;
|
import org.gcube.common.storagehub.model.types.GenericItemType;
|
||||||
import org.gcube.common.storagehubwrapper.shared.ACLType;
|
import org.gcube.common.storagehubwrapper.shared.ACLType;
|
||||||
|
@ -302,7 +301,6 @@ public interface Workspace{
|
||||||
public List<WorkspaceFileVersion> getListVersionsForFile(String fileItemId) throws Exception;
|
public List<WorkspaceFileVersion> getListVersionsForFile(String fileItemId) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the thumbnail data.
|
* Gets the thumbnail data.
|
||||||
*
|
*
|
||||||
|
@ -310,7 +308,7 @@ public interface Workspace{
|
||||||
* @return the thumbnail data
|
* @return the thumbnail data
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public StreamDescriptor getThumbnailData(String itemId) throws Exception;
|
public ItemStreamDescriptor getThumbnailData(String itemId) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ public class StreamDescriptor implements ItemStreamDescriptor, Serializable{
|
||||||
private static final long serialVersionUID = -5482612709953553644L;
|
private static final long serialVersionUID = -5482612709953553644L;
|
||||||
private InputStream stream;
|
private InputStream stream;
|
||||||
private String itemName;
|
private String itemName;
|
||||||
|
private Long size;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue