mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-22 04:09:22 +00:00
fixes
This commit is contained in:
parent
af4e20c971
commit
b72deaebf0
@ -14,17 +14,16 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.util.HtmlUtils;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import stirling.software.common.configuration.InstallationPathConfig;
|
||||
import stirling.software.common.model.ApplicationProperties;
|
||||
import stirling.software.common.util.GeneralUtils;
|
||||
import stirling.software.proprietary.security.model.api.admin.SettingValueResponse;
|
||||
@ -39,10 +38,18 @@ import stirling.software.proprietary.security.model.api.admin.UpdateSettingsRequ
|
||||
@Slf4j
|
||||
public class AdminSettingsController {
|
||||
|
||||
private static final java.util.Set<String> VALID_SECTIONS = java.util.Set.of(
|
||||
"security", "system", "ui", "endpoints", "metrics", "mail",
|
||||
"premium", "processExecutor", "autoPipeline", "legal"
|
||||
);
|
||||
private static final java.util.Set<String> VALID_SECTIONS =
|
||||
java.util.Set.of(
|
||||
"security",
|
||||
"system",
|
||||
"ui",
|
||||
"endpoints",
|
||||
"metrics",
|
||||
"mail",
|
||||
"premium",
|
||||
"processExecutor",
|
||||
"autoPipeline",
|
||||
"legal");
|
||||
|
||||
private final ApplicationProperties applicationProperties;
|
||||
|
||||
@ -78,7 +85,8 @@ public class AdminSettingsController {
|
||||
responseCode = "500",
|
||||
description = "Failed to save settings to configuration file")
|
||||
})
|
||||
public ResponseEntity<String> updateSettings(@Valid @RequestBody UpdateSettingsRequest request) {
|
||||
public ResponseEntity<String> updateSettings(
|
||||
@Valid @RequestBody UpdateSettingsRequest request) {
|
||||
try {
|
||||
Map<String, Object> settings = request.getSettings();
|
||||
|
||||
@ -195,8 +203,7 @@ public class AdminSettingsController {
|
||||
.body("Failed to save settings to configuration file.");
|
||||
} catch (Exception e) {
|
||||
log.error("Unexpected error while updating section settings: {}", e.getMessage(), e);
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||
.body("Invalid section data.");
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Invalid section data.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,7 +226,8 @@ public class AdminSettingsController {
|
||||
try {
|
||||
Object value = getSettingByKey(key);
|
||||
if (value == null) {
|
||||
return ResponseEntity.badRequest().body("Setting key not found: " + HtmlUtils.htmlEscape(key));
|
||||
return ResponseEntity.badRequest()
|
||||
.body("Setting key not found: " + HtmlUtils.htmlEscape(key));
|
||||
}
|
||||
log.debug("Admin requested setting: {}", key);
|
||||
return ResponseEntity.ok(new SettingValueResponse(key, value));
|
||||
|
@ -0,0 +1,22 @@
|
||||
package stirling.software.proprietary.security.model.api.admin;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "Response containing a setting key and its current value")
|
||||
public class SettingValueResponse {
|
||||
|
||||
@Schema(
|
||||
description = "The setting key in dot notation (e.g., 'system.enableAnalytics')",
|
||||
example = "system.enableAnalytics")
|
||||
private String key;
|
||||
|
||||
@Schema(description = "The current value of the setting", example = "true")
|
||||
private Object value;
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package stirling.software.proprietary.security.model.api.admin;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Schema(description = "Request to update a single setting value")
|
||||
public class UpdateSettingValueRequest {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "The new value for the setting", example = "false")
|
||||
private Object value;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package stirling.software.proprietary.security.model.api.admin;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@Schema(description = "Request to update multiple application settings using delta updates")
|
||||
public class UpdateSettingsRequest {
|
||||
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
@Schema(
|
||||
description =
|
||||
"Map of setting keys to their new values using dot notation. Only changed values need to be included for delta updates.",
|
||||
example = "{\"system.enableAnalytics\": false, \"ui.appName\": \"My PDF Tool\"}")
|
||||
private Map<String, Object> settings;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user