diff --git a/doc/release-notes/8796-fix-license-display-indexing.md b/doc/release-notes/8796-fix-license-display-indexing.md
new file mode 100644
index 00000000000..ebded088875
--- /dev/null
+++ b/doc/release-notes/8796-fix-license-display-indexing.md
@@ -0,0 +1 @@
+When datasets have neither a license nor custom terms of use the display will indicate this. Also, these datasets will no longer be indexed as having custom terms.
diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetVersionServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/DatasetVersionServiceBean.java
index ab23fa779d5..f99b3ee1b53 100644
--- a/src/main/java/edu/harvard/iq/dataverse/DatasetVersionServiceBean.java
+++ b/src/main/java/edu/harvard/iq/dataverse/DatasetVersionServiceBean.java
@@ -315,6 +315,23 @@ private void msg(String s){
//logger.fine(s);
}
+ public boolean isVersionDefaultCustomTerms(DatasetVersion datasetVersion) {
+
+ if (datasetVersion.getId() != null) {
+ try {
+ TermsOfUseAndAccess toua = (TermsOfUseAndAccess) em.createNamedQuery("TermsOfUseAndAccess.findByDatasetVersionIdAndDefaultTerms")
+ .setParameter("id", datasetVersion.getId()).setParameter("defaultTerms", TermsOfUseAndAccess.DEFAULT_NOTERMS).getSingleResult();
+ if (toua != null && datasetVersion.getTermsOfUseAndAccess().getLicense() == null) {
+ return true;
+ }
+
+ } catch (NoResultException e) {
+ return false;
+ }
+ }
+ return false;
+ }
+
/**
* Does the version identifier in the URL ask for a "DRAFT"?
*
diff --git a/src/main/java/edu/harvard/iq/dataverse/TermsOfUseAndAccess.java b/src/main/java/edu/harvard/iq/dataverse/TermsOfUseAndAccess.java
index ee865770dbe..9e48c6c0165 100644
--- a/src/main/java/edu/harvard/iq/dataverse/TermsOfUseAndAccess.java
+++ b/src/main/java/edu/harvard/iq/dataverse/TermsOfUseAndAccess.java
@@ -17,6 +17,28 @@
import jakarta.persistence.Transient;
import edu.harvard.iq.dataverse.license.License;
+import jakarta.persistence.NamedQueries;
+import jakarta.persistence.NamedQuery;
+
+@NamedQueries({
+ // TermsOfUseAndAccess.findByDatasetVersionIdAndDefaultTerms
+ // is used to determine if the dataset terms were set by the multi license support update
+ // as part of the 5.10 release.
+
+ @NamedQuery(name = "TermsOfUseAndAccess.findByDatasetVersionIdAndDefaultTerms",
+ query = "SELECT o FROM TermsOfUseAndAccess o, DatasetVersion dv WHERE "
+ + "dv.id =:id "
+ + "AND dv.termsOfUseAndAccess.id = o.id "
+ + "AND o.termsOfUse =:defaultTerms "
+ + "AND o.confidentialityDeclaration IS null "
+ + "AND o.specialPermissions IS null "
+ + "AND o.restrictions IS null "
+ + "AND o.citationRequirements IS null "
+ + "AND o.depositorRequirements IS null "
+ + "AND o.conditions IS null "
+ + "AND o.disclaimer IS null "
+ )
+})
/**
*
@@ -26,6 +48,8 @@
@Entity
@ValidateTermsOfUseAndAccess
public class TermsOfUseAndAccess implements Serializable {
+
+ public static final String DEFAULT_NOTERMS = "This dataset is made available without information on how it can be used. You should communicate with the Contact(s) specified before use.";
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
diff --git a/src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java b/src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java
index 98bd26b51d6..060b8694e9c 100644
--- a/src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java
+++ b/src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java
@@ -653,6 +653,15 @@ public static License getLicense(DatasetVersion dsv) {
}
public static String getLicenseName(DatasetVersion dsv) {
+
+ DatasetVersionServiceBean datasetVersionService = CDI.current().select(DatasetVersionServiceBean.class).get();
+ /*
+ Special case where there are default custom terms indicating that no actual choice has been made...
+ */
+ if (datasetVersionService.isVersionDefaultCustomTerms(dsv)) {
+ return BundleUtil.getStringFromBundle("license.none.chosen");
+ }
+
License license = DatasetUtil.getLicense(dsv);
return getLocalizedLicenseName(license);
}
@@ -683,7 +692,16 @@ public static String getLicenseIcon(DatasetVersion dsv) {
}
public static String getLicenseDescription(DatasetVersion dsv) {
+
+ DatasetVersionServiceBean datasetVersionService = CDI.current().select(DatasetVersionServiceBean.class).get();
+ /*
+ Special case where there are default custom terms indicating that no actual choice has been made...
+ */
+ if (datasetVersionService.isVersionDefaultCustomTerms(dsv)) {
+ return BundleUtil.getStringFromBundle("license.none.chosen.description");
+ }
License license = DatasetUtil.getLicense(dsv);
+
return license != null ? getLocalizedLicenseDetails(license,"DESCRIPTION") : BundleUtil.getStringFromBundle("license.custom.description");
}
diff --git a/src/main/java/edu/harvard/iq/dataverse/search/IndexServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/search/IndexServiceBean.java
index 26b42734d19..c91eb0bfa7c 100644
--- a/src/main/java/edu/harvard/iq/dataverse/search/IndexServiceBean.java
+++ b/src/main/java/edu/harvard/iq/dataverse/search/IndexServiceBean.java
@@ -100,6 +100,8 @@ public class IndexServiceBean {
@EJB
DatasetServiceBean datasetService;
@EJB
+ DatasetVersionServiceBean datasetVersionService;
+ @EJB
BuiltinUserServiceBean dataverseUserServiceBean;
@EJB
PermissionServiceBean permissionService;
@@ -1840,9 +1842,19 @@ private List
-