Skip to content

Commit

Permalink
IQSS#9060 IQSS#7482 Fix NullPointer possible case and IndexServiceBea…
Browse files Browse the repository at this point in the history
…nTest issues
  • Loading branch information
luddaniel committed Jan 4, 2024
1 parent aa33328 commit aa3ce68
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import edu.harvard.iq.dataverse.harvest.client.HarvestingClient;
import edu.harvard.iq.dataverse.settings.JvmSettings;
import edu.harvard.iq.dataverse.settings.SettingsServiceBean;
import edu.harvard.iq.dataverse.util.BundleUtil;
import edu.harvard.iq.dataverse.util.FileUtil;
import edu.harvard.iq.dataverse.util.StringUtil;
import edu.harvard.iq.dataverse.util.SystemConfig;
Expand Down Expand Up @@ -858,7 +857,7 @@ public SolrInputDocuments toSolrDocs(IndexableDataset indexableDataset, Set<Long
String parentDatasetTitle = "TBD";
if (datasetVersion != null) {

solrInputDocument.addField(SearchFields.DATASET_LICENSE, datasetVersion.getTermsOfUseAndAccess().getLicense().getName());
addLicenseToSolrDoc(solrInputDocument, datasetVersion);

solrInputDocument.addField(SearchFields.DATASET_VERSION_ID, datasetVersion.getId());
solrInputDocument.addField(SearchFields.DATASET_CITATION, datasetVersion.getCitation(false));
Expand Down Expand Up @@ -1247,7 +1246,7 @@ public SolrInputDocuments toSolrDocs(IndexableDataset indexableDataset, Set<Long
datafileSolrInputDocument.addField(SearchFields.FILE_NAME, filenameCompleteFinal);

datafileSolrInputDocument.addField(SearchFields.DATASET_VERSION_ID, datasetVersion.getId());
datafileSolrInputDocument.addField(SearchFields.DATASET_LICENSE, datasetVersion.getTermsOfUseAndAccess().getLicense().getName());
addLicenseToSolrDoc(datafileSolrInputDocument, datasetVersion);

/**
* for rules on sorting files see
Expand Down Expand Up @@ -1617,6 +1616,12 @@ private List<String> getDataversePathsFromSegments(List<String> dataversePathSeg
return subtrees;
}

private void addLicenseToSolrDoc(SolrInputDocument solrInputDocument, DatasetVersion datasetVersion) {
if (datasetVersion != null && datasetVersion.getTermsOfUseAndAccess() != null && datasetVersion.getTermsOfUseAndAccess().getLicense() != null) {
solrInputDocument.addField(SearchFields.DATASET_LICENSE, datasetVersion.getTermsOfUseAndAccess().getLicense().getName());
}
}

private void addDataverseReleaseDateToSolrDoc(SolrInputDocument solrInputDocument, Dataverse dataverse) {
if (dataverse.getPublicationDate() != null) {
Calendar calendar = Calendar.getInstance();
Expand Down

0 comments on commit aa3ce68

Please sign in to comment.