Add internal API to manually invoke invitation manager.

This commit is contained in:
Anatoliy Sablin
2021-01-25 22:45:18 +03:00
parent e0ec887118
commit ea8e386939
6 changed files with 76 additions and 0 deletions

View File

@@ -82,6 +82,7 @@ public class SaneHandler extends BasicHttpHandler {
} catch (InvalidJsonException e) {
respond(exchange, HttpStatus.SC_BAD_REQUEST, e.getErrorCode(), e.getError());
} catch (InvalidCredentialsException e) {
log.error("Unauthorized: ", e);
respond(exchange, HttpStatus.SC_UNAUTHORIZED, "M_UNAUTHORIZED", e.getMessage());
} catch (TermsNotSignedException e) {
respond(exchange, HttpStatus.SC_FORBIDDEN, "M_TERMS_NOT_SIGNED", e.getMessage());

View File

@@ -0,0 +1,30 @@
package io.kamax.mxisd.http.undertow.handler.internal;
import com.google.gson.JsonObject;
import io.kamax.mxisd.http.undertow.handler.BasicHttpHandler;
import io.kamax.mxisd.invitation.InvitationManager;
import io.undertow.server.HttpServerExchange;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class InternalInviteManagerHandler extends BasicHttpHandler {
public static final String PATH = "/_ma1sd/internal/admin/inv_manager";
private final InvitationManager invitationManager;
private final ExecutorService executors = Executors.newFixedThreadPool(1);
public InternalInviteManagerHandler(InvitationManager invitationManager) {
this.invitationManager = invitationManager;
}
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
executors.submit(invitationManager::doMaintenance);
JsonObject obj = new JsonObject();
obj.addProperty("result", "ok");
respond(exchange, obj);
}
}