From 2653ef2cd833460436dc9d92385edc0edcc5840f Mon Sep 17 00:00:00 2001 From: ErykKul Date: Thu, 17 Mar 2022 09:32:57 +0100 Subject: [PATCH 1/5] fixed unmarshaling van LocalDateTime error in the DDIExporterTest.java --- .../harvard/iq/dataverse/export/DDIExporterTest.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/test/java/edu/harvard/iq/dataverse/export/DDIExporterTest.java b/src/test/java/edu/harvard/iq/dataverse/export/DDIExporterTest.java index 8ce823eb600..2518e2ca335 100644 --- a/src/test/java/edu/harvard/iq/dataverse/export/DDIExporterTest.java +++ b/src/test/java/edu/harvard/iq/dataverse/export/DDIExporterTest.java @@ -1,6 +1,6 @@ package edu.harvard.iq.dataverse.export; -import com.google.gson.Gson; +import com.google.gson.*; import edu.harvard.iq.dataverse.ControlledVocabularyValue; import edu.harvard.iq.dataverse.DatasetFieldType; import edu.harvard.iq.dataverse.DatasetFieldType.FieldType; @@ -17,10 +17,15 @@ import java.io.File; import java.io.IOException; import java.io.StringReader; +import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.Arrays; import java.util.HashSet; import java.util.Set; @@ -42,7 +47,10 @@ public class DDIExporterTest { private static final SettingsServiceBean settingsService = Mockito.mock(SettingsServiceBean.class); private static final LicenseServiceBean licenseService = Mockito.mock(LicenseServiceBean.class); private static final MockDatasetFieldSvc datasetFieldTypeSvc = new MockDatasetFieldSvc(); - private static final Gson gson = new Gson(); + private static final Gson gson = new GsonBuilder().registerTypeAdapter(LocalDate.class, (JsonDeserializer) (JsonElement json, Type type, JsonDeserializationContext jsonDeserializationContext) -> { + Instant instant = Instant.ofEpochMilli(json.getAsJsonPrimitive().getAsLong()); + return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); + }).create(); /* * Setup and teardown mocks for BrandingUtil for atomicity. From 9016b6d81fe1f7f95183761435300d133e9304e4 Mon Sep 17 00:00:00 2001 From: ErykKul Date: Thu, 17 Mar 2022 09:35:46 +0100 Subject: [PATCH 2/5] fixed not unique identifier error and syntax error in the catch block in fileupload.js --- src/main/webapp/resources/js/fileupload.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/resources/js/fileupload.js b/src/main/webapp/resources/js/fileupload.js index af7bed0d492..564239ee7ef 100644 --- a/src/main/webapp/resources/js/fileupload.js +++ b/src/main/webapp/resources/js/fileupload.js @@ -124,7 +124,7 @@ async function cancelDatasetEdit() { var inDataverseCall = false; -class fileUpload { +var fileUpload = class fileUploadClass { constructor(file) { this.file = file; this.state = UploadState.QUEUED; @@ -549,8 +549,9 @@ async function uploadFailure(jqXHR, upid, filename) { id = arguments.callee.caller.caller.arguments[1].files[0].row[0].attributes.upid.value; status = arguments.callee.caller.caller.arguments[1].jqXHR.status; statusText = arguments.callee.caller.caller.arguments[1].jqXHR.statusText; - } catch { + } catch(err) { console.log("Unable to determine status for error - assuming network issue"); + console.log("Exception: " + err.message); } } From 778c9d133f3cb8f3ab5efe70746065d83f972eb5 Mon Sep 17 00:00:00 2001 From: ErykKul Date: Thu, 17 Mar 2022 10:54:04 +0100 Subject: [PATCH 3/5] nullpointers fix when license image is not defined, now licenses can be used also without an image --- .../harvard/iq/dataverse/license/License.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 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 a780bf1c625..a51214837e2 100644 --- a/src/main/java/edu/harvard/iq/dataverse/license/License.java +++ b/src/main/java/edu/harvard/iq/dataverse/license/License.java @@ -84,7 +84,11 @@ public License(String name, String shortDescription, URI uri, URI iconUrl, boole this.name = name; this.shortDescription = shortDescription; this.uri = uri.toASCIIString(); - this.iconUrl = iconUrl.toASCIIString(); + if (iconUrl != null) { + this.iconUrl = iconUrl.toASCIIString(); + } else { + this.iconUrl = null; + } this.active = active; isDefault = false; } @@ -118,6 +122,9 @@ public void setUri(URI uri) { } public URI getIconUrl() { + if (iconUrl == null) { + return null; + } try { return new URI(iconUrl); } catch (URISyntaxException e) { @@ -134,7 +141,11 @@ public void setShortDescription(String shortDescription) { } public void setIconUrl(URI iconUrl) { - this.iconUrl = iconUrl.toASCIIString(); + if (iconUrl != null) { + this.iconUrl = iconUrl.toASCIIString(); + } else { + this.iconUrl = null; + } } public boolean isActive() { @@ -166,7 +177,7 @@ 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) && iconUrl.equals(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); } @Override From f0590eb3d8193c173da1831f53b0c80bfc7188fc Mon Sep 17 00:00:00 2001 From: ErykKul Date: Thu, 17 Mar 2022 10:56:22 +0100 Subject: [PATCH 4/5] fix for validation of xhtml files with lib that can not be found (namespace declaration moved to body tag) --- src/main/webapp/dataverse_template.xhtml | 2 +- src/main/webapp/editdatafiles.xhtml | 5 ++--- src/main/webapp/file.xhtml | 5 ++--- src/main/webapp/permissions-manage-files.xhtml | 5 ++--- src/main/webapp/permissions-manage.xhtml | 5 ++--- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main/webapp/dataverse_template.xhtml b/src/main/webapp/dataverse_template.xhtml index 8c4b323d93f..ac9135e7035 100644 --- a/src/main/webapp/dataverse_template.xhtml +++ b/src/main/webapp/dataverse_template.xhtml @@ -48,7 +48,7 @@ diff --git a/src/main/webapp/editdatafiles.xhtml b/src/main/webapp/editdatafiles.xhtml index aa4eb5f228c..4d9bfd6ef1f 100644 --- a/src/main/webapp/editdatafiles.xhtml +++ b/src/main/webapp/editdatafiles.xhtml @@ -8,12 +8,11 @@ xmlns:jsf="http://xmlns.jcp.org/jsf" xmlns:pt="http://java.sun.com/jsf/passthrough" xmlns:cc="http://java.sun.com/jsf/composite" - xmlns:o="http://omnifaces.org/ui" - xmlns:iqbs="http://xmlns.jcp.org/jsf/composite/iqbs"> + xmlns:o="http://omnifaces.org/ui"> - + diff --git a/src/main/webapp/file.xhtml b/src/main/webapp/file.xhtml index f5232623822..1fd0bb884d5 100644 --- a/src/main/webapp/file.xhtml +++ b/src/main/webapp/file.xhtml @@ -8,12 +8,11 @@ xmlns:jsf="http://xmlns.jcp.org/jsf" xmlns:pt="http://java.sun.com/jsf/passthrough" xmlns:cc="http://java.sun.com/jsf/composite" - xmlns:o="http://omnifaces.org/ui" - xmlns:iqbs="http://xmlns.jcp.org/jsf/composite/iqbs"> + xmlns:o="http://omnifaces.org/ui"> - + diff --git a/src/main/webapp/permissions-manage-files.xhtml b/src/main/webapp/permissions-manage-files.xhtml index 49e930bc2ef..800fc5d8750 100644 --- a/src/main/webapp/permissions-manage-files.xhtml +++ b/src/main/webapp/permissions-manage-files.xhtml @@ -6,11 +6,10 @@ xmlns:p="http://primefaces.org/ui" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:o="http://omnifaces.org/ui" - xmlns:jsf="http://xmlns.jcp.org/jsf" - xmlns:iqbs="http://xmlns.jcp.org/jsf/composite/iqbs"> + xmlns:jsf="http://xmlns.jcp.org/jsf"> - + diff --git a/src/main/webapp/permissions-manage.xhtml b/src/main/webapp/permissions-manage.xhtml index c0a7508be04..9fecf5ce5bc 100644 --- a/src/main/webapp/permissions-manage.xhtml +++ b/src/main/webapp/permissions-manage.xhtml @@ -4,12 +4,11 @@ xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui" - xmlns:c="http://java.sun.com/jsp/jstl/core" - xmlns:iqbs="http://xmlns.jcp.org/jsf/composite/iqbs"> + xmlns:c="http://java.sun.com/jsp/jstl/core"> - + From 8c4ebecdf9368e27187ec66d5844c85647e23c01 Mon Sep 17 00:00:00 2001 From: ErykKul Date: Thu, 17 Mar 2022 12:51:12 +0100 Subject: [PATCH 5/5] fixed remaining nullpointer for licenses without image url --- src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java | 2 +- .../java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 a33caa9f890..4e0a89183da 100644 --- a/src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java +++ b/src/main/java/edu/harvard/iq/dataverse/dataset/DatasetUtil.java @@ -561,7 +561,7 @@ public static String getLicenseURI(DatasetVersion dsv) { public static String getLicenseIcon(DatasetVersion dsv) { License license = dsv.getTermsOfUseAndAccess().getLicense(); - return license != null ? license.getIconUrl().toString() : null; + return license != null && license.getIconUrl() != null ? license.getIconUrl().toString() : null; } public static String getLicenseDescription(DatasetVersion dsv) { 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 ccde79bf233..ed3460b6759 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 @@ -798,7 +798,7 @@ public static JsonObjectBuilder json(License license) { .add("name", license.getName()) .add("shortDescription", license.getShortDescription()) .add("uri", license.getUri().toString()) - .add("iconUrl", license.getIconUrl().toString()) + .add("iconUrl", license.getIconUrl() == null ? null : license.getIconUrl().toString()) .add("active", license.isActive()) .add("isDefault", license.isDefault()); }