mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-06 18:30:57 +00:00

# Description This pull request includes several changes aimed at improving the code structure and removing redundant code. The most significant changes involve reordering methods, removing unnecessary annotations, and refactoring constructors to use dependency injection. Autowired now comes via constructor (which also doesn't need autowired annotation as its done by default for configuration) ## Checklist - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have performed a self-review of my own code - [ ] I have attached images of the change if it is UI based - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] If my code has heavily changed functionality I have updated relevant docs on [Stirling-PDFs doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) - [ ] My changes generate no new warnings - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only)
43 lines
1.6 KiB
Java
43 lines
1.6 KiB
Java
package stirling.software.SPDF.controller.web;
|
|
|
|
import java.util.List;
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.core.Authentication;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import stirling.software.SPDF.config.security.database.DatabaseBackupHelper;
|
|
import stirling.software.SPDF.utils.FileInfo;
|
|
|
|
@Controller
|
|
@Tag(name = "Database Management", description = "Database management and security APIs")
|
|
public class DatabaseWebController {
|
|
|
|
private final DatabaseBackupHelper databaseBackupHelper;
|
|
|
|
public DatabaseWebController(DatabaseBackupHelper databaseBackupHelper) {
|
|
this.databaseBackupHelper = databaseBackupHelper;
|
|
}
|
|
|
|
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
|
@GetMapping("/database")
|
|
public String database(HttpServletRequest request, Model model, Authentication authentication) {
|
|
String error = request.getParameter("error");
|
|
String confirmed = request.getParameter("infoMessage");
|
|
if (error != null) {
|
|
model.addAttribute("error", error);
|
|
} else if (confirmed != null) {
|
|
model.addAttribute("infoMessage", confirmed);
|
|
}
|
|
List<FileInfo> backupList = databaseBackupHelper.getBackupList();
|
|
model.addAttribute("backupFiles", backupList);
|
|
model.addAttribute("databaseVersion", databaseBackupHelper.getH2Version());
|
|
return "database";
|
|
}
|
|
}
|