working on transformation of legacy notes tables
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.legacy;
|
||||
|
||||
import static de.srsoftware.umbrella.core.Constants.URI;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.missingFieldException;
|
||||
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.unprocessable;
|
||||
|
||||
import com.sun.net.httpserver.HttpExchange;
|
||||
import de.srsoftware.configuration.Configuration;
|
||||
import de.srsoftware.tools.Path;
|
||||
import de.srsoftware.umbrella.core.BaseHandler;
|
||||
import de.srsoftware.umbrella.core.ModuleRegistry;
|
||||
import java.io.IOException;
|
||||
|
||||
public class NotesLegacy extends BaseHandler {
|
||||
private final ModuleRegistry registry;
|
||||
private final Configuration config;
|
||||
|
||||
public NotesLegacy(ModuleRegistry registry, Configuration config) {
|
||||
this.registry = registry;
|
||||
this.config = config.subset("umbrella.modules").orElseThrow(() -> new RuntimeException("Missing configuration: umbrella.modules"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doDelete(Path path, HttpExchange ex) throws IOException {
|
||||
return super.doDelete(path, ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doGet(Path path, HttpExchange ex) throws IOException {
|
||||
return super.doGet(path, ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doOptions(Path path, HttpExchange ex) throws IOException {
|
||||
return super.doOptions(path, ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doPatch(Path path, HttpExchange ex) throws IOException {
|
||||
return super.doPatch(path, ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doPost(Path path, HttpExchange ex) throws IOException {
|
||||
addCors(ex);
|
||||
var data = formData(ex);
|
||||
var noteService = registry.noteService();
|
||||
if (!(data.get(URI) instanceof String uri)) throw missingFieldException(URI);
|
||||
var parts = uri.split(":",2);
|
||||
if (parts.length<2) throw unprocessable("Expected URI to contain colon (:)!");
|
||||
String module = parts[0];
|
||||
String entityId = parts[1];
|
||||
var notes = noteService.getNotes(module,entityId);
|
||||
return super.doPost(path, ex);
|
||||
}
|
||||
}
|
||||
@@ -29,13 +29,13 @@ import java.time.Instant;
|
||||
import java.util.*;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class LegacyApi extends BaseHandler {
|
||||
public class UserLegacy extends BaseHandler {
|
||||
|
||||
private final Configuration config;
|
||||
private final String messageUrl;
|
||||
private final ModuleRegistry registry;
|
||||
|
||||
public LegacyApi(ModuleRegistry registry, Configuration config) {
|
||||
public UserLegacy(ModuleRegistry registry, Configuration config) {
|
||||
this.registry = registry;
|
||||
this.config = config.subset("umbrella.modules").orElseThrow(() -> new RuntimeException("Missing configuration: umbrella.modules"));
|
||||
this.messageUrl = null;
|
||||
@@ -270,7 +270,7 @@ public class LegacyApi extends BaseHandler {
|
||||
var keys = config.keys();
|
||||
var match = false;
|
||||
for (var key : keys){
|
||||
var baseUrl = config.get(key + ".baseUrl").map(LegacyApi::stripTrailingSlash).orElse(null);
|
||||
var baseUrl = config.get(key + ".baseUrl").map(UserLegacy::stripTrailingSlash).orElse(null);
|
||||
if (domain.equals(baseUrl)){
|
||||
match = true;
|
||||
break;
|
||||
Reference in New Issue
Block a user