diff --git a/build.gradle b/build.gradle index adbe18fa..d7453849 100644 --- a/build.gradle +++ b/build.gradle @@ -300,7 +300,7 @@ dependencies { implementation 'com.unboundid.product.scim2:scim2-sdk-client:2.3.5' // Don't upgrade h2database - runtimeOnly "com.h2database:h2:2.3.232" + runtimeOnly "org.postgresql:postgresql:42.7.4" constraints { implementation "org.opensaml:opensaml-core:$openSamlVersion" implementation "org.opensaml:opensaml-saml-api:$openSamlVersion" diff --git a/src/main/java/stirling/software/SPDF/config/security/InitialSecuritySetup.java b/src/main/java/stirling/software/SPDF/config/security/InitialSecuritySetup.java index 3291021c..08356a83 100644 --- a/src/main/java/stirling/software/SPDF/config/security/InitialSecuritySetup.java +++ b/src/main/java/stirling/software/SPDF/config/security/InitialSecuritySetup.java @@ -20,6 +20,7 @@ public class InitialSecuritySetup { @Autowired private ApplicationProperties applicationProperties; + // todo: wip add Postgres here @Autowired private DatabaseBackupInterface databaseBackupHelper; @PostConstruct diff --git a/src/main/java/stirling/software/SPDF/config/security/database/DatabaseBackupHelper.java b/src/main/java/stirling/software/SPDF/config/security/database/DatabaseBackupHelper.java index 85cef66f..1da9b108 100644 --- a/src/main/java/stirling/software/SPDF/config/security/database/DatabaseBackupHelper.java +++ b/src/main/java/stirling/software/SPDF/config/security/database/DatabaseBackupHelper.java @@ -115,6 +115,7 @@ public class DatabaseBackupHelper implements DatabaseBackupInterface { return executeDatabaseScript(Paths.get(backupList.get(0).getFilePath())); } + // fixMe: Needs to check the type of DB before executing script @Override public void exportDatabase() throws IOException { // Check if the backup directory exists, and create it if it does not diff --git a/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java b/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java index fd7c278b..7d66574b 100644 --- a/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java +++ b/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java @@ -6,6 +6,7 @@ import java.net.HttpURLConnection; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; +import java.sql.Driver; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -247,6 +248,28 @@ public class ApplicationProperties { private String tessdataDir; private Boolean enableAlphaFunctionality; private String enableAnalytics; + private Datasource datasource; + } + + @Data + public static class Datasource { + private String url; + private Driver driver; + private String username; + private String password; + } + + public enum Driver { + H2("h2"), + POSTGRESQL("postgresql"), + ORACLE("oracle"), + MY_SQL("mysql"); + + private final String driverName; + + Driver(String driverName) { + this.driverName = driverName; + } } @Data diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 41cb3832..b789d768 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -41,13 +41,14 @@ spring.mvc.async.request-timeout=${SYSTEM_CONNECTIONTIMEOUTMILLISECONDS:1200000} #spring.thymeleaf.prefix=file:/customFiles/templates/,classpath:/templates/ #spring.thymeleaf.cache=false -spring.datasource.url=jdbc:h2:file:./configs/stirling-pdf-DB-2.3.232;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE -spring.datasource.driver-class-name=org.h2.Driver -spring.datasource.username=sa +spring.datasource.url=jdbc:postgresql://localhost:5432/stirling-pdf-DB +spring.datasource.driver-class-name=org.postgresql.Driver +spring.datasource.username=postgres spring.datasource.password= -spring.h2.console.enabled=false +spring.jpa.generate-ddl=true spring.jpa.hibernate.ddl-auto=update -server.servlet.session.timeout: 30m +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +server.servlet.session.timeout=30m # Change the default URL path for OpenAPI JSON springdoc.api-docs.path=/v1/api-docs diff --git a/src/main/resources/settings.yml.template b/src/main/resources/settings.yml.template index a110744a..dcd94080 100644 --- a/src/main/resources/settings.yml.template +++ b/src/main/resources/settings.yml.template @@ -85,6 +85,11 @@ system: customHTMLFiles: false # enable to have files placed in /customFiles/templates override the existing template HTML files tessdataDir: /usr/share/tessdata # path to the directory containing the Tessdata files. This setting is relevant for Windows systems. For Windows users, this path should be adjusted to point to the appropriate directory where the Tessdata files are stored. enableAnalytics: undefined # set to 'true' to enable analytics, set to 'false' to disable analytics; for enterprise users, this is set to true + datasource: + url: jdbc:postgresql://localhost:5432/stirling-pdf-DB + driver: postgresql + username: postgres + password: ui: appName: '' # application's visible name