Improved Configuration and YAML Management
Description of Changes
What was changed:
-
Configuration Updates:
Replaced all calls toGeneralUtils.saveKeyToConfigwith the newGeneralUtils.saveKeyToSettingsmethod across multiple classes (e.g.,LicenseKeyChecker,InitialSetup,SettingsController, etc.). This update ensures consistent management of configuration settings. -
File Path and Exception Handling:
Updated file path handling inSPDFApplicationby creatingPathobjects from string paths and logging these paths for clarity. Also refined exception handling by catching more specific exceptions (e.g., usingIOExceptioninstead of a genericException). -
Analytics Flag and Rate Limiting:
Changed the analytics flag in the application properties from aStringto aBoolean, and updated related logic inAppConfigandPostHogService. The rate-limiting property retrieval inAppConfigwas also refined for clarity. -
YAML Configuration Management:
Replaced the previous manual, line-based YAML merging logic inConfigInitializerwith a newYamlHelperclass. This helper leverages the SnakeYAML engine to load, update, and save YAML configurations more robustly while preserving comments and formatting.
Why the change was made:
-
Improved Maintainability:
Consolidating configuration update logic into a single utility method (saveKeyToSettings) reduces code duplication and simplifies future maintenance. -
Enhanced Robustness:
The newYamlHelperclass ensures that configuration files are merged accurately and safely, minimizing risks of data loss or format corruption. -
Better Type Safety and Exception Handling:
Switching the analytics flag to a Boolean and refining exception handling improves code robustness and debugging efficiency. -
Clarity and Consistency:
Standardizing file path handling and logging practices enhances code readability across the project.
Challenges encountered:
-
YAML Merging Complexity:
Integrating the newYamlHelperrequired careful handling to preserve existing settings, comments, and formatting during merges. -
Type Conversion and Backward Compatibility:
Updating the analytics flag from a string to a Boolean required extensive testing to ensure backward compatibility and proper functionality. -
Exception Granularity:
Refactoring exception handling from a generic to a more specific approach involved a detailed review to cover all edge cases.
Closes #<issue_number>
Checklist
- [x] I have read the Contribution Guidelines
- [ ] I have read the Stirling-PDF Developer Guide (if applicable)
- [ ] I have read the How to add new languages to Stirling-PDF (if applicable)
- [x] I have performed a self-review of my own code
- [x] My changes generate no new warnings
Documentation
- [ ] I have updated relevant docs on Stirling-PDF's doc repo (if functionality has heavily changed)
- [ ] I have read the section Add New Translation Tags (for new translation tags only)
UI Changes (if applicable)
- [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR)
Testing (if applicable)
- [x] I have tested my changes locally. Refer to the Testing Guide for more details.
/deploypr
/deploypr
/deploypr fixed now haha
🚀 PR Test Deployment
Your PR has been deployed for testing!
🔗 Test URL: http://185.252.234.121:2966
This deployment will be automatically cleaned up when the PR is closed.
/deploypr
🚀 PR Test Deployment
Your PR has been deployed for testing!
🔗 Test URL: http://185.252.234.121:2966
This deployment will be automatically cleaned up when the PR is closed.
/deploypr
🚀 PR Test Deployment
Your PR has been deployed for testing!
🔗 Test URL: http://185.252.234.121:2966
This deployment will be automatically cleaned up when the PR is closed.