From 8bf24d047b6df2ea7a8403873b77632f7127e7d5 Mon Sep 17 00:00:00 2001 From: jo-pol Date: Thu, 15 Aug 2024 11:59:28 +0200 Subject: [PATCH] added toString methods --- .../main/java/nl/knaw/dans/lib/dataverse/AdminApi.java | 2 ++ .../nl/knaw/dans/lib/dataverse/BasicFileAccessApi.java | 2 ++ .../java/nl/knaw/dans/lib/dataverse/BuiltinUserApi.java | 2 ++ .../main/java/nl/knaw/dans/lib/dataverse/DatasetApi.java | 8 +++++++- .../java/nl/knaw/dans/lib/dataverse/DataverseApi.java | 2 ++ .../java/nl/knaw/dans/lib/dataverse/DataverseClient.java | 2 ++ lib/src/main/java/nl/knaw/dans/lib/dataverse/FileApi.java | 2 ++ .../main/java/nl/knaw/dans/lib/dataverse/LicenseApi.java | 2 ++ .../main/java/nl/knaw/dans/lib/dataverse/SearchApi.java | 2 ++ .../main/java/nl/knaw/dans/lib/dataverse/SwordApi.java | 2 ++ .../main/java/nl/knaw/dans/lib/dataverse/TokenApi.java | 2 ++ 11 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/src/main/java/nl/knaw/dans/lib/dataverse/AdminApi.java b/lib/src/main/java/nl/knaw/dans/lib/dataverse/AdminApi.java index 366cc7b85..210c01fed 100644 --- a/lib/src/main/java/nl/knaw/dans/lib/dataverse/AdminApi.java +++ b/lib/src/main/java/nl/knaw/dans/lib/dataverse/AdminApi.java @@ -15,6 +15,7 @@ */ package nl.knaw.dans.lib.dataverse; +import lombok.ToString; import lombok.extern.slf4j.Slf4j; import nl.knaw.dans.lib.dataverse.model.DataMessage; import nl.knaw.dans.lib.dataverse.model.user.AuthenticatedUser; @@ -31,6 +32,7 @@ * @see Dataverse documentation */ @Slf4j +@ToString public class AdminApi extends AbstractApi { private final Path targetBase; diff --git a/lib/src/main/java/nl/knaw/dans/lib/dataverse/BasicFileAccessApi.java b/lib/src/main/java/nl/knaw/dans/lib/dataverse/BasicFileAccessApi.java index 1e8102f8b..5bb1bd3b2 100644 --- a/lib/src/main/java/nl/knaw/dans/lib/dataverse/BasicFileAccessApi.java +++ b/lib/src/main/java/nl/knaw/dans/lib/dataverse/BasicFileAccessApi.java @@ -15,6 +15,7 @@ */ package nl.knaw.dans.lib.dataverse; +import lombok.ToString; import lombok.extern.slf4j.Slf4j; import org.apache.hc.core5.http.io.HttpClientResponseHandler; @@ -31,6 +32,7 @@ * @see Dataverse documentation */ @Slf4j +@ToString public class BasicFileAccessApi extends AbstractTargetedApi { BasicFileAccessApi(HttpClientWrapper httpClientWrapper, String id, boolean isPersistentId) { super(httpClientWrapper, id, isPersistentId, null, Paths.get("api/access/datafile")); diff --git a/lib/src/main/java/nl/knaw/dans/lib/dataverse/BuiltinUserApi.java b/lib/src/main/java/nl/knaw/dans/lib/dataverse/BuiltinUserApi.java index 50a9b3920..b77de1863 100644 --- a/lib/src/main/java/nl/knaw/dans/lib/dataverse/BuiltinUserApi.java +++ b/lib/src/main/java/nl/knaw/dans/lib/dataverse/BuiltinUserApi.java @@ -15,9 +15,11 @@ */ package nl.knaw.dans.lib.dataverse; +import lombok.ToString; import lombok.extern.slf4j.Slf4j; @Slf4j +@ToString public class BuiltinUserApi extends AbstractApi { BuiltinUserApi(HttpClientWrapper httpClientWrapper) { diff --git a/lib/src/main/java/nl/knaw/dans/lib/dataverse/DatasetApi.java b/lib/src/main/java/nl/knaw/dans/lib/dataverse/DatasetApi.java index 1fc8f7756..a58cab152 100644 --- a/lib/src/main/java/nl/knaw/dans/lib/dataverse/DatasetApi.java +++ b/lib/src/main/java/nl/knaw/dans/lib/dataverse/DatasetApi.java @@ -46,6 +46,7 @@ import java.util.Map; import java.util.Optional; +import static java.text.MessageFormat.format; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; @@ -62,6 +63,11 @@ public class DatasetApi extends AbstractTargetedApi { this(httpClientWrapper, id, isPersistentId, null); } + @Override + public String toString() { + return format("DatasetApi(id=''{0}, isPersistentId={1})", id, isPersistentId); + } + DatasetApi(HttpClientWrapper httpClientWrapper, String id, boolean isPersistentId, String invocationId) { super(httpClientWrapper, id, isPersistentId, invocationId, Paths.get("api/datasets/")); } @@ -550,7 +556,7 @@ public DataverseHttpResponse setRetentionPeriod(RetentionPeriod retenti public DataverseHttpResponse setRetentionPeriod(String json) throws IOException, DataverseException { return httpClientWrapper.postJsonString(subPath("files/actions/:set-retention"), json, params(emptyMap()), extraHeaders, HashMap.class); } - + /* * Helper methods */ diff --git a/lib/src/main/java/nl/knaw/dans/lib/dataverse/DataverseApi.java b/lib/src/main/java/nl/knaw/dans/lib/dataverse/DataverseApi.java index c44ba0ef6..fbb7c7025 100644 --- a/lib/src/main/java/nl/knaw/dans/lib/dataverse/DataverseApi.java +++ b/lib/src/main/java/nl/knaw/dans/lib/dataverse/DataverseApi.java @@ -15,6 +15,7 @@ */ package nl.knaw.dans.lib.dataverse; +import lombok.ToString; import nl.knaw.dans.lib.dataverse.model.DataMessage; import nl.knaw.dans.lib.dataverse.model.Role; import nl.knaw.dans.lib.dataverse.model.RoleAssignment; @@ -43,6 +44,7 @@ * * @see Dataverse documentation */ +@ToString public class DataverseApi extends AbstractApi { private static final Logger log = LoggerFactory.getLogger(DataverseApi.class); diff --git a/lib/src/main/java/nl/knaw/dans/lib/dataverse/DataverseClient.java b/lib/src/main/java/nl/knaw/dans/lib/dataverse/DataverseClient.java index e8232d83e..72187d1f9 100644 --- a/lib/src/main/java/nl/knaw/dans/lib/dataverse/DataverseClient.java +++ b/lib/src/main/java/nl/knaw/dans/lib/dataverse/DataverseClient.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.module.SimpleModule; +import lombok.ToString; import lombok.extern.slf4j.Slf4j; import nl.knaw.dans.lib.dataverse.model.dataset.MetadataField; import nl.knaw.dans.lib.dataverse.model.dataverse.DataverseItem; @@ -30,6 +31,7 @@ * Object that lets your code talk to a Dataverse server. */ @Slf4j +@ToString public class DataverseClient { private final HttpClientWrapper httpClientWrapper; private SearchApi searchApi; diff --git a/lib/src/main/java/nl/knaw/dans/lib/dataverse/FileApi.java b/lib/src/main/java/nl/knaw/dans/lib/dataverse/FileApi.java index 80d1c1213..f59a9f4a0 100644 --- a/lib/src/main/java/nl/knaw/dans/lib/dataverse/FileApi.java +++ b/lib/src/main/java/nl/knaw/dans/lib/dataverse/FileApi.java @@ -15,6 +15,7 @@ */ package nl.knaw.dans.lib.dataverse; +import lombok.ToString; import lombok.extern.slf4j.Slf4j; import nl.knaw.dans.lib.dataverse.model.dataset.FileList; import nl.knaw.dans.lib.dataverse.model.file.FileMeta; @@ -31,6 +32,7 @@ import static java.util.Collections.emptyMap; @Slf4j +@ToString public class FileApi extends AbstractTargetedApi { FileApi(HttpClientWrapper httpClientWrapper, String id, boolean isPersistentId) { diff --git a/lib/src/main/java/nl/knaw/dans/lib/dataverse/LicenseApi.java b/lib/src/main/java/nl/knaw/dans/lib/dataverse/LicenseApi.java index 897e6e2c5..43c81a73b 100644 --- a/lib/src/main/java/nl/knaw/dans/lib/dataverse/LicenseApi.java +++ b/lib/src/main/java/nl/knaw/dans/lib/dataverse/LicenseApi.java @@ -15,6 +15,7 @@ */ package nl.knaw.dans.lib.dataverse; +import lombok.ToString; import lombok.extern.slf4j.Slf4j; import nl.knaw.dans.lib.dataverse.model.DataMessage; import nl.knaw.dans.lib.dataverse.model.license.License; @@ -31,6 +32,7 @@ * @see Dataverse documentation */ @Slf4j +@ToString public class LicenseApi extends AbstractApi { private final Path targetBase; diff --git a/lib/src/main/java/nl/knaw/dans/lib/dataverse/SearchApi.java b/lib/src/main/java/nl/knaw/dans/lib/dataverse/SearchApi.java index 52c02604d..681747fde 100644 --- a/lib/src/main/java/nl/knaw/dans/lib/dataverse/SearchApi.java +++ b/lib/src/main/java/nl/knaw/dans/lib/dataverse/SearchApi.java @@ -15,6 +15,7 @@ */ package nl.knaw.dans.lib.dataverse; +import lombok.ToString; import lombok.extern.slf4j.Slf4j; import nl.knaw.dans.lib.dataverse.model.search.ResultItem; import nl.knaw.dans.lib.dataverse.model.search.SearchResult; @@ -31,6 +32,7 @@ import java.util.stream.Collectors; @Slf4j +@ToString public class SearchApi extends AbstractApi { private final Path subPath = Paths.get("api", "search"); diff --git a/lib/src/main/java/nl/knaw/dans/lib/dataverse/SwordApi.java b/lib/src/main/java/nl/knaw/dans/lib/dataverse/SwordApi.java index 6892aaa11..261b48c29 100644 --- a/lib/src/main/java/nl/knaw/dans/lib/dataverse/SwordApi.java +++ b/lib/src/main/java/nl/knaw/dans/lib/dataverse/SwordApi.java @@ -15,6 +15,7 @@ */ package nl.knaw.dans.lib.dataverse; +import lombok.ToString; import lombok.extern.slf4j.Slf4j; import java.io.IOException; @@ -22,6 +23,7 @@ import java.nio.file.Paths; @Slf4j +@ToString public class SwordApi extends AbstractApi { SwordApi(HttpClientWrapper httpClientWrapper) { diff --git a/lib/src/main/java/nl/knaw/dans/lib/dataverse/TokenApi.java b/lib/src/main/java/nl/knaw/dans/lib/dataverse/TokenApi.java index 433b52509..aa8378866 100644 --- a/lib/src/main/java/nl/knaw/dans/lib/dataverse/TokenApi.java +++ b/lib/src/main/java/nl/knaw/dans/lib/dataverse/TokenApi.java @@ -15,9 +15,11 @@ */ package nl.knaw.dans.lib.dataverse; +import lombok.ToString; import lombok.extern.slf4j.Slf4j; @Slf4j +@ToString public class TokenApi extends AbstractApi { TokenApi(HttpClientWrapper httpClientWrapper) { super(httpClientWrapper);