2023-08-13 02:15:26 +02:00
|
|
|
package stirling.software.SPDF.config;
|
|
|
|
|
2023-08-26 18:30:49 +02:00
|
|
|
import java.util.Arrays;
|
|
|
|
|
2023-08-26 13:27:52 +02:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
2023-08-13 02:15:26 +02:00
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
2023-08-26 13:27:52 +02:00
|
|
|
import org.springframework.core.env.Environment;
|
2023-08-13 02:15:26 +02:00
|
|
|
|
2023-08-26 18:30:49 +02:00
|
|
|
import stirling.software.SPDF.utils.PropertyConfigs;
|
|
|
|
import stirling.software.SPDF.model.ApplicationProperties;
|
2023-08-13 02:15:26 +02:00
|
|
|
@Configuration
|
|
|
|
public class AppConfig {
|
2023-08-26 13:27:52 +02:00
|
|
|
|
2023-08-26 18:30:49 +02:00
|
|
|
@Autowired
|
|
|
|
ApplicationProperties applicationProperties;
|
|
|
|
|
2023-08-26 13:27:52 +02:00
|
|
|
@Bean(name = "loginEnabled")
|
2023-08-13 02:15:26 +02:00
|
|
|
public boolean loginEnabled() {
|
2023-08-26 18:30:49 +02:00
|
|
|
System.out.println(applicationProperties.toString());
|
|
|
|
return applicationProperties.getSecurity().getEnableLogin();
|
2023-08-13 02:15:26 +02:00
|
|
|
}
|
2023-08-26 13:27:52 +02:00
|
|
|
|
2023-08-13 02:15:26 +02:00
|
|
|
@Bean(name = "appName")
|
|
|
|
public String appName() {
|
2023-08-27 00:33:35 +02:00
|
|
|
String homeTitle = applicationProperties.getUi().getHomeName();
|
|
|
|
return (homeTitle != null) ? homeTitle : "Stirling PDF";
|
2023-08-13 02:15:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Bean(name = "appVersion")
|
|
|
|
public String appVersion() {
|
|
|
|
String version = getClass().getPackage().getImplementationVersion();
|
|
|
|
return (version != null) ? version : "0.0.0";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Bean(name = "homeText")
|
|
|
|
public String homeText() {
|
2023-08-27 00:45:43 +02:00
|
|
|
return (applicationProperties.getUi().getHomeDescription() != null) ? applicationProperties.getUi().getHomeDescription() : "null";
|
2023-08-13 02:15:26 +02:00
|
|
|
}
|
|
|
|
|
2023-08-26 18:30:49 +02:00
|
|
|
|
2023-08-13 02:15:26 +02:00
|
|
|
@Bean(name = "navBarText")
|
|
|
|
public String navBarText() {
|
2023-08-26 18:30:49 +02:00
|
|
|
String defaultNavBar = applicationProperties.getUi().getNavbarName() != null ? applicationProperties.getUi().getNavbarName() : applicationProperties.getUi().getHomeName();
|
2023-08-27 00:33:35 +02:00
|
|
|
return (defaultNavBar != null) ? defaultNavBar : "Stirling PDF";
|
2023-08-26 13:27:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Bean(name = "rateLimit")
|
|
|
|
public boolean rateLimit() {
|
|
|
|
String appName = System.getProperty("rateLimit");
|
|
|
|
if (appName == null)
|
|
|
|
appName = System.getenv("rateLimit");
|
|
|
|
System.out.println("rateLimit=" + appName);
|
|
|
|
return (appName != null) ? Boolean.valueOf(appName) : false;
|
2023-08-13 02:15:26 +02:00
|
|
|
}
|
2023-08-26 13:27:52 +02:00
|
|
|
|
|
|
|
|
2023-03-20 22:55:11 +01:00
|
|
|
}
|