Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Configuration and YAML Management #2966

Merged
merged 14 commits into from
Feb 25, 2025
Merged

Conversation

Ludy87
Copy link
Contributor

@Ludy87 Ludy87 commented Feb 16, 2025

Description of Changes

What was changed:

  • Configuration Updates:
    Replaced all calls to GeneralUtils.saveKeyToConfig with the new GeneralUtils.saveKeyToSettings method 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 in SPDFApplication by creating Path objects from string paths and logging these paths for clarity. Also refined exception handling by catching more specific exceptions (e.g., using IOException instead of a generic Exception).

  • Analytics Flag and Rate Limiting:
    Changed the analytics flag in the application properties from a String to a Boolean, and updated related logic in AppConfig and PostHogService. The rate-limiting property retrieval in AppConfig was also refined for clarity.

  • YAML Configuration Management:
    Replaced the previous manual, line-based YAML merging logic in ConfigInitializer with a new YamlHelper class. 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 new YamlHelper class 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 new YamlHelper required 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

Documentation

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)

  • I have tested my changes locally. Refer to the Testing Guide for more details.

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Feb 16, 2025
@github-actions github-actions bot added Java Pull requests that update Java code Back End Issues related to back-end development API API-related issues or pull requests labels Feb 16, 2025
@Ludy87
Copy link
Contributor Author

Ludy87 commented Feb 16, 2025

/deploypr

@Ludy87 Ludy87 changed the title Config rework # PR: Improved Configuration and YAML Management Feb 16, 2025
@Ludy87 Ludy87 changed the title # PR: Improved Configuration and YAML Management Improved Configuration and YAML Management Feb 16, 2025
@Ludy87
Copy link
Contributor Author

Ludy87 commented Feb 18, 2025

/deploypr

@Frooodle
Copy link
Member

/deploypr
fixed now haha

Copy link
Contributor

🚀 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.

@Frooodle
Copy link
Member

/deploypr

Copy link
Contributor

🚀 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.

@Ludy87
Copy link
Contributor Author

Ludy87 commented Feb 25, 2025

/deploypr

Copy link
Contributor

🚀 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.

@Frooodle Frooodle merged commit ac10c9f into Stirling-Tools:main Feb 25, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API API-related issues or pull requests Back End Issues related to back-end development Java Pull requests that update Java code size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants