forked from folio-org/mod-circulation-storage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTlrFeatureToggleImpl.java
41 lines (32 loc) · 1.37 KB
/
TlrFeatureToggleImpl.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package org.folio.rest.impl;
import static io.vertx.core.Future.succeededFuture;
import static org.folio.rest.jaxrs.resource.TlrFeatureToggleJobStart.PostTlrFeatureToggleJobStartResponse.respond202;
import java.lang.invoke.MethodHandles;
import java.util.Map;
import javax.ws.rs.core.Response;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.folio.rest.jaxrs.resource.TlrFeatureToggleJobStart;
import org.folio.service.tlr.TlrFeatureToggleService;
import io.vertx.core.AsyncResult;
import io.vertx.core.Context;
import io.vertx.core.Handler;
public class TlrFeatureToggleImpl implements TlrFeatureToggleJobStart {
private static final Logger log = LogManager.getLogger(MethodHandles.lookup().lookupClass());
@Override
public void postTlrFeatureToggleJobStart(Map<String, String> okapiHeaders,
Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
asyncResultHandler.handle(succeededFuture(respond202()));
vertxContext.owner().executeBlocking(promise ->
new TlrFeatureToggleService(okapiHeaders, vertxContext)
.handle()
.onComplete(v -> promise.complete()),
result -> {
if (result.failed()) {
log.error("TLR feature toggle job failed", result.cause());
} else {
log.info("TLR feature toggle job succeeded");
}
});
}
}