From bef05a8f0ab1bd57f2bc407d1e4316c41137b4b4 Mon Sep 17 00:00:00 2001 From: delinea-rajani <164006534+delinea-rajani@users.noreply.github.com> Date: Fri, 30 Aug 2024 03:18:40 -0400 Subject: [PATCH] Update Secret.java class to resolve error --- .../delinea/secrets/server/spring/Secret.java | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/delinea/secrets/server/spring/Secret.java b/src/main/java/com/delinea/secrets/server/spring/Secret.java index f664b20..e074326 100644 --- a/src/main/java/com/delinea/secrets/server/spring/Secret.java +++ b/src/main/java/com/delinea/secrets/server/spring/Secret.java @@ -1,7 +1,9 @@ package com.delinea.secrets.server.spring; +import java.util.Collections; import java.util.Date; import java.util.List; +import java.util.ArrayList; import com.fasterxml.jackson.annotation.JsonProperty; @@ -13,8 +15,14 @@ public class Secret { * Java representation of an Item of a Secret. */ public static class Field { - private int id, fieldId, fileAttachmentId; - private String fieldDescription, fieldName, filename, value, slug; + private int id; + private int fieldId; + private int fileAttachmentId; + private String fieldDescription; + private String fieldName; + private String filename; + private String value; + private String slug; @JsonProperty("itemId") public int getId() { @@ -55,13 +63,23 @@ void setValue(final String value) { } } - private String name, secretTemplateName; + private String name; + private String secretTemplateName; private String lastHeartBeatStatus; - private Date lastHeartBeatCheck, lastPasswordChangeAttempt; - private int id, folderId, secretTemplateId, siteId; - private boolean active, checkedOut, checkoutEnabled; - private List fields; - + private Date lastHeartBeatCheck; + private Date lastPasswordChangeAttempt; + private int id; + private int folderId; + private int secretTemplateId; + private int siteId; + private boolean active; + private boolean checkedOut; + private boolean checkoutEnabled; + + // List of Field objects + private List fields = new ArrayList<>(); + + // Getters for the fields public String getName() { return name; } @@ -112,12 +130,12 @@ public boolean isCheckoutEnabled() { @JsonProperty("items") public List getFields() { - return fields; + return Collections.unmodifiableList(fields); // Return an unmodifiable view } @Override public String toString() { - return String.format("Secret { id: %d, folderId: %d, name: %s, templateName: %s }", this.id, this.folderId, - this.name, this.secretTemplateName); + return String.format("Secret { id: %d, folderId: %d, name: %s, templateName: %s }", + this.id, this.folderId, this.name, this.secretTemplateName); } }