Merge branch 'main' into lang_de, working on further translations
This commit is contained in:
@@ -36,7 +36,7 @@ public class Configuration {
|
||||
var newVals = (JSONObject) new JSONParser().parse(Files.readString(file.toPath()));
|
||||
data.putAll(newVals);
|
||||
} catch (ParseException | IOException e){
|
||||
LOG.warn("Was not able to load configuration from {}:",file,e);
|
||||
LOG.warn("Konnte Konfiguration nicht aus {} laden:",file,e);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class Configuration {
|
||||
}
|
||||
|
||||
public Configuration save() throws IOException {
|
||||
if (file == null) throw new NullPointerException("Cannot save configuration: file is null!");
|
||||
if (file == null) throw new NullPointerException("Konnte Konfiguration nicht speichern: Datei ist null!");
|
||||
file.getParentFile().mkdirs();
|
||||
Files.writeString(file.toPath(),data.toJSONString());
|
||||
return this;
|
||||
|
||||
@@ -213,35 +213,35 @@ public class Rest extends HttpServlet {
|
||||
return Map.of(SUCCESS,t("Mailing-List '{}' wurde {}!",listEmail,enable ? "aktiviert" : "inaktiviert"));
|
||||
} catch (SQLException e) {
|
||||
LOG.error("Aktivieren/Inaktivieren der Mailing-Liste fehlgeschlagen: ",e);
|
||||
return Map.of("error",t("Failed to update list '{}'",listEmail));
|
||||
return Map.of(ERROR,t("Aktualisieren der Liste '{}' fehlgeschlagen!",listEmail));
|
||||
}
|
||||
}
|
||||
return Map.of("error",t("You are not allowed to edit '{}'",listEmail));
|
||||
return Map.of(ERROR,t("Sie haben nicht die Berechtigng, '{}' zu bearbeiten",listEmail));
|
||||
}
|
||||
|
||||
private Map<String, String> hideList(String listEmail, User user, boolean hide) {
|
||||
if (listEmail == null || listEmail.isBlank()) return Map.of(ERROR,"no list email provided!");
|
||||
if (listEmail == null || listEmail.isBlank()) return Map.of(ERROR,"Keine Listen-Email übergeben!");
|
||||
if (user.hashPermission(User.PERMISSION_ADMIN) || ListMember.listsOwnedBy(user).contains(listEmail)){
|
||||
try {
|
||||
MailingList.load(listEmail).hide(hide);
|
||||
return Map.of(SUCCESS,t("Mailing list '{}' was {}!",listEmail,hide ? "hidden" : "made public"));
|
||||
return Map.of(SUCCESS,t("Mailing-List '{}' wurde {}!",listEmail,hide ? "versteckt" : "veröffentlicht"));
|
||||
} catch (SQLException e) {
|
||||
LOG.error("Failed to (un)hide mailing list: ",e);
|
||||
return Map.of("error",t("Failed to update list '{}'",listEmail));
|
||||
LOG.error("Verstecken/Veröffentlichen der Mailinglist fehlgeschlagen: ",e);
|
||||
return Map.of("error",t("Aktualisieren der Liste '{}' fehlgeschlagen",listEmail));
|
||||
}
|
||||
|
||||
}
|
||||
return Map.of("error",t("You are not allowed to edit '{}'",listEmail));
|
||||
return Map.of(ERROR,t("Sie haben nicht die Berechtigng, '{}' zu bearbeiten",listEmail));
|
||||
}
|
||||
|
||||
private Map testList(String listEmail, User user) {
|
||||
if (listEmail == null || listEmail.isBlank()) return Map.of(ERROR,"no list email provided!");
|
||||
if (listEmail == null || listEmail.isBlank()) return Map.of(ERROR,"Keine Listen-Email übergeben!");
|
||||
try {
|
||||
MailingList.load(listEmail).test(user);
|
||||
return Map.of(SUCCESS,t("Sent test email to {}",user.email()));
|
||||
return Map.of(SUCCESS,t("Test-Email an {} gesendet",user.email()));
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Failed to send test email",e);
|
||||
return Map.of(ERROR,t("Failed to send test email to {}",user.email()));
|
||||
LOG.warn("Senden der Test-Email fehlgeschlagen",e);
|
||||
return Map.of(ERROR,t("Senden der Test-Email an {} fehlgeschlagen",user.email()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ public abstract class TemplateServlet extends HttpServlet {
|
||||
protected String loadFile(String filename, HttpServletResponse resp) {
|
||||
var path = String.join(File.separator,baseDir,"static",filename);
|
||||
var file = new File(path);
|
||||
if (!file.exists()) return t("File {} does not exist!",filename);
|
||||
if (!file.exists()) return t("Datei {} existiert nicht!",filename);
|
||||
try {
|
||||
var content = Files.readString(file.toPath());
|
||||
resp.getWriter().println(content);
|
||||
} catch (IOException e) {
|
||||
return t("Failed to load file '{}'!",filename);
|
||||
return t("Ladend der Datei '{}' fehlgeschlagen!",filename);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -44,10 +44,10 @@ public abstract class TemplateServlet extends HttpServlet {
|
||||
resp.getWriter().println(template.render());
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
return t("Failed to load template '{}'",path);
|
||||
return t("Laden der Vorlage '{}' fehlgeschlagen",path);
|
||||
}
|
||||
}
|
||||
return t("No template for path '{}'!",path);
|
||||
return t("Keine Vorlage für den Pfad '{}' vorhanden!",path);
|
||||
}
|
||||
|
||||
protected void loadTemplates() {
|
||||
|
||||
@@ -60,7 +60,7 @@ public class Web extends TemplateServlet {
|
||||
data.put(USER, user);
|
||||
|
||||
if (!user.hashPermission(User.PERMISSION_CREATE_LISTS)){
|
||||
data.put(ERROR,t("You are not allowed to create new mailing lists!"));
|
||||
data.put(ERROR,t("Ihnen ist es nicht gestattet, neue Mailinglisten anzulegen!"));
|
||||
return loadTemplate(ADMIN,data,resp);
|
||||
}
|
||||
|
||||
@@ -88,17 +88,17 @@ public class Web extends TemplateServlet {
|
||||
data.put(SMTP_PORT, smtpPort);
|
||||
|
||||
if (name == null || name.isBlank() || email == null || email.isBlank()) {
|
||||
data.put(ERROR, "List name and address are required!");
|
||||
data.put(ERROR, "Name und Adresse der Liste sind notwendige Felder!");
|
||||
return loadTemplate(ADD_LIST, data, resp);
|
||||
}
|
||||
|
||||
if (!Util.isEmail(email)) {
|
||||
data.put(ERROR, t("List email ({}) is not a valid email address!", email));
|
||||
data.put(ERROR, t("Listen-E-Mail-Adresse ({}) ist keine gültige E-Mail-Adresse!", email));
|
||||
return loadTemplate(ADD_LIST, data, resp);
|
||||
}
|
||||
|
||||
if (imapHost == null || imapHost.isBlank() || imapUser == null || imapUser.isBlank() || imapPass == null || imapPass.isBlank()) {
|
||||
data.put(ERROR, "IMAP credentials are required!");
|
||||
data.put(ERROR, "IMAP-Zugangsdaten sind erforderlich!");
|
||||
return loadTemplate(ADD_LIST, data, resp);
|
||||
}
|
||||
|
||||
@@ -107,12 +107,12 @@ public class Web extends TemplateServlet {
|
||||
imapPort = Integer.parseInt(req.getParameter(IMAP_PORT));
|
||||
data.put(IMAP_PORT, imapPort);
|
||||
} catch (NumberFormatException nfe) {
|
||||
data.put(ERROR, t("'{}' is not a proper port number!", req.getParameter(IMAP_PORT)));
|
||||
data.put(ERROR, t("'{}' ist keine gültige Port-Nummer!", req.getParameter(IMAP_PORT)));
|
||||
return loadTemplate(ADD_LIST, data, resp);
|
||||
}
|
||||
|
||||
if (smtpHost == null || smtpHost.isBlank() || smtpUser == null || smtpUser.isBlank() || smtpPass == null || smtpPass.isBlank()) {
|
||||
data.put(ERROR, "SMTP credentials are required!");
|
||||
data.put(ERROR, "SMTP-Zugangsdaten sind erforderlich!");
|
||||
return loadTemplate(ADD_LIST, data, resp);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class Web extends TemplateServlet {
|
||||
smtpPort = Integer.parseInt(req.getParameter(SMTP_PORT));
|
||||
data.put(SMTP_PORT, smtpPort);
|
||||
} catch (NumberFormatException nfe) {
|
||||
data.put(ERROR, t("'{}' is not a proper port number!", req.getParameter(SMTP_PORT)));
|
||||
data.put(ERROR, t("'{}' ist keine gültige Port-Nummer!", req.getParameter(SMTP_PORT)));
|
||||
return loadTemplate(ADD_LIST, data, resp);
|
||||
}
|
||||
|
||||
@@ -129,20 +129,20 @@ public class Web extends TemplateServlet {
|
||||
ListMember.create(list, user, ListMember.STATE_OWNER);
|
||||
return redirectTo(INDEX, resp);
|
||||
} catch (SQLException e) {
|
||||
return t("Failed to create list '{}': {}", name, e.getMessage());
|
||||
return t("Erzeugen der Liste '{}' fehlgeschlagen: {}", name, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private String confirm(HttpServletRequest req, HttpServletResponse resp) {
|
||||
try {
|
||||
var token = req.getParameter(TOKEN);
|
||||
if (token== null || token.isBlank()) return t("Invalid or missing token!");
|
||||
if (token== null || token.isBlank()) return t("Ungültiger oder fehlender Token!");
|
||||
var user = ListMember.confirm(token);
|
||||
if (user != null) return loadTemplate(INDEX,Map.of(USER,user.safeMap(),NOTES,"Confirmed list subscription!"),resp);
|
||||
return t("Unknown user or token");
|
||||
if (user != null) return loadTemplate(INDEX,Map.of(USER,user.safeMap(),NOTES,"Listen-Mitgliedschaft bestätigt!"),resp);
|
||||
return t("Nutzer oder Token unbekannt");
|
||||
} catch (Exception e) {
|
||||
LOG.debug("Failed to confirm list membership:",e);
|
||||
return t("Confirmation of list membership failed!");
|
||||
LOG.debug("Bestätigung des Listen-Abonnements fehlgeschlagen:",e);
|
||||
return t("Bestätigung des Listen-Abonnements fehlgeschlagen!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ public class Web extends TemplateServlet {
|
||||
return confirm(req,resp);
|
||||
case RELOAD:
|
||||
loadTemplates();
|
||||
data.put(NOTES,t("Templates have been reloaded"));
|
||||
data.put(NOTES,t("Vorlagen wurden neu geladen"));
|
||||
path = INDEX;
|
||||
case "css":
|
||||
case INDEX:
|
||||
@@ -199,16 +199,16 @@ public class Web extends TemplateServlet {
|
||||
data.put(LIST,listEmail);
|
||||
return loadTemplate(path, data, resp);
|
||||
}
|
||||
return t("You are not allowed to subscribe to '{}'!",list.email());
|
||||
return t("Es ist ihnen nicht gestattet, '{}' zu abonnieren!",list.email());
|
||||
case "js":
|
||||
resp.setContentType("text/javascript");
|
||||
return loadTemplate(path,data,resp);
|
||||
case LOGIN:
|
||||
try {
|
||||
if (User.noUsers()) return loadTemplate(REGISTER, Map.of(NOTES,t("User database is empty. Create admin user first:")), resp);
|
||||
if (User.noUsers()) return loadTemplate(REGISTER, Map.of(NOTES,t("Nutzer-Datenbank ist leer. Admin-Nutzer wird hiermit angelegt:")), resp);
|
||||
return loadTemplate(path,null,resp);
|
||||
} catch (SQLException e) {
|
||||
return "Error reading user database!";
|
||||
return "Fehler beim Lesen der Datenbank!";
|
||||
}
|
||||
case LOGOUT:
|
||||
req.getSession().invalidate();
|
||||
@@ -231,8 +231,8 @@ public class Web extends TemplateServlet {
|
||||
private String handleLogin(HttpServletRequest req, HttpServletResponse resp) {
|
||||
var email = req.getParameter("email");
|
||||
var pass = req.getParameter("pass");
|
||||
if (email == null || pass == null) return loadTemplate("login", Map.of("error",t("Missing username or password!")), resp);
|
||||
if (!Util.isEmail(email)) return loadTemplate("login", Map.of("error",t("'{}' is not a valid email address!",email)), resp);
|
||||
if (email == null || pass == null) return loadTemplate("login", Map.of("error",t("Nutzername oder Passwort fehlen!")), resp);
|
||||
if (!Util.isEmail(email)) return loadTemplate("login", Map.of("error",t("'{}' ist keine gültige Mailadresse!",email)), resp);
|
||||
try {
|
||||
var user = User.loadUser(email,pass);
|
||||
req.getSession().setAttribute("user",user);
|
||||
@@ -240,10 +240,10 @@ public class Web extends TemplateServlet {
|
||||
resp.sendRedirect(String.join("/",WEB_ROOT,"admin"));
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
LOG.warn("Static.handleLogin failed:",e);
|
||||
LOG.warn("Static.handleLogin fehlgeschlagen:",e);
|
||||
Thread.sleep(10000);
|
||||
} finally {
|
||||
return loadTemplate("login", Map.of(ERROR,t("Invalid username/password"),EMAIL,email), resp);
|
||||
return loadTemplate("login", Map.of(ERROR,t("Ungültiger Nutzername oder ungültiges Passwort!"),EMAIL,email), resp);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -265,7 +265,7 @@ public class Web extends TemplateServlet {
|
||||
return unsubscribe(req,resp);
|
||||
}
|
||||
|
||||
return t("No handler for path {}!",path);
|
||||
return t("Kein Handler für den Pfad '{}'!",path);
|
||||
}
|
||||
|
||||
|
||||
@@ -277,7 +277,7 @@ public class Web extends TemplateServlet {
|
||||
resp.sendRedirect(String.join("/",WEB_ROOT,page));
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
return t("Was not able to redirect to {} page: {}", page, e.getMessage());
|
||||
return t("Weiterleitung nach {} fehlgeschlagen: {}", page, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,15 +293,15 @@ public class Web extends TemplateServlet {
|
||||
if (email == null || email.isBlank() ||
|
||||
name == null || name.isBlank() ||
|
||||
pass == null || pass.isBlank() ||
|
||||
pass_repeat == null || pass_repeat.isBlank()) return loadTemplate(REGISTER,Map.of(ERROR,"Fill all fields, please!",NAME,name,EMAIL,email),resp);
|
||||
if (!pass.equals(pass_repeat)) return loadTemplate(REGISTER,Map.of(ERROR,"Passwords do not match!",NAME,name,EMAIL,email),resp);
|
||||
if (Util.simplePassword(pass)) return loadTemplate(REGISTER,Map.of(ERROR,"Password to short or to simple!",NAME,name,EMAIL,email),resp);
|
||||
pass_repeat == null || pass_repeat.isBlank()) return loadTemplate(REGISTER,Map.of(ERROR,"Bitte alle Felder ausfüllen!",NAME,name,EMAIL,email),resp);
|
||||
if (!pass.equals(pass_repeat)) return loadTemplate(REGISTER,Map.of(ERROR,"Passworte stimmen nicht überein!",NAME,name,EMAIL,email),resp);
|
||||
if (Util.simplePassword(pass)) return loadTemplate(REGISTER,Map.of(ERROR,"Passwort zu kurz oder zu einfach!",NAME,name,EMAIL,email),resp);
|
||||
|
||||
var firstUser = false;
|
||||
try {
|
||||
firstUser = User.noUsers();
|
||||
} catch (SQLException e) {
|
||||
return t("Failed to access user database: {}",e.getMessage());
|
||||
return t("Fehler beim Zugriff auf die Nutzer-Datenbank: {}",e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -311,8 +311,8 @@ public class Web extends TemplateServlet {
|
||||
req.getSession().setAttribute("user",user);
|
||||
return redirectTo(INDEX,resp);
|
||||
} catch (SQLException e) {
|
||||
LOG.warn("Failed to create new user:",e);
|
||||
return t("Failed to create new user: {}",e.getMessage());
|
||||
LOG.warn("Erzeugen des neuen Nutzers fehlgeschlagen:",e);
|
||||
return t("Erzeugen des neuen Nutzers fehlgeschlagen: {}",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,12 +330,12 @@ public class Web extends TemplateServlet {
|
||||
var list = MailingList.load(listEmail);
|
||||
|
||||
if (list == null){
|
||||
data.put(ERROR,"No list provided by form data!");
|
||||
data.put(ERROR,"Formular-Daten enthalten keine Liste!");
|
||||
return loadTemplate(SUBSCRIBE,data,resp);
|
||||
|
||||
}
|
||||
if (name == null || name.isBlank() || email == null || email.isBlank()){
|
||||
data.put(ERROR,"Name and email are required fields for list subscription!");
|
||||
data.put(ERROR,"Name und E-Mail-Adresse sind für das Abonnieren der Mailingliste erforderlich!");
|
||||
return loadTemplate(SUBSCRIBE,data,resp);
|
||||
}
|
||||
if (pass != null && pass.isBlank()) pass = null;
|
||||
@@ -352,36 +352,36 @@ public class Web extends TemplateServlet {
|
||||
// success → subscribe
|
||||
} catch (InvalidKeyException | SQLException e) {
|
||||
// invalid credentials
|
||||
data.put(ERROR,t("'{}' already in database, but with different password!",email));
|
||||
data.put(ERROR,t("'{}' gibt es schon in der Datenbank, hat dort aber ein anderes Passwort!",email));
|
||||
return loadTemplate(SUBSCRIBE,data,resp);
|
||||
}
|
||||
}
|
||||
data.put(USER,user.safeMap());
|
||||
|
||||
if (!list.isOpenFor(user)){
|
||||
data.put(ERROR,t("You are not allowed to join {}!",list.email()));
|
||||
data.put(ERROR,t("Ihnen ist es nicht gestattet, '{}' zu abonnieren!",list.email()));
|
||||
return loadTemplate(SUBSCRIBE,data,resp);
|
||||
}
|
||||
|
||||
try {
|
||||
list.requestSubscription(user,skipConfirmation);
|
||||
if (skipConfirmation) {
|
||||
data.put(NOTES, t("Successfully subscribed '{}' to '{}'.", user.email(), list.email()));
|
||||
data.put(NOTES, t("'{}' hat die Mailingliste '{}' erfolgreich abonniert.", user.email(), list.email()));
|
||||
} else {
|
||||
data.put(NOTES, t("Sent confirmation mail to '{}.", user.email()));
|
||||
data.put(NOTES, t("Bestätigungs-Email wurde an '{} versendet.", user.email()));
|
||||
}
|
||||
return loadTemplate(INDEX,data,resp);
|
||||
} catch (SQLException sqle) {
|
||||
LOG.debug("List subscription failed: ",sqle);
|
||||
LOG.debug("Abonnieren der Liste fehlgeschlagen: ",sqle);
|
||||
var cause = getCausingException(sqle);
|
||||
int code = cause.getErrorCode();
|
||||
if (code == PRIMARY_KEY_CONSTRAINT) {// user already exists
|
||||
data.put(ERROR,t("You already are member of this list!",sqle.getMessage()));
|
||||
} else data.put(ERROR,t("Subscription failed: {}",sqle.getMessage()));
|
||||
data.put(ERROR,t("Sie haben diese Liste bereits abonniert!",sqle.getMessage()));
|
||||
} else data.put(ERROR,t("Abonnieren der Liste fehlgeschlagen: {}",sqle.getMessage()));
|
||||
return loadTemplate(SUBSCRIBE,data,resp);
|
||||
} catch (MessagingException e) {
|
||||
LOG.warn("Failed to send request confirmation email:",e);
|
||||
data.put(ERROR,t("Failed to send request confirmation email: {}",e.getMessage()));
|
||||
LOG.warn("Senden der Bestätigungs-Email fehlgeschlagen:",e);
|
||||
data.put(ERROR,t("Senden der Bestätigungs-Email fehlgeschlagen: {}",e.getMessage()));
|
||||
return loadTemplate(SUBSCRIBE,data,resp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ public class DatabaseTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testUpdate(){
|
||||
assertEquals("UPDATE Test",Database.open().update("Test").sql());
|
||||
assertEquals("UPDATE Test SET x = 5",Database.open().update("Test").set("x",5).sql());
|
||||
assertEquals("UPDATE Test SET x = 5, y = 6",Database.open().update("Test").set("x",5).set("y",6).sql());
|
||||
assertEquals("UPDATE Test",Database.open().update("Test").compile().toString());
|
||||
assertEquals("UPDATE Test SET x = 5",Database.open().update("Test").set("x",5).compile().toString());
|
||||
assertEquals("UPDATE Test SET x = 5, y = 6",Database.open().update("Test").set("x",5).set("y",6).compile().toString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user