diff --git a/conf/docker-aio/0prep_deps.sh b/conf/docker-aio/0prep_deps.sh index 09eaefdf27f..d7b875f4b78 100755 --- a/conf/docker-aio/0prep_deps.sh +++ b/conf/docker-aio/0prep_deps.sh @@ -4,9 +4,9 @@ if [ ! -d dv/deps ]; then fi wdir=`pwd` -if [ ! -e dv/deps/payara-5.2021.5.zip ]; then +if [ ! -e dv/deps/payara-5.2021.6.zip ]; then echo "payara dependency prep" - wget https://s3-eu-west-1.amazonaws.com/payara.fish/Payara+Downloads/5.2021.5/payara-5.2021.5.zip -O dv/deps/payara-5.2021.5.zip + wget https://s3-eu-west-1.amazonaws.com/payara.fish/Payara+Downloads/5.2021.6/payara-5.2021.6.zip -O dv/deps/payara-5.2021.6.zip fi if [ ! -e dv/deps/solr-8.11.1dv.tgz ]; then diff --git a/conf/docker-aio/c8.dockerfile b/conf/docker-aio/c8.dockerfile index dacb46d6924..dab6d814ece 100644 --- a/conf/docker-aio/c8.dockerfile +++ b/conf/docker-aio/c8.dockerfile @@ -24,7 +24,7 @@ COPY disableipv6.conf /etc/sysctl.d/ RUN rm /etc/httpd/conf/* COPY httpd.conf /etc/httpd/conf RUN cd /opt ; tar zxf /tmp/dv/deps/solr-8.11.1dv.tgz -RUN cd /opt ; unzip /tmp/dv/deps/payara-5.2021.5.zip ; ln -s /opt/payara5 /opt/glassfish4 +RUN cd /opt ; unzip /tmp/dv/deps/payara-5.2021.6.zip ; ln -s /opt/payara5 /opt/glassfish4 # this copy of domain.xml is the result of running `asadmin set server.monitoring-service.module-monitoring-levels.jvm=LOW` on a default glassfish installation (aka - enable the glassfish REST monitir endpoint for the jvm` # this dies under Java 11, do we keep it? diff --git a/doc/release-notes/5.10.1-release-notes.md b/doc/release-notes/5.10.1-release-notes.md new file mode 100644 index 00000000000..a7f2250dac9 --- /dev/null +++ b/doc/release-notes/5.10.1-release-notes.md @@ -0,0 +1,96 @@ +# Dataverse Software 5.10.1 + +This release brings new features, enhancements, and bug fixes to the Dataverse Software. Thank you to all of the community members who contributed code, suggestions, bug reports, and other assistance across the project. + +## Release Highlights + +### Bug Fix for Request Access + +Dataverse Software 5.10 contains a bug where the "Request Access" button doesn't work from the file listing on the dataset page if the dataset contains custom terms. This has been fixed in PR #8555. + +### Bug Fix for Searching and Selecting Controlled Vocabulary Values + +Dataverse Software 5.10 contains a bug where the search option is no longer present when selecting from more than ten controlled vocabulary values. This has been fixed in PR #8521. + +## Major Use Cases and Infrastructure Enhancements + +Changes and fixes in this release include: + +- Users can use the "Request Access" button when the dataset has custom terms. (Issue #8553, PR #8555) +- Users can search when selecting from more than ten controlled vocabulary values. (Issue #8519, PR #8521) +- The default file categories ("Documentation", "Data", and "Code") can be redefined through the `:FileCategories` database setting. (Issue #8461, PR #8478) +- Documentation on troubleshooting Excel ingest errors was improved. (PR #8541) +- Internationalized controlled vocabulary values can now be searched. (Issue #8286, PR #8435) +- Curation labels can be internationalized. (Issue #8381, PR #8466) +- "NONE" is no longer accepted as a license using the SWORD API (since 5.10). See "Backward Incompatibilities" below for details. (Issue #8551, PR #8558). + +## Notes for Dataverse Installation Administrators + +### PostgreSQL Version 10+ Required Soon + +Because 5.10.1 is a bug fix release, an upgrade to PostgreSQL is not required. However, this upgrade is still coming in the next non-bug fix release. For details, please see the release notes for 5.10: https://github.com/IQSS/dataverse/releases/tag/v5.10 + +### Payara Upgrade + +You may notice that the Payara version used in the install scripts has been updated from 5.2021.5 to 5.2021.6. This was to address a bug where it was not possible to easily update the logging level. For existing installations, this release does not require upgrading Payara and a Payara upgrade is not part of the Upgrade Instructions below. For more information, see PR #8508. + +## New JVM Options and DB Settings + +The following DB settings have been added: + +- `:FileCategories` - The default list of the pre-defined file categories ("Documentation", "Data" and "Code") can now be redefined with a comma-separated list (e.g. `'Docs,Data,Code,Workflow'`). + +See the [Database Settings](https://guides.dataverse.org/en/5.10.1/installation/config.html#database-settings) section of the Guides for more information. + +## Notes for Developers and Integrators + +In the "Backward Incompatibilities" section below, note changes in the API regarding licenses and the SWORD API. + +## Backward Incompatibilities + +As of Dataverse 5.10, "NONE" is no longer supported as a valid license when creating a dataset using the SWORD API. The API Guide has been updated to reflect this. Additionally, if you specify an invalid license, a list of available licenses will be returned in the response. + +## Complete List of Changes + +For the complete list of code changes in this release, see the [5.10.1 Milestone](https://github.com/IQSS/dataverse/milestone/102?closed=1) in Github. + +For help with upgrading, installing, or general questions please post to the [Dataverse Community Google Group](https://groups.google.com/forum/#!forum/dataverse-community) or email support@dataverse.org. + +## Installation + +If this is a new installation, please see our [Installation Guide](https://guides.dataverse.org/en/5.10.1/installation/). Please also contact us to get added to the [Dataverse Project Map](https://guides.dataverse.org/en/5.10.1/installation/config.html#putting-your-dataverse-installation-on-the-map-at-dataverse-org) if you have not done so already. + +## Upgrade Instructions + +0\. These instructions assume that you've already successfully upgraded from Dataverse Software 4.x to Dataverse Software 5 following the instructions in the [Dataverse Software 5 Release Notes](https://github.com/IQSS/dataverse/releases/tag/v5.0). After upgrading from the 4.x series to 5.0, you should progress through the other 5.x releases before attempting the upgrade to 5.10.1. + +If you are running Payara as a non-root user (and you should be!), **remember not to execute the commands below as root**. Use `sudo` to change to that user first. For example, `sudo -i -u dataverse` if `dataverse` is your dedicated application user. + +In the following commands we assume that Payara 5 is installed in `/usr/local/payara5`. If not, adjust as needed. + +`export PAYARA=/usr/local/payara5` + +(or `setenv PAYARA /usr/local/payara5` if you are using a `csh`-like shell) + +1\. Undeploy the previous version. + +- `$PAYARA/bin/asadmin list-applications` +- `$PAYARA/bin/asadmin undeploy dataverse<-version>` + +2\. Stop Payara and remove the generated directory + +- `service payara stop` +- `rm -rf $PAYARA/glassfish/domains/domain1/generated` + +3\. Start Payara + +- `service payara start` + +4\. Deploy this version. + +- `$PAYARA/bin/asadmin deploy dataverse-5.10.1.war` + +5\. Restart payara + +- `service payara stop` +- `service payara start` diff --git a/doc/release-notes/8210-importddi-fix.md b/doc/release-notes/8210-importddi-fix.md deleted file mode 100644 index 98981263e58..00000000000 --- a/doc/release-notes/8210-importddi-fix.md +++ /dev/null @@ -1 +0,0 @@ -importddi API subject validation problem was fixed by filling subject with "N/A". diff --git a/doc/release-notes/8452-multiple-collectionmode.md b/doc/release-notes/8452-multiple-collectionmode.md deleted file mode 100644 index b367b9230cd..00000000000 --- a/doc/release-notes/8452-multiple-collectionmode.md +++ /dev/null @@ -1,12 +0,0 @@ -### A small modification to the Social Science metadata block - -The metadata block update allows the field "collectionMode" to have multiple values. - -For the upgrade instruction: - -Update the Social Science metadata block as follows: - -- `wget https://github.com/IQSS/dataverse/releases/download/v5.10/social_science.tsv` -- `curl http://localhost:8080/api/admin/datasetfield/load -X POST --data-binary @social_science.tsv -H "Content-type: text/tab-separated-values"` - -As a general reminder, please note that it is important to keep your metadata block definitions up-to-date. \ No newline at end of file diff --git a/doc/sphinx-guides/source/api/sword-atom-entry.xml b/doc/sphinx-guides/source/api/sword-atom-entry.xml index d47a3dd4f56..8d73653e93e 100755 --- a/doc/sphinx-guides/source/api/sword-atom-entry.xml +++ b/doc/sphinx-guides/source/api/sword-atom-entry.xml @@ -27,8 +27,8 @@ United States Canada - NONE - Downloader will not use the Materials in any way prohibited by applicable laws. + CC0 1.0 + Peets, J., & Stumptown, J. (2013). Roasting at Home. New England Journal of Coffee, 3(1), 22-34. diff --git a/doc/sphinx-guides/source/api/sword.rst b/doc/sphinx-guides/source/api/sword.rst index d853994f073..d4f56ddb5b4 100755 --- a/doc/sphinx-guides/source/api/sword.rst +++ b/doc/sphinx-guides/source/api/sword.rst @@ -65,6 +65,8 @@ Differences in Dataverse Software 4 from DVN 3.x lead to a few minor backward in - The Service Document will show a single API Terms of Use rather than root level and Dataverse collection level Deposit Terms of Use. +- As of Dataverse Software 5.10, ``NONE`` is no longer supported as a license. + New features as of v1.1 ----------------------- @@ -80,7 +82,7 @@ New features as of v1.1 - "Contributor" can now be populated and the "Type" (Editor, Funder, Researcher, etc.) can be specified with an XML attribute. For example: ``CaffeineForAll`` -- "License" can now be set with ``dcterms:license`` and the possible values are "CC0" and "NONE". "License" interacts with "Terms of Use" (``dcterms:rights``) in that if you include ``dcterms:rights`` in the XML, the license will be set to "NONE". If you don't include ``dcterms:rights``, the license will default to "CC0". It is invalid to specify "CC0" as a license and also include ``dcterms:rights``; an error will be returned. For backwards compatibility, ``dcterms:rights`` is allowed to be blank (i.e. ````) but blank values will not be persisted to the database and the license will be set to "NONE". +- "License" can now be set with ``dcterms:license`` and the possible values determined by the installation ("CC0 1.0" and "CC BY 4.0" by default). "License" interacts with "Terms of Use" (``dcterms:rights``) in that if you include ``dcterms:rights`` in the XML and don't include ``dcterms:license``, the license will be "Custom Dataset Terms" and "Terms of Use" will be populated. If you don't include ``dcterms:rights``, the default license will be used. It is invalid to specify a license and also include ``dcterms:rights``; an error will be returned. For backwards compatibility, ``dcterms:rights`` is allowed to be blank (i.e. ````) but blank values will not be persisted to the database and the license will be set to "Custom Dataset Terms". - "Contact E-mail" is automatically populated from dataset owner's email. @@ -143,9 +145,9 @@ Dublin Core Terms (DC Terms) Qualified Mapping - Dataverse Project DB Element Cr +-----------------------------+----------------------------------------------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+ |dcterms:coverage | otherGeographicCoverage | | General information on the geographic coverage of the Dataset. | +-----------------------------+----------------------------------------------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+ -|dcterms:license | license | | Set the license to CC0 (default in a Dataverse installation for new Datasets), otherwise enter "NONE" and fill in the dcterms:rights field. | +|dcterms:license | license | | Set the license. Alternatively, use the dcterms:rights field instead. | +-----------------------------+----------------------------------------------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+ -|dcterms:rights | termsofuse | | If not using CC0, enter any terms of use or restrictions for the Dataset. | +|dcterms:rights | termsofuse | | If not using dcterms:license, enter any terms of use or restrictions for the Dataset. | +-----------------------------+----------------------------------------------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+ |dcterms:isReferencedBy | publicationCitation | | The publication (journal article, book, other work) that uses this dataset (include citation, permanent identifier (DOI), and permanent URL). | +-----------------------------+----------------------------------------------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/doc/sphinx-guides/source/conf.py b/doc/sphinx-guides/source/conf.py index 2d08c687467..748c797bbab 100755 --- a/doc/sphinx-guides/source/conf.py +++ b/doc/sphinx-guides/source/conf.py @@ -65,9 +65,9 @@ # built documents. # # The short X.Y version. -version = '5.10' +version = '5.10.1' # The full version, including alpha/beta/rc tags. -release = '5.10' +release = '5.10.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/sphinx-guides/source/developers/dev-environment.rst b/doc/sphinx-guides/source/developers/dev-environment.rst index 4b76e475da7..38549637f8a 100755 --- a/doc/sphinx-guides/source/developers/dev-environment.rst +++ b/doc/sphinx-guides/source/developers/dev-environment.rst @@ -79,15 +79,15 @@ On Linux, install ``jq`` from your package manager or download a binary from htt Install Payara ~~~~~~~~~~~~~~ -Payara 5.201 or higher is required. +Payara 5.2021.6 or higher is required. To install Payara, run the following commands: ``cd /usr/local`` -``sudo curl -O -L https://s3-eu-west-1.amazonaws.com/payara.fish/Payara+Downloads/5.2021.5/payara-5.2021.5.zip`` +``sudo curl -O -L https://s3-eu-west-1.amazonaws.com/payara.fish/Payara+Downloads/5.2021.6/payara-5.2021.6.zip`` -``sudo unzip payara-5.2021.5.zip`` +``sudo unzip payara-5.2021.6.zip`` ``sudo chown -R $USER /usr/local/payara5`` diff --git a/doc/sphinx-guides/source/installation/config.rst b/doc/sphinx-guides/source/installation/config.rst index 69bec48ed04..77feed18491 100644 --- a/doc/sphinx-guides/source/installation/config.rst +++ b/doc/sphinx-guides/source/installation/config.rst @@ -2506,6 +2506,14 @@ Each set of labels is identified by a curationLabelSet name and a JSON Array of ``curl -X PUT -d '{"Standard Process":["Author contacted", "Privacy Review", "Awaiting paper publication", "Final Approval"], "Alternate Process":["State 1","State 2","State 3"]}' http://localhost:8080/api/admin/settings/:AllowedCurationLabels`` +If the Dataverse Installation supports multiple languages, the curation label translations should be added to the ``CurationLabels`` properties files. (See :ref:`i18n` for more on properties files and internationalization in general.) +Since the Curation labels are free text, while creating the key, it has to be converted to lowercase, replace space with underscore. + +Example:: + + standard_process=Standard Process + author_contacted=Author contacted + .. _:AllowCustomTermsOfUse: :AllowCustomTermsOfUse @@ -2576,3 +2584,18 @@ For example: ++++++++++++++++++++++++++++++++ When set to ``true``, this setting allows a superuser to publish and/or update Dataverse collections and datasets bypassing the external validation checks (specified by the settings above). In an event where an external script is reporting validation failures that appear to be in error, this option gives an admin with superuser privileges a quick way to publish the dataset or update a collection for the user. + +:FileCategories ++++++++++++++++ + +Overrides the default list of file categories that is used in the UI when adding tags to files. The default list is Documentation, Data, and Code. + +This setting is a comma-separated list of the new tags. + +To override the default list with Docs, Data, Code, and Workflow: + +``curl -X PUT -d 'Docs,Data,Code,Workflow' http://localhost:8080/api/admin/settings/:FileCategories`` + +To remove the override and go back to the default list: + +``curl -X PUT -d '' http://localhost:8080/api/admin/settings/:FileCategories`` \ No newline at end of file diff --git a/doc/sphinx-guides/source/installation/installation-main.rst b/doc/sphinx-guides/source/installation/installation-main.rst index 0042a0db6d8..1b426bc0712 100755 --- a/doc/sphinx-guides/source/installation/installation-main.rst +++ b/doc/sphinx-guides/source/installation/installation-main.rst @@ -100,10 +100,6 @@ The Dataverse Software uses JHOVE_ to help identify the file format (CSV, PNG, e .. _JHOVE: http://jhove.openpreservation.org -**A note about Payara-5.2021.5:** as of this writing there exists a logging configuration bug in Payara-5.2021.5. Any change to the logging configuration results in the contents of ``/usr/local/payara/glassfish/domains/domain1/config/logging.properties`` getting clobbered. In the absence of a proper logging configuration, Payara logs a number of WELD INFO entries on Payara launch, then proceeds to attempt to update its logging configuration approximately twice a second. This will result in unnecessarily junked-up system logs. - -This bug appears to be triggered in new Payara installations during the Dataverse installation routine. As the ``default-logging.properties`` file doesn't match the ``logging.proprties`` file distributed with Payara, we are offering :download:`a copy of it here<../_static/installation/files/usr/local/payara5/glassfish/domains/domain1/config/logging.properties>`. Simply stopping Payara, replacing the file, and starting Payara should correct the issue. - Logging In ---------- diff --git a/doc/sphinx-guides/source/installation/prerequisites.rst b/doc/sphinx-guides/source/installation/prerequisites.rst index 6778fe6a236..85a5cfa4d8a 100644 --- a/doc/sphinx-guides/source/installation/prerequisites.rst +++ b/doc/sphinx-guides/source/installation/prerequisites.rst @@ -44,7 +44,7 @@ On RHEL/derivative you can make Java 11 the default with the ``alternatives`` co Payara ------ -Payara 5.2021.5 is recommended. Newer versions might work fine, regular updates are recommended. +Payara 5.2021.6 is recommended. Newer versions might work fine, regular updates are recommended. Installing Payara ================= @@ -55,8 +55,8 @@ Installing Payara - Download and install Payara (installed in ``/usr/local/payara5`` in the example commands below):: - # wget https://s3-eu-west-1.amazonaws.com/payara.fish/Payara+Downloads/5.2021.5/payara-5.2021.5.zip - # unzip payara-5.2021.5.zip + # wget https://s3-eu-west-1.amazonaws.com/payara.fish/Payara+Downloads/5.2021.6/payara-5.2021.6.zip + # unzip payara-5.2021.6.zip # mv payara5 /usr/local If you intend to install and run Payara under a service account (and we hope you do), chown -R the Payara hierarchy to root to protect it but give the service account access to the below directories: diff --git a/doc/sphinx-guides/source/user/tabulardataingest/excel.rst b/doc/sphinx-guides/source/user/tabulardataingest/excel.rst index b82cc45bfde..0013b4eaf88 100644 --- a/doc/sphinx-guides/source/user/tabulardataingest/excel.rst +++ b/doc/sphinx-guides/source/user/tabulardataingest/excel.rst @@ -1,10 +1,32 @@ Excel +++++++ +Microsoft Excel files (XLSX format). + .. contents:: |toctitle| :local: -Excel files (**New** in Dataverse Software 4.0!) +Supported Formats +------------------ + +Only the newer XLSX Excel files are supported. We are not planning to add support for the old-style, binary XLS files. + +Limitations +----------- + +If an Excel file has multiple sheets, only the first sheet of the file will be ingested. The other sheets will be available when a user downloads the original Excel file. To have all sheets of an Excel file ingested and searchable at the variable level, upload each sheet as an individual file in your dataset. + +Ingest Errors +------------- + +You may encounter ingest errors after uploading an Excel file if the file is formatted in a way that can't be ingested by the Dataverse software. Ingest errors can be caused by a variety of formatting inconsistencies, including: + +* line breaks in a cell +* blank cells +* single cells that span multiple rows +* missing headers -Note: only the "new", XLSX Excel files are supported. We are not planning to add support for the old-style, binary XLS files. +Example Data +------------ +`An example of an Excel file that successfully ingests `_ is available in the Dataverse Sample Data GitHub repository. diff --git a/doc/sphinx-guides/source/user/tabulardataingest/rdata.rst b/doc/sphinx-guides/source/user/tabulardataingest/rdata.rst index d8f3b23cf66..91810543803 100644 --- a/doc/sphinx-guides/source/user/tabulardataingest/rdata.rst +++ b/doc/sphinx-guides/source/user/tabulardataingest/rdata.rst @@ -6,20 +6,19 @@ Support for R (.RData) files has been introduced in DVN 3.5. .. contents:: |toctitle| :local: -Overview. +Overview =========== - R has been increasingly popular in the research/academic community, owing to the fact that it is free and open-source (unlike SPSS and STATA). Consequently, there is an increasing amount of data available exclusively in R format. -Data Formatting Requirements. +Data Formatting Requirements ============================== -The data must be formatted as an R dataframe (data.frame()). If an -.RData file contains multiple dataframes, only the 1st one will be +The data must be formatted as an R dataframe (``data.frame()``). If an +.RData file contains multiple dataframes, only the first one will be ingested (this may change in the future). Data Types, compared to other supported formats (Stat, SPSS) @@ -82,7 +81,7 @@ Boolean values R Boolean (logical) values are supported. -Limitations of R, as compared to SPSS and STATA. +Limitations of R, as compared to SPSS and STATA ------------------------------------------------ Most noticeably, R lacks a standard mechanism for defining descriptive diff --git a/doc/sphinx-guides/source/versions.rst b/doc/sphinx-guides/source/versions.rst index ddbc4d7957c..21b4ac9d6f4 100755 --- a/doc/sphinx-guides/source/versions.rst +++ b/doc/sphinx-guides/source/versions.rst @@ -6,8 +6,9 @@ Dataverse Software Documentation Versions This list provides a way to refer to the documentation for previous versions of the Dataverse Software. In order to learn more about the updates delivered from one version to another, visit the `Releases `__ page in our GitHub repo. -- 5.10 +- 5.10.1 +- `5.10 `__ - `5.9 `__ - `5.8 `__ - `5.7 `__ diff --git a/downloads/download.sh b/downloads/download.sh index 5362a0a2b7c..3d37d9f0940 100755 --- a/downloads/download.sh +++ b/downloads/download.sh @@ -1,5 +1,5 @@ #!/bin/sh -curl -L -O https://s3-eu-west-1.amazonaws.com/payara.fish/Payara+Downloads/5.2021.5/payara-5.2021.5.zip +curl -L -O https://s3-eu-west-1.amazonaws.com/payara.fish/Payara+Downloads/5.2021.6/payara-5.2021.6.zip curl -L -O https://archive.apache.org/dist/lucene/solr/8.11.1/solr-8.11.1.tgz curl -L -O https://search.maven.org/remotecontent?filepath=org/jboss/weld/weld-osgi-bundle/2.2.10.Final/weld-osgi-bundle-2.2.10.Final-glassfish4.jar curl -s -L http://sourceforge.net/projects/schemaspy/files/schemaspy/SchemaSpy%205.0.0/schemaSpy_5.0.0.jar/download > schemaSpy_5.0.0.jar diff --git a/modules/dataverse-parent/pom.xml b/modules/dataverse-parent/pom.xml index 280a0803c79..ab5a915e7e9 100644 --- a/modules/dataverse-parent/pom.xml +++ b/modules/dataverse-parent/pom.xml @@ -129,7 +129,7 @@ - 5.10 + 5.10.1 11 UTF-8 @@ -146,7 +146,7 @@ -Duser.timezone=${project.timezone} -Dfile.encoding=${project.build.sourceEncoding} -Duser.language=${project.language} -Duser.region=${project.region} - 5.2021.5 + 5.2021.6 42.3.3 8.8.1 1.11.762 diff --git a/scripts/vagrant/setup.sh b/scripts/vagrant/setup.sh index a424a99975f..e4915ae9ffa 100644 --- a/scripts/vagrant/setup.sh +++ b/scripts/vagrant/setup.sh @@ -51,7 +51,7 @@ SOLR_USER=solr echo "Ensuring Unix user '$SOLR_USER' exists" useradd $SOLR_USER || : DOWNLOAD_DIR='/dataverse/downloads' -PAYARA_ZIP="$DOWNLOAD_DIR/payara-5.2021.5.zip" +PAYARA_ZIP="$DOWNLOAD_DIR/payara-5.2021.6.zip" SOLR_TGZ="$DOWNLOAD_DIR/solr-8.11.1.tgz" if [ ! -f $PAYARA_ZIP ] || [ ! -f $SOLR_TGZ ]; then echo "Couldn't find $PAYARA_ZIP or $SOLR_TGZ! Running download script...." diff --git a/src/main/java/edu/harvard/iq/dataverse/DataFileCategoryServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/DataFileCategoryServiceBean.java new file mode 100644 index 00000000000..3fa4691a6dd --- /dev/null +++ b/src/main/java/edu/harvard/iq/dataverse/DataFileCategoryServiceBean.java @@ -0,0 +1,87 @@ +package edu.harvard.iq.dataverse; + +import edu.harvard.iq.dataverse.settings.SettingsServiceBean; +import edu.harvard.iq.dataverse.util.BundleUtil; + +import javax.ejb.EJB; +import javax.ejb.Stateless; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * Service to manage the default values for Dataset file categories and allow + * to be overridden with a :FileCategories Settings configuration. + * + * @author adaybujeda + */ +@Stateless +public class DataFileCategoryServiceBean { + + public static final String FILE_CATEGORIES_KEY = ":FileCategories"; + + @EJB + private SettingsServiceBean settingsService; + + public List mergeDatasetFileCategories(List datasetFileCategories) { + List fileCategories = Optional.ofNullable(datasetFileCategories).orElse(Collections.emptyList()); + List defaultFileCategories = getFileCategories(); + + //avoid resizing + List mergedFileCategories = new ArrayList<>(defaultFileCategories.size() + fileCategories.size()); + + for(DataFileCategory category: fileCategories) { + mergedFileCategories.add(category.getName()); + } + + for(String defaultCategory: defaultFileCategories) { + if (!mergedFileCategories.contains(defaultCategory)) { + mergedFileCategories.add(defaultCategory); + } + } + + return mergedFileCategories; + } + + public List getFileCategories() { + List fileCategoriesOverride = getFileCategoriesOverride(); + return fileCategoriesOverride.isEmpty() ? getFileCategoriesDefault() : fileCategoriesOverride; + } + + private List getFileCategoriesDefault() { + // "Documentation", "Data" and "Code" are the 3 default categories that we + // present by default + return Arrays.asList( + BundleUtil.getStringFromBundle("dataset.category.documentation"), + BundleUtil.getStringFromBundle("dataset.category.data"), + BundleUtil.getStringFromBundle("dataset.category.code") + ); + } + + private List getFileCategoriesOverride() { + String applicationLanguage = BundleUtil.getCurrentLocale().getLanguage(); + Optional fileCategoriesOverride = Optional.ofNullable(settingsService.get(FILE_CATEGORIES_KEY)); + + if (fileCategoriesOverride.isPresent()) { + // There is an override, check if there is language specific value + String overrideValue = settingsService.get(FILE_CATEGORIES_KEY, applicationLanguage, fileCategoriesOverride.get()); + + return parseCategoriesString(overrideValue); + } + + return Collections.emptyList(); + } + + private List parseCategoriesString(String categoriesString) { + if (categoriesString == null) { + return Collections.emptyList(); + } + + String[] categories = categoriesString.split(","); + return Arrays.stream(categories).map(item -> item.trim()).filter(item -> !item.isBlank()).collect(Collectors.toUnmodifiableList()); + } + +} diff --git a/src/main/java/edu/harvard/iq/dataverse/Dataset.java b/src/main/java/edu/harvard/iq/dataverse/Dataset.java index 569a5cdfd2a..32ec6bdcf99 100644 --- a/src/main/java/edu/harvard/iq/dataverse/Dataset.java +++ b/src/main/java/edu/harvard/iq/dataverse/Dataset.java @@ -448,24 +448,6 @@ public void addFileCategory(DataFileCategory category) { dataFileCategories.add(category); } - public Collection getCategoriesByName() { - Collection ret = getCategoryNames(); - - // "Documentation", "Data" and "Code" are the 3 default categories that we - // present by default: - if (!ret.contains(BundleUtil.getStringFromBundle("dataset.category.documentation"))) { - ret.add(BundleUtil.getStringFromBundle("dataset.category.documentation")); - } - if (!ret.contains(BundleUtil.getStringFromBundle("dataset.category.data"))) { - ret.add(BundleUtil.getStringFromBundle("dataset.category.data")); - } - if (!ret.contains(BundleUtil.getStringFromBundle("dataset.category.code"))) { - ret.add(BundleUtil.getStringFromBundle("dataset.category.code")); - } - - return ret; - } - public void setCategoriesByName(List newCategoryNames) { if (newCategoryNames != null) { Collection oldCategoryNames = getCategoryNames(); diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java index 4a864ada2ae..29f08d885cd 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetPage.java @@ -64,9 +64,6 @@ import java.io.InputStream; import java.sql.Timestamp; import java.text.SimpleDateFormat; -import java.time.Instant; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -78,7 +75,6 @@ import java.util.Set; import java.util.Collection; import java.util.logging.Logger; -import java.util.stream.Collectors; import javax.ejb.EJB; import javax.ejb.EJBException; import javax.faces.application.FacesMessage; @@ -88,7 +84,6 @@ import javax.faces.view.ViewScoped; import javax.inject.Inject; import javax.inject.Named; -import javax.json.JsonObject; import org.apache.commons.lang3.StringUtils; import org.primefaces.event.FileUploadEvent; @@ -128,7 +123,6 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.text.StringEscapeUtils; -import org.apache.commons.validator.routines.EmailValidator; import org.apache.commons.lang3.mutable.MutableBoolean; import org.apache.commons.io.IOUtils; import org.primefaces.component.selectonemenu.SelectOneMenu; @@ -251,6 +245,8 @@ public enum DisplayMode { EmbargoServiceBean embargoService; @Inject LicenseServiceBean licenseServiceBean; + @Inject + DataFileCategoryServiceBean dataFileCategoryService; private Dataset dataset = new Dataset(); @@ -4529,7 +4525,8 @@ public void setTabFileTagsByName(List tabFileTagsByName) { private void refreshCategoriesByName(){ categoriesByName= new ArrayList<>(); - for (String category: dataset.getCategoriesByName() ){ + List datasetFileCategories = dataFileCategoryService.mergeDatasetFileCategories(dataset.getCategories()); + for (String category: datasetFileCategories ){ categoriesByName.add(category); } refreshSelectedTags(); @@ -5647,7 +5644,10 @@ public void setExternalStatus(String status) { if (status == null || status.isEmpty()) { JsfHelper.addInfoMessage(BundleUtil.getStringFromBundle("dataset.externalstatus.removed")); } else { - JH.addMessage(FacesMessage.SEVERITY_INFO, BundleUtil.getStringFromBundle("dataset.externalstatus.header"), BundleUtil.getStringFromBundle("dataset.externalstatus.info", Arrays.asList(status))); + JH.addMessage(FacesMessage.SEVERITY_INFO, BundleUtil.getStringFromBundle("dataset.externalstatus.header"), + BundleUtil.getStringFromBundle("dataset.externalstatus.info", + Arrays.asList(DatasetUtil.getLocaleExternalStatus(status)) + )); } } catch (CommandException ex) { @@ -5656,7 +5656,7 @@ public void setExternalStatus(String status) { JsfHelper.addErrorMessage(msg); } } - + public List getAllowedExternalStatuses() { return settingsWrapper.getAllowedExternalStatuses(dataset); } diff --git a/src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java b/src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java index b766e5d7b58..f211ccd0410 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java +++ b/src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java @@ -1,6 +1,7 @@ package edu.harvard.iq.dataverse; import edu.harvard.iq.dataverse.util.MarkupChecker; +import edu.harvard.iq.dataverse.util.BundleUtil; import edu.harvard.iq.dataverse.DatasetFieldType.FieldType; import edu.harvard.iq.dataverse.branding.BrandingUtil; import edu.harvard.iq.dataverse.dataset.DatasetUtil; diff --git a/src/main/java/edu/harvard/iq/dataverse/DataversePage.java b/src/main/java/edu/harvard/iq/dataverse/DataversePage.java index 664658818e3..b48ff725e1e 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DataversePage.java +++ b/src/main/java/edu/harvard/iq/dataverse/DataversePage.java @@ -5,6 +5,7 @@ import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser; import edu.harvard.iq.dataverse.authorization.users.User; import edu.harvard.iq.dataverse.dataaccess.DataAccess; +import edu.harvard.iq.dataverse.dataset.DatasetUtil; import edu.harvard.iq.dataverse.dataverse.DataverseUtil; import edu.harvard.iq.dataverse.engine.command.Command; import edu.harvard.iq.dataverse.engine.command.exception.CommandException; @@ -1249,8 +1250,10 @@ public Set> getCurationLabelSetOptions() { } // Add an entry for disabled setNames.put(BundleUtil.getStringFromBundle("dataverse.curationLabels.disabled"), SystemConfig.CURATIONLABELSDISABLED); + allowedSetNames.forEach(name -> { - setNames.put(name, name); + String localizedName = DatasetUtil.getLocaleExternalStatus(name) ; + setNames.put(localizedName,name); }); } curationLabelSetOptions = setNames.entrySet(); diff --git a/src/main/java/edu/harvard/iq/dataverse/EditDatafilesPage.java b/src/main/java/edu/harvard/iq/dataverse/EditDatafilesPage.java index 7250f85a493..393aa870bc8 100644 --- a/src/main/java/edu/harvard/iq/dataverse/EditDatafilesPage.java +++ b/src/main/java/edu/harvard/iq/dataverse/EditDatafilesPage.java @@ -138,6 +138,8 @@ public enum Referrer { SettingsWrapper settingsWrapper; @Inject LicenseServiceBean licenseServiceBean; + @Inject + DataFileCategoryServiceBean dataFileCategoryService; private Dataset dataset = new Dataset(); @@ -2737,7 +2739,8 @@ private void refreshSelectedTabFileTags() { private void refreshCategoriesByName(){ categoriesByName= new ArrayList<>(); - for (String category: dataset.getCategoriesByName() ){ + List datasetFileCategories = dataFileCategoryService.mergeDatasetFileCategories(dataset.getCategories()); + for (String category: datasetFileCategories ){ categoriesByName.add(category); } refreshSelectedTags(); diff --git a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java index acc53528f5f..7c4569e1dc5 100644 --- a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java +++ b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java @@ -331,37 +331,20 @@ public Boolean isHasDropBoxKey() { public boolean isLocalesConfigured() { if (configuredLocales == null) { - initLocaleSettings(); + configuredLocales = new LinkedHashMap<>(); + settingsService.initLocaleSettings(configuredLocales); } return configuredLocales.size() > 1; } public Map getConfiguredLocales() { if (configuredLocales == null) { - initLocaleSettings(); + configuredLocales = new LinkedHashMap<>(); + settingsService.initLocaleSettings(configuredLocales); } return configuredLocales; } - private void initLocaleSettings() { - - configuredLocales = new LinkedHashMap<>(); - - try { - JSONArray entries = new JSONArray(getValueForKey(SettingsServiceBean.Key.Languages, "[]")); - for (Object obj : entries) { - JSONObject entry = (JSONObject) obj; - String locale = entry.getString("locale"); - String title = entry.getString("title"); - - configuredLocales.put(locale, title); - } - } catch (JSONException e) { - //e.printStackTrace(); - // do we want to know? - probably not - } - } - public boolean isDoiInstallation() { String protocol = getValueForKey(SettingsServiceBean.Key.Protocol); if ("doi".equals(protocol)) { @@ -490,31 +473,16 @@ public void validateEmbargoDate(FacesContext context, UIComponent component, Obj public Map getBaseMetadataLanguageMap(boolean refresh) { if (languageMap == null || refresh) { - languageMap = new HashMap(); - - /* If MetadataLanaguages is set, use it. - * If not, we can't assume anything and should avoid assuming a metadata language - */ - String mlString = getValueForKey(SettingsServiceBean.Key.MetadataLanguages,""); - - if(mlString.isEmpty()) { - mlString="[]"; - } - JsonReader jsonReader = Json.createReader(new StringReader(mlString)); - JsonArray languages = jsonReader.readArray(); - for(JsonValue jv: languages) { - JsonObject lang = (JsonObject) jv; - languageMap.put(lang.getString("locale"), lang.getString("title")); - } + languageMap = settingsService.getBaseMetadataLanguageMap(languageMap, true); } return languageMap; } public Map getMetadataLanguages(DvObjectContainer target) { Map currentMap = new HashMap(); - currentMap.putAll(getBaseMetadataLanguageMap(true)); - languageMap.put(DvObjectContainer.UNDEFINED_METADATA_LANGUAGE_CODE, getDefaultMetadataLanguageLabel(target)); - return languageMap; + currentMap.putAll(getBaseMetadataLanguageMap(false)); + currentMap.put(DvObjectContainer.UNDEFINED_METADATA_LANGUAGE_CODE, getDefaultMetadataLanguageLabel(target)); + return currentMap; } private String getDefaultMetadataLanguageLabel(DvObjectContainer target) { diff --git a/src/main/java/edu/harvard/iq/dataverse/api/datadeposit/SwordServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/api/datadeposit/SwordServiceBean.java index 7e45381d410..46c38e04153 100644 --- a/src/main/java/edu/harvard/iq/dataverse/api/datadeposit/SwordServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/api/datadeposit/SwordServiceBean.java @@ -12,6 +12,7 @@ import edu.harvard.iq.dataverse.license.License; import edu.harvard.iq.dataverse.license.LicenseServiceBean; import edu.harvard.iq.dataverse.util.BundleUtil; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -186,7 +187,13 @@ public void setDatasetLicenseAndTermsOfUse(DatasetVersion datasetVersionToMutate setTermsOfUse(datasetVersionToMutate, dcterms, null); } else { License licenseToSet = licenseServiceBean.getByNameOrUri(licenseProvided); - if (licenseToSet == null) throw new SwordError("Couldn't find an active license with: " + licenseProvided); + if (licenseToSet == null || !licenseToSet.isActive()) { + List licenses = new ArrayList<>(); + for (License license : licenseServiceBean.listAllActive()) { + licenses.add(license.getName()); + } + throw new SwordError("Couldn't find an active license with: " + licenseProvided + ". Valid licenses: " + licenses); + } terms.setLicense(licenseToSet); setTermsOfUse(datasetVersionToMutate, dcterms, licenseToSet); } @@ -204,7 +211,7 @@ private void setTermsOfUse(DatasetVersion datasetVersionToMutate, Map 0) { - throw new SwordError("Terms of Use (dcterms:rights) can not be specified in combination with a license. A Custom License can be used instead."); + throw new SwordError("Terms of Use (dcterms:rights) cannot be specified in combination with a license."); } } else { if (numRightsProvided != 1) { 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 4e0a89183da..ccf947b8868 100644 --- a/src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java +++ b/src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java @@ -568,4 +568,19 @@ public static String getLicenseDescription(DatasetVersion dsv) { License license = dsv.getTermsOfUseAndAccess().getLicense(); return license != null ? license.getShortDescription() : BundleUtil.getStringFromBundle("license.custom.description"); } + + public static String getLocaleExternalStatus(String status) { + String localizedName = "" ; + try { + localizedName = BundleUtil.getStringFromPropertyFile(status.toLowerCase().replace(" ", "_"), "CurationLabels"); + } + catch (Exception e) { + localizedName = status; + } + + if (localizedName == null) { + localizedName = status ; + } + return localizedName; + } } 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 e4844156271..7fbeb3ae0f5 100644 --- a/src/main/java/edu/harvard/iq/dataverse/search/IndexServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/search/IndexServiceBean.java @@ -247,10 +247,14 @@ public Future indexDataverse(Dataverse dataverse, boolean processPaths) solrInputDocument.addField(SearchFields.AFFILIATION, dataverse.getAffiliation()); solrInputDocument.addField(SearchFields.DATAVERSE_AFFILIATION, dataverse.getAffiliation()); } + Set langs = settingsService.getConfiguredLanguages(); for (ControlledVocabularyValue dataverseSubject : dataverse.getDataverseSubjects()) { String subject = dataverseSubject.getStrValue(); if (!subject.equals(DatasetField.NA_VALUE)) { - solrInputDocument.addField(SearchFields.DATAVERSE_SUBJECT, subject); + // Index in all used languages (display and metadata languages + for(String locale: langs) { + solrInputDocument.addField(SearchFields.DATAVERSE_SUBJECT, dataverseSubject.getLocaleStrValue(locale)); + } // collapse into shared "subject" field used as a facet solrInputDocument.addField(SearchFields.SUBJECT, subject); } @@ -805,6 +809,7 @@ private String addOrUpdateDataset(IndexableDataset indexableDataset, Set d solrInputDocument.addField(SearchFields.EXTERNAL_STATUS, datasetVersion.getExternalStatusLabel()); } + Set langs = settingsService.getConfiguredLanguages(); Map cvocMap = datasetFieldService.getCVocConf(false); for (DatasetField dsf : datasetVersion.getFlatDatasetFields()) { @@ -892,7 +897,10 @@ private String addOrUpdateDataset(IndexableDataset indexableDataset, Set d if (controlledVocabularyValue.getStrValue().equals(DatasetField.NA_VALUE)) { continue; } - solrInputDocument.addField(solrFieldSearchable, controlledVocabularyValue.getStrValue()); + // Index in all used languages (display and metadata languages + for(String locale: langs) { + solrInputDocument.addField(solrFieldSearchable, controlledVocabularyValue.getLocaleStrValue(locale)); + } if (dsfType.getSolrField().isFacetable()) { solrInputDocument.addField(solrFieldFacetable, controlledVocabularyValue.getStrValue()); } diff --git a/src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java index efa944cf633..e13ea806dc7 100644 --- a/src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java @@ -9,12 +9,23 @@ import javax.ejb.Stateless; import javax.inject.Named; import javax.json.Json; +import javax.json.JsonArray; import javax.json.JsonObject; +import javax.json.JsonReader; +import javax.json.JsonValue; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + import java.io.StringReader; +import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -730,5 +741,53 @@ public Set listAll() { return new HashSet<>(em.createNamedQuery("Setting.findAll", Setting.class).getResultList()); } + public Map getBaseMetadataLanguageMap(Map languageMap, boolean refresh) { + if (languageMap == null || refresh) { + languageMap = new HashMap(); + + /* If MetadataLanaguages is set, use it. + * If not, we can't assume anything and should avoid assuming a metadata language + */ + String mlString = getValueForKey(SettingsServiceBean.Key.MetadataLanguages,""); + + if(mlString.isEmpty()) { + mlString="[]"; + } + JsonReader jsonReader = Json.createReader(new StringReader(mlString)); + JsonArray languages = jsonReader.readArray(); + for(JsonValue jv: languages) { + JsonObject lang = (JsonObject) jv; + languageMap.put(lang.getString("locale"), lang.getString("title")); + } + } + return languageMap; + } + public void initLocaleSettings(Map configuredLocales) { + + try { + JSONArray entries = new JSONArray(getValueForKey(SettingsServiceBean.Key.Languages, "[]")); + for (Object obj : entries) { + JSONObject entry = (JSONObject) obj; + String locale = entry.getString("locale"); + String title = entry.getString("title"); + + configuredLocales.put(locale, title); + } + } catch (JSONException e) { + //e.printStackTrace(); + // do we want to know? - probably not + } + } + + + public Set getConfiguredLanguages() { + Set langs = new HashSet(); + langs.addAll(getBaseMetadataLanguageMap(new HashMap(), true).keySet()); + Map configuredLocales = new LinkedHashMap<>(); + initLocaleSettings(configuredLocales); + langs.addAll(configuredLocales.keySet()); + return langs; + } + } diff --git a/src/main/java/edu/harvard/iq/dataverse/util/DataSourceProducer.java b/src/main/java/edu/harvard/iq/dataverse/util/DataSourceProducer.java index e9ac5bfd230..630f192890b 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/DataSourceProducer.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/DataSourceProducer.java @@ -38,7 +38,7 @@ //}) // // ... but at this time we don't think we need any. The full list -// of properties can be found at https://docs.payara.fish/community/docs/5.2021.5/documentation/payara-server/jdbc/advanced-connection-pool-properties.html#full-list-of-properties +// of properties can be found at https://docs.payara.fish/community/docs/5.2021.6/documentation/payara-server/jdbc/advanced-connection-pool-properties.html#full-list-of-properties // // All these properties cannot be configured via MPCONFIG as Payara doesn't support this (yet). To be enhanced. // See also https://github.com/payara/Payara/issues/5024 diff --git a/src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java b/src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java index 62d576193f6..8d3d63da99d 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java @@ -1471,73 +1471,65 @@ public static String getCiteDataFileFilename(String fileTitle, FileCitationExten * elaborate on the text "This file cannot be downloaded publicly." */ public static boolean isDownloadPopupRequired(DatasetVersion datasetVersion) { - // Each of these conditions is sufficient reason to have to - // present the user with the popup: - if (datasetVersion == null) { - logger.fine("Download popup required because datasetVersion is null."); - return false; - } - //0. if version is draft then Popup "not required" - if (!datasetVersion.isReleased()) { - logger.fine("Download popup required because datasetVersion has not been released."); - return false; - } - // 1. License and Terms of Use: - if (datasetVersion.getTermsOfUseAndAccess() != null) { - License license = datasetVersion.getTermsOfUseAndAccess().getLicense(); - if ((license == null && StringUtils.isNotBlank(datasetVersion.getTermsOfUseAndAccess().getTermsOfUse())) - || (license != null && !license.isDefault())) { - logger.fine("Download popup required because of license or terms of use."); - return true; - } - - // 2. Terms of Access: - if (!(datasetVersion.getTermsOfUseAndAccess().getTermsOfAccess() == null) && !datasetVersion.getTermsOfUseAndAccess().getTermsOfAccess().equals("")) { - logger.fine("Download popup required because of terms of access."); - return true; - } + logger.fine("Checking if download popup is required."); + Boolean answer = popupDueToStateOrTerms(datasetVersion); + if (answer != null) { + return answer; } - // 3. Guest Book: if (datasetVersion.getDataset() != null && datasetVersion.getDataset().getGuestbook() != null && datasetVersion.getDataset().getGuestbook().isEnabled() && datasetVersion.getDataset().getGuestbook().getDataverse() != null) { logger.fine("Download popup required because of guestbook."); return true; } - logger.fine("Download popup is not required."); return false; } - public static boolean isRequestAccessPopupRequired(DatasetVersion datasetVersion){ - // Each of these conditions is sufficient reason to have to - // present the user with the popup: + public static boolean isRequestAccessPopupRequired(DatasetVersion datasetVersion) { + + Boolean answer = popupDueToStateOrTerms(datasetVersion); + if (answer != null) { + return answer; + } + logger.fine("Request access popup is not required."); + return false; + } + + /* Code shared by isDownloadPopupRequired and isRequestAccessPopupRequired. + * + * Returns Boolean to allow null = no decision. This allows the isDownloadPopupRequired method to then add another check w.r.t. guestbooks before returning its value. + * + */ + private static Boolean popupDueToStateOrTerms(DatasetVersion datasetVersion) { + + // Each of these conditions is sufficient reason to have to + // present the user with the popup: if (datasetVersion == null) { - logger.fine("Download popup required because datasetVersion is null."); + logger.fine("Popup not required because datasetVersion is null."); return false; } - //0. if version is draft then Popup "not required" + // 0. if version is draft then Popup "not required" if (!datasetVersion.isReleased()) { - logger.fine("Download popup required because datasetVersion has not been released."); + logger.fine("Popup not required because datasetVersion has not been released."); return false; } // 1. License and Terms of Use: if (datasetVersion.getTermsOfUseAndAccess() != null) { - if (!datasetVersion.getTermsOfUseAndAccess().getLicense().isDefault() - && !(datasetVersion.getTermsOfUseAndAccess().getTermsOfUse() == null - || datasetVersion.getTermsOfUseAndAccess().getTermsOfUse().equals(""))) { - logger.fine("Download popup required because of license or terms of use."); + License license = datasetVersion.getTermsOfUseAndAccess().getLicense(); + if ((license == null && StringUtils.isNotBlank(datasetVersion.getTermsOfUseAndAccess().getTermsOfUse())) + || (license != null && !license.isDefault())) { + logger.fine("Popup required because of license or terms of use."); return true; } // 2. Terms of Access: if (!(datasetVersion.getTermsOfUseAndAccess().getTermsOfAccess() == null) && !datasetVersion.getTermsOfUseAndAccess().getTermsOfAccess().equals("")) { - logger.fine("Download popup required because of terms of access."); + logger.fine("Popup required because of terms of access."); return true; } } - - logger.fine("Download popup is not required."); - return false; + //No decision based on the criteria above + return null; } /** diff --git a/src/main/webapp/dataset.xhtml b/src/main/webapp/dataset.xhtml index 1503a87600a..e96b0a9f1bd 100644 --- a/src/main/webapp/dataset.xhtml +++ b/src/main/webapp/dataset.xhtml @@ -125,7 +125,8 @@ - + + @@ -340,8 +341,9 @@