Skip to content

Commit

Permalink
adding fix from review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenwinship committed Sep 23, 2024
1 parent 48f9f72 commit d215221
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import edu.harvard.iq.dataverse.dataaccess.StorageIO;
import edu.harvard.iq.dataverse.dataset.DatasetUtil;
import edu.harvard.iq.dataverse.search.SolrSearchResult;
import edu.harvard.iq.dataverse.util.FileUtil;
import edu.harvard.iq.dataverse.util.SystemConfig;

import java.io.IOException;
Expand Down Expand Up @@ -49,14 +50,16 @@ public class ThumbnailServiceWrapper implements java.io.Serializable {
private Map<Long, Boolean> hasThumbMap = new HashMap<>();

public String getFileCardImageAsUrl(SolrSearchResult result) {

if (!result.isHarvested() && result.getEntity() != null && (!((DataFile)result.getEntity()).isRestricted()
|| permissionsWrapper.hasDownloadFilePermission(result.getEntity()))
&& isThumbnailAvailable((DataFile) result.getEntity())) {
return SystemConfig.getDataverseSiteUrlStatic() + "/api/access/datafile/" + result.getEntity().getId() + "?imageThumb=true";
DataFile dataFile = result != null && result.getEntity() != null ? ((DataFile) result.getEntity()) : null;
if (dataFile == null || result.isHarvested()
|| !isThumbnailAvailable(dataFile)
|| dataFile.isRestricted()
|| !dataFile.isReleased()
|| FileUtil.isActivelyEmbargoed(dataFile)
|| FileUtil.isRetentionExpired(dataFile)) {
return null;
}

return null;
return SystemConfig.getDataverseSiteUrlStatic() + "/api/access/datafile/" + dataFile.getId() + "?imageThumb=true";
}

// it's the responsibility of the user - to make sure the search result
Expand Down

0 comments on commit d215221

Please sign in to comment.