Merge branch 'feature/singleton_registry'
This commit is contained in:
@@ -10,7 +10,6 @@ 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.exceptions.UmbrellaException;
|
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||||
import de.srsoftware.umbrella.documents.DocumentApi;
|
import de.srsoftware.umbrella.documents.DocumentApi;
|
||||||
@@ -59,26 +58,25 @@ 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);
|
|
||||||
|
|
||||||
server.setExecutor(Executors.newFixedThreadPool(threads));
|
server.setExecutor(Executors.newFixedThreadPool(threads));
|
||||||
server.start();
|
server.start();
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,78 +19,79 @@ public class ModuleRegistry {
|
|||||||
private Translator translator;
|
private Translator translator;
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
|
private static final ModuleRegistry singleton = new ModuleRegistry();
|
||||||
|
|
||||||
|
private ModuleRegistry(){}
|
||||||
|
|
||||||
public ModuleRegistry add(Object service) {
|
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 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
@@ -24,11 +26,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
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
@@ -20,11 +22,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
|
||||||
|
|||||||
@@ -6,12 +6,13 @@ 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;
|
||||||
@@ -24,11 +25,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
|
||||||
|
|||||||
@@ -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.*;
|
||||||
@@ -34,8 +35,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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ 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;
|
||||||
@@ -31,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
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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";
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -9,13 +9,14 @@ 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 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
|
||||||
|
|||||||
Reference in New Issue
Block a user