From 216b11fb603680f6674e70fc633abd0ba69e6876 Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Wed, 17 Apr 2024 15:52:05 +0100 Subject: [PATCH] [sdk] Reiterate on the UnindexReport API - record a collection of URIs in each unindex failure --- .../pt/ua/dicoogle/sdk/IndexerInterface.java | 4 +- .../sdk/datastructs/UnindexReport.java | 39 +++++++++++-------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/sdk/src/main/java/pt/ua/dicoogle/sdk/IndexerInterface.java b/sdk/src/main/java/pt/ua/dicoogle/sdk/IndexerInterface.java index 475d33eb0..e7df68890 100755 --- a/sdk/src/main/java/pt/ua/dicoogle/sdk/IndexerInterface.java +++ b/sdk/src/main/java/pt/ua/dicoogle/sdk/IndexerInterface.java @@ -143,10 +143,10 @@ public default Task unindex(Collection uris, Consumer urisAffected; /** The exception describing the error which led to the failure. * This field can be null @@ -50,11 +50,16 @@ public static final class FailedUnindex implements Serializable { * @param uri the URI of the file which could not be unindexed * @param cause the underlying exception, if any */ - public FailedUnindex(URI uri, Exception cause) { - Objects.requireNonNull(uri); - this.uri = uri; + public FailedUnindex(Collection urisAffected, Exception cause) { + Objects.requireNonNull(urisAffected); + this.urisAffected = urisAffected; this.cause = cause; } + + @Override + public String toString() { + return "FailedUnindex{urisAffected=" + urisAffected + ", cause=" + cause + "}"; + } } /** URIs of files which were not found. */ @@ -64,6 +69,8 @@ public FailedUnindex(URI uri, Exception cause) { /** Creates a full report for a bulk unindexing operation. * All parameters are nullable, * in which case is equivalent to passing an empty collection. + * Once created, the report is final and immutable. + * * @param notFound the URIs of files which were not found * @param failures the error reports of files which could not be unindexed */ @@ -78,13 +85,13 @@ public UnindexReport(Collection notFound, Collection failure this.failures = failures; } - /** Creates a report that all files were successfully unindexed. */ + /** Creates a report with no unindexing failures. + */ public static UnindexReport ok() { return new UnindexReport(null, null); } - /** Creates a report with the files which failed to unindex - * due to some error. + /** Creates a report with the given failures. */ public static UnindexReport withFailures(Collection failures) { return new UnindexReport(null, failures); @@ -110,7 +117,7 @@ public boolean allUnindexed() { } /** Obtains an immutable collection to - * the files which failed to unindex due to an error. + * the file batches which failed to unindex due to errors. */ public Collection getUnindexFailures() { return Collections.unmodifiableCollection(this.failures); @@ -123,8 +130,8 @@ public Collection getNotFound() { return Collections.unmodifiableCollection(this.notFound); } - /** Return the total count of files which were requested to be unindexed, - * but were either not found or failed to unindex. + /** Returns the total count of errors reported during unindexing + * due to either not having been found or other failures. */ public long errorCount() { return this.failures.size() + this.notFound.size();