From d295d868d57aa41b458c0b5803990bb62f6cc558 Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Wed, 4 May 2022 17:23:33 +0200 Subject: [PATCH 01/26] sorting of licenses with the new sort order column --- .../harvard/iq/dataverse/api/Licenses.java | 31 +++++++++++++++++++ .../harvard/iq/dataverse/license/License.java | 26 +++++++++++++--- .../dataverse/license/LicenseServiceBean.java | 12 +++++++ .../iq/dataverse/util/json/JsonPrinter.java | 3 +- .../V5.10.1.1__8671-sorting_licenses.sql | 9 ++++++ .../iq/dataverse/DatasetVersionTest.java | 2 +- .../harvard/iq/dataverse/api/LicensesIT.java | 14 +++++++++ .../edu/harvard/iq/dataverse/api/UtilIT.java | 9 +++++- .../export/SchemaDotOrgExporterTest.java | 2 +- .../iq/dataverse/util/FileUtilTest.java | 4 +-- 10 files changed, 101 insertions(+), 11 deletions(-) create mode 100644 src/main/resources/db/migration/V5.10.1.1__8671-sorting_licenses.sql diff --git a/src/main/java/edu/harvard/iq/dataverse/api/Licenses.java b/src/main/java/edu/harvard/iq/dataverse/api/Licenses.java index 58e1f8cc2c5..1fdf7818cfb 100644 --- a/src/main/java/edu/harvard/iq/dataverse/api/Licenses.java +++ b/src/main/java/edu/harvard/iq/dataverse/api/Licenses.java @@ -146,6 +146,37 @@ public Response setActiveState(@PathParam("id") long id, @PathParam("activeState } } + @PUT + @Path("/{id}/:sortOrder/{sortOrder}") + public Response setSortOrder(@PathParam("id") long id, @PathParam("sortOrder") long sortOrder) { + User authenticatedUser; + try { + authenticatedUser = findAuthenticatedUserOrDie(); + if (!authenticatedUser.isSuperuser()) { + return error(Status.FORBIDDEN, "must be superuser"); + } + } catch (WrappedResponse e) { + return error(Status.UNAUTHORIZED, "api key required"); + } + try { + if (licenseSvc.setSortOrder(id, sortOrder) == 0) { + return error(Response.Status.NOT_FOUND, "License with ID " + id + " not found"); + } + License license = licenseSvc.getById(id); + actionLogSvc + .log(new ActionLogRecord(ActionLogRecord.ActionType.Admin, "sortOrderLicenseChanged") + .setInfo("License " + license.getName() + "(" + license.getUri() + ") as id: " + id + + "has now sort order " + sortOrder + ".") + .setUserIdentifier(authenticatedUser.getIdentifier())); + return ok("License ID " + id + " sort order set to " + sortOrder); + } catch (WrappedResponse e) { + if (e.getCause() instanceof IllegalArgumentException) { + return badRequest(e.getCause().getMessage()); + } + return error(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage()); + } + } + @DELETE @Path("/{id}") public Response deleteLicenseById(@PathParam("id") long id) { diff --git a/src/main/java/edu/harvard/iq/dataverse/license/License.java b/src/main/java/edu/harvard/iq/dataverse/license/License.java index 96baacc6731..4f99470d7b4 100644 --- a/src/main/java/edu/harvard/iq/dataverse/license/License.java +++ b/src/main/java/edu/harvard/iq/dataverse/license/License.java @@ -23,9 +23,9 @@ */ @NamedQueries({ @NamedQuery( name="License.findAll", - query="SELECT l FROM License l ORDER BY (case when l.isDefault then 0 else 1 end), l.id asc"), + query="SELECT l FROM License l ORDER BY (case when l.isDefault then 0 else 1 end), l.sortOrder, l.name asc"), @NamedQuery( name="License.findAllActive", - query="SELECT l FROM License l WHERE l.active='true' ORDER BY (case when l.isDefault then 0 else 1 end), l.id asc"), + query="SELECT l FROM License l WHERE l.active='true' ORDER BY (case when l.isDefault then 0 else 1 end), l.sortOrder, l.name asc"), @NamedQuery( name="License.findById", query = "SELECT l FROM License l WHERE l.id=:id"), @NamedQuery( name="License.findDefault", @@ -42,6 +42,8 @@ query = "UPDATE License l SET l.isDefault='false'"), @NamedQuery( name="License.setActiveState", query = "UPDATE License l SET l.active=:state WHERE l.id=:id"), + @NamedQuery( name="License.setSortOrder", + query = "UPDATE License l SET l.sortOrder=:sortOrder WHERE l.id=:id"), }) @Entity @@ -73,6 +75,9 @@ public class License { @Column(nullable = false) private boolean isDefault; + + @Column(nullable = false) + private Long sortOrder; @OneToMany(mappedBy="license") private List termsOfUseAndAccess; @@ -80,7 +85,7 @@ public class License { public License() { } - public License(String name, String shortDescription, URI uri, URI iconUrl, boolean active) { + public License(String name, String shortDescription, URI uri, URI iconUrl, boolean active, Long sortOrder) { this.name = name; this.shortDescription = shortDescription; this.uri = uri.toASCIIString(); @@ -91,6 +96,7 @@ public License(String name, String shortDescription, URI uri, URI iconUrl, boole } this.active = active; isDefault = false; + this.sortOrder = sortOrder; } public Long getId() { @@ -172,17 +178,26 @@ public void setTermsOfUseAndAccess(List termsOfUseAndAccess this.termsOfUseAndAccess = termsOfUseAndAccess; } + public Long getSortOrder() { + return sortOrder; + } + + public void setSortOrder(Long sortOrder) { + this.sortOrder = sortOrder; + } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; License license = (License) o; - return active == license.active && id.equals(license.id) && name.equals(license.name) && shortDescription.equals(license.shortDescription) && uri.equals(license.uri) && Objects.equals(iconUrl, license.iconUrl); + return active == license.active && id.equals(license.id) && name.equals(license.name) && shortDescription.equals(license.shortDescription) && uri.equals(license.uri) && Objects.equals(iconUrl, license.iconUrl) + && Objects.equals(sortOrder, license.sortOrder); } @Override public int hashCode() { - return Objects.hash(id, name, shortDescription, uri, iconUrl, active); + return Objects.hash(id, name, shortDescription, uri, iconUrl, active, sortOrder); } @Override @@ -195,6 +210,7 @@ public String toString() { ", iconUrl=" + iconUrl + ", active=" + active + ", isDefault=" + isDefault + + ", sortOrder=" + sortOrder + '}'; } diff --git a/src/main/java/edu/harvard/iq/dataverse/license/LicenseServiceBean.java b/src/main/java/edu/harvard/iq/dataverse/license/LicenseServiceBean.java index c18e168685a..b554fecd437 100644 --- a/src/main/java/edu/harvard/iq/dataverse/license/LicenseServiceBean.java +++ b/src/main/java/edu/harvard/iq/dataverse/license/LicenseServiceBean.java @@ -93,11 +93,23 @@ public int setActive(Long id, boolean state) throws WrappedResponse { new IllegalArgumentException("License already " + (state ? "active" : "inactive")), null); } } + + public int setSortOrder(Long id, Long sortOrder) throws WrappedResponse { + License candidate = getById(id); + if (candidate == null) + return 0; + + return em.createNamedQuery("License.setSortOrder").setParameter("id", id).setParameter("sortOrder", sortOrder) + .executeUpdate(); + } public License save(License license) throws WrappedResponse { if (license.getId() != null) { throw new WrappedResponse(new IllegalArgumentException("There shouldn't be an ID in the request body"), null); } + if (license.getSortOrder() == null) { + throw new WrappedResponse(new IllegalArgumentException("There should be a sort order value in the request body"), null); + } try { em.persist(license); em.flush(); diff --git a/src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java b/src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java index ed3460b6759..e4f15e8992b 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java @@ -800,7 +800,8 @@ public static JsonObjectBuilder json(License license) { .add("uri", license.getUri().toString()) .add("iconUrl", license.getIconUrl() == null ? null : license.getIconUrl().toString()) .add("active", license.isActive()) - .add("isDefault", license.isDefault()); + .add("isDefault", license.isDefault()) + .add("sortOrder", license.getSortOrder()); } public static Collector stringsToJsonArray() { diff --git a/src/main/resources/db/migration/V5.10.1.1__8671-sorting_licenses.sql b/src/main/resources/db/migration/V5.10.1.1__8671-sorting_licenses.sql new file mode 100644 index 00000000000..5bc18e69df0 --- /dev/null +++ b/src/main/resources/db/migration/V5.10.1.1__8671-sorting_licenses.sql @@ -0,0 +1,9 @@ +ALTER TABLE license +ADD COLUMN IF NOT EXISTS sortorder BIGINT; + +UPDATE license +SET sortorder = id +WHERE sortorder IS NULL; + +CREATE INDEX IF NOT EXISTS license_sortorder_id +ON license (sortorder, id); \ No newline at end of file diff --git a/src/test/java/edu/harvard/iq/dataverse/DatasetVersionTest.java b/src/test/java/edu/harvard/iq/dataverse/DatasetVersionTest.java index 884a2fd6244..a8e011d0036 100644 --- a/src/test/java/edu/harvard/iq/dataverse/DatasetVersionTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/DatasetVersionTest.java @@ -92,7 +92,7 @@ public void testIsInReview() { @Test public void testGetJsonLd() throws ParseException { Dataset dataset = new Dataset(); - License license = new License("CC0 1.0", "You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.", URI.create("http://creativecommons.org/publicdomain/zero/1.0"), URI.create("/resources/images/cc0.png"), true); + License license = new License("CC0 1.0", "You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.", URI.create("http://creativecommons.org/publicdomain/zero/1.0"), URI.create("/resources/images/cc0.png"), true, 1l); license.setDefault(true); dataset.setProtocol("doi"); dataset.setAuthority("10.5072/FK2"); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java index 09443732f09..e189336b61e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java @@ -144,6 +144,20 @@ public void testLicenses(){ status = JsonPath.from(body).getString("status"); assertEquals("OK", status); + //Fail trying to set null sort order + Response setSortOrderErrorResponse = UtilIT.setLicenseSortOrderById(activeLicenseId, null, adminApiToken); + setSortOrderErrorResponse.prettyPrint(); + body = setSortOrderErrorResponse.getBody().asString(); + status = JsonPath.from(body).getString("status"); + assertEquals("ERROR", status); + + //Succeed in setting sort order + Response setSortOrderResponse = UtilIT.setLicenseSortOrderById(activeLicenseId, 2l, adminApiToken); + setSortOrderResponse.prettyPrint(); + body = setSortOrderResponse.getBody().asString(); + status = JsonPath.from(body).getString("status"); + assertEquals("OK", status); + //Succeed in deleting our test license Response deleteLicenseByIdResponse = UtilIT.deleteLicenseById(licenseId, adminApiToken); deleteLicenseByIdResponse.prettyPrint(); diff --git a/src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java b/src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java index 7b9b5f3b129..f9bdabe367b 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java @@ -2808,7 +2808,14 @@ static Response setLicenseActiveById(Long id, boolean state, String apiToken) { .put("/api/licenses/"+id.toString() + "/:active/" + state); return activateLicenseResponse; } - + + static Response setLicenseSortOrderById(Long id, Long sortOrder, String apiToken) { + Response setSortOrderLicenseResponse = given() + .header(API_TOKEN_HTTP_HEADER, apiToken) + .urlEncodingEnabled(false) + .put("/api/licenses/"+id.toString() + "/:sortOrder/" + sortOrder); + return setSortOrderLicenseResponse; + } static Response updateDatasetJsonLDMetadata(Integer datasetId, String apiToken, String jsonLDBody, boolean replace) { Response response = given() diff --git a/src/test/java/edu/harvard/iq/dataverse/export/SchemaDotOrgExporterTest.java b/src/test/java/edu/harvard/iq/dataverse/export/SchemaDotOrgExporterTest.java index b5453e75fe5..641eaf68a3e 100644 --- a/src/test/java/edu/harvard/iq/dataverse/export/SchemaDotOrgExporterTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/export/SchemaDotOrgExporterTest.java @@ -67,7 +67,7 @@ public static void tearDownClass() { public void testExportDataset() throws Exception { File datasetVersionJson = new File("src/test/resources/json/dataset-finch2.json"); String datasetVersionAsJson = new String(Files.readAllBytes(Paths.get(datasetVersionJson.getAbsolutePath()))); - License license = new License("CC0 1.0", "You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.", URI.create("http://creativecommons.org/publicdomain/zero/1.0/"), URI.create("/resources/images/cc0.png"), true); + License license = new License("CC0 1.0", "You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.", URI.create("http://creativecommons.org/publicdomain/zero/1.0/"), URI.create("/resources/images/cc0.png"), true, 1l); license.setDefault(true); JsonReader jsonReader1 = Json.createReader(new StringReader(datasetVersionAsJson)); diff --git a/src/test/java/edu/harvard/iq/dataverse/util/FileUtilTest.java b/src/test/java/edu/harvard/iq/dataverse/util/FileUtilTest.java index 141e97b9b9b..7b5a5ef9d78 100644 --- a/src/test/java/edu/harvard/iq/dataverse/util/FileUtilTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/util/FileUtilTest.java @@ -138,7 +138,7 @@ public void testIsDownloadPopupRequiredLicenseCC0() { DatasetVersion dsv1 = new DatasetVersion(); dsv1.setVersionState(DatasetVersion.VersionState.RELEASED); TermsOfUseAndAccess termsOfUseAndAccess = new TermsOfUseAndAccess(); - License license = new License("CC0", "You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.", URI.create("http://creativecommons.org/publicdomain/zero/1.0"), URI.create("/resources/images/cc0.png"), true); + License license = new License("CC0", "You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.", URI.create("http://creativecommons.org/publicdomain/zero/1.0"), URI.create("/resources/images/cc0.png"), true, 1l); license.setDefault(true); termsOfUseAndAccess.setLicense(license); dsv1.setTermsOfUseAndAccess(termsOfUseAndAccess); @@ -155,7 +155,7 @@ public void testIsDownloadPopupRequiredHasTermsOfUseAndCc0License() { * the popup when the are Terms of Use. This feels like a bug since the * Terms of Use should probably be shown. */ - License license = new License("CC0", "You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.", URI.create("http://creativecommons.org/publicdomain/zero/1.0"), URI.create("/resources/images/cc0.png"), true); + License license = new License("CC0", "You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.", URI.create("http://creativecommons.org/publicdomain/zero/1.0"), URI.create("/resources/images/cc0.png"), true, 2l); license.setDefault(true); termsOfUseAndAccess.setLicense(license); termsOfUseAndAccess.setTermsOfUse("be excellent to each other"); From c9ff44b09130222a9f60c203d199b06f21f01ed2 Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Mon, 9 May 2022 12:25:43 +0200 Subject: [PATCH 02/26] license sorting documentation --- doc/release-notes/8671-sorting-licenses.md | 3 +++ doc/sphinx-guides/source/api/native-api.rst | 7 ++++++ .../source/installation/config.rst | 24 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 doc/release-notes/8671-sorting-licenses.md diff --git a/doc/release-notes/8671-sorting-licenses.md b/doc/release-notes/8671-sorting-licenses.md new file mode 100644 index 00000000000..34ad697d5a7 --- /dev/null +++ b/doc/release-notes/8671-sorting-licenses.md @@ -0,0 +1,3 @@ +## License sorting + +Licenses as shown in the dropdown in UI can be now sorted by the superusers. See [Configuring Licenses](https://guides.dataverse.org/en/5.10/installation/config.html#configuring-licenses) section of the Installation Guide for reference. \ No newline at end of file diff --git a/doc/sphinx-guides/source/api/native-api.rst b/doc/sphinx-guides/source/api/native-api.rst index 5c56166dd6a..cb387dbbef2 100644 --- a/doc/sphinx-guides/source/api/native-api.rst +++ b/doc/sphinx-guides/source/api/native-api.rst @@ -3806,3 +3806,10 @@ Superusers can delete a license that is not in use by the license ``$ID``: .. code-block:: bash curl -X DELETE -H X-Dataverse-key:$API_TOKEN $SERVER_URL/api/licenses/$ID + +Superusers can change the sorting order of a license specified by the license ``$ID``: + +.. code-block:: bash + + export SORT_ORDER=100 + curl -X PUT -H 'Content-Type: application/json' -H X-Dataverse-key:$API_TOKEN $SERVER_URL/api/licenses/$ID/:sortOrder/$SORT_ORDER \ No newline at end of file diff --git a/doc/sphinx-guides/source/installation/config.rst b/doc/sphinx-guides/source/installation/config.rst index 55d96335a68..d0a7cff1ea3 100644 --- a/doc/sphinx-guides/source/installation/config.rst +++ b/doc/sphinx-guides/source/installation/config.rst @@ -997,6 +997,30 @@ Disabling Custom Dataset Terms See :ref:`:AllowCustomTermsOfUse` for how to disable the "Custom Dataset Terms" option. +.. _ChangeLicenseSortOrder: + +Sorting licenses +---------------- + +The default order of licenses in the dropdown in the user interface is as follows: + +* The default license is shown first +* Followed by the remaining installed licenses in the order of installation +* The custom license is at the end + +Only the order of the installed licenses can be changed with the API calls. The default license always remains first and the custom license last. + +The order of licenses can be changed by setting the ``sortOrder`` property of a license. For the purpose of making sorting easier and to allow grouping of the licenses, ``sortOrder`` property does not have to be unique. Licenses with the same ``sortOrder`` are sorted by their name alfabetically. Nevertheless, you can set a unique ``sortOrder`` for every license in order to sort them fully manually. + +The ``sortOrder`` is an whole number and is used to sort licenses in ascending fashion. All licenses must have a sort order and initially it is set to installation order (``id`` property). + +Changing the sorting order of a license specified by the license ``$ID`` is done by superusers using the following API call: + +.. code-block:: bash + + export SORT_ORDER=100 + curl -X PUT -H 'Content-Type: application/json' -H X-Dataverse-key:$API_TOKEN $SERVER_URL/api/licenses/$ID/:sortOrder/$SORT_ORDER + .. _BagIt Export: BagIt Export From 7aeaa72b9583ddbc3e9585f28ef6d0572a81e0ee Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Tue, 10 May 2022 16:50:36 +0200 Subject: [PATCH 03/26] renamed flyway script to unique version --- ...-sorting_licenses.sql => V5.10.1.2__8671-sorting_licenses.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V5.10.1.1__8671-sorting_licenses.sql => V5.10.1.2__8671-sorting_licenses.sql} (100%) diff --git a/src/main/resources/db/migration/V5.10.1.1__8671-sorting_licenses.sql b/src/main/resources/db/migration/V5.10.1.2__8671-sorting_licenses.sql similarity index 100% rename from src/main/resources/db/migration/V5.10.1.1__8671-sorting_licenses.sql rename to src/main/resources/db/migration/V5.10.1.2__8671-sorting_licenses.sql From 7f1561d239031beba167c024d432a88ce7813e33 Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Mon, 16 May 2022 12:52:01 +0200 Subject: [PATCH 04/26] licenses are now sorted first by sortOrder then by ID --- doc/sphinx-guides/source/installation/config.rst | 4 ++-- src/main/java/edu/harvard/iq/dataverse/license/License.java | 6 +++--- .../db/migration/V5.10.1.2__8671-sorting_licenses.sql | 4 ---- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/doc/sphinx-guides/source/installation/config.rst b/doc/sphinx-guides/source/installation/config.rst index b99ee2bca83..8bc1e063075 100644 --- a/doc/sphinx-guides/source/installation/config.rst +++ b/doc/sphinx-guides/source/installation/config.rst @@ -1051,9 +1051,9 @@ The default order of licenses in the dropdown in the user interface is as follow Only the order of the installed licenses can be changed with the API calls. The default license always remains first and the custom license last. -The order of licenses can be changed by setting the ``sortOrder`` property of a license. For the purpose of making sorting easier and to allow grouping of the licenses, ``sortOrder`` property does not have to be unique. Licenses with the same ``sortOrder`` are sorted by their name alfabetically. Nevertheless, you can set a unique ``sortOrder`` for every license in order to sort them fully manually. +The order of licenses can be changed by setting the ``sortOrder`` property of a license. For the purpose of making sorting easier and to allow grouping of the licenses, ``sortOrder`` property does not have to be unique. Licenses with the same ``sortOrder`` are sorted by their ID, i.e., first by the sortOrder, then by the ID. Nevertheless, you can set a unique ``sortOrder`` for every license in order to sort them fully manually. -The ``sortOrder`` is an whole number and is used to sort licenses in ascending fashion. All licenses must have a sort order and initially it is set to installation order (``id`` property). +The ``sortOrder`` is an whole number and is used to sort licenses in ascending fashion. Changing the sorting order of a license specified by the license ``$ID`` is done by superusers using the following API call: diff --git a/src/main/java/edu/harvard/iq/dataverse/license/License.java b/src/main/java/edu/harvard/iq/dataverse/license/License.java index 4f99470d7b4..0c8465e88e4 100644 --- a/src/main/java/edu/harvard/iq/dataverse/license/License.java +++ b/src/main/java/edu/harvard/iq/dataverse/license/License.java @@ -23,9 +23,9 @@ */ @NamedQueries({ @NamedQuery( name="License.findAll", - query="SELECT l FROM License l ORDER BY (case when l.isDefault then 0 else 1 end), l.sortOrder, l.name asc"), + query="SELECT l FROM License l ORDER BY (case when l.isDefault then 0 else 1 end), l.sortOrder, l.id asc"), @NamedQuery( name="License.findAllActive", - query="SELECT l FROM License l WHERE l.active='true' ORDER BY (case when l.isDefault then 0 else 1 end), l.sortOrder, l.name asc"), + query="SELECT l FROM License l WHERE l.active='true' ORDER BY (case when l.isDefault then 0 else 1 end), l.sortOrder, l.id asc"), @NamedQuery( name="License.findById", query = "SELECT l FROM License l WHERE l.id=:id"), @NamedQuery( name="License.findDefault", @@ -76,7 +76,7 @@ public class License { @Column(nullable = false) private boolean isDefault; - @Column(nullable = false) + @Column(nullable = true) private Long sortOrder; @OneToMany(mappedBy="license") diff --git a/src/main/resources/db/migration/V5.10.1.2__8671-sorting_licenses.sql b/src/main/resources/db/migration/V5.10.1.2__8671-sorting_licenses.sql index 5bc18e69df0..43631ebd165 100644 --- a/src/main/resources/db/migration/V5.10.1.2__8671-sorting_licenses.sql +++ b/src/main/resources/db/migration/V5.10.1.2__8671-sorting_licenses.sql @@ -1,9 +1,5 @@ ALTER TABLE license ADD COLUMN IF NOT EXISTS sortorder BIGINT; -UPDATE license -SET sortorder = id -WHERE sortorder IS NULL; - CREATE INDEX IF NOT EXISTS license_sortorder_id ON license (sortorder, id); \ No newline at end of file From 46212be671fbc42a6d56f4069baafac9a29521ee Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Tue, 31 May 2022 12:51:53 +0200 Subject: [PATCH 05/26] updated documentation and example with mandatory sort order in licenses --- doc/release-notes/5.10-release-notes.md | 2 +- doc/sphinx-guides/source/_static/api/add-license.json | 3 ++- doc/sphinx-guides/source/api/native-api.rst | 2 +- doc/sphinx-guides/source/api/sword.rst | 2 +- doc/sphinx-guides/source/installation/config.rst | 3 +-- scripts/api/data/licenses/licenseCC-BY-4.0.json | 3 ++- scripts/api/data/licenses/licenseCC-BY-NC-4.0.json | 3 ++- scripts/api/data/licenses/licenseCC-BY-NC-ND-4.0.json | 3 ++- scripts/api/data/licenses/licenseCC-BY-NC-SA-4.0.json | 3 ++- scripts/api/data/licenses/licenseCC-BY-ND-4.0.json | 3 ++- scripts/api/data/licenses/licenseCC-BY-SA-4.0.json | 3 ++- scripts/api/data/licenses/licenseCC0-1.0.json | 3 ++- ...rting_licenses.sql => V5.10.1.3__8671-sorting_licenses.sql} | 0 13 files changed, 20 insertions(+), 13 deletions(-) rename src/main/resources/db/migration/{V5.10.1.2__8671-sorting_licenses.sql => V5.10.1.3__8671-sorting_licenses.sql} (100%) diff --git a/doc/release-notes/5.10-release-notes.md b/doc/release-notes/5.10-release-notes.md index 0da42a7b527..4e9e5e0ef94 100644 --- a/doc/release-notes/5.10-release-notes.md +++ b/doc/release-notes/5.10-release-notes.md @@ -6,7 +6,7 @@ This release brings new features, enhancements, and bug fixes to the Dataverse S ### Multiple License Support -Users can now select from a set of configured licenses in addition to or instead of the previous Creative Commons CC0 choice or provide custom terms of use (if configured) for their datasets. Administrators can configure their Dataverse instance via API to allow any desired license as a choice and can enable or disable the option to allow custom terms. Administrators can also mark licenses as "inactive" to disallow future use while keeping that license for existing datasets. For upgrades, only the CC0 license will be preinstalled. New installations will have both CC0 and CC BY preinstalled. The [Configuring Licenses](https://guides.dataverse.org/en/5.10/installation/config.html#configuring-licenses) section of the Installation Guide shows how to add or remove licenses. +Users can now select from a set of configured licenses in addition to or instead of the previous Creative Commons CC0 choice or provide custom terms of use (if configured) for their datasets. Administrators can configure their Dataverse instance via API to allow any desired license as a choice and can enable or disable the option to allow custom terms. Administrators can also mark licenses as "inactive" to disallow future use while keeping that license for existing datasets. For upgrades, only the CC0 license will be preinstalled. New installations will have both CC0 1.0 preinstalled. The [Configuring Licenses](https://guides.dataverse.org/en/5.10/installation/config.html#configuring-licenses) section of the Installation Guide shows how to add or remove licenses. **Note: Datasets in existing installations will automatically be updated to conform to new requirements that custom terms cannot be used with a standard license and that custom terms cannot be empty. Administrators may wish to manually update datasets with these conditions if they do not like the automated migration choices. See the "Notes for Dataverse Installation Administrators" section below for details.** diff --git a/doc/sphinx-guides/source/_static/api/add-license.json b/doc/sphinx-guides/source/_static/api/add-license.json index 969d6d58dab..a9d5dd34093 100644 --- a/doc/sphinx-guides/source/_static/api/add-license.json +++ b/doc/sphinx-guides/source/_static/api/add-license.json @@ -3,5 +3,6 @@ "uri": "http://creativecommons.org/licenses/by/4.0", "shortDescription": "Creative Commons Attribution 4.0 International License.", "iconUrl": "https://i.creativecommons.org/l/by/4.0/88x31.png", - "active": true + "active": true, + "sortOrder": 2 } diff --git a/doc/sphinx-guides/source/api/native-api.rst b/doc/sphinx-guides/source/api/native-api.rst index 249d1812507..da82be9ad7b 100644 --- a/doc/sphinx-guides/source/api/native-api.rst +++ b/doc/sphinx-guides/source/api/native-api.rst @@ -3858,7 +3858,7 @@ View the details of the standard license with the database ID specified in ``$ID curl $SERVER_URL/api/licenses/$ID -Superusers can add a new license by posting a JSON file adapted from this example :download:`add-license.json <../_static/api/add-license.json>`. The ``name`` and ``uri`` of the new license must be unique. If you are interested in adding a Creative Commons license, you are encouarged to use the JSON files under :ref:`adding-creative-commons-licenses`: +Superusers can add a new license by posting a JSON file adapted from this example :download:`add-license.json <../_static/api/add-license.json>`. The ``name`` and ``uri`` of the new license must be unique. Sort order field is mandatory. If you are interested in adding a Creative Commons license, you are encouarged to use the JSON files under :ref:`adding-creative-commons-licenses`: .. code-block:: bash diff --git a/doc/sphinx-guides/source/api/sword.rst b/doc/sphinx-guides/source/api/sword.rst index 11b43e98774..8041dff4891 100755 --- a/doc/sphinx-guides/source/api/sword.rst +++ b/doc/sphinx-guides/source/api/sword.rst @@ -82,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 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". Note that if admins of an installation have disabled "Custom Dataset Terms" you will get an error if you try to pass ``dcterms:rights``. +- "License" can now be set with ``dcterms:license`` and the possible values determined by the installation ("CC0 1.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". Note that if admins of an installation have disabled "Custom Dataset Terms" you will get an error if you try to pass ``dcterms:rights``. - "Contact E-mail" is automatically populated from dataset owner's email. diff --git a/doc/sphinx-guides/source/installation/config.rst b/doc/sphinx-guides/source/installation/config.rst index 99ed622c911..61e13ad10c8 100644 --- a/doc/sphinx-guides/source/installation/config.rst +++ b/doc/sphinx-guides/source/installation/config.rst @@ -991,7 +991,6 @@ Configuring Licenses Out of the box, users select from the following licenses or terms: - CC0 1.0 (default) -- CC BY 4.0 - Custom Dataset Terms You have a lot of control over which licenses and terms are available. You can remove licenses and add new ones. You can decide which license is the default. You can remove "Custom Dataset Terms" as a option. You can remove all licenses and make "Custom Dataset Terms" the only option. @@ -1015,7 +1014,7 @@ Licenses are added with curl using JSON file as explained in the API Guide under Adding Creative Common Licenses ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -JSON files for `Creative Commons licenses `_ are provided below. Note that a new installation of Dataverse already includes CC0 and CC BY. +JSON files for `Creative Commons licenses `_ are provided below. Note that a new installation of Dataverse already includes CC0. - :download:`licenseCC0-1.0.json <../../../../scripts/api/data/licenses/licenseCC0-1.0.json>` - :download:`licenseCC-BY-4.0.json <../../../../scripts/api/data/licenses/licenseCC-BY-4.0.json>` diff --git a/scripts/api/data/licenses/licenseCC-BY-4.0.json b/scripts/api/data/licenses/licenseCC-BY-4.0.json index 5596e65e947..59201b8d08e 100644 --- a/scripts/api/data/licenses/licenseCC-BY-4.0.json +++ b/scripts/api/data/licenses/licenseCC-BY-4.0.json @@ -3,5 +3,6 @@ "uri": "http://creativecommons.org/licenses/by/4.0", "shortDescription": "Creative Commons Attribution 4.0 International License.", "iconUrl": "https://licensebuttons.net/l/by/4.0/88x31.png", - "active": true + "active": true, + "sortOrder": 2 } diff --git a/scripts/api/data/licenses/licenseCC-BY-NC-4.0.json b/scripts/api/data/licenses/licenseCC-BY-NC-4.0.json index 8154c9ec5df..c19087664db 100644 --- a/scripts/api/data/licenses/licenseCC-BY-NC-4.0.json +++ b/scripts/api/data/licenses/licenseCC-BY-NC-4.0.json @@ -3,5 +3,6 @@ "uri": "http://creativecommons.org/licenses/by-nc/4.0", "shortDescription": "Creative Commons Attribution-NonCommercial 4.0 International License.", "iconUrl": "https://licensebuttons.net/l/by-nc/4.0/88x31.png", - "active": true + "active": true, + "sortOrder": 4 } diff --git a/scripts/api/data/licenses/licenseCC-BY-NC-ND-4.0.json b/scripts/api/data/licenses/licenseCC-BY-NC-ND-4.0.json index 247ce52f6ea..2e374917d28 100644 --- a/scripts/api/data/licenses/licenseCC-BY-NC-ND-4.0.json +++ b/scripts/api/data/licenses/licenseCC-BY-NC-ND-4.0.json @@ -3,5 +3,6 @@ "uri": "http://creativecommons.org/licenses/by-nc-nd/4.0", "shortDescription": "Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.", "iconUrl": "https://licensebuttons.net/l/by-nc-nd/4.0/88x31.png", - "active": true + "active": true, + "sortOrder": 7 } diff --git a/scripts/api/data/licenses/licenseCC-BY-NC-SA-4.0.json b/scripts/api/data/licenses/licenseCC-BY-NC-SA-4.0.json index e9726fb6374..5018884f65e 100644 --- a/scripts/api/data/licenses/licenseCC-BY-NC-SA-4.0.json +++ b/scripts/api/data/licenses/licenseCC-BY-NC-SA-4.0.json @@ -3,5 +3,6 @@ "uri": "http://creativecommons.org/licenses/by-nc-sa/4.0", "shortDescription": "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.", "iconUrl": "https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png", - "active": true + "active": true, + "sortOrder": 3 } diff --git a/scripts/api/data/licenses/licenseCC-BY-ND-4.0.json b/scripts/api/data/licenses/licenseCC-BY-ND-4.0.json index 7ae81bacc10..317d459a7ae 100644 --- a/scripts/api/data/licenses/licenseCC-BY-ND-4.0.json +++ b/scripts/api/data/licenses/licenseCC-BY-ND-4.0.json @@ -3,5 +3,6 @@ "uri": "http://creativecommons.org/licenses/by-nd/4.0", "shortDescription": "Creative Commons Attribution-NoDerivatives 4.0 International License.", "iconUrl": "https://licensebuttons.net/l/by-nd/4.0/88x31.png", - "active": true + "active": true, + "sortOrder": 6 } diff --git a/scripts/api/data/licenses/licenseCC-BY-SA-4.0.json b/scripts/api/data/licenses/licenseCC-BY-SA-4.0.json index e9a02880885..0d28c9423aa 100644 --- a/scripts/api/data/licenses/licenseCC-BY-SA-4.0.json +++ b/scripts/api/data/licenses/licenseCC-BY-SA-4.0.json @@ -3,5 +3,6 @@ "uri": "http://creativecommons.org/licenses/by-sa/4.0", "shortDescription": "Creative Commons Attribution-ShareAlike 4.0 International License.", "iconUrl": "https://licensebuttons.net/l/by-sa/4.0/88x31.png", - "active": true + "active": true, + "sortOrder": 5 } diff --git a/scripts/api/data/licenses/licenseCC0-1.0.json b/scripts/api/data/licenses/licenseCC0-1.0.json index 396ba133327..216260a5de8 100644 --- a/scripts/api/data/licenses/licenseCC0-1.0.json +++ b/scripts/api/data/licenses/licenseCC0-1.0.json @@ -3,5 +3,6 @@ "uri": "http://creativecommons.org/publicdomain/zero/1.0", "shortDescription": "Creative Commons CC0 1.0 Universal Public Domain Dedication.", "iconUrl": "https://licensebuttons.net/p/zero/1.0/88x31.png", - "active": true + "active": true, + "sortOrder": 1 } diff --git a/src/main/resources/db/migration/V5.10.1.2__8671-sorting_licenses.sql b/src/main/resources/db/migration/V5.10.1.3__8671-sorting_licenses.sql similarity index 100% rename from src/main/resources/db/migration/V5.10.1.2__8671-sorting_licenses.sql rename to src/main/resources/db/migration/V5.10.1.3__8671-sorting_licenses.sql From adc8c18e8481426a5614efbccdc94e3be5d9c051 Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Thu, 2 Jun 2022 17:41:36 +0200 Subject: [PATCH 06/26] revert of removing cc by from documentation --- doc/release-notes/5.10-release-notes.md | 2 +- doc/sphinx-guides/source/api/sword.rst | 2 +- doc/sphinx-guides/source/installation/config.rst | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/release-notes/5.10-release-notes.md b/doc/release-notes/5.10-release-notes.md index 4e9e5e0ef94..0da42a7b527 100644 --- a/doc/release-notes/5.10-release-notes.md +++ b/doc/release-notes/5.10-release-notes.md @@ -6,7 +6,7 @@ This release brings new features, enhancements, and bug fixes to the Dataverse S ### Multiple License Support -Users can now select from a set of configured licenses in addition to or instead of the previous Creative Commons CC0 choice or provide custom terms of use (if configured) for their datasets. Administrators can configure their Dataverse instance via API to allow any desired license as a choice and can enable or disable the option to allow custom terms. Administrators can also mark licenses as "inactive" to disallow future use while keeping that license for existing datasets. For upgrades, only the CC0 license will be preinstalled. New installations will have both CC0 1.0 preinstalled. The [Configuring Licenses](https://guides.dataverse.org/en/5.10/installation/config.html#configuring-licenses) section of the Installation Guide shows how to add or remove licenses. +Users can now select from a set of configured licenses in addition to or instead of the previous Creative Commons CC0 choice or provide custom terms of use (if configured) for their datasets. Administrators can configure their Dataverse instance via API to allow any desired license as a choice and can enable or disable the option to allow custom terms. Administrators can also mark licenses as "inactive" to disallow future use while keeping that license for existing datasets. For upgrades, only the CC0 license will be preinstalled. New installations will have both CC0 and CC BY preinstalled. The [Configuring Licenses](https://guides.dataverse.org/en/5.10/installation/config.html#configuring-licenses) section of the Installation Guide shows how to add or remove licenses. **Note: Datasets in existing installations will automatically be updated to conform to new requirements that custom terms cannot be used with a standard license and that custom terms cannot be empty. Administrators may wish to manually update datasets with these conditions if they do not like the automated migration choices. See the "Notes for Dataverse Installation Administrators" section below for details.** diff --git a/doc/sphinx-guides/source/api/sword.rst b/doc/sphinx-guides/source/api/sword.rst index 8041dff4891..11b43e98774 100755 --- a/doc/sphinx-guides/source/api/sword.rst +++ b/doc/sphinx-guides/source/api/sword.rst @@ -82,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 determined by the installation ("CC0 1.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". Note that if admins of an installation have disabled "Custom Dataset Terms" you will get an error if you try to pass ``dcterms:rights``. +- "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". Note that if admins of an installation have disabled "Custom Dataset Terms" you will get an error if you try to pass ``dcterms:rights``. - "Contact E-mail" is automatically populated from dataset owner's email. diff --git a/doc/sphinx-guides/source/installation/config.rst b/doc/sphinx-guides/source/installation/config.rst index 61e13ad10c8..99ed622c911 100644 --- a/doc/sphinx-guides/source/installation/config.rst +++ b/doc/sphinx-guides/source/installation/config.rst @@ -991,6 +991,7 @@ Configuring Licenses Out of the box, users select from the following licenses or terms: - CC0 1.0 (default) +- CC BY 4.0 - Custom Dataset Terms You have a lot of control over which licenses and terms are available. You can remove licenses and add new ones. You can decide which license is the default. You can remove "Custom Dataset Terms" as a option. You can remove all licenses and make "Custom Dataset Terms" the only option. @@ -1014,7 +1015,7 @@ Licenses are added with curl using JSON file as explained in the API Guide under Adding Creative Common Licenses ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -JSON files for `Creative Commons licenses `_ are provided below. Note that a new installation of Dataverse already includes CC0. +JSON files for `Creative Commons licenses `_ are provided below. Note that a new installation of Dataverse already includes CC0 and CC BY. - :download:`licenseCC0-1.0.json <../../../../scripts/api/data/licenses/licenseCC0-1.0.json>` - :download:`licenseCC-BY-4.0.json <../../../../scripts/api/data/licenses/licenseCC-BY-4.0.json>` From 49286e361964161cc8a02d092037fd3919d6c81d Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Thu, 23 Jun 2022 12:18:56 +0200 Subject: [PATCH 07/26] license sorting: renamed sql script --- ...-sorting_licenses.sql => V5.11.0.1__8671-sorting_licenses.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V5.10.1.3__8671-sorting_licenses.sql => V5.11.0.1__8671-sorting_licenses.sql} (100%) diff --git a/src/main/resources/db/migration/V5.10.1.3__8671-sorting_licenses.sql b/src/main/resources/db/migration/V5.11.0.1__8671-sorting_licenses.sql similarity index 100% rename from src/main/resources/db/migration/V5.10.1.3__8671-sorting_licenses.sql rename to src/main/resources/db/migration/V5.11.0.1__8671-sorting_licenses.sql From 0124da0e8263698be7e04ee96e4f5b61f93ea08e Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Mon, 8 Aug 2022 11:58:25 +0200 Subject: [PATCH 08/26] added sortOrder column in the license test file --- src/test/resources/json/license.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/resources/json/license.json b/src/test/resources/json/license.json index dd251322110..00502ded9a6 100644 --- a/src/test/resources/json/license.json +++ b/src/test/resources/json/license.json @@ -3,5 +3,6 @@ "uri": "http://dataverse..org/licenses/test/1.0", "iconUrl": "http://dataverse.org/licenses/test/1.0/icon.png", "shortDescription": "Dataverse Test License v1.0.", - "active": false + "active": false, + "sortOrder": 1 } From 5c7674c3c2f61de4e65b90b8d8e20db382127dc5 Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Mon, 8 Aug 2022 12:10:32 +0200 Subject: [PATCH 09/26] added icompatibilities mention for the license sorting order field --- doc/release-notes/8671-sorting-licenses.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/release-notes/8671-sorting-licenses.md b/doc/release-notes/8671-sorting-licenses.md index 34ad697d5a7..4ceb9ec056f 100644 --- a/doc/release-notes/8671-sorting-licenses.md +++ b/doc/release-notes/8671-sorting-licenses.md @@ -1,3 +1,7 @@ ## License sorting -Licenses as shown in the dropdown in UI can be now sorted by the superusers. See [Configuring Licenses](https://guides.dataverse.org/en/5.10/installation/config.html#configuring-licenses) section of the Installation Guide for reference. \ No newline at end of file +Licenses as shown in the dropdown in UI can be now sorted by the superusers. See [Configuring Licenses](https://guides.dataverse.org/en/5.10/installation/config.html#configuring-licenses) section of the Installation Guide for reference. + +## Backward Incompatibilities + +License files are now required to contain the new "sortOrder" column. When attempting to create a new license without this field, an error would be returned. See [Configuring Licenses](https://guides.dataverse.org/en/5.10/installation/config.html#configuring-licenses) section of the Installation Guide for reference. \ No newline at end of file From 9ad8d6401eb0aa25fe4808e76322421376aa924b Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Mon, 8 Aug 2022 12:13:38 +0200 Subject: [PATCH 10/26] renamed: V5.11.0.1__8671-sorting_licenses.sql -> V5.11.1.2__8671-sorting_licenses.sql --- ...-sorting_licenses.sql => V5.11.1.2__8671-sorting_licenses.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V5.11.0.1__8671-sorting_licenses.sql => V5.11.1.2__8671-sorting_licenses.sql} (100%) diff --git a/src/main/resources/db/migration/V5.11.0.1__8671-sorting_licenses.sql b/src/main/resources/db/migration/V5.11.1.2__8671-sorting_licenses.sql similarity index 100% rename from src/main/resources/db/migration/V5.11.0.1__8671-sorting_licenses.sql rename to src/main/resources/db/migration/V5.11.1.2__8671-sorting_licenses.sql From ca0bac2a10828207c4ec9c00e0ebdfddd85339f2 Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Mon, 8 Aug 2022 15:24:14 +0200 Subject: [PATCH 11/26] added sortOrder also in the error test license --- pom.xml | 2 +- src/test/resources/json/licenseError.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index eab64e522a5..19bdee46127 100644 --- a/pom.xml +++ b/pom.xml @@ -558,7 +558,7 @@ com.jayway.restassured rest-assured - 2.4.0 + 2.9.0 test diff --git a/src/test/resources/json/licenseError.json b/src/test/resources/json/licenseError.json index 552b6acadfb..533aa7ce7dc 100644 --- a/src/test/resources/json/licenseError.json +++ b/src/test/resources/json/licenseError.json @@ -4,5 +4,6 @@ "uri": "http://dataverse..org/licenses/test/ln6", "iconUrl": "http://dataverse.org/licenses/test/ln6/icon.png", "shortDescription": "A License that must have id 6.", - "active": true + "active": true, + "sortOrder": 1 } From 2af5cb31d1864588bfe7129c54bd61a7e653e55f Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Mon, 8 Aug 2022 15:26:00 +0200 Subject: [PATCH 12/26] revert by accident commited change in pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 19bdee46127..eab64e522a5 100644 --- a/pom.xml +++ b/pom.xml @@ -558,7 +558,7 @@ com.jayway.restassured rest-assured - 2.9.0 + 2.4.0 test From 255e30865162b649283737d585f7441103919715 Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Mon, 8 Aug 2022 17:18:11 +0200 Subject: [PATCH 13/26] test license created last should be at the end of the list now because of the increased sortOrder --- src/test/resources/json/license.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/json/license.json b/src/test/resources/json/license.json index 00502ded9a6..d126b1d2280 100644 --- a/src/test/resources/json/license.json +++ b/src/test/resources/json/license.json @@ -4,5 +4,5 @@ "iconUrl": "http://dataverse.org/licenses/test/1.0/icon.png", "shortDescription": "Dataverse Test License v1.0.", "active": false, - "sortOrder": 1 + "sortOrder": 1000 } From 962dde77db3d24c6cdea719b381774469ab5e2db Mon Sep 17 00:00:00 2001 From: Philip Durbin Date: Fri, 14 Oct 2022 13:48:30 -0400 Subject: [PATCH 14/26] rename sql script post 5.12 release #8671 --- ...-sorting_licenses.sql => V5.12.0.1__8671-sorting_licenses.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/db/migration/{V5.11.1.2__8671-sorting_licenses.sql => V5.12.0.1__8671-sorting_licenses.sql} (100%) diff --git a/src/main/resources/db/migration/V5.11.1.2__8671-sorting_licenses.sql b/src/main/resources/db/migration/V5.12.0.1__8671-sorting_licenses.sql similarity index 100% rename from src/main/resources/db/migration/V5.11.1.2__8671-sorting_licenses.sql rename to src/main/resources/db/migration/V5.12.0.1__8671-sorting_licenses.sql From eca4c2d57ac92a07c3be19ea2676f59b776952c8 Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Tue, 25 Oct 2022 17:38:34 +0200 Subject: [PATCH 15/26] fix for the test with license sorting --- src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java index e189336b61e..50d3c5b34ea 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java @@ -91,7 +91,8 @@ public void testLicenses(){ getLicensesResponse.prettyPrint(); body = getLicensesResponse.getBody().asString(); status = JsonPath.from(body).getString("status"); - long licenseId = JsonPath.from(body).getLong("data[-1].id"); + //Last added licens; with the highest id + long licenseId = JsonPath.from(body).getList("data[*].id").stream().max((x, y) -> Long.compare(x, y)).get(); //Assumes the first license is active, which should be true on a test server long activeLicenseId = JsonPath.from(body).getLong("data[0].id"); assertEquals("OK", status); From b1d94c86197a1d2ccfd998b5ba47700af9d95c04 Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Mon, 7 Nov 2022 11:00:57 +0100 Subject: [PATCH 16/26] sortOrder column made not nullable --- src/main/java/edu/harvard/iq/dataverse/license/License.java | 2 +- .../resources/db/migration/V5.12.0.1__8671-sorting_licenses.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/license/License.java b/src/main/java/edu/harvard/iq/dataverse/license/License.java index 0c8465e88e4..3073291a9d5 100644 --- a/src/main/java/edu/harvard/iq/dataverse/license/License.java +++ b/src/main/java/edu/harvard/iq/dataverse/license/License.java @@ -76,7 +76,7 @@ public class License { @Column(nullable = false) private boolean isDefault; - @Column(nullable = true) + @Column(nullable = false) private Long sortOrder; @OneToMany(mappedBy="license") diff --git a/src/main/resources/db/migration/V5.12.0.1__8671-sorting_licenses.sql b/src/main/resources/db/migration/V5.12.0.1__8671-sorting_licenses.sql index 43631ebd165..a449c85cf16 100644 --- a/src/main/resources/db/migration/V5.12.0.1__8671-sorting_licenses.sql +++ b/src/main/resources/db/migration/V5.12.0.1__8671-sorting_licenses.sql @@ -1,5 +1,5 @@ ALTER TABLE license -ADD COLUMN IF NOT EXISTS sortorder BIGINT; +ADD COLUMN IF NOT EXISTS sortorder BIGINT NOT NULL DEFAULT(0); CREATE INDEX IF NOT EXISTS license_sortorder_id ON license (sortorder, id); \ No newline at end of file From 81254adc4b3a2d0f9584b083143c2a4ec17fe980 Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Tue, 8 Nov 2022 15:39:03 +0100 Subject: [PATCH 17/26] bugfix in test: licenseId was not parsed correctly --- src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java index 50d3c5b34ea..30fc603a998 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java @@ -92,7 +92,7 @@ public void testLicenses(){ body = getLicensesResponse.getBody().asString(); status = JsonPath.from(body).getString("status"); //Last added licens; with the highest id - long licenseId = JsonPath.from(body).getList("data[*].id").stream().max((x, y) -> Long.compare(x, y)).get(); + long licenseId = (long) JsonPath.from(body).getList("data.id").stream().max((x, y) -> Integer.compare(x, y)).get(); //Assumes the first license is active, which should be true on a test server long activeLicenseId = JsonPath.from(body).getLong("data[0].id"); assertEquals("OK", status); From 35540f95834f1b59f06635a2f5ff33e6dbce5fd2 Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Tue, 8 Nov 2022 15:50:43 +0100 Subject: [PATCH 18/26] typo fix --- src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java b/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java index 30fc603a998..d6bfdb96777 100644 --- a/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java +++ b/src/test/java/edu/harvard/iq/dataverse/api/LicensesIT.java @@ -91,7 +91,7 @@ public void testLicenses(){ getLicensesResponse.prettyPrint(); body = getLicensesResponse.getBody().asString(); status = JsonPath.from(body).getString("status"); - //Last added licens; with the highest id + //Last added license; with the highest id long licenseId = (long) JsonPath.from(body).getList("data.id").stream().max((x, y) -> Integer.compare(x, y)).get(); //Assumes the first license is active, which should be true on a test server long activeLicenseId = JsonPath.from(body).getLong("data[0].id"); From 2ec2c251403168e16e62ab96bf2184e8e67cbc2e Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Thu, 10 Nov 2022 14:03:05 +0100 Subject: [PATCH 19/26] renamed flyway script and fixed default value --- ...orting_licenses.sql => V5.13.0.1__8671-sorting_licenses.sql} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/resources/db/migration/{V5.12.0.1__8671-sorting_licenses.sql => V5.13.0.1__8671-sorting_licenses.sql} (60%) diff --git a/src/main/resources/db/migration/V5.12.0.1__8671-sorting_licenses.sql b/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql similarity index 60% rename from src/main/resources/db/migration/V5.12.0.1__8671-sorting_licenses.sql rename to src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql index a449c85cf16..6fe3f1142c2 100644 --- a/src/main/resources/db/migration/V5.12.0.1__8671-sorting_licenses.sql +++ b/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql @@ -1,5 +1,5 @@ ALTER TABLE license -ADD COLUMN IF NOT EXISTS sortorder BIGINT NOT NULL DEFAULT(0); +ADD COLUMN IF NOT EXISTS sortorder BIGINT NOT NULL DEFAULT 0; CREATE INDEX IF NOT EXISTS license_sortorder_id ON license (sortorder, id); \ No newline at end of file From 6b78dc562e9ab9ee6720e49615ee1c70180df389 Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Wed, 16 Nov 2022 10:54:16 +0100 Subject: [PATCH 20/26] drop sortorder column in integration test --- .../resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql b/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql index 6fe3f1142c2..b5b76628e14 100644 --- a/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql +++ b/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql @@ -1,3 +1,4 @@ +ALTER TABLE license DROP COLUMN sortorder; ALTER TABLE license ADD COLUMN IF NOT EXISTS sortorder BIGINT NOT NULL DEFAULT 0; From ff392049595aaaf1a1d242cf8bfe3de13649a31a Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Wed, 16 Nov 2022 10:55:37 +0100 Subject: [PATCH 21/26] revert de column drop --- .../resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql b/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql index b5b76628e14..6fe3f1142c2 100644 --- a/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql +++ b/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql @@ -1,4 +1,3 @@ -ALTER TABLE license DROP COLUMN sortorder; ALTER TABLE license ADD COLUMN IF NOT EXISTS sortorder BIGINT NOT NULL DEFAULT 0; From 08c7e88d8f12a6cc5ff40490f05db09cebd5de91 Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Wed, 16 Nov 2022 10:59:03 +0100 Subject: [PATCH 22/26] moved drop sortorder column to the right file --- .../db/migration/V5.9.0.1__7440-configurable-license-list.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/db/migration/V5.9.0.1__7440-configurable-license-list.sql b/src/main/resources/db/migration/V5.9.0.1__7440-configurable-license-list.sql index cb76b2270a4..a6b5f55f70c 100644 --- a/src/main/resources/db/migration/V5.9.0.1__7440-configurable-license-list.sql +++ b/src/main/resources/db/migration/V5.9.0.1__7440-configurable-license-list.sql @@ -1,3 +1,4 @@ +ALTER TABLE license DROP COLUMN sortorder; ALTER TABLE termsofuseandaccess ADD COLUMN IF NOT EXISTS license_id BIGINT; DO $$ From b50081d3aafcadc2fe211636bbbee2f63c800ffb Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Wed, 16 Nov 2022 10:59:31 +0100 Subject: [PATCH 23/26] revert de column drop --- .../db/migration/V5.9.0.1__7440-configurable-license-list.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/resources/db/migration/V5.9.0.1__7440-configurable-license-list.sql b/src/main/resources/db/migration/V5.9.0.1__7440-configurable-license-list.sql index a6b5f55f70c..cb76b2270a4 100644 --- a/src/main/resources/db/migration/V5.9.0.1__7440-configurable-license-list.sql +++ b/src/main/resources/db/migration/V5.9.0.1__7440-configurable-license-list.sql @@ -1,4 +1,3 @@ -ALTER TABLE license DROP COLUMN sortorder; ALTER TABLE termsofuseandaccess ADD COLUMN IF NOT EXISTS license_id BIGINT; DO $$ From cbe1092434a1ddb21da522db43d42682c4490d0d Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Wed, 16 Nov 2022 11:13:49 +0100 Subject: [PATCH 24/26] drop colomn sort order if exists --- .../resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql | 1 + .../db/migration/V5.9.0.1__7440-configurable-license-list.sql | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql b/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql index 6fe3f1142c2..11338afc0f3 100644 --- a/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql +++ b/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql @@ -1,3 +1,4 @@ +ALTER TABLE license DROP COLUMN IF EXISTS sortorder; ALTER TABLE license ADD COLUMN IF NOT EXISTS sortorder BIGINT NOT NULL DEFAULT 0; diff --git a/src/main/resources/db/migration/V5.9.0.1__7440-configurable-license-list.sql b/src/main/resources/db/migration/V5.9.0.1__7440-configurable-license-list.sql index cb76b2270a4..2772f4b656b 100644 --- a/src/main/resources/db/migration/V5.9.0.1__7440-configurable-license-list.sql +++ b/src/main/resources/db/migration/V5.9.0.1__7440-configurable-license-list.sql @@ -2,7 +2,7 @@ ALTER TABLE termsofuseandaccess ADD COLUMN IF NOT EXISTS license_id BIGINT; DO $$ BEGIN - + ALTER TABLE license DROP COLUMN IF EXISTS sortorder; BEGIN ALTER TABLE termsofuseandaccess ADD CONSTRAINT fk_termsofuseandcesss_license_id foreign key (license_id) REFERENCES license(id); EXCEPTION From 98d697411e3a3ade9ab9fe183543ba1f29952466 Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Wed, 16 Nov 2022 11:15:29 +0100 Subject: [PATCH 25/26] revert dropping --- .../resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql | 1 - .../db/migration/V5.9.0.1__7440-configurable-license-list.sql | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql b/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql index 11338afc0f3..6fe3f1142c2 100644 --- a/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql +++ b/src/main/resources/db/migration/V5.13.0.1__8671-sorting_licenses.sql @@ -1,4 +1,3 @@ -ALTER TABLE license DROP COLUMN IF EXISTS sortorder; ALTER TABLE license ADD COLUMN IF NOT EXISTS sortorder BIGINT NOT NULL DEFAULT 0; diff --git a/src/main/resources/db/migration/V5.9.0.1__7440-configurable-license-list.sql b/src/main/resources/db/migration/V5.9.0.1__7440-configurable-license-list.sql index 2772f4b656b..a8f7f41e2ef 100644 --- a/src/main/resources/db/migration/V5.9.0.1__7440-configurable-license-list.sql +++ b/src/main/resources/db/migration/V5.9.0.1__7440-configurable-license-list.sql @@ -2,7 +2,6 @@ ALTER TABLE termsofuseandaccess ADD COLUMN IF NOT EXISTS license_id BIGINT; DO $$ BEGIN - ALTER TABLE license DROP COLUMN IF EXISTS sortorder; BEGIN ALTER TABLE termsofuseandaccess ADD CONSTRAINT fk_termsofuseandcesss_license_id foreign key (license_id) REFERENCES license(id); EXCEPTION From bb1865cf4e0ba19e36f96b6e6cf6c646fa6ae52c Mon Sep 17 00:00:00 2001 From: Eryk Kulikowski Date: Wed, 16 Nov 2022 14:47:45 +0100 Subject: [PATCH 26/26] sortorder colomn definition fix in entity bean --- src/main/java/edu/harvard/iq/dataverse/license/License.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/license/License.java b/src/main/java/edu/harvard/iq/dataverse/license/License.java index 3073291a9d5..c6e2cdbc2e5 100644 --- a/src/main/java/edu/harvard/iq/dataverse/license/License.java +++ b/src/main/java/edu/harvard/iq/dataverse/license/License.java @@ -76,7 +76,7 @@ public class License { @Column(nullable = false) private boolean isDefault; - @Column(nullable = false) + @Column(nullable = false, columnDefinition = "BIGINT NOT NULL DEFAULT 0") private Long sortOrder; @OneToMany(mappedBy="license")