Skip to content

Commit 6c4cd02

Browse files
committed
feat: return operation details from setAllFromJson in SettingsServiceBean after bulk operation #11639
1 parent 34ad442 commit 6c4cd02

2 files changed

Lines changed: 14 additions & 13 deletions

File tree

src/main/java/edu/harvard/iq/dataverse/api/Admin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ public Response putAllSettings(JsonObject settings) {
226226
}
227227

228228
// Transfer to domain objects and deeper validation to be handled by the service layer.
229-
settingsSvc.setAllFromJson(settings);
230-
return ok("All database options successfully updated.");
229+
JsonObjectBuilder successfullOperations = settingsSvc.setAllFromJson(settings);
230+
return ok("All database options successfully updated.", successfullOperations);
231231

232232
} catch (IllegalArgumentException iae) {
233233
return error(Response.Status.BAD_REQUEST, iae.getMessage());

src/main/java/edu/harvard/iq/dataverse/settings/SettingsServiceBean.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,17 +1104,16 @@ public JsonObject listAllAsJson() {
11041104
}
11051105

11061106
/**
1107-
* Updates all settings by replacing them with the settings provided in the given JSON object.
1108-
* This method validates the keys and values from the JSON object, converts them into
1109-
* a list of Setting objects, and performs an atomic update of the internal settings.
1107+
* Updates all current settings from the specified JSON object. Validates the input JSON,
1108+
* converts it to a set of settings, and replaces all existing settings with the new ones
1109+
* in an atomic operation. If the settings object is null, contains invalid keys, or if the new
1110+
* set of settings is empty, the method throws an appropriate exception.
11101111
*
1111-
* @param settings a JsonObject containing the new settings to apply.
1112-
* Each key corresponds to a setting name, and each value corresponds
1113-
* to its respective value. The keys and values will be validated before
1114-
* applying the updates.
1115-
* @throws IllegalArgumentException if the JSON object contains invalid keys or invalid settings.
1112+
* @param settings the JSON object containing the new configuration settings to be applied; must not be null
1113+
* @return a JsonObjectBuilder representing the operational details of the applied updates
1114+
* @throws IllegalArgumentException if the settings object is null, contains invalid keys, or results in empty settings
11161115
*/
1117-
public void setAllFromJson(JsonObject settings) {
1116+
public JsonObjectBuilder setAllFromJson(JsonObject settings) {
11181117
if (settings == null) {
11191118
throw new IllegalArgumentException("Settings cannot be null");
11201119
}
@@ -1128,8 +1127,10 @@ public void setAllFromJson(JsonObject settings) {
11281127
// Convert JSON to Setting objects
11291128
Set<Setting> newSettings = convertJsonToSettings(settings);
11301129

1131-
// Perform atomic update (replace all settings)
1132-
replaceAllSettings(newSettings);
1130+
// Execute the update (in one atomic operation using a transaction)
1131+
Map<Setting, Op> operationalDetails = replaceAllSettings(newSettings);
1132+
1133+
return Op.convertToJson(operationalDetails);
11331134
}
11341135

11351136
/**

0 commit comments

Comments
 (0)