ottoka commented on code in PR #1004:
URL: https://github.com/apache/james-project/pull/1004#discussion_r875605597


##########
server/protocols/webadmin/webadmin-mailbox/src/main/java/org/apache/james/webadmin/service/ExpireInboxesTask.java:
##########
@@ -0,0 +1,124 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.webadmin.service;
+
+import java.time.Clock;
+import java.time.Instant;
+import java.util.Date;
+import java.util.Optional;
+
+import javax.inject.Inject;
+
+import org.apache.james.task.Task;
+import org.apache.james.task.TaskExecutionDetails;
+import org.apache.james.task.TaskType;
+import org.apache.james.webadmin.service.ExpireInboxesService.Context;
+import org.apache.james.webadmin.service.ExpireInboxesService.RunningOptions;
+
+import reactor.core.scheduler.Schedulers;
+
+public class ExpireInboxesTask implements Task {
+    public static final TaskType TASK_TYPE = TaskType.of("ExpireInboxesTask");
+
+    public static class AdditionalInformation implements 
TaskExecutionDetails.AdditionalInformation {
+
+        public static ExpireInboxesTask.AdditionalInformation from(Context 
context,
+                                                                   
RunningOptions runningOptions) {
+            return new ExpireInboxesTask.AdditionalInformation(
+                Clock.systemUTC().instant(),
+                runningOptions,
+                context.getInboxesExpired(),
+                context.getInboxesFailed(),
+                context.getInboxesProcessed());
+        }
+
+        private final Instant timestamp;
+        private final RunningOptions runningOptions;
+        private final long inboxesExpired;
+        private final long inboxesFailed;
+        private final long inboxesProcessed;
+
+        public AdditionalInformation(Instant timestamp,
+                                     RunningOptions runningOptions,
+                                     long inboxesExpired,
+                                     long inboxesFailed,
+                                     long inboxesProcessed) {
+            this.timestamp = timestamp;
+            this.runningOptions = runningOptions;
+            this.inboxesExpired = inboxesExpired;
+            this.inboxesFailed = inboxesFailed;
+            this.inboxesProcessed = inboxesProcessed;
+        }
+
+        public RunningOptions getRunningOptions() {
+            return runningOptions;
+        }
+
+        public long getInboxesExpired() {
+            return inboxesExpired;
+        }
+
+        public long getInboxesFailed() {
+            return inboxesFailed;
+        }
+
+        public long getInboxesProcessed() {
+            return inboxesProcessed;
+        }
+
+        @Override
+        public Instant timestamp() {
+            return timestamp;
+        }
+    }
+
+    private final ExpireInboxesService expireInboxesService;
+    private final Context context;
+    private final RunningOptions runningOptions;
+
+    @Inject
+    public ExpireInboxesTask(ExpireInboxesService expireInboxesService,
+                             RunningOptions runningOptions) {
+        this.expireInboxesService = expireInboxesService;
+        this.context = new Context();
+        this.runningOptions = runningOptions;
+    }
+
+    @Override
+    public Result run() {
+        return expireInboxesService.expireInboxes(context, runningOptions, new 
Date())
+            .subscribeOn(Schedulers.elastic())

Review Comment:
   Ok, that is an easy fix.



-- 
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