preparing file service
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -16,6 +16,7 @@ dependencies{
|
||||
implementation(project(":contact"))
|
||||
implementation(project(":core"))
|
||||
implementation(project(":documents"))
|
||||
implementation(project(":files"))
|
||||
implementation(project(":items"))
|
||||
implementation(project(":legacy"))
|
||||
implementation(project(":markdown"))
|
||||
|
||||
@@ -13,6 +13,7 @@ import de.srsoftware.umbrella.company.CompanyModule;
|
||||
import de.srsoftware.umbrella.core.Util;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
import de.srsoftware.umbrella.documents.DocumentApi;
|
||||
import de.srsoftware.umbrella.files.FileModule;
|
||||
import de.srsoftware.umbrella.items.ItemApi;
|
||||
import de.srsoftware.umbrella.legacy.*;
|
||||
import de.srsoftware.umbrella.markdown.MarkdownApi;
|
||||
@@ -79,6 +80,7 @@ public class Application {
|
||||
new TimeModule(config).bindPath("/api/time").on(server);
|
||||
new WebHandler().bindPath("/").on(server);
|
||||
new WikiModule(config).bindPath("/api/wiki").on(server);
|
||||
new FileModule(config).bindPath("/api/files").on(server);
|
||||
|
||||
server.setExecutor(Executors.newFixedThreadPool(threads));
|
||||
server.start();
|
||||
|
||||
@@ -6,19 +6,20 @@ import de.srsoftware.umbrella.core.api.*;
|
||||
|
||||
public class ModuleRegistry {
|
||||
private BookmarkService bookmarkService;
|
||||
private CompanyService companyService;
|
||||
private CompanyService companyService;
|
||||
private DocumentService documentService;
|
||||
private ItemService itemService;
|
||||
private FileService fileService;
|
||||
private ItemService itemService;
|
||||
private MarkdownService markdownService;
|
||||
private NoteService noteService;
|
||||
private PostBox postBox;
|
||||
private ProjectService projectService;
|
||||
private TagService tagService;
|
||||
private TaskService taskService;
|
||||
private TimeService timeService;
|
||||
private Translator translator;
|
||||
private UserService userService;
|
||||
private WikiService wikiService;
|
||||
private NoteService noteService;
|
||||
private PostBox postBox;
|
||||
private ProjectService projectService;
|
||||
private TagService tagService;
|
||||
private TaskService taskService;
|
||||
private TimeService timeService;
|
||||
private Translator translator;
|
||||
private UserService userService;
|
||||
private WikiService wikiService;
|
||||
|
||||
private static final ModuleRegistry singleton = new ModuleRegistry();
|
||||
|
||||
@@ -29,6 +30,7 @@ public class ModuleRegistry {
|
||||
case BookmarkService bs: singleton.bookmarkService = bs; break;
|
||||
case CompanyService cs: singleton.companyService = cs; break;
|
||||
case DocumentService ds: singleton.documentService = ds; break;
|
||||
case FileService fs singleton.fileService = fs; breaK;
|
||||
case ItemService is: singleton.itemService = is; break;
|
||||
case MarkdownService ms: singleton.markdownService = ms; break;
|
||||
case NoteService ns: singleton.noteService = ns; break;
|
||||
@@ -61,6 +63,10 @@ public class ModuleRegistry {
|
||||
return singleton.itemService;
|
||||
}
|
||||
|
||||
public static FileService fileService(){
|
||||
return singleton.fileService;
|
||||
}
|
||||
|
||||
public static MarkdownService markdownService(){
|
||||
return singleton.markdownService;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package de.srsoftware.umbrella.core.api;
|
||||
|
||||
public interface FileService {
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package de.srsoftware.umbrella.files;
|
||||
|
||||
public class Constants {
|
||||
public static final String CONFIG_DATABASE = "umbrella.modules.files.database";
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package de.srsoftware.umbrella.files;
|
||||
|
||||
public interface FileDb {
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package de.srsoftware.umbrella.files;
|
||||
|
||||
import de.srsoftware.configuration.Configuration;
|
||||
import de.srsoftware.umbrella.core.BaseHandler;
|
||||
import de.srsoftware.umbrella.core.ModuleRegistry;
|
||||
import de.srsoftware.umbrella.core.api.FileService;
|
||||
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
|
||||
|
||||
import static de.srsoftware.umbrella.core.ConnectionProvider.connect;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingFieldException;
|
||||
import static de.srsoftware.umbrella.files.Constants.CONFIG_DATABASE;
|
||||
|
||||
public class FileModule extends BaseHandler implements FileService {
|
||||
|
||||
FileDb fileDb;
|
||||
|
||||
public FileModule(Configuration config) throws UmbrellaException {
|
||||
super();
|
||||
var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE));
|
||||
fileDb = new SqliteDb(connect(dbFile));
|
||||
ModuleRegistry.add(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package de.srsoftware.umbrella.files;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
public class SqliteDb implements FileDb {
|
||||
private final Connection db;
|
||||
|
||||
public SqliteDb(Connection conn) {
|
||||
this.db = conn;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ include("company")
|
||||
include("contact")
|
||||
include("core")
|
||||
include("documents")
|
||||
include("files")
|
||||
include("legacy")
|
||||
include("items")
|
||||
include("messages")
|
||||
|
||||
@@ -13,7 +13,6 @@ import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.*;
|
||||
import static de.srsoftware.umbrella.core.model.Permission.*;
|
||||
import static de.srsoftware.umbrella.project.Constants.PERMISSIONS;
|
||||
import static de.srsoftware.umbrella.task.Constants.*;
|
||||
import static java.lang.System.Logger.Level.DEBUG;
|
||||
import static java.lang.System.Logger.Level.WARNING;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
|
||||
Reference in New Issue
Block a user