From 3ad53d7c0b73260122ec5deecf072edc456d2a8e Mon Sep 17 00:00:00 2001 From: qqmyers Date: Wed, 20 Sep 2023 14:54:43 -0400 Subject: [PATCH] fix Dataverse UI ability to set GB at request param --- .../java/edu/harvard/iq/dataverse/DvObjectContainer.java | 9 ++++++--- .../java/edu/harvard/iq/dataverse/SettingsWrapper.java | 2 +- src/main/java/edu/harvard/iq/dataverse/api/Datasets.java | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/DvObjectContainer.java b/src/main/java/edu/harvard/iq/dataverse/DvObjectContainer.java index da77df786d8..f7d361d76f5 100644 --- a/src/main/java/edu/harvard/iq/dataverse/DvObjectContainer.java +++ b/src/main/java/edu/harvard/iq/dataverse/DvObjectContainer.java @@ -116,12 +116,15 @@ public boolean getEffectiveGuestbookEntryAtRequest() { return gbAtRequest; } - public Boolean getGuestbookEntryAtRequest() { - return guestbookAtRequest; + public String getGuestbookEntryAtRequest() { + if(guestbookAtRequest==null) { + return UNDEFINED_CODE; + } + return Boolean.valueOf(guestbookAtRequest).toString(); } public void setGuestbookEntryAtRequest(String gbAtRequest) { - if (gbAtRequest != null && gbAtRequest.equals(UNDEFINED_CODE)) { + if (gbAtRequest == null || gbAtRequest.equals(UNDEFINED_CODE)) { this.guestbookAtRequest = null; } else { //Force to true or false diff --git a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java index e41a18c1431..0a1d0effc03 100644 --- a/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java +++ b/src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java @@ -649,7 +649,7 @@ public Map getGuestbookEntryOptions(DvObjectContainer target) { useDefault = (defaultOption ? atRequest : atDownload) + BundleUtil.getStringFromBundle("dataverse.inherited"); } - currentMap.put("null", useDefault); + currentMap.put(DvObjectContainer.UNDEFINED_CODE, useDefault); currentMap.put(Boolean.toString(true), atRequest); currentMap.put(Boolean.toString(false), atDownload); } else { diff --git a/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java b/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java index a1191a6f4e6..55e329bea68 100644 --- a/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java +++ b/src/main/java/edu/harvard/iq/dataverse/api/Datasets.java @@ -3888,8 +3888,8 @@ public Response getGuestbookEntryOption(@Context ContainerRequestContext crc, @P } catch (WrappedResponse ex) { return error(Response.Status.NOT_FOUND, "No such dataset"); } - Boolean gbAtRequest = dataset.getGuestbookEntryAtRequest(); - if(gbAtRequest == null) { + String gbAtRequest = dataset.getGuestbookEntryAtRequest(); + if(gbAtRequest == null || gbAtRequest.equals(DvObjectContainer.UNDEFINED_CODE)) { return ok("Not set on dataset, using the default: " + dataset.getEffectiveGuestbookEntryAtRequest()); } return ok(dataset.getEffectiveGuestbookEntryAtRequest());