use of edu.harvard.iq.dataverse.dataaccess.StorageIO in project dataverse by IQSS.
the class Access method dsCardImage.
// Note:
// the Dataverse page is no longer using this method.
@Path("dsCardImage/{versionId}")
@GET
@Produces({ "image/png" })
public InputStream dsCardImage(@PathParam("versionId") Long versionId, @Context UriInfo uriInfo, @Context HttpHeaders headers, @Context HttpServletResponse response) /*throws NotFoundException, ServiceUnavailableException, PermissionDeniedException, AuthorizationRequiredException*/
{
DatasetVersion datasetVersion = versionService.find(versionId);
if (datasetVersion == null) {
logger.warning("Preview: Version service could not locate a DatasetVersion object for id " + versionId + "!");
return null;
}
// String imageThumbFileName = null;
StorageIO thumbnailDataAccess = null;
if (datasetVersion.getDataset() != null) {
DataFile logoDataFile = datasetVersion.getDataset().getThumbnailFile();
if (logoDataFile != null) {
try {
StorageIO<DataFile> dataAccess = logoDataFile.getStorageIO();
if (dataAccess != null) {
// && dataAccess.isLocalFile()) {
dataAccess.open();
thumbnailDataAccess = ImageThumbConverter.getImageThumbnailAsInputStream(dataAccess, 48);
}
} catch (IOException ioEx) {
thumbnailDataAccess = null;
}
}
if (thumbnailDataAccess != null && thumbnailDataAccess.getInputStream() != null) {
return thumbnailDataAccess.getInputStream();
}
}
return null;
}
Aggregations