Skip to content

Commit 2d01752

Browse files
authored
Merge pull request #12492 from IQSS/12491-include-name-in-guestbook-responces-api
Include name in guestbook responses api
2 parents 2f723c8 + 4d38b40 commit 2d01752

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## BUG ##
2+
Changed "userName" in guestbook response to "name" to match the parser in API GET /api/guestbooks/{guestbookId}/responses

src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import edu.harvard.iq.dataverse.util.BundleUtil;
3232
import edu.harvard.iq.dataverse.util.DatasetFieldWalker;
3333
import edu.harvard.iq.dataverse.util.MailUtil;
34+
import edu.harvard.iq.dataverse.util.StringUtil;
3435
import edu.harvard.iq.dataverse.workflow.Workflow;
3536
import edu.harvard.iq.dataverse.workflow.step.WorkflowStepData;
3637
import jakarta.ejb.EJB;
@@ -426,7 +427,9 @@ public static JsonObjectBuilder json(GuestbookResponse gbResponse) {
426427
if (gbResponse.getDataFile().getGlobalId() != null) {
427428
guestbookResponseObject.add("filePid", gbResponse.getDataFile().getGlobalId().asString());
428429
}
429-
guestbookResponseObject.add("userName", gbResponse.getAuthenticatedUser() != null ? gbResponse.getAuthenticatedUser().getUserIdentifier() : "Guest");
430+
if (!StringUtil.isEmpty(gbResponse.getName())) {
431+
guestbookResponseObject.add("name", gbResponse.getName());
432+
}
430433
if (gbResponse.getEmail() != null) {
431434
guestbookResponseObject.add("email", gbResponse.getEmail());
432435
}

src/test/java/edu/harvard/iq/dataverse/api/FilesIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4114,6 +4114,8 @@ public void testDownloadFileWithGuestbookResponse() throws IOException, JsonPars
41144114
.statusCode(OK.getStatusCode());
41154115
JsonPath jsonPath = JsonPath.from(guestbookListResponses.body().asString());
41164116
int totalCount = jsonPath.getList("data.responses").size();
4117+
assertTrue(totalCount > 0);
4118+
assertNotNull(jsonPath.getString("data.responses[0].name"));
41174119

41184120
// Test Get Responses with pagination
41194121
int pages = 4; // total should be 17. set to 4 pages

0 commit comments

Comments
 (0)