2024-01-03 17:59:04 +00:00
|
|
|
package stirling.software.SPDF.config;
|
|
|
|
|
2024-01-09 21:13:35 -05:00
|
|
|
import java.io.IOException;
|
2024-01-09 22:39:21 +00:00
|
|
|
import java.nio.file.Files;
|
2024-05-25 00:22:01 +08:00
|
|
|
import java.nio.file.Path;
|
2024-01-09 22:39:21 +00:00
|
|
|
import java.nio.file.Paths;
|
2025-02-03 11:52:34 +01:00
|
|
|
import java.util.List;
|
2024-01-09 21:13:35 -05:00
|
|
|
import java.util.Properties;
|
2024-05-25 00:22:01 +08:00
|
|
|
import java.util.function.Predicate;
|
2024-01-09 21:13:35 -05:00
|
|
|
|
2025-03-20 08:53:29 +01:00
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
2024-04-21 22:16:39 +02:00
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
2024-04-27 11:03:57 +01:00
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
2024-01-03 17:59:04 +00:00
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
2024-04-27 11:03:57 +01:00
|
|
|
import org.springframework.context.annotation.Lazy;
|
2024-10-22 11:10:09 +01:00
|
|
|
import org.springframework.context.annotation.Scope;
|
2024-01-09 21:13:35 -05:00
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
|
import org.springframework.core.io.Resource;
|
2024-04-27 11:03:57 +01:00
|
|
|
import org.springframework.core.io.ResourceLoader;
|
|
|
|
import org.thymeleaf.spring6.SpringTemplateEngine;
|
2024-01-03 17:59:04 +00:00
|
|
|
|
Upload File Size Limit (#3334)
# Description of Changes
The change this PR aims to introduce is a setting for enabling an upload
file size limit. The author of the issue mentioned in this PR wanted
this feature as they themselves enforced a limit of 50MB file sizes on
their NGINX configuration.
This was implemented by adding an entry to the
[settings.yml.template](https://github.com/PedroPF1234/Stirling-PDF/blob/e52fc0e478e279169329b7e30782d57b2dbd8cbe/src/main/resources/settings.yml.template)
file. This entry has two sub-configurations in which you declare if the
application should enable upload file size limiting and then you declare
the limit itself.
For this to be available in code, a new field in the
[System](https://github.com/PedroPF1234/Stirling-PDF/blob/e52fc0e478e279169329b7e30782d57b2dbd8cbe/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java#L280)
class was added, one named `uploadLimit`.
After that, inside the [AppConfig](url) class, a new thymeleaf bean was
created, one called `uploadLimit`. This bean takes the values available
in the `System` class and creates a `long` value representing the limit
value. This value is interpreted as non-existent if it is `0`, otherwise
it is the value in `bytes` of the upload limit.
In order to make this value available in the
[common.html](https://github.com/PedroPF1234/Stirling-PDF/blob/e52fc0e478e279169329b7e30782d57b2dbd8cbe/src/main/resources/templates/fragments/common.html)
file, where the submitFile form is imported from, a new controller
[GlobalUploadLimitWebController](https://github.com/PedroPF1234/Stirling-PDF/blob/e52fc0e478e279169329b7e30782d57b2dbd8cbe/src/main/java/stirling/software/SPDF/controller/web/GlobalUploadLimitWebController.java)
was created. This controller has the tag `ControllerAdvice` so that
every controller has the `ModelAttributes` defined within it. I am not
sure if this was a good approach but upon first investigations, I
couldn't find another method to make these attributes available in every
Controller, or template. If there is already a place like this in the
code with this specific purpose, please let me know so I can fix it.
After making these attributes available, I updated the code in
`common.html`to now display the upload limit if it is defined. This was
done with localization in mind.
Lastly, the
[downloader.js](https://github.com/PedroPF1234/Stirling-PDF/blob/e52fc0e478e279169329b7e30782d57b2dbd8cbe/src/main/resources/static/js/downloader.js)
and
[fileInput.js](https://github.com/PedroPF1234/Stirling-PDF/blob/e52fc0e478e279169329b7e30782d57b2dbd8cbe/src/main/resources/static/js/fileInput.js)
files to include logic to enforce the upload limit if it is defined.
The UI updates, when the upload limit is defined, are as so:
<img width="708" alt="image"
src="https://github.com/user-attachments/assets/4852fa10-2ec3-45cb-83e6-41a102f256d4"
/>
When the limit is disabled, the page looks exactly as it did before any
implementation:
<img width="707" alt="image"
src="https://github.com/user-attachments/assets/21e5e810-ffdc-4a99-a16d-491aea103709"
/>\\
Thank you.
Closes #2903
---
## Checklist
### General
- [x] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [x] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md)
(if applicable)
- [x] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md)
(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](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [x] 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)
### UI Changes (if applicable)
- [x] 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](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing)
for more details.
---------
Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com>
2025-04-14 10:36:33 +01:00
|
|
|
import com.posthog.java.shaded.kotlin.text.Regex;
|
|
|
|
|
2024-12-17 10:26:18 +01:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2025-02-23 13:36:21 +00:00
|
|
|
|
2024-01-03 17:59:04 +00:00
|
|
|
import stirling.software.SPDF.model.ApplicationProperties;
|
|
|
|
|
|
|
|
@Configuration
|
2024-04-27 11:03:57 +01:00
|
|
|
@Lazy
|
2024-12-17 10:26:18 +01:00
|
|
|
@Slf4j
|
2024-01-03 17:59:04 +00:00
|
|
|
public class AppConfig {
|
|
|
|
|
2024-12-24 09:52:53 +00:00
|
|
|
private final ApplicationProperties applicationProperties;
|
|
|
|
|
|
|
|
public AppConfig(ApplicationProperties applicationProperties) {
|
|
|
|
this.applicationProperties = applicationProperties;
|
|
|
|
}
|
2024-01-03 17:59:04 +00:00
|
|
|
|
2024-04-27 11:03:57 +01:00
|
|
|
@Bean
|
2025-02-24 22:18:34 +00:00
|
|
|
@ConditionalOnProperty(name = "system.customHTMLFiles", havingValue = "true")
|
2024-04-27 11:03:57 +01:00
|
|
|
public SpringTemplateEngine templateEngine(ResourceLoader resourceLoader) {
|
|
|
|
SpringTemplateEngine templateEngine = new SpringTemplateEngine();
|
|
|
|
templateEngine.addTemplateResolver(new FileFallbackTemplateResolver(resourceLoader));
|
|
|
|
return templateEngine;
|
|
|
|
}
|
|
|
|
|
2024-01-03 17:59:04 +00:00
|
|
|
@Bean(name = "loginEnabled")
|
|
|
|
public boolean loginEnabled() {
|
|
|
|
return applicationProperties.getSecurity().getEnableLogin();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Bean(name = "appName")
|
|
|
|
public String appName() {
|
|
|
|
String homeTitle = applicationProperties.getUi().getAppName();
|
|
|
|
return (homeTitle != null) ? homeTitle : "Stirling PDF";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Bean(name = "appVersion")
|
|
|
|
public String appVersion() {
|
2024-01-09 21:13:35 -05:00
|
|
|
Resource resource = new ClassPathResource("version.properties");
|
|
|
|
Properties props = new Properties();
|
|
|
|
try {
|
|
|
|
props.load(resource.getInputStream());
|
|
|
|
return props.getProperty("version");
|
|
|
|
} catch (IOException e) {
|
2024-12-17 10:26:18 +01:00
|
|
|
log.error("exception", e);
|
2024-01-09 21:13:35 -05:00
|
|
|
}
|
|
|
|
return "0.0.0";
|
2024-01-03 17:59:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Bean(name = "homeText")
|
|
|
|
public String homeText() {
|
|
|
|
return (applicationProperties.getUi().getHomeDescription() != null)
|
|
|
|
? applicationProperties.getUi().getHomeDescription()
|
|
|
|
: "null";
|
|
|
|
}
|
|
|
|
|
2025-02-03 11:52:34 +01:00
|
|
|
@Bean(name = "languages")
|
|
|
|
public List<String> languages() {
|
|
|
|
return applicationProperties.getUi().getLanguages();
|
|
|
|
}
|
|
|
|
|
2025-03-20 08:53:29 +01:00
|
|
|
@Bean
|
|
|
|
public String contextPath(@Value("${server.servlet.context-path}") String contextPath) {
|
|
|
|
return contextPath;
|
|
|
|
}
|
|
|
|
|
2024-01-03 17:59:04 +00:00
|
|
|
@Bean(name = "navBarText")
|
|
|
|
public String navBarText() {
|
|
|
|
String defaultNavBar =
|
|
|
|
applicationProperties.getUi().getAppNameNavbar() != null
|
|
|
|
? applicationProperties.getUi().getAppNameNavbar()
|
|
|
|
: applicationProperties.getUi().getAppName();
|
|
|
|
return (defaultNavBar != null) ? defaultNavBar : "Stirling PDF";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Bean(name = "enableAlphaFunctionality")
|
|
|
|
public boolean enableAlphaFunctionality() {
|
|
|
|
return applicationProperties.getSystem().getEnableAlphaFunctionality() != null
|
|
|
|
? applicationProperties.getSystem().getEnableAlphaFunctionality()
|
|
|
|
: false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Bean(name = "rateLimit")
|
|
|
|
public boolean rateLimit() {
|
Improved Configuration and YAML Management (#2966)
# 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
- [x] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md)
(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](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] 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)
### 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](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing)
for more details.
---------
Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com>
2025-02-25 22:52:59 +01:00
|
|
|
String rateLimit = System.getProperty("rateLimit");
|
|
|
|
if (rateLimit == null) rateLimit = System.getenv("rateLimit");
|
|
|
|
return (rateLimit != null) ? Boolean.valueOf(rateLimit) : false;
|
2024-01-03 17:59:04 +00:00
|
|
|
}
|
2024-01-09 22:39:21 +00:00
|
|
|
|
|
|
|
@Bean(name = "RunningInDocker")
|
|
|
|
public boolean runningInDocker() {
|
|
|
|
return Files.exists(Paths.get("/.dockerenv"));
|
|
|
|
}
|
|
|
|
|
2024-12-18 18:04:10 +00:00
|
|
|
@Bean(name = "configDirMounted")
|
|
|
|
public boolean isRunningInDockerWithConfig() {
|
|
|
|
Path dockerEnv = Paths.get("/.dockerenv");
|
|
|
|
// default to true if not docker
|
|
|
|
if (!Files.exists(dockerEnv)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
Path mountInfo = Paths.get("/proc/1/mountinfo");
|
|
|
|
// this should always exist, if not some unknown usecase
|
|
|
|
if (!Files.exists(mountInfo)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
return Files.lines(mountInfo).anyMatch(line -> line.contains(" /configs "));
|
|
|
|
} catch (IOException e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-21 22:16:39 +02:00
|
|
|
@ConditionalOnMissingClass("stirling.software.SPDF.config.security.SecurityConfiguration")
|
2025-02-24 22:18:34 +00:00
|
|
|
@Bean(name = "activeSecurity")
|
|
|
|
public boolean missingActiveSecurity() {
|
2024-04-21 22:16:39 +02:00
|
|
|
return false;
|
|
|
|
}
|
2024-05-25 00:22:01 +08:00
|
|
|
|
|
|
|
@Bean(name = "directoryFilter")
|
2024-08-24 18:08:51 +02:00
|
|
|
public Predicate<Path> processOnlyFiles() {
|
2024-05-25 00:22:01 +08:00
|
|
|
return path -> {
|
|
|
|
if (Files.isDirectory(path)) {
|
2024-06-01 13:55:28 +01:00
|
|
|
return !path.toString().contains("processing");
|
2024-05-25 00:22:01 +08:00
|
|
|
} else {
|
2024-08-24 18:08:51 +02:00
|
|
|
return true;
|
2024-05-25 00:22:01 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2024-09-13 16:42:38 +01:00
|
|
|
|
|
|
|
@Bean(name = "termsAndConditions")
|
|
|
|
public String termsAndConditions() {
|
|
|
|
return applicationProperties.getLegal().getTermsAndConditions();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Bean(name = "privacyPolicy")
|
|
|
|
public String privacyPolicy() {
|
|
|
|
return applicationProperties.getLegal().getPrivacyPolicy();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Bean(name = "cookiePolicy")
|
|
|
|
public String cookiePolicy() {
|
|
|
|
return applicationProperties.getLegal().getCookiePolicy();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Bean(name = "impressum")
|
|
|
|
public String impressum() {
|
|
|
|
return applicationProperties.getLegal().getImpressum();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Bean(name = "accessibilityStatement")
|
|
|
|
public String accessibilityStatement() {
|
|
|
|
return applicationProperties.getLegal().getAccessibilityStatement();
|
|
|
|
}
|
2024-10-14 22:34:41 +01:00
|
|
|
|
|
|
|
@Bean(name = "analyticsPrompt")
|
2024-10-22 11:10:09 +01:00
|
|
|
@Scope("request")
|
2024-10-14 22:34:41 +01:00
|
|
|
public boolean analyticsPrompt() {
|
Improved Configuration and YAML Management (#2966)
# 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
- [x] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md)
(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](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] 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)
### 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](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing)
for more details.
---------
Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com>
2025-02-25 22:52:59 +01:00
|
|
|
return applicationProperties.getSystem().getEnableAnalytics() == null;
|
2024-10-14 22:34:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Bean(name = "analyticsEnabled")
|
2024-10-22 11:10:09 +01:00
|
|
|
@Scope("request")
|
2024-10-14 22:34:41 +01:00
|
|
|
public boolean analyticsEnabled() {
|
2025-03-25 17:57:17 +00:00
|
|
|
if (applicationProperties.getPremium().isEnabled()) return true;
|
Improved Configuration and YAML Management (#2966)
# 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
- [x] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [ ] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md)
(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](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] 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)
### 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](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing)
for more details.
---------
Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com>
2025-02-25 22:52:59 +01:00
|
|
|
return applicationProperties.getSystem().isAnalyticsEnabled();
|
2024-10-14 22:34:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Bean(name = "StirlingPDFLabel")
|
|
|
|
public String stirlingPDFLabel() {
|
|
|
|
return "Stirling-PDF" + " v" + appVersion();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Bean(name = "UUID")
|
|
|
|
public String uuid() {
|
|
|
|
return applicationProperties.getAutomaticallyGenerated().getUUID();
|
|
|
|
}
|
2024-01-03 17:59:04 +00:00
|
|
|
}
|