Skip to content

Commit

Permalink
Merge branch 'main' into bug/2490/2488/image-to-pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
reecebrowne authored Dec 18, 2024
2 parents 9eed761 + b0daac2 commit a72615c
Show file tree
Hide file tree
Showing 105 changed files with 535 additions and 547 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,7 @@
"editor.indentSize": "tabSize",
"editor.stickyScroll.enabled": false,
"editor.minimap.enabled": false,
"editor.formatOnSave": true
"editor.formatOnSave": true,
"java.format.settings.google.mode": "jar-file",
"java.format.settings.google.extra": "--aosp --skip-sorting-imports"
}
7 changes: 0 additions & 7 deletions DATABASE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# New Database Backup and Import Functionality

> [!IMPORTANT]
> **Full activation will take place on approximately January 5th, 2025!**
Why is the waiting time six months?

There are users who only install updates sporadically; if they skip the preparation, it can/will lead to data loss in the database.

## Functionality Overview

The newly introduced feature enhances the application with robust database backup and import capabilities. This feature is designed to ensure data integrity and provide a straightforward way to manage database backups. Here's how it works:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Stirling-PDF currently supports 38 languages!
| English (English) (en_GB) | ![100%](https://geps.dev/progress/100) |
| English (US) (en_US) | ![100%](https://geps.dev/progress/100) |
| French (Français) (fr_FR) | ![92%](https://geps.dev/progress/92) |
| German (Deutsch) (de_DE) | ![99%](https://geps.dev/progress/99) |
| German (Deutsch) (de_DE) | ![100%](https://geps.dev/progress/100) |
| Greek (Ελληνικά) (el_GR) | ![90%](https://geps.dev/progress/90) |
| Hindi (हिंदी) (hi_IN) | ![88%](https://geps.dev/progress/88) |
| Hungarian (Magyar) (hu_HU) | ![91%](https://geps.dev/progress/91) |
Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ ext {
imageioVersion = "3.12.0"
lombokVersion = "1.18.36"
bouncycastleVersion = "1.79"
springSecuritySamlVersion = "6.4.1"
springSecuritySamlVersion = "6.4.2"
openSamlVersion = "4.3.2"
}

group = "stirling.software"
version = "0.36.3"
version = "0.36.4"


java {
Expand Down Expand Up @@ -247,7 +247,7 @@ spotless {
java {
target project.fileTree('src/main/java')

googleJavaFormat("1.22.0").aosp().reorderImports(false)
googleJavaFormat("1.25.2").aosp().reorderImports(false)

importOrder("java", "javax", "org", "com", "net", "io")
toggleOffOn()
Expand Down Expand Up @@ -278,9 +278,9 @@ dependencies {
}

//security updates
implementation "org.springframework:spring-webmvc:6.2.0"
implementation "org.springframework:spring-webmvc:6.2.1"

implementation("io.github.pixee:java-security-toolkit:1.2.0")
implementation("io.github.pixee:java-security-toolkit:1.2.1")

// implementation "org.yaml:snakeyaml:2.2"
implementation 'com.github.Carleslc.Simple-YAML:Simple-Yaml:1.8.4'
Expand Down Expand Up @@ -372,7 +372,7 @@ dependencies {
implementation "org.bouncycastle:bcprov-jdk18on:$bouncycastleVersion"
implementation "org.bouncycastle:bcpkix-jdk18on:$bouncycastleVersion"
implementation "org.springframework.boot:spring-boot-starter-actuator:$springBootVersion"
implementation "io.micrometer:micrometer-core:1.14.1"
implementation "io.micrometer:micrometer-core:1.14.2"
implementation group: "com.google.zxing", name: "core", version: "3.5.3"
// https://mvnrepository.com/artifact/org.commonmark/commonmark
implementation "org.commonmark:commonmark:0.24.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.github.pixee.security.SystemCommand;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class LibreOfficeListener {

private static final Logger logger = LoggerFactory.getLogger(LibreOfficeListener.class);
private static final long ACTIVITY_TIMEOUT = 20L * 60 * 1000; // 20 minutes

private static final LibreOfficeListener INSTANCE = new LibreOfficeListener();
Expand Down Expand Up @@ -87,7 +83,7 @@ public void start() throws IOException {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
logger.error("exception", e);
log.error("exception", e);
} // Check every 1 second
}
}
Expand Down
21 changes: 9 additions & 12 deletions src/main/java/stirling/software/SPDF/SPdfApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

import javax.swing.*;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
Expand All @@ -23,6 +21,7 @@
import org.springframework.scheduling.annotation.EnableScheduling;

import io.github.pixee.security.SystemCommand;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -35,8 +34,6 @@
@Slf4j
public class SPdfApplication {

private static final Logger logger = LoggerFactory.getLogger(SPdfApplication.class);

@Autowired private Environment env;
@Autowired ApplicationProperties applicationProperties;

Expand Down Expand Up @@ -95,7 +92,7 @@ public static void main(String[] args) throws IOException, InterruptedException
if (Files.exists(Paths.get("configs/settings.yml"))) {
propertyFiles.put("spring.config.additional-location", "file:configs/settings.yml");
} else {
logger.warn("External configuration file 'configs/settings.yml' does not exist.");
log.warn("External configuration file 'configs/settings.yml' does not exist.");
}

if (Files.exists(Paths.get("configs/custom_settings.yml"))) {
Expand All @@ -108,7 +105,7 @@ public static void main(String[] args) throws IOException, InterruptedException
"spring.config.additional-location",
existingLocation + "file:configs/custom_settings.yml");
} else {
logger.warn("Custom configuration file 'configs/custom_settings.yml' does not exist.");
log.warn("Custom configuration file 'configs/custom_settings.yml' does not exist.");
}
Properties finalProps = new Properties();

Expand All @@ -131,16 +128,16 @@ public static void main(String[] args) throws IOException, InterruptedException
Files.createDirectories(Path.of("customFiles/static/"));
Files.createDirectories(Path.of("customFiles/templates/"));
} catch (Exception e) {
logger.error("Error creating directories: {}", e.getMessage());
log.error("Error creating directories: {}", e.getMessage());
}

printStartupLogs();
}

private static void printStartupLogs() {
logger.info("Stirling-PDF Started.");
log.info("Stirling-PDF Started.");
String url = baseUrlStatic + ":" + getStaticPort();
logger.info("Navigate to {}", url);
log.info("Navigate to {}", url);
}

@Autowired(required = false)
Expand All @@ -154,7 +151,7 @@ public void init() {
&& Boolean.parseBoolean(System.getProperty("STIRLING_PDF_DESKTOP_UI", "false"))) {
webBrowser.initWebUI(url);
} else {
String browserOpenEnv = env.getProperty("BROWSER_OPEN");
String browserOpenEnv = env.getProperty("BROWSER_OPEN");
boolean browserOpen = browserOpenEnv != null && "true".equalsIgnoreCase(browserOpenEnv);
if (browserOpen) {
try {
Expand All @@ -169,11 +166,11 @@ public void init() {
SystemCommand.runCommand(rt, "xdg-open " + url);
}
} catch (Exception e) {
logger.error("Error opening browser: {}", e.getMessage());
log.error("Error opening browser: {}", e.getMessage());
}
}
}
logger.info("Running configs {}", applicationProperties.toString());
log.info("Running configs {}", applicationProperties.toString());
}

@PreDestroy
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/stirling/software/SPDF/config/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import java.util.Properties;
import java.util.function.Predicate;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand All @@ -21,14 +19,14 @@
import org.springframework.core.io.ResourceLoader;
import org.thymeleaf.spring6.SpringTemplateEngine;

import lombok.extern.slf4j.Slf4j;
import stirling.software.SPDF.model.ApplicationProperties;

@Configuration
@Lazy
@Slf4j
public class AppConfig {

private static final Logger logger = LoggerFactory.getLogger(AppConfig.class);

@Autowired ApplicationProperties applicationProperties;

@Bean
Expand Down Expand Up @@ -61,7 +59,7 @@ public String appVersion() {
props.load(resource.getInputStream());
return props.getProperty("version");
} catch (IOException e) {
logger.error("exception", e);
log.error("exception", e);
}
return "0.0.0";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
import org.simpleyaml.configuration.file.YamlFile;
import org.simpleyaml.configuration.implementation.SimpleYamlImplementation;
import org.simpleyaml.configuration.implementation.snakeyaml.lib.DumperOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class ConfigInitializer
implements ApplicationContextInitializer<ConfigurableApplicationContext> {

private static final Logger logger = LoggerFactory.getLogger(ConfigInitializer.class);

@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
try {
Expand Down Expand Up @@ -149,7 +148,7 @@ private void changeConfigItemFromCommentToKeyValue(
.commentSide(settingsTemplateFile.getComment(path, CommentType.SIDE));
} else {
// Log if the key is not found in both YAML files
logger.info("Key not found in both YAML files: " + path);
log.info("Key not found in both YAML files: " + path);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Service;

import lombok.extern.slf4j.Slf4j;
import stirling.software.SPDF.model.ApplicationProperties;

@Service
@Slf4j
@DependsOn({"bookAndHtmlFormatsInstalled"})
public class EndpointConfiguration {
private static final Logger logger = LoggerFactory.getLogger(EndpointConfiguration.class);

private Map<String, Boolean> endpointStatuses = new ConcurrentHashMap<>();
private Map<String, Set<String>> endpointGroups = new ConcurrentHashMap<>();

Expand All @@ -43,7 +43,7 @@ public void enableEndpoint(String endpoint) {

public void disableEndpoint(String endpoint) {
if (!endpointStatuses.containsKey(endpoint) || endpointStatuses.get(endpoint) != false) {
logger.debug("Disabling {}", endpoint);
log.debug("Disabling {}", endpoint);
endpointStatuses.put(endpoint, false);
}
}
Expand Down Expand Up @@ -87,7 +87,7 @@ public void logDisabledEndpointsSummary() {
.collect(Collectors.toList());

if (!disabledList.isEmpty()) {
logger.info(
log.info(
"Total disabled endpoints: {}. Disabled endpoints: {}",
disabledList.size(),
String.join(", ", disabledList));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import stirling.software.SPDF.utils.FileInfo;

public interface DatabaseBackupInterface {

void exportDatabase() throws IOException;

boolean importDatabase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import java.util.Optional;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.authentication.LockedException;
import org.springframework.security.oauth2.client.oidc.userinfo.OidcUserRequest;
import org.springframework.security.oauth2.client.oidc.userinfo.OidcUserService;
Expand All @@ -13,13 +11,15 @@
import org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser;
import org.springframework.security.oauth2.core.oidc.user.OidcUser;

import lombok.extern.slf4j.Slf4j;
import stirling.software.SPDF.config.security.LoginAttemptService;
import stirling.software.SPDF.config.security.UserService;
import stirling.software.SPDF.model.ApplicationProperties;
import stirling.software.SPDF.model.ApplicationProperties.Security.OAUTH2;
import stirling.software.SPDF.model.ApplicationProperties.Security.OAUTH2.Client;
import stirling.software.SPDF.model.User;

@Slf4j
public class CustomOAuth2UserService implements OAuth2UserService<OidcUserRequest, OidcUser> {

private final OidcUserService delegate = new OidcUserService();
Expand All @@ -30,8 +30,6 @@ public class CustomOAuth2UserService implements OAuth2UserService<OidcUserReques

private ApplicationProperties applicationProperties;

private static final Logger logger = LoggerFactory.getLogger(CustomOAuth2UserService.class);

public CustomOAuth2UserService(
ApplicationProperties applicationProperties,
UserService userService,
Expand Down Expand Up @@ -82,10 +80,10 @@ public OidcUser loadUser(OidcUserRequest userRequest) throws OAuth2Authenticatio
user.getUserInfo(),
usernameAttribute);
} catch (IllegalArgumentException e) {
logger.error("Error loading OIDC user: {}", e.getMessage());
log.error("Error loading OIDC user: {}", e.getMessage());
throw new OAuth2AuthenticationException(new OAuth2Error(e.getMessage()), e);
} catch (Exception e) {
logger.error("Unexpected error loading OIDC user", e);
log.error("Unexpected error loading OIDC user", e);
throw new OAuth2AuthenticationException("Unexpected error during authentication");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import org.apache.pdfbox.pdmodel.PDPageContentStream.AppendMode;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ModelAttribute;
Expand All @@ -33,8 +31,6 @@
@Tag(name = "General", description = "General APIs")
public class CropController {

private static final Logger logger = LoggerFactory.getLogger(CropController.class);

private final CustomPDDocumentFactory pdfDocumentFactory;

private final PostHogService postHogService;
Expand Down
Loading

0 comments on commit a72615c

Please sign in to comment.