Browse Source

Merge branch 'main' into module/wiki

module/wiki
Stephan Richter 2 months ago
parent
commit
667052e3c4
  1. 46
      backend/src/main/java/de/srsoftware/umbrella/backend/Application.java
  2. 13
      bookmark/src/main/java/de/srsoftware/umbrella/bookmarks/BookmarkApi.java
  3. 6
      company/src/main/java/de/srsoftware/umbrella/company/CompanyModule.java
  4. 45
      core/src/main/java/de/srsoftware/umbrella/core/BaseHandler.java
  5. 90
      core/src/main/java/de/srsoftware/umbrella/core/ModuleRegistry.java
  6. 1
      core/src/main/java/de/srsoftware/umbrella/core/api/WikiService.java
  7. 12
      core/src/main/java/de/srsoftware/umbrella/core/model/WikiPage.java
  8. 6
      documents/src/main/java/de/srsoftware/umbrella/documents/DocumentApi.java
  9. BIN
      frontend/public/umbrella100px.png
  10. 2
      frontend/src/routes/user/EditService.svelte
  11. 7
      items/src/main/java/de/srsoftware/umbrella/items/ItemApi.java
  12. 9
      legacy/src/main/java/de/srsoftware/umbrella/legacy/CompanyLegacy.java
  13. 9
      legacy/src/main/java/de/srsoftware/umbrella/legacy/NotesLegacy.java
  14. 9
      legacy/src/main/java/de/srsoftware/umbrella/legacy/ProjectLegacy.java
  15. 10
      legacy/src/main/java/de/srsoftware/umbrella/legacy/TaskLegacy.java
  16. 6
      legacy/src/main/java/de/srsoftware/umbrella/legacy/UserLegacy.java
  17. 6
      markdown/src/main/java/de/srsoftware/umbrella/markdown/MarkdownApi.java
  18. 7
      messages/src/main/java/de/srsoftware/umbrella/message/MessageSystem.java
  19. 9
      notes/src/main/java/de/srsoftware/umbrella/notes/NoteModule.java
  20. 6
      project/src/main/java/de/srsoftware/umbrella/project/ProjectModule.java
  21. 6
      tags/src/main/java/de/srsoftware/umbrella/tags/TagModule.java
  22. 6
      task/src/main/java/de/srsoftware/umbrella/task/TaskModule.java
  23. 6
      time/src/main/java/de/srsoftware/umbrella/time/TimeModule.java
  24. 4
      translations/src/main/java/de/srsoftware/umbrella/translations/Translations.java
  25. 2
      translations/src/main/resources/de.json
  26. 4
      user/src/main/java/de/srsoftware/umbrella/user/Constants.java
  27. 6
      user/src/main/java/de/srsoftware/umbrella/user/UserModule.java
  28. 5
      web/src/main/java/de/srsoftware/umbrella/web/WebHandler.java
  29. 28
      wiki/src/main/java/de/srsoftware/umbrella/wiki/SqliteDb.java
  30. 1
      wiki/src/main/java/de/srsoftware/umbrella/wiki/WikiDb.java
  31. 24
      wiki/src/main/java/de/srsoftware/umbrella/wiki/WikiModule.java

46
backend/src/main/java/de/srsoftware/umbrella/backend/Application.java

@ -10,9 +10,7 @@ import de.srsoftware.configuration.JsonConfig;
import de.srsoftware.tools.ColorLogger; import de.srsoftware.tools.ColorLogger;
import de.srsoftware.umbrella.bookmarks.BookmarkApi; import de.srsoftware.umbrella.bookmarks.BookmarkApi;
import de.srsoftware.umbrella.company.CompanyModule; import de.srsoftware.umbrella.company.CompanyModule;
import de.srsoftware.umbrella.core.ModuleRegistry;
import de.srsoftware.umbrella.core.Util; import de.srsoftware.umbrella.core.Util;
import de.srsoftware.umbrella.core.api.WikiService;
import de.srsoftware.umbrella.core.exceptions.UmbrellaException; import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
import de.srsoftware.umbrella.documents.DocumentApi; import de.srsoftware.umbrella.documents.DocumentApi;
import de.srsoftware.umbrella.items.ItemApi; import de.srsoftware.umbrella.items.ItemApi;
@ -27,12 +25,11 @@ import de.srsoftware.umbrella.time.TimeModule;
import de.srsoftware.umbrella.translations.Translations; import de.srsoftware.umbrella.translations.Translations;
import de.srsoftware.umbrella.user.UserModule; import de.srsoftware.umbrella.user.UserModule;
import de.srsoftware.umbrella.web.WebHandler; import de.srsoftware.umbrella.web.WebHandler;
import de.srsoftware.umbrella.wiki.WikiModule;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import de.srsoftware.umbrella.wiki.WikiModule;
import org.json.JSONObject; import org.json.JSONObject;
public class Application { public class Application {
@ -62,27 +59,26 @@ public class Application {
var server = HttpServer.create(new InetSocketAddress(port), 0); var server = HttpServer.create(new InetSocketAddress(port), 0);
var registry = new ModuleRegistry(); new Translations().bindPath("/api/translations").on(server);
new Translations(registry).bindPath("/api/translations").on(server); new MessageSystem(config);
new MessageSystem(registry,config); new UserModule(config).bindPath("/api/user").on(server);
new UserModule(registry,config).bindPath("/api/user").on(server); new TagModule(config).bindPath("/api/tags").on(server);
new TagModule(registry,config).bindPath("/api/tags").on(server); new BookmarkApi(config).bindPath("/api/bookmark").on(server);
new BookmarkApi(registry,config).bindPath("/api/bookmark").on(server); new CompanyModule(config).bindPath("/api/company").on(server);
new CompanyModule(registry, config).bindPath("/api/company").on(server); new CompanyLegacy(config).bindPath("/legacy/company").on(server);
new CompanyLegacy(registry, config).bindPath("/legacy/company").on(server); new DocumentApi(config).bindPath("/api/document").on(server);
new DocumentApi(registry, config).bindPath("/api/document").on(server); new ItemApi(config).bindPath("/api/items").on(server);
new ItemApi(registry, config).bindPath("/api/items").on(server); new UserLegacy(config).bindPath("/legacy/user").on(server);
new UserLegacy(registry,config).bindPath("/legacy/user").on(server); new NotesLegacy(config).bindPath("/legacy/notes").on(server);
new NotesLegacy(registry,config).bindPath("/legacy/notes").on(server); new MarkdownApi().bindPath("/api/markdown").on(server);
new MarkdownApi(registry).bindPath("/api/markdown").on(server); new NoteModule(config).bindPath("/api/notes").on(server);
new NoteModule(registry,config).bindPath("/api/notes").on(server); new ProjectModule(config).bindPath("/api/project").on(server);
new ProjectModule(registry, config).bindPath("/api/project").on(server); new ProjectLegacy(config).bindPath("/legacy/project").on(server);
new ProjectLegacy(registry,config).bindPath("/legacy/project").on(server); new TaskModule(config).bindPath("/api/task").on(server);
new TaskModule(registry, config).bindPath("/api/task").on(server); new TaskLegacy().bindPath("/legacy/task").on(server);
new TaskLegacy(registry, config).bindPath("/legacy/task").on(server); new TimeModule(config).bindPath("/api/time").on(server);
new TimeModule(registry, config).bindPath("/api/time").on(server); new WebHandler().bindPath("/").on(server);
new WebHandler(registry).bindPath("/").on(server); new WikiModule(config).bindPath("/api/wiki").on(server);
new WikiModule(registry, config).bindPath("/api/wiki").on(server);
server.setExecutor(Executors.newFixedThreadPool(threads)); server.setExecutor(Executors.newFixedThreadPool(threads));
server.start(); server.start();

13
bookmark/src/main/java/de/srsoftware/umbrella/bookmarks/BookmarkApi.java

@ -29,10 +29,11 @@ import org.json.JSONArray;
public class BookmarkApi extends BaseHandler implements BookmarkService { public class BookmarkApi extends BaseHandler implements BookmarkService {
private final BookmarkDb db; private final BookmarkDb db;
public BookmarkApi(ModuleRegistry registry, Configuration config) { public BookmarkApi(Configuration config) {
super(registry); super();
var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE)); var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE));
db = new SqliteDb(connect(dbFile)); db = new SqliteDb(connect(dbFile));
ModuleRegistry.add(this);
} }
@Override @Override
@ -40,7 +41,7 @@ public class BookmarkApi extends BaseHandler implements BookmarkService {
addCors(ex); addCors(ex);
try { try {
Optional<Token> token = SessionToken.from(ex).map(Token::of); Optional<Token> token = SessionToken.from(ex).map(Token::of);
var user = userService().loadUser(token); var user = ModuleRegistry.userService().loadUser(token);
if (user.isEmpty()) return unauthorized(ex); if (user.isEmpty()) return unauthorized(ex);
var head = path.pop(); var head = path.pop();
return switch (head) { return switch (head) {
@ -60,7 +61,7 @@ public class BookmarkApi extends BaseHandler implements BookmarkService {
private boolean getBookmark(UmbrellaUser user, long id, HttpExchange ex) throws IOException { private boolean getBookmark(UmbrellaUser user, long id, HttpExchange ex) throws IOException {
var bookmark = db.load(id,user.id()); var bookmark = db.load(id,user.id());
tagService().getTags(BOOKMARK, id, user).forEach(bookmark.tags()::add); ModuleRegistry.tagService().getTags(BOOKMARK, id, user).forEach(bookmark.tags()::add);
return sendContent(ex,bookmark); return sendContent(ex,bookmark);
} }
@ -69,7 +70,7 @@ public class BookmarkApi extends BaseHandler implements BookmarkService {
addCors(ex); addCors(ex);
try { try {
Optional<Token> token = SessionToken.from(ex).map(Token::of); Optional<Token> token = SessionToken.from(ex).map(Token::of);
var user = userService().loadUser(token); var user = ModuleRegistry.userService().loadUser(token);
if (user.isEmpty()) return unauthorized(ex); if (user.isEmpty()) return unauthorized(ex);
var head = path.pop(); var head = path.pop();
return switch (head) { return switch (head) {
@ -117,7 +118,7 @@ public class BookmarkApi extends BaseHandler implements BookmarkService {
if (json.has(TAGS) && json.get(TAGS) instanceof JSONArray tagList){ if (json.has(TAGS) && json.get(TAGS) instanceof JSONArray tagList){
var list = tagList.toList().stream().map(Object::toString).toList(); var list = tagList.toList().stream().map(Object::toString).toList();
tagService().save(BOOKMARK,bookmark.urlId(), userList, list); ModuleRegistry.tagService().save(BOOKMARK,bookmark.urlId(), userList, list);
} }
return sendContent(ex,bookmark); return sendContent(ex,bookmark);
} }

6
company/src/main/java/de/srsoftware/umbrella/company/CompanyModule.java

@ -4,6 +4,7 @@ package de.srsoftware.umbrella.company;
import static de.srsoftware.umbrella.company.Constants.CONFIG_DATABASE; import static de.srsoftware.umbrella.company.Constants.CONFIG_DATABASE;
import static de.srsoftware.umbrella.core.ConnectionProvider.connect; import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.Constants.*; import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.ModuleRegistry.*;
import static de.srsoftware.umbrella.core.Paths.LIST; import static de.srsoftware.umbrella.core.Paths.LIST;
import static de.srsoftware.umbrella.core.Paths.SEARCH; import static de.srsoftware.umbrella.core.Paths.SEARCH;
import static de.srsoftware.umbrella.core.Util.mapValues; import static de.srsoftware.umbrella.core.Util.mapValues;
@ -26,10 +27,11 @@ public class CompanyModule extends BaseHandler implements CompanyService {
private final CompanyDb companyDb; private final CompanyDb companyDb;
public CompanyModule(ModuleRegistry registry, Configuration config) throws UmbrellaException { public CompanyModule(Configuration config) throws UmbrellaException {
super(registry); super();
var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE)); var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE));
companyDb = new SqliteDb(connect(dbFile)); companyDb = new SqliteDb(connect(dbFile));
ModuleRegistry.add(this);
} }
private boolean deleteCompany(long companyId, UmbrellaUser user, HttpExchange ex) throws IOException { private boolean deleteCompany(long companyId, UmbrellaUser user, HttpExchange ex) throws IOException {

45
core/src/main/java/de/srsoftware/umbrella/core/BaseHandler.java

@ -17,13 +17,8 @@ import java.util.List;
public abstract class BaseHandler extends PathHandler { public abstract class BaseHandler extends PathHandler {
private final ModuleRegistry registry;
public record Page(String mime, byte[] bytes){} public record Page(String mime, byte[] bytes){}
public BaseHandler(ModuleRegistry registry){
this.registry = registry.add(this);
}
public HttpExchange addCors(HttpExchange ex){ public HttpExchange addCors(HttpExchange ex){
var headers = ex.getRequestHeaders(); var headers = ex.getRequestHeaders();
@ -41,23 +36,11 @@ public abstract class BaseHandler extends PathHandler {
return ex; return ex;
} }
public CompanyService companyService(){
return registry.companyService();
}
public DocumentService documentService(){
return registry.documentService();
}
@Override @Override
public boolean doOptions(Path path, HttpExchange ex) throws IOException { public boolean doOptions(Path path, HttpExchange ex) throws IOException {
return ok(addCors(ex)); return ok(addCors(ex));
} }
public ItemService itemService(){
return registry.itemService();
}
public boolean load(Path path, HttpExchange ex) throws IOException { public boolean load(Path path, HttpExchange ex) throws IOException {
try { try {
var doc = load(path.toString()); var doc = load(path.toString());
@ -84,43 +67,15 @@ public abstract class BaseHandler extends PathHandler {
} }
} }
public NoteService noteService(){
return registry.noteService();
}
public boolean ok(HttpExchange ex) throws IOException { public boolean ok(HttpExchange ex) throws IOException {
return sendEmptyResponse(HTTP_OK,ex); return sendEmptyResponse(HTTP_OK,ex);
} }
public PostBox postBox() {
return registry.postBox();
}
public ProjectService projectService(){
return registry.projectService();
}
public boolean send(HttpExchange ex, UmbrellaException e) throws IOException { public boolean send(HttpExchange ex, UmbrellaException e) throws IOException {
return sendContent(ex,e.statusCode(),e.getMessage()); return sendContent(ex,e.statusCode(),e.getMessage());
} }
public TagService tagService(){
return registry.tagService();
}
public TaskService taskService(){
return registry.taskService();
}
public Translator translator(){
return registry.translator();
}
public boolean unauthorized(HttpExchange ex) throws IOException { public boolean unauthorized(HttpExchange ex) throws IOException {
return sendEmptyResponse(HTTP_UNAUTHORIZED,ex); return sendEmptyResponse(HTTP_UNAUTHORIZED,ex);
} }
public UserService userService(){
return registry.userService();
}
} }

90
core/src/main/java/de/srsoftware/umbrella/core/ModuleRegistry.java

@ -20,80 +20,82 @@ public class ModuleRegistry {
private UserService userService; private UserService userService;
private WikiService wikiService; private WikiService wikiService;
private static final ModuleRegistry singleton = new ModuleRegistry();
public ModuleRegistry add(Object service) { private ModuleRegistry(){}
public static void add(Object service) {
switch (service) { switch (service) {
case BookmarkService bs: bookmarkService = bs; break; case BookmarkService bs: singleton.bookmarkService = bs; break;
case CompanyService cs: companyService = cs; break; case CompanyService cs: singleton.companyService = cs; break;
case DocumentService ds: documentService = ds; break; case DocumentService ds: singleton.documentService = ds; break;
case ItemService is: itemService = is; break; case ItemService is: singleton.itemService = is; break;
case MarkdownService ms: markdownService = ms; break; case MarkdownService ms: singleton.markdownService = ms; break;
case NoteService ns: noteService = ns; break; case NoteService ns: singleton.noteService = ns; break;
case PostBox pb: postBox = pb; break; case PostBox pb: singleton.postBox = pb; break;
case ProjectService ps: projectService = ps; break; case ProjectService ps: singleton.projectService = ps; break;
case TagService ts: tagService = ts; break; case TagService ts: singleton.tagService = ts; break;
case TaskService ts: taskService = ts; break; case TaskService ts: singleton.taskService = ts; break;
case TimeService ts: timeService = ts; break; case TimeService ts: singleton.timeService = ts; break;
case Translator tr: translator = tr; break; case Translator tr: singleton.translator = tr; break;
case UserService us: userService = us; break; case UserService us: singleton.userService = us; break;
case WikiService ws: wikiService = ws; break; case WikiService ws: singleton.wikiService = ws; break;
case null: break; case null: break;
default: System.getLogger(getClass().getSimpleName()).log(System.Logger.Level.WARNING,"Trying to add untracked class {0} to {1}",service.getClass().getSimpleName(),getClass().getSimpleName()); default: System.getLogger(ModuleRegistry.class.getSimpleName()).log(System.Logger.Level.WARNING,"Trying to add untracked class {0}",service.getClass().getSimpleName());
} }
return this;
} }
public BookmarkService bookmarkService(){ public static BookmarkService bookmarkService(){
return bookmarkService; return singleton.bookmarkService;
} }
public CompanyService companyService(){ public static CompanyService companyService(){
return companyService; return singleton.companyService;
} }
public DocumentService documentService(){ public static DocumentService documentService(){
return documentService; return singleton.documentService;
} }
public ItemService itemService(){ public static ItemService itemService(){
return itemService; return singleton.itemService;
} }
public MarkdownService markdownService(){ public static MarkdownService markdownService(){
return markdownService; return singleton.markdownService;
} }
public NoteService noteService(){ public static NoteService noteService(){
return noteService; return singleton.noteService;
} }
public PostBox postBox() { public static PostBox postBox() {
return postBox; return singleton.postBox;
} }
public ProjectService projectService(){ public static ProjectService projectService(){
return projectService; return singleton.projectService;
} }
public TagService tagService(){ public static TagService tagService(){
return tagService; return singleton.tagService;
} }
public TaskService taskService(){ public static TaskService taskService(){
return taskService; return singleton.taskService;
} }
public TimeService timeService(){ public static TimeService timeService(){
return timeService; return singleton.timeService;
} }
public Translator translator(){ public static Translator translator(){
return translator; return singleton.translator;
} }
public UserService userService(){ public static UserService userService(){
return userService; return singleton.userService;
} }
public WikiService wikiService() { return wikiService; }; public static WikiService wikiService() { return singleton.wikiService; };
} }

1
core/src/main/java/de/srsoftware/umbrella/core/api/WikiService.java

@ -1,3 +1,4 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.core.api; package de.srsoftware.umbrella.core.api;
public interface WikiService { public interface WikiService {

12
core/src/main/java/de/srsoftware/umbrella/core/model/WikiPage.java

@ -1,16 +1,16 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.core.model; package de.srsoftware.umbrella.core.model;
import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.Util.markdown;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.invalidFieldException;
import de.srsoftware.tools.Mappable; import de.srsoftware.tools.Mappable;
import de.srsoftware.umbrella.core.api.UserService; import de.srsoftware.umbrella.core.api.UserService;
import org.json.JSONObject;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.*; import java.util.*;
import org.json.JSONObject;
import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.Util.markdown;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.invalidFieldException;
public class WikiPage implements Mappable { public class WikiPage implements Mappable {

6
documents/src/main/java/de/srsoftware/umbrella/documents/DocumentApi.java

@ -22,6 +22,7 @@ import static de.srsoftware.umbrella.core.Constants.FIELD_PRICE_FORMAT;
import static de.srsoftware.umbrella.core.Constants.FIELD_TIME_ID; import static de.srsoftware.umbrella.core.Constants.FIELD_TIME_ID;
import static de.srsoftware.umbrella.core.Constants.FIELD_TYPE; import static de.srsoftware.umbrella.core.Constants.FIELD_TYPE;
import static de.srsoftware.umbrella.core.Constants.FIELD_UNIT; import static de.srsoftware.umbrella.core.Constants.FIELD_UNIT;
import static de.srsoftware.umbrella.core.ModuleRegistry.*;
import static de.srsoftware.umbrella.core.Paths.*; import static de.srsoftware.umbrella.core.Paths.*;
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_UNPROCESSABLE; import static de.srsoftware.umbrella.core.ResponseCode.HTTP_UNPROCESSABLE;
import static de.srsoftware.umbrella.core.Util.mapValues; import static de.srsoftware.umbrella.core.Util.mapValues;
@ -76,11 +77,12 @@ public class DocumentApi extends BaseHandler implements DocumentService {
private final Configuration config; private final Configuration config;
private final DocumentDb db; private final DocumentDb db;
public DocumentApi(ModuleRegistry registry, Configuration config) throws UmbrellaException { public DocumentApi(Configuration config) throws UmbrellaException {
super(registry); super();
this.config = config; this.config = config;
var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE)); var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE));
db = new SqliteDb(connect(dbFile)); db = new SqliteDb(connect(dbFile));
ModuleRegistry.add(this);
Optional<String> templates = config.get(CONFIG_TEMPLATES); Optional<String> templates = config.get(CONFIG_TEMPLATES);
if (templates.isEmpty()) throw missingFieldException(CONFIG_TEMPLATES); if (templates.isEmpty()) throw missingFieldException(CONFIG_TEMPLATES);

BIN
frontend/public/umbrella100px.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 14 KiB

2
frontend/src/routes/user/EditService.svelte

@ -43,7 +43,7 @@
</script> </script>
<fieldset> <fieldset>
<legend>{t('edit_service',serviceName)}</legend> <legend>{t('edit_service',{name:(serviceName||"")})}</legend>
{#if service.name || !serviceName} {#if service.name || !serviceName}
<table> <table>
<tbody> <tbody>

7
items/src/main/java/de/srsoftware/umbrella/items/ItemApi.java

@ -3,6 +3,8 @@ package de.srsoftware.umbrella.items;
import static de.srsoftware.umbrella.core.ConnectionProvider.connect; import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.Constants.*; import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.ModuleRegistry.companyService;
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
import static de.srsoftware.umbrella.core.Paths.LIST; import static de.srsoftware.umbrella.core.Paths.LIST;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.forbidden; import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.forbidden;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingFieldException; import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingFieldException;
@ -28,10 +30,11 @@ public class ItemApi extends BaseHandler implements ItemService {
private final ItemDb itemDb; private final ItemDb itemDb;
public ItemApi(ModuleRegistry registry, Configuration config) throws UmbrellaException { public ItemApi(Configuration config) throws UmbrellaException {
super(registry); super();
var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE)); var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE));
itemDb = new SqliteDb(connect(dbFile)); itemDb = new SqliteDb(connect(dbFile));
ModuleRegistry.add(this);
} }
@Override @Override

9
legacy/src/main/java/de/srsoftware/umbrella/legacy/CompanyLegacy.java

@ -4,6 +4,8 @@ package de.srsoftware.umbrella.legacy;
import static de.srsoftware.tools.Optionals.nullable; import static de.srsoftware.tools.Optionals.nullable;
import static de.srsoftware.umbrella.core.Constants.TOKEN; 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.Paths.JSON;
import static de.srsoftware.umbrella.core.Util.mapValues; import static de.srsoftware.umbrella.core.Util.mapValues;
@ -20,11 +22,10 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class CompanyLegacy extends BaseHandler { public class CompanyLegacy extends BaseHandler {
private final Configuration config;
public CompanyLegacy(ModuleRegistry registry, Configuration config) { public CompanyLegacy(Configuration config) {
super(registry); super();
this.config = config.subset("umbrella.modules").orElseThrow(() -> new RuntimeException("Missing configuration: umbrella.modules")); ModuleRegistry.add(this);
} }
@Override @Override

9
legacy/src/main/java/de/srsoftware/umbrella/legacy/NotesLegacy.java

@ -5,6 +5,8 @@ package de.srsoftware.umbrella.legacy;
import static de.srsoftware.tools.Optionals.nullable; import static de.srsoftware.tools.Optionals.nullable;
import static de.srsoftware.umbrella.core.Constants.TOKEN; import static de.srsoftware.umbrella.core.Constants.TOKEN;
import static de.srsoftware.umbrella.core.Constants.URI; 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.Util.markdown;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.invalidFieldException; import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.invalidFieldException;
@ -14,7 +16,6 @@ import de.srsoftware.tools.Path;
import de.srsoftware.tools.SessionToken; import de.srsoftware.tools.SessionToken;
import de.srsoftware.tools.Tag; import de.srsoftware.tools.Tag;
import de.srsoftware.umbrella.core.BaseHandler; import de.srsoftware.umbrella.core.BaseHandler;
import de.srsoftware.umbrella.core.ModuleRegistry;
import de.srsoftware.umbrella.core.model.Token; import de.srsoftware.umbrella.core.model.Token;
import de.srsoftware.umbrella.core.model.UmbrellaUser; import de.srsoftware.umbrella.core.model.UmbrellaUser;
import java.io.IOException; import java.io.IOException;
@ -24,11 +25,9 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class NotesLegacy extends BaseHandler { public class NotesLegacy extends BaseHandler {
private final Configuration config;
public NotesLegacy(ModuleRegistry registry, Configuration config) { public NotesLegacy(Configuration config) {
super(registry); super();
this.config = config.subset("umbrella.modules").orElseThrow(() -> new RuntimeException("Missing configuration: umbrella.modules"));
} }
@Override @Override

9
legacy/src/main/java/de/srsoftware/umbrella/legacy/ProjectLegacy.java

@ -4,6 +4,8 @@ package de.srsoftware.umbrella.legacy;
import static de.srsoftware.tools.Optionals.nullable; import static de.srsoftware.tools.Optionals.nullable;
import static de.srsoftware.umbrella.core.Constants.*; 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.Paths.JSON;
import static de.srsoftware.umbrella.core.Util.mapValues; import static de.srsoftware.umbrella.core.Util.mapValues;
@ -12,7 +14,6 @@ import de.srsoftware.configuration.Configuration;
import de.srsoftware.tools.Path; import de.srsoftware.tools.Path;
import de.srsoftware.tools.SessionToken; import de.srsoftware.tools.SessionToken;
import de.srsoftware.umbrella.core.BaseHandler; import de.srsoftware.umbrella.core.BaseHandler;
import de.srsoftware.umbrella.core.ModuleRegistry;
import de.srsoftware.umbrella.core.model.Token; import de.srsoftware.umbrella.core.model.Token;
import de.srsoftware.umbrella.core.model.UmbrellaUser; import de.srsoftware.umbrella.core.model.UmbrellaUser;
import java.io.IOException; import java.io.IOException;
@ -20,11 +21,9 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class ProjectLegacy extends BaseHandler { public class ProjectLegacy extends BaseHandler {
private final Configuration config;
public ProjectLegacy(ModuleRegistry registry, Configuration config) { public ProjectLegacy(Configuration config) {
super(registry); super();
this.config = config.subset("umbrella.modules").orElseThrow(() -> new RuntimeException("Missing configuration: umbrella.modules"));
} }
@Override @Override

10
legacy/src/main/java/de/srsoftware/umbrella/legacy/TaskLegacy.java

@ -6,16 +6,16 @@ package de.srsoftware.umbrella.legacy;
import static de.srsoftware.tools.Optionals.nullable; import static de.srsoftware.tools.Optionals.nullable;
import static de.srsoftware.umbrella.core.Constants.DESCRIPTION; import static de.srsoftware.umbrella.core.Constants.DESCRIPTION;
import static de.srsoftware.umbrella.core.Constants.TOKEN; 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.Paths.JSON;
import static de.srsoftware.umbrella.core.Util.mapValues; import static de.srsoftware.umbrella.core.Util.mapValues;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.unprocessable; import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.unprocessable;
import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpExchange;
import de.srsoftware.configuration.Configuration;
import de.srsoftware.tools.Path; import de.srsoftware.tools.Path;
import de.srsoftware.tools.SessionToken; import de.srsoftware.tools.SessionToken;
import de.srsoftware.umbrella.core.BaseHandler; import de.srsoftware.umbrella.core.BaseHandler;
import de.srsoftware.umbrella.core.ModuleRegistry;
import de.srsoftware.umbrella.core.model.Token; import de.srsoftware.umbrella.core.model.Token;
import de.srsoftware.umbrella.core.model.UmbrellaUser; import de.srsoftware.umbrella.core.model.UmbrellaUser;
import java.io.IOException; import java.io.IOException;
@ -24,11 +24,9 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
public class TaskLegacy extends BaseHandler { public class TaskLegacy extends BaseHandler {
private final Configuration config;
public TaskLegacy(ModuleRegistry registry, Configuration config) { public TaskLegacy() {
super(registry); super();
this.config = config.subset("umbrella.modules").orElseThrow(() -> new RuntimeException("Missing configuration: umbrella.modules"));
} }
@Override @Override

6
legacy/src/main/java/de/srsoftware/umbrella/legacy/UserLegacy.java

@ -5,6 +5,7 @@ import static de.srsoftware.tools.MimeType.MIME_FORM_URL;
import static de.srsoftware.tools.Query.decode; import static de.srsoftware.tools.Query.decode;
import static de.srsoftware.umbrella.core.Constants.*; import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.Constants.TOKEN; 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.Paths.*;
import static de.srsoftware.umbrella.core.Util.request; import static de.srsoftware.umbrella.core.Util.request;
import static de.srsoftware.umbrella.user.Paths.*; import static de.srsoftware.umbrella.user.Paths.*;
@ -19,7 +20,6 @@ import de.srsoftware.configuration.Configuration;
import de.srsoftware.tools.Path; import de.srsoftware.tools.Path;
import de.srsoftware.tools.SessionToken; import de.srsoftware.tools.SessionToken;
import de.srsoftware.umbrella.core.BaseHandler; import de.srsoftware.umbrella.core.BaseHandler;
import de.srsoftware.umbrella.core.ModuleRegistry;
import de.srsoftware.umbrella.core.exceptions.UmbrellaException; import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
import de.srsoftware.umbrella.core.model.Session; import de.srsoftware.umbrella.core.model.Session;
import de.srsoftware.umbrella.core.model.Token; import de.srsoftware.umbrella.core.model.Token;
@ -34,8 +34,8 @@ public class UserLegacy extends BaseHandler {
private final Configuration config; private final Configuration config;
private final String messageUrl; private final String messageUrl;
public UserLegacy(ModuleRegistry registry, Configuration config) { public UserLegacy(Configuration config) {
super(registry); super();
this.config = config.subset("umbrella.modules").orElseThrow(() -> new RuntimeException("Missing configuration: umbrella.modules")); this.config = config.subset("umbrella.modules").orElseThrow(() -> new RuntimeException("Missing configuration: umbrella.modules"));
this.messageUrl = null; this.messageUrl = null;
} }

6
markdown/src/main/java/de/srsoftware/umbrella/markdown/MarkdownApi.java

@ -2,6 +2,7 @@
package de.srsoftware.umbrella.markdown; package de.srsoftware.umbrella.markdown;
import static de.srsoftware.tools.MimeType.MIME_HTML; import static de.srsoftware.tools.MimeType.MIME_HTML;
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpExchange;
import de.srsoftware.tools.Path; import de.srsoftware.tools.Path;
@ -18,8 +19,9 @@ import java.util.Optional;
public class MarkdownApi extends BaseHandler implements MarkdownService { public class MarkdownApi extends BaseHandler implements MarkdownService {
public MarkdownApi(ModuleRegistry registry) { public MarkdownApi() {
super(registry); super();
ModuleRegistry.add(this);
} }
@Override @Override

7
messages/src/main/java/de/srsoftware/umbrella/message/MessageSystem.java

@ -32,7 +32,6 @@ import java.util.function.BiFunction;
public class MessageSystem implements PostBox { public class MessageSystem implements PostBox {
public static final System.Logger LOG = System.getLogger(MessageSystem.class.getSimpleName()); public static final System.Logger LOG = System.getLogger(MessageSystem.class.getSimpleName());
private final Timer timer = new Timer(); private final Timer timer = new Timer();
private final ModuleRegistry registry;
private record Receiver(User user, de.srsoftware.umbrella.core.model.Message message){} private record Receiver(User user, de.srsoftware.umbrella.core.model.Message message){}
@ -72,7 +71,7 @@ public class MessageSystem implements PostBox {
private String debugAddress; private String debugAddress;
private final HashMap<Receiver,List<Exception>> exceptions = new HashMap<>(); private final HashMap<Receiver,List<Exception>> exceptions = new HashMap<>();
public MessageSystem(ModuleRegistry moduleRegistry, Configuration config) throws UmbrellaException { public MessageSystem(Configuration config) throws UmbrellaException {
var dbFile = config.get(CONFIG_DB).orElseThrow(() -> missingConfigException(CONFIG_DB)); var dbFile = config.get(CONFIG_DB).orElseThrow(() -> missingConfigException(CONFIG_DB));
db = new SqliteMessageDb(connect(dbFile)); db = new SqliteMessageDb(connect(dbFile));
debugAddress = config.get(DEBUG_ADDREESS).map(Object::toString).orElse(null); debugAddress = config.get(DEBUG_ADDREESS).map(Object::toString).orElse(null);
@ -81,7 +80,7 @@ public class MessageSystem implements PostBox {
user = config.get(CONFIG_SMTP_USER).map(Object::toString).orElseThrow(() -> new RuntimeException("umbrella.modules.message.smtp.user 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!")); pass = config.get(CONFIG_SMTP_PASS).map(Object::toString).orElseThrow(() -> new RuntimeException("umbrella.modules.message.smtp.pass not configured!"));
from = user; from = user;
registry = moduleRegistry.add(this); ModuleRegistry.add(this);
new SubmissionTask(8).schedule(); new SubmissionTask(8).schedule();
new SubmissionTask(10).schedule(); new SubmissionTask(10).schedule();
new SubmissionTask(12).schedule(); new SubmissionTask(12).schedule();
@ -117,7 +116,7 @@ public class MessageSystem implements PostBox {
var date = new Date(); var date = new Date();
for (var receiver : dueRecipients){ for (var receiver : dueRecipients){
BiFunction<String,Map<String,String>,String> translateFunction = (text,fills) -> registry.translator().translate(receiver.language(),text,fills); BiFunction<String,Map<String,String>,String> translateFunction = (text,fills) -> ModuleRegistry.translator().translate(receiver.language(),text,fills);
var combined = new CombinedMessage("Collected messages",translateFunction); var combined = new CombinedMessage("Collected messages",translateFunction);
var envelopes = queue.stream().filter(env -> env.isFor(receiver)).toList(); var envelopes = queue.stream().filter(env -> env.isFor(receiver)).toList();

9
notes/src/main/java/de/srsoftware/umbrella/notes/NoteModule.java

@ -4,19 +4,17 @@ package de.srsoftware.umbrella.notes;
import static de.srsoftware.umbrella.core.ConnectionProvider.connect; import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.Constants.*; import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.Constants.FULLTEXT; import static de.srsoftware.umbrella.core.Constants.FULLTEXT;
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
import static de.srsoftware.umbrella.core.Paths.SEARCH; import static de.srsoftware.umbrella.core.Paths.SEARCH;
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_UNPROCESSABLE; import static de.srsoftware.umbrella.core.ResponseCode.HTTP_UNPROCESSABLE;
import static de.srsoftware.umbrella.core.Util.mapValues; import static de.srsoftware.umbrella.core.Util.mapValues;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*; import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
import static de.srsoftware.umbrella.notes.Constants.CONFIG_DATABASE; import static de.srsoftware.umbrella.notes.Constants.CONFIG_DATABASE;
import static de.srsoftware.umbrella.notes.Constants.TABLE_NOTES;
import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpExchange;
import de.srsoftware.configuration.Configuration; import de.srsoftware.configuration.Configuration;
import de.srsoftware.tools.Path; import de.srsoftware.tools.Path;
import de.srsoftware.tools.SessionToken; import de.srsoftware.tools.SessionToken;
import de.srsoftware.tools.jdbc.Condition;
import de.srsoftware.tools.jdbc.Query;
import de.srsoftware.umbrella.core.BaseHandler; import de.srsoftware.umbrella.core.BaseHandler;
import de.srsoftware.umbrella.core.ModuleRegistry; import de.srsoftware.umbrella.core.ModuleRegistry;
import de.srsoftware.umbrella.core.api.NoteService; import de.srsoftware.umbrella.core.api.NoteService;
@ -34,10 +32,11 @@ import java.util.stream.Collectors;
public class NoteModule extends BaseHandler implements NoteService { public class NoteModule extends BaseHandler implements NoteService {
private final NotesDb notesDb; private final NotesDb notesDb;
public NoteModule(ModuleRegistry registry, Configuration config) { public NoteModule(Configuration config) {
super(registry); super();
var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE)); var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE));
notesDb = new SqliteDb(connect(dbFile)); notesDb = new SqliteDb(connect(dbFile));
ModuleRegistry.add(this);
} }
@Override @Override

6
project/src/main/java/de/srsoftware/umbrella/project/ProjectModule.java

@ -3,6 +3,7 @@ package de.srsoftware.umbrella.project;
import static de.srsoftware.umbrella.core.ConnectionProvider.connect; import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.Constants.*; import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.ModuleRegistry.*;
import static de.srsoftware.umbrella.core.Paths.LIST; import static de.srsoftware.umbrella.core.Paths.LIST;
import static de.srsoftware.umbrella.core.Paths.SEARCH; import static de.srsoftware.umbrella.core.Paths.SEARCH;
import static de.srsoftware.umbrella.core.Util.mapValues; import static de.srsoftware.umbrella.core.Util.mapValues;
@ -32,10 +33,11 @@ public class ProjectModule extends BaseHandler implements ProjectService {
private final ProjectDb projectDb; private final ProjectDb projectDb;
public ProjectModule(ModuleRegistry registry, Configuration config) throws UmbrellaException { public ProjectModule(Configuration config) throws UmbrellaException {
super(registry); super();
var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE)); var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE));
projectDb = new SqliteDb(connect(dbFile)); projectDb = new SqliteDb(connect(dbFile));
ModuleRegistry.add(this);
} }
private void addMember(Project project, long userId) { private void addMember(Project project, long userId) {

6
tags/src/main/java/de/srsoftware/umbrella/tags/TagModule.java

@ -3,6 +3,7 @@ package de.srsoftware.umbrella.tags;
import static de.srsoftware.umbrella.core.ConnectionProvider.connect; import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.Constants.*; import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_UNPROCESSABLE; import static de.srsoftware.umbrella.core.ResponseCode.HTTP_UNPROCESSABLE;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingFieldException; import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingFieldException;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.unprocessable; import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.unprocessable;
@ -26,11 +27,12 @@ import org.json.JSONArray;
public class TagModule extends BaseHandler implements TagService { public class TagModule extends BaseHandler implements TagService {
private final SqliteDb tagDb; private final SqliteDb tagDb;
public TagModule(ModuleRegistry registry, Configuration config) { public TagModule(Configuration config) {
super(registry); super();
var tagDbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE)); var tagDbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE));
var bmDbFile = config.get(de.srsoftware.umbrella.bookmarks.Constants.CONFIG_DATABASE).orElseThrow(() -> missingFieldException(de.srsoftware.umbrella.bookmarks.Constants.CONFIG_DATABASE)); var bmDbFile = config.get(de.srsoftware.umbrella.bookmarks.Constants.CONFIG_DATABASE).orElseThrow(() -> missingFieldException(de.srsoftware.umbrella.bookmarks.Constants.CONFIG_DATABASE));
tagDb = new SqliteDb(connect(tagDbFile),connect(bmDbFile)); tagDb = new SqliteDb(connect(tagDbFile),connect(bmDbFile));
ModuleRegistry.add(this);
} }
@Override @Override

6
task/src/main/java/de/srsoftware/umbrella/task/TaskModule.java

@ -5,6 +5,7 @@ import static de.srsoftware.tools.Optionals.is0;
import static de.srsoftware.tools.Optionals.isSet; import static de.srsoftware.tools.Optionals.isSet;
import static de.srsoftware.umbrella.core.ConnectionProvider.connect; import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.Constants.*; import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.ModuleRegistry.*;
import static de.srsoftware.umbrella.core.Paths.*; import static de.srsoftware.umbrella.core.Paths.*;
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_NOT_IMPLEMENTED; import static de.srsoftware.umbrella.core.ResponseCode.HTTP_NOT_IMPLEMENTED;
import static de.srsoftware.umbrella.core.Util.mapValues; import static de.srsoftware.umbrella.core.Util.mapValues;
@ -37,10 +38,11 @@ public class TaskModule extends BaseHandler implements TaskService {
private final TaskDb taskDb; private final TaskDb taskDb;
public TaskModule(ModuleRegistry registry, Configuration config) throws UmbrellaException { public TaskModule(Configuration config) throws UmbrellaException {
super(registry); super();
var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE)); var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE));
taskDb = new SqliteDb(connect(dbFile)); taskDb = new SqliteDb(connect(dbFile));
ModuleRegistry.add(this);
} }
private void addMember(Task task, long userId) { private void addMember(Task task, long userId) {

6
time/src/main/java/de/srsoftware/umbrella/time/TimeModule.java

@ -3,6 +3,7 @@ package de.srsoftware.umbrella.time;
import static de.srsoftware.umbrella.core.ConnectionProvider.connect; import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.Constants.*; import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.ModuleRegistry.*;
import static de.srsoftware.umbrella.core.Paths.*; import static de.srsoftware.umbrella.core.Paths.*;
import static de.srsoftware.umbrella.core.Util.mapValues; import static de.srsoftware.umbrella.core.Util.mapValues;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*; import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
@ -27,10 +28,11 @@ public class TimeModule extends BaseHandler implements TimeService {
private final TimeDb timeDb; private final TimeDb timeDb;
public TimeModule(ModuleRegistry registry, Configuration config) throws UmbrellaException { public TimeModule( Configuration config) throws UmbrellaException {
super(registry); super();
var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE)); var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE));
timeDb = new SqliteDb(connect(dbFile)); timeDb = new SqliteDb(connect(dbFile));
ModuleRegistry.add(this);
} }

4
translations/src/main/java/de/srsoftware/umbrella/translations/Translations.java

@ -21,8 +21,8 @@ public class Translations extends PathHandler implements Translator {
private HashMap<String, JSONObject> translations = new HashMap<>(); private HashMap<String, JSONObject> translations = new HashMap<>();
public Translations(ModuleRegistry registry) { public Translations() {
registry.add(this); ModuleRegistry.add(this);
} }
@Override @Override

2
translations/src/main/resources/de.json

@ -70,7 +70,7 @@
"edit_object" : "{object} bearbeiten", "edit_object" : "{object} bearbeiten",
"editing": "Nutzer {0} bearbeiten", "editing": "Nutzer {0} bearbeiten",
"edit_password": "Passwort ändern", "edit_password": "Passwort ändern",
"edit_service": "Login-Service \"{0}\" bearbeiten", "edit_service": "Login-Service \"{name}\" bearbeiten",
"email": "E-Mail", "email": "E-Mail",
"email_or_username": "Email oder Nutzername", "email_or_username": "Email oder Nutzername",
"end": "Ende", "end": "Ende",

4
user/src/main/java/de/srsoftware/umbrella/user/Constants.java

@ -35,8 +35,8 @@ public class Constants {
public static final String SCOPE = "scope"; public static final String SCOPE = "scope";
public static final String SERVICE_ID = "service_id"; public static final String SERVICE_ID = "service_id";
public static final String TABLE_LOGIN_SERVICES = "user_login_services"; public static final String TABLE_LOGIN_SERVICES = "login_services";
public static final String TABLE_SERVICE_IDS_USERS = "user_service_ids_users"; public static final String TABLE_SERVICE_IDS_USERS = "service_ids_users";
public static final String TABLE_TOKENS = "tokens"; public static final String TABLE_TOKENS = "tokens";
public static final String TABLE_TOKEN_USES = "token_uses"; public static final String TABLE_TOKEN_USES = "token_uses";
public static final String TABLE_USERS = "users"; public static final String TABLE_USERS = "users";

6
user/src/main/java/de/srsoftware/umbrella/user/UserModule.java

@ -8,6 +8,7 @@ import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.Constants.*; import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.Constants.CODE; import static de.srsoftware.umbrella.core.Constants.CODE;
import static de.srsoftware.umbrella.core.Constants.TOKEN; import static de.srsoftware.umbrella.core.Constants.TOKEN;
import static de.srsoftware.umbrella.core.ModuleRegistry.postBox;
import static de.srsoftware.umbrella.core.Paths.*; import static de.srsoftware.umbrella.core.Paths.*;
import static de.srsoftware.umbrella.core.ResponseCode.*; import static de.srsoftware.umbrella.core.ResponseCode.*;
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_SERVER_ERROR; import static de.srsoftware.umbrella.core.ResponseCode.HTTP_SERVER_ERROR;
@ -80,12 +81,13 @@ public class UserModule extends BaseHandler implements UserService {
} }
} }
public UserModule(ModuleRegistry registry, Configuration config) throws UmbrellaException { public UserModule(Configuration config) throws UmbrellaException {
super(registry); super();
var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingConfigException(CONFIG_DATABASE)); var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingConfigException(CONFIG_DATABASE));
// may be splitted in separate db files later // may be splitted in separate db files later
logins = new SqliteDB(connect(dbFile)); logins = new SqliteDB(connect(dbFile));
users = new SqliteDB(connect(dbFile)); users = new SqliteDB(connect(dbFile));
ModuleRegistry.add(this);
} }
private boolean deleteOIDC(HttpExchange ex, UmbrellaUser user, Path path) throws IOException { private boolean deleteOIDC(HttpExchange ex, UmbrellaUser user, Path path) throws IOException {

5
web/src/main/java/de/srsoftware/umbrella/web/WebHandler.java

@ -8,14 +8,13 @@ import static java.net.HttpURLConnection.HTTP_NOT_FOUND;
import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpExchange;
import de.srsoftware.tools.Path; import de.srsoftware.tools.Path;
import de.srsoftware.umbrella.core.BaseHandler; import de.srsoftware.umbrella.core.BaseHandler;
import de.srsoftware.umbrella.core.ModuleRegistry;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
public class WebHandler extends BaseHandler { public class WebHandler extends BaseHandler {
public WebHandler(ModuleRegistry registry){ public WebHandler(){
super(registry); super();
} }
@Override @Override

28
wiki/src/main/java/de/srsoftware/umbrella/wiki/SqliteDb.java

@ -1,20 +1,11 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.wiki; package de.srsoftware.umbrella.wiki;
import de.srsoftware.tools.jdbc.Condition;
import de.srsoftware.tools.jdbc.Query;
import de.srsoftware.umbrella.core.BaseDb;
import de.srsoftware.umbrella.core.ModuleRegistry;
import de.srsoftware.umbrella.core.model.Permission;
import de.srsoftware.umbrella.core.model.WikiPage;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.*;
import static de.srsoftware.tools.jdbc.Query.*; import static de.srsoftware.tools.jdbc.Query.*;
import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL; import static de.srsoftware.tools.jdbc.Query.SelectQuery.ALL;
import static de.srsoftware.umbrella.core.Constants.*; import static de.srsoftware.umbrella.core.Constants.*;
import static de.srsoftware.umbrella.core.Constants.ERROR_FAILED_CREATE_TABLE; import static de.srsoftware.umbrella.core.Constants.ERROR_FAILED_CREATE_TABLE;
import static de.srsoftware.umbrella.core.ModuleRegistry.noteService;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException; import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.databaseException;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.notFound; import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.notFound;
import static de.srsoftware.umbrella.core.model.Permission.EDIT; import static de.srsoftware.umbrella.core.model.Permission.EDIT;
@ -23,13 +14,20 @@ import static de.srsoftware.umbrella.wiki.Constants.*;
import static java.lang.System.Logger.Level.*; import static java.lang.System.Logger.Level.*;
import static java.text.MessageFormat.format; import static java.text.MessageFormat.format;
import de.srsoftware.tools.jdbc.Condition;
import de.srsoftware.tools.jdbc.Query;
import de.srsoftware.umbrella.core.BaseDb;
import de.srsoftware.umbrella.core.model.Permission;
import de.srsoftware.umbrella.core.model.WikiPage;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.*;
public class SqliteDb extends BaseDb implements WikiDb { public class SqliteDb extends BaseDb implements WikiDb {
private static final System.Logger LOG = System.getLogger("TaskDb"); private static final System.Logger LOG = System.getLogger("TaskDb");
private final ModuleRegistry registry;
public SqliteDb(Connection connection, ModuleRegistry registry) { public SqliteDb(Connection connection) {
super(connection); super(connection);
this.registry = registry;
} }
@Override @Override
@ -242,7 +240,7 @@ public class SqliteDb extends BaseDb implements WikiDb {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
var notes = registry.noteService(); var notes = noteService();
for (var entry : pageMap.entrySet()){ for (var entry : pageMap.entrySet()){
var oldId = entry.getKey(); var oldId = entry.getKey();
var newId = entry.getValue(); var newId = entry.getValue();

1
wiki/src/main/java/de/srsoftware/umbrella/wiki/WikiDb.java

@ -4,7 +4,6 @@ package de.srsoftware.umbrella.wiki;
import de.srsoftware.umbrella.core.model.Permission; import de.srsoftware.umbrella.core.model.Permission;
import de.srsoftware.umbrella.core.model.WikiPage; import de.srsoftware.umbrella.core.model.WikiPage;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

24
wiki/src/main/java/de/srsoftware/umbrella/wiki/WikiModule.java

@ -1,35 +1,35 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.wiki; package de.srsoftware.umbrella.wiki;
import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.Constants.VERSION;
import static de.srsoftware.umbrella.core.ModuleRegistry.userService;
import static de.srsoftware.umbrella.core.Paths.PAGE;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
import static de.srsoftware.umbrella.core.model.Permission.EDIT;
import static de.srsoftware.umbrella.wiki.Constants.*;
import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpExchange;
import de.srsoftware.configuration.Configuration; import de.srsoftware.configuration.Configuration;
import de.srsoftware.tools.Path; import de.srsoftware.tools.Path;
import de.srsoftware.tools.SessionToken; import de.srsoftware.tools.SessionToken;
import de.srsoftware.umbrella.core.BaseHandler; import de.srsoftware.umbrella.core.BaseHandler;
import de.srsoftware.umbrella.core.ModuleRegistry;
import de.srsoftware.umbrella.core.api.WikiService; import de.srsoftware.umbrella.core.api.WikiService;
import de.srsoftware.umbrella.core.exceptions.UmbrellaException; import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
import de.srsoftware.umbrella.core.model.Member; import de.srsoftware.umbrella.core.model.Member;
import de.srsoftware.umbrella.core.model.Token; import de.srsoftware.umbrella.core.model.Token;
import de.srsoftware.umbrella.core.model.UmbrellaUser; import de.srsoftware.umbrella.core.model.UmbrellaUser;
import de.srsoftware.umbrella.core.model.WikiPage; import de.srsoftware.umbrella.core.model.WikiPage;
import java.io.IOException; import java.io.IOException;
import java.util.Optional; import java.util.Optional;
import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
import static de.srsoftware.umbrella.core.Constants.VERSION;
import static de.srsoftware.umbrella.core.Paths.PAGE;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
import static de.srsoftware.umbrella.core.model.Permission.EDIT;
import static de.srsoftware.umbrella.wiki.Constants.*;
public class WikiModule extends BaseHandler implements WikiService { public class WikiModule extends BaseHandler implements WikiService {
private final WikiDb wikiDb; private final WikiDb wikiDb;
public WikiModule(ModuleRegistry registry, Configuration config) { public WikiModule(Configuration config) {
super(registry); super();
var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE)); var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE));
wikiDb = new SqliteDb(connect(dbFile),registry); wikiDb = new SqliteDb(connect(dbFile));
} }

Loading…
Cancel
Save