implemented task legacy code

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-08-18 00:12:05 +02:00
parent a50a451b95
commit 763718277d
8 changed files with 31 additions and 68 deletions

View File

@@ -27,26 +27,12 @@ public class CompanyLegacy extends BaseHandler {
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 {
if (path.empty()) return sendRedirect(ex, url(ex).replaceAll("/legacy/","/"));
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{

View File

@@ -31,27 +31,12 @@ public class NotesLegacy extends BaseHandler {
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 {
if (path.empty()) return sendRedirect(ex, url(ex).replaceAll("/legacy/","/"));
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 {
var params = formData(ex);

View File

@@ -38,16 +38,6 @@ public class ProjectLegacy extends BaseHandler {
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{
var params = formData(ex);

View File

@@ -2,11 +2,12 @@
package de.srsoftware.umbrella.legacy;
import static de.srsoftware.tools.Optionals.nullable;
import static de.srsoftware.umbrella.core.Constants.TOKEN;
import static de.srsoftware.umbrella.core.Constants.USERS;
import static de.srsoftware.umbrella.core.Paths.JSON;
import static de.srsoftware.umbrella.core.Util.mapValues;
import static de.srsoftware.umbrella.core.exceptions.UmbrellaException.unprocessable;
import com.sun.net.httpserver.HttpExchange;
import de.srsoftware.configuration.Configuration;
@@ -28,11 +29,6 @@ public class TaskLegacy extends BaseHandler {
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 {
if (path.empty()) return sendRedirect(ex, url(ex).replaceAll("/legacy/","/"));
@@ -40,17 +36,7 @@ public class TaskLegacy extends BaseHandler {
}
@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{
public boolean doPost(Path path, HttpExchange ex) throws IOException {
var params = formData(ex);
Optional<Token> token = SessionToken.from(ex).map(Token::of);
@@ -59,14 +45,17 @@ public class TaskLegacy extends BaseHandler {
if (user.isEmpty()) return unauthorized(ex);
return switch (path.pop()){
case JSON -> postProjectJson(ex,params,user.get());
default -> super.doPost(path, ex);
case JSON -> postJson(user.get(),params,ex);
case null, default -> super.doPost(path,ex);
};
}
private boolean postProjectJson(HttpExchange ex, Map<String, Object> params, UmbrellaUser user) throws IOException {
var includeUsers = "1".equals(params.get(USERS));
var projects = projectService().listUserProjects(user.id(), false);
return sendContent(ex, mapValues(projects));
private boolean postJson(UmbrellaUser umbrellaUser, Map<String, Object> params, HttpExchange ex) throws IOException {
LOG.log(System.Logger.Level.DEBUG,params);
if (params.get("ids") instanceof Map<?,?> taskIdMap){
var taskIds = taskIdMap.values().stream().map(Object::toString).map(Long::parseLong).toList();
return sendContent(ex,mapValues(taskService().load(taskIds)));
}
throw unprocessable("Invalid request");
}
}