|
13 | 13 | import java.util.HashMap;
|
14 | 14 | import java.util.Map;
|
15 | 15 | import java.util.logging.Logger;
|
| 16 | +import edu.harvard.iq.dataverse.dataaccess.DataAccess; |
| 17 | +import edu.harvard.iq.dataverse.dataaccess.StorageIO; |
| 18 | +import edu.harvard.iq.dataverse.dataset.DatasetUtil; |
| 19 | +import java.io.IOException; |
16 | 20 |
|
17 | 21 | import jakarta.ejb.EJB;
|
18 | 22 | import jakarta.enterprise.context.RequestScoped;
|
@@ -170,13 +174,25 @@ public String getDatasetCardImageAsUrl(Dataset dataset, Long versionId, boolean
|
170 | 174 |
|
171 | 175 | if (thumbnailFile == null) {
|
172 | 176 |
|
173 |
| - // We attempt to auto-select via the optimized, native query-based method |
| 177 | + boolean hasDatasetLogo = false; |
| 178 | + StorageIO<DvObject> storageIO = null; |
| 179 | + try { |
| 180 | + storageIO = DataAccess.getStorageIO(dataset); |
| 181 | + if (storageIO.isAuxObjectCached(DatasetUtil.datasetLogoFilenameFinal)) { |
| 182 | + // If not, return null/use the default, otherwise pass the logo URL |
| 183 | + hasDatasetLogo = true; |
| 184 | + } |
| 185 | + } catch (IOException ioex) { |
| 186 | + logger.warning("getDatasetCardImageAsUrl(): Failed to initialize dataset StorageIO for " |
| 187 | + + dataset.getStorageIdentifier() + " (" + ioex.getMessage() + ")"); |
| 188 | + } |
| 189 | + // If no other logo we attempt to auto-select via the optimized, native |
| 190 | + // query-based method |
174 | 191 | // from the DatasetVersionService:
|
175 |
| - if (datasetVersionService.getThumbnailByVersionId(versionId) == null) { |
| 192 | + if (!hasDatasetLogo && datasetVersionService.getThumbnailByVersionId(versionId) == null) { |
176 | 193 | return null;
|
177 | 194 | }
|
178 | 195 | }
|
179 |
| - |
180 | 196 | String url = SystemConfig.getDataverseSiteUrlStatic() + "/api/datasets/" + dataset.getId() + "/logo";
|
181 | 197 | logger.fine("getDatasetCardImageAsUrl: " + url);
|
182 | 198 | this.dvobjectThumbnailsMap.put(datasetId,url);
|
|
0 commit comments