unified loading of user in UserModule

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-07-08 23:12:49 +02:00
parent e6e3ed4052
commit 4ba113daf5
6 changed files with 89 additions and 112 deletions

View File

@@ -4,7 +4,7 @@ package de.srsoftware.umbrella.core;
import static de.srsoftware.tools.Optionals.nullable;
import static java.lang.System.Logger.Level.DEBUG;
import static java.lang.System.Logger.Level.WARNING;
import static java.net.HttpURLConnection.HTTP_NOT_FOUND;
import static java.net.HttpURLConnection.*;
import com.sun.net.httpserver.HttpExchange;
import de.srsoftware.tools.Path;
@@ -30,6 +30,10 @@ public abstract class BaseHandler extends PathHandler {
return ex;
}
public boolean forbidden(HttpExchange ex) throws IOException {
return sendEmptyResponse(HTTP_FORBIDDEN,ex);
}
public record Document(String mime, byte[] bytes){}
public boolean load(Path path, HttpExchange ex) throws IOException {
@@ -58,7 +62,15 @@ public abstract class BaseHandler extends PathHandler {
}
}
public boolean ok(HttpExchange ex) throws IOException {
return sendEmptyResponse(HTTP_OK,ex);
}
public boolean send(HttpExchange ex, UmbrellaException e) throws IOException {
return sendContent(ex,e.statusCode(),e.getMessage());
}
public boolean unauthorized(HttpExchange ex) throws IOException {
return sendEmptyResponse(HTTP_FORBIDDEN,ex);
}
}

View File

@@ -1,11 +1,10 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.core.model;
import de.srsoftware.umbrella.core.UmbrellaException;
import static de.srsoftware.tools.Optionals.allSet;
import static java.net.HttpURLConnection.HTTP_BAD_REQUEST;
import static java.text.MessageFormat.format;
import de.srsoftware.umbrella.core.UmbrellaException;
public class EmailAddress {
private final String email;