overhauling constants, working on translations
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -3,8 +3,8 @@ 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.core.exceptions.UmbrellaException.missingConfigException;
|
||||
import static de.srsoftware.umbrella.core.constants.Constants.UTF8;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingConfig;
|
||||
import static de.srsoftware.umbrella.message.Constants.*;
|
||||
import static java.lang.System.Logger.Level.*;
|
||||
|
||||
@@ -72,7 +72,7 @@ public class MessageSystem implements PostBox {
|
||||
private final HashMap<Receiver,List<Exception>> exceptions = new HashMap<>();
|
||||
|
||||
public MessageSystem(Configuration config) throws UmbrellaException {
|
||||
var dbFile = config.get(CONFIG_DB).orElseThrow(() -> missingConfigException(CONFIG_DB));
|
||||
var dbFile = config.get(CONFIG_DB).orElseThrow(() -> missingConfig(CONFIG_DB));
|
||||
db = new SqliteMessageDb(connect(dbFile));
|
||||
debugAddress = config.get(DEBUG_ADDREESS).map(Object::toString).orElse(null);
|
||||
port = config.get(CONFIG_SMTP_PORT,587);
|
||||
|
||||
@@ -3,13 +3,16 @@ package de.srsoftware.umbrella.message;
|
||||
|
||||
import static de.srsoftware.tools.jdbc.Condition.equal;
|
||||
import static de.srsoftware.tools.jdbc.Query.*;
|
||||
import static de.srsoftware.umbrella.core.Constants.*;
|
||||
import static de.srsoftware.umbrella.core.Errors.*;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
|
||||
import static de.srsoftware.umbrella.core.constants.Constants.TABLE_SETTINGS;
|
||||
import static de.srsoftware.umbrella.core.constants.Field.*;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
|
||||
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||
import static de.srsoftware.umbrella.message.model.Settings.Times;
|
||||
import static java.lang.System.Logger.Level.WARNING;
|
||||
import static java.text.MessageFormat.format;
|
||||
|
||||
import de.srsoftware.umbrella.core.constants.Text;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||
import de.srsoftware.umbrella.message.model.Settings;
|
||||
@@ -40,7 +43,7 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} Integer PRIMARY KEY, {2} VARCHAR(255) NOT N
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_SUBMISSIONS).causedBy(e);
|
||||
throw failedToCreateTable(TABLE_SUBMISSIONS).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +57,7 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_CREATE_TABLE,TABLE_SETTINGS).causedBy(e);
|
||||
throw failedToCreateTable(TABLE_SETTINGS).causedBy(e);
|
||||
}
|
||||
|
||||
Integer version = null;
|
||||
@@ -68,7 +71,7 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
|
||||
}
|
||||
return version;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_UPDATE_ENTITY,DB_VERSION).causedBy(e);
|
||||
throw databaseException(FAILED_TO_UPDATE_OBJECT, OBJECT,DB_VERSION).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +90,7 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
|
||||
if (settings != null) return settings;
|
||||
throw new UmbrellaException(500,"No submission settings stored for {0}",user);
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_LOAD_USER_SETTINGS,user).causedBy(e);
|
||||
throw databaseException(FAILED_TO_LOAD_ENTITIES_OF_OWNER, TYPE,t(Text.SETTINGS), OWNER,user).causedBy(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +117,7 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
|
||||
replaceInto(TABLE_SUBMISSIONS, USER_ID, VALUE).values(user.id(),times).execute(db).close();
|
||||
return settings;
|
||||
} catch (SQLException e) {
|
||||
throw databaseException(FAILED_TO_STORE_ENTITY,"submission data").causedBy(e);
|
||||
throw failedToStoreObject("submission data").causedBy(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user