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

@@ -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();