major refactoring: working towards more interface-implementation splitting

This commit is contained in:
2025-07-10 10:56:03 +02:00
parent d68dc991d0
commit 21812d2b42
22 changed files with 168 additions and 84 deletions

View File

@@ -3,6 +3,13 @@ package de.srsoftware.umbrella.message;
public class Constants {
public static final String AUTH = "mail.smtp.auth";
public static final String CONFIG_DB = "umbrella.modules.message.database";
public static final String CONFIG_SMTP_HOST = "umbrella.modules.message.smtp.host";
public static final String CONFIG_SMTP_PASS = "umbrella.modules.message.smtp.pass";
public static final String CONFIG_SMTP_PORT = "umbrella.modules.message.smtp.port";
public static final String CONFIG_SMTP_USER = "umbrella.modules.message.smtp.user";
public static final String DEBUG_ADDREESS = "debug_addres";
public static final String ENVELOPE_FROM = "mail.smtp.from";
public static final String FIELD_MESSAGES = "messages";
@@ -13,7 +20,6 @@ public class Constants {
public static final String JSONOBJECT = "json object";
public static final String PORT = "mail.smtp.port";
public static final String RECEIVERS = "receivers";
public static final String SMTP = "smtp";
public static final String SSL = "mail.smtp.ssl.enable";
public static final String SUBMISSION = "submission";

View File

@@ -2,6 +2,7 @@
package de.srsoftware.umbrella.message;
import static de.srsoftware.tools.PathHandler.CONTENT_TYPE;
import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.message.Constants.*;
import static java.lang.System.Logger.Level.*;
@@ -68,15 +69,16 @@ public class MessageSystem implements PostBox {
private final HashMap<Receiver,List<Exception>> exceptions = new HashMap<>();
private final Translator translator;
public MessageSystem(SqliteMessageDb messageDb, Translator translator, Configuration config) {
db = messageDb;
public MessageSystem(Translator translator, Configuration config) throws UmbrellaException {
var messageDbFile = config.get(CONFIG_DB).orElseThrow(() -> new UmbrellaException(500,ERROR_MISSING_CONFIG,CONFIG_DB));
db = new SqliteMessageDb(connect(messageDbFile));
this.translator = translator;
debugAddress = config.get(DEBUG_ADDREESS).map(Object::toString).orElse(null);
config = config.subset(SMTP).orElseThrow(() -> new RuntimeException("umbrella.modules.message.smtp not configured!"));
port = config.get(FIELD_PORT,587);
host = config.get(FIELD_HOST).map(Object::toString).orElseThrow(() -> new RuntimeException("umbrella.modules.message.smtp.host not configured!"));
user = config.get(USER).map(Object::toString).orElseThrow(() -> new RuntimeException("umbrella.modules.message.smtp.user not configured!"));
pass = config.get(PASS).map(Object::toString).orElseThrow(() -> new RuntimeException("umbrella.modules.message.smtp.pass not configured!"));
port = config.get(CONFIG_SMTP_PORT,587);
host = config.get(CONFIG_SMTP_HOST).map(Object::toString).orElseThrow(() -> new RuntimeException("umbrella.modules.message.smtp.host not configured!"));
user = config.get(CONFIG_SMTP_USER).map(Object::toString).orElseThrow(() -> new RuntimeException("umbrella.modules.message.smtp.user not configured!"));
pass = config.get(CONFIG_SMTP_PASS).map(Object::toString).orElseThrow(() -> new RuntimeException("umbrella.modules.message.smtp.pass not configured!"));
from = user;
new SubmissionTask(8).schedule();
new SubmissionTask(10).schedule();