overhauling constants, working on translations

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-01-15 13:58:50 +01:00
parent 669853352e
commit 0d1cdd35d1
103 changed files with 2161 additions and 1207 deletions

View File

@@ -3,11 +3,11 @@ package de.srsoftware.umbrella.legacy;
import static de.srsoftware.tools.Optionals.nullable;
import static de.srsoftware.umbrella.core.Constants.TOKEN;
import static de.srsoftware.umbrella.core.ModuleRegistry.companyService;
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
import static de.srsoftware.umbrella.core.Paths.JSON;
import static de.srsoftware.umbrella.core.Util.mapValues;
import static de.srsoftware.umbrella.core.constants.Field.TOKEN;
import static de.srsoftware.umbrella.core.constants.Path.JSON;
import com.sun.net.httpserver.HttpExchange;
import de.srsoftware.configuration.Configuration;

View File

@@ -3,12 +3,12 @@ package de.srsoftware.umbrella.legacy;
import static de.srsoftware.tools.Optionals.nullable;
import static de.srsoftware.umbrella.core.Constants.TOKEN;
import static de.srsoftware.umbrella.core.Constants.URI;
import static de.srsoftware.umbrella.core.ModuleRegistry.noteService;
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
import static de.srsoftware.umbrella.core.Util.markdown;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.invalidFieldException;
import static de.srsoftware.umbrella.core.constants.Field.TOKEN;
import static de.srsoftware.umbrella.core.constants.Field.URI;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.invalidField;
import com.sun.net.httpserver.HttpExchange;
import de.srsoftware.configuration.Configuration;
@@ -53,9 +53,9 @@ public class NotesLegacy extends BaseHandler {
}
private boolean postNotesHtml(HttpExchange ex, Map<String, Object> params) throws IOException {
if (!(params.get(URI) instanceof String uri)) throw invalidFieldException(URI,"URI of the form \"module:entry-id\"");
if (!(params.get(URI) instanceof String uri)) throw invalidField(URI,"URI of the form \"module:entry-id\"");
var parts = uri.split(":",2);
if (parts.length<2) throw invalidFieldException(URI,"URI of the form \"module:entry-id\"");
if (parts.length<2) throw invalidField(URI,"URI of the form \"module:entry-id\"");
var module = parts[0];
var entryId = parts[1];
var notes = noteService().getNotes(module,entryId);

View File

@@ -3,11 +3,12 @@ package de.srsoftware.umbrella.legacy;
import static de.srsoftware.tools.Optionals.nullable;
import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.ModuleRegistry.projectService;
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
import static de.srsoftware.umbrella.core.Paths.JSON;
import static de.srsoftware.umbrella.core.Util.mapValues;
import static de.srsoftware.umbrella.core.constants.Field.TOKEN;
import static de.srsoftware.umbrella.core.constants.Field.USERS;
import static de.srsoftware.umbrella.core.constants.Path.JSON;
import com.sun.net.httpserver.HttpExchange;
import de.srsoftware.configuration.Configuration;

View File

@@ -4,12 +4,11 @@ package de.srsoftware.umbrella.legacy;
import static de.srsoftware.tools.Optionals.nullable;
import static de.srsoftware.umbrella.core.Constants.DESCRIPTION;
import static de.srsoftware.umbrella.core.Constants.TOKEN;
import static de.srsoftware.umbrella.core.ModuleRegistry.taskService;
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
import static de.srsoftware.umbrella.core.Paths.JSON;
import static de.srsoftware.umbrella.core.Util.mapValues;
import static de.srsoftware.umbrella.core.constants.Field.*;
import static de.srsoftware.umbrella.core.constants.Path.JSON;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.unprocessable;
import com.sun.net.httpserver.HttpExchange;
@@ -63,6 +62,6 @@ public class TaskLegacy extends BaseHandler {
var taskIds = taskIdMap.values().stream().map(Object::toString).map(Long::parseLong).toList();
return sendContent(ex,mapValues(taskService().load(taskIds)));
}
throw unprocessable("Invalid request");
throw unprocessable("Invalid request");
}
}

View File

@@ -3,11 +3,13 @@ package de.srsoftware.umbrella.legacy;
import static de.srsoftware.tools.MimeType.MIME_FORM_URL;
import static de.srsoftware.tools.Query.decode;
import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.Constants.TOKEN;
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
import static de.srsoftware.umbrella.core.Paths.*;
import static de.srsoftware.umbrella.core.Util.request;
import static de.srsoftware.umbrella.core.constants.Constants.HOME;
import static de.srsoftware.umbrella.core.constants.Field.*;
import static de.srsoftware.umbrella.core.constants.Field.REDIRECT;
import static de.srsoftware.umbrella.core.constants.Field.TOKEN;
import static de.srsoftware.umbrella.core.constants.Path.*;
import static de.srsoftware.umbrella.user.Paths.*;
import static java.lang.Long.parseLong;
import static java.lang.System.Logger.Level.*;
@@ -17,9 +19,9 @@ import static java.time.temporal.ChronoUnit.DAYS;
import com.sun.net.httpserver.HttpExchange;
import de.srsoftware.configuration.Configuration;
import de.srsoftware.tools.Path;
import de.srsoftware.tools.SessionToken;
import de.srsoftware.umbrella.core.BaseHandler;
import de.srsoftware.umbrella.core.constants.Path;
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
import de.srsoftware.umbrella.core.model.Session;
import de.srsoftware.umbrella.core.model.Token;
@@ -41,7 +43,7 @@ public class UserLegacy extends BaseHandler {
}
@Override
public boolean doGet(Path path, HttpExchange ex) throws IOException {
public boolean doGet(de.srsoftware.tools.Path path, HttpExchange ex) throws IOException {
var head = path.pop();
return switch (head){
case null -> sendRedirect(ex, url(ex).replaceAll("/legacy/.*",""));
@@ -49,7 +51,7 @@ public class UserLegacy extends BaseHandler {
allowOrigin(ex, "*"); // add CORS header
yield load(path,ex);
}
case LOGIN -> getLogin(ex);
case Path.LOGIN -> getLogin(ex);
case LOGOUT-> logout(ex);
case MODULES -> getModules(ex);
case SEARCH -> sendRedirect(ex,url(ex).replaceAll("/legacy/","/"));
@@ -58,7 +60,7 @@ public class UserLegacy extends BaseHandler {
}
@Override
public boolean doPost(Path path, HttpExchange ex) throws IOException {
public boolean doPost(de.srsoftware.tools.Path path, HttpExchange ex) throws IOException {
try {
return switch (path.pop()) {
case JSON -> jsonUser(ex);
@@ -136,7 +138,7 @@ public class UserLegacy extends BaseHandler {
for (var entry : userMap.entrySet()){
return sendContent(ex,entry.getValue());
}
throw UmbrellaException.notFound("Failed to load user(s) for id(s): {0}",ids);
throw UmbrellaException.notFound("Failed to load user(s) for id(s): {id}", ID,ids);
}
private boolean legacyNotify(HttpExchange ex) throws UmbrellaException, IOException {
@@ -206,12 +208,12 @@ public class UserLegacy extends BaseHandler {
var expiredToken = new SessionToken(token.toString(),"/", Instant.now().minus(1, DAYS),true);
expiredToken.addTo(ex);
if (returnTo instanceof String location) return sendRedirect(ex,location);
return sendContent(ex, Map.of(REDIRECT,"home"));
return sendContent(ex, Map.of(REDIRECT,HOME));
} catch (UmbrellaException e) {
return send(ex,e);
}
if (returnTo instanceof String location) return sendRedirect(ex,location);
return sendContent(ex,Map.of(REDIRECT,"home"));
return sendContent(ex,Map.of(REDIRECT,HOME));
}
private boolean postSearch(HttpExchange ex) throws IOException, UmbrellaException {
@@ -282,7 +284,7 @@ public class UserLegacy extends BaseHandler {
var session = userService().load(Token.of(token));
var user = userService().load(session);
var userMap = user.toMap();
userMap.put(TOKEN,Map.of(TOKEN,token,EXPIRATION,session.expiration().getEpochSecond()));
userMap.put(TOKEN,Map.of(TOKEN,token, EXPIRATION,session.expiration().getEpochSecond()));
return sendContent(ex,userMap);
}
}