Arsnael commented on code in PR #2824:
URL: https://github.com/apache/james-project/pull/2824#discussion_r2412841885


##########
server/protocols/webadmin/webadmin-core/src/main/java/org/apache/james/webadmin/tasks/TaskFromRequest.java:
##########
@@ -43,15 +46,35 @@ class TaskRoute implements Route {
 
         @Override
         public TaskIdDto handle(Request request, Response response) throws 
Exception {
-            Task task = taskFromRequest.fromRequest(request);
-            TaskId taskId = taskManager.submit(task);
+            SingleTaskHandler taskHandler = (SingleTaskHandler) 
taskFromRequest.fromRequest(request);
+            TaskId taskId = taskManager.submit(taskHandler.task());
             response.status(HttpStatus.CREATED_201);
             response.header(LOCATION.asString(), TasksRoutes.BASE + "/" + 
taskId.asString());
             return new TaskIdDto(taskId.getValue());
         }
     }
 
-    Task fromRequest(Request request) throws Exception;
+    class MultiTaskRoute implements Route {
+        private final TaskFromRequest taskFromRequest;
+        private final TaskManager taskManager;
+
+        MultiTaskRoute(TaskFromRequest taskFromRequest, TaskManager 
taskManager) {
+            this.taskFromRequest = taskFromRequest;
+            this.taskManager = taskManager;
+        }
+
+        @Override
+        public List<TaskIdUserDTO> handle(Request request, Response response) 
throws Exception {
+            MultiTaskHandler task = (MultiTaskHandler) 
taskFromRequest.fromRequest(request);
+            response.status(HttpStatus.CREATED_201);
+            return task.userTasks()
+                .stream()
+                .map(userTask -> new TaskIdUserDTO(userTask.username(), 
taskManager.submit(userTask.task())))
+                .toList();

Review Comment:
   Is it? Now that I tinker around I'm not convinced, i.e.:
   
   with List we get a structure like this:
   "
   [
   {"username": "bob", "taskId": "123"},
   {"username": "alice", "taskId":"456"}
   ]
   "
   
   while with a map first value is a key... The bast I could come up with was 
Map<String, TaskIdDTO> (where string is the username.asString()):
   
   "
   {
   "bob": {"taskId": "123"},
   "alice":{"taskId":"456"}
   }
   "
   
   Depends which syntax we expect best here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to