Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IQSS/10268 fix thumbnail selection logic #10269

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
*/
package edu.harvard.iq.dataverse;

import edu.harvard.iq.dataverse.dataaccess.DataAccess;
import edu.harvard.iq.dataverse.dataaccess.ImageThumbConverter;

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.SystemConfig;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
Expand Down Expand Up @@ -170,17 +173,30 @@ public String getDatasetCardImageAsUrl(Dataset dataset, Long versionId, boolean

if (thumbnailFile == null) {

// We attempt to auto-select via the optimized, native query-based method
boolean hasDatasetLogo = false;
StorageIO<DvObject> storageIO = null;
try {
storageIO = DataAccess.getStorageIO(dataset);
if (storageIO.isAuxObjectCached(DatasetUtil.datasetLogoFilenameFinal)) {
// If not, return null/use the default, otherwise pass the logo URL
hasDatasetLogo = true;
}
} catch (IOException ioex) {
logger.warning("getDatasetCardImageAsUrl(): Failed to initialize dataset StorageIO for "
+ dataset.getStorageIdentifier() + " (" + ioex.getMessage() + ")");
}
// If no other logo we attempt to auto-select via the optimized, native
// query-based method
// from the DatasetVersionService:
if (datasetVersionService.getThumbnailByVersionId(versionId) == null) {
if (!hasDatasetLogo && datasetVersionService.getThumbnailByVersionId(versionId) == null) {
return null;
}
}

String url = SystemConfig.getDataverseSiteUrlStatic() + "/api/datasets/" + dataset.getId() + "/logo";
logger.fine("getDatasetCardImageAsUrl: " + url);
this.dvobjectThumbnailsMap.put(datasetId,url);
return url;

}

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