added WrapperUtility
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@173587 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
bcf3c94f72
commit
7ac8579282
|
@ -3,7 +3,6 @@
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
@ -869,7 +868,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
||||||
try{
|
try{
|
||||||
|
|
||||||
byte[] thumbBytes = 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));
|
return new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(WrapperUtility.toInputStream(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);
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.gcube.common.storagehubwrapper.server;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Oct 17, 2018
|
||||||
|
*/
|
||||||
|
public class WrapperUtility {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To input stream.
|
||||||
|
*
|
||||||
|
* @param content the content
|
||||||
|
* @return the input stream
|
||||||
|
*/
|
||||||
|
public static InputStream toInputStream(byte[] content) {
|
||||||
|
|
||||||
|
int size = content.length;
|
||||||
|
InputStream is = null;
|
||||||
|
byte[] b = new byte[size];
|
||||||
|
try {
|
||||||
|
is = new ByteArrayInputStream(content);
|
||||||
|
is.read(b);
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
if (is != null)
|
||||||
|
is.close();
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue