forked from folio-org/mod-circulation-storage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TenantRefAPI.java
54 lines (49 loc) · 1.89 KB
/
TenantRefAPI.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
42
43
44
45
46
47
48
49
50
51
52
53
54
package org.folio.rest.impl;
import java.util.Map;
import javax.ws.rs.core.Response;
import org.folio.rest.jaxrs.model.TenantAttributes;
import io.vertx.core.AsyncResult;
import io.vertx.core.Context;
import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import org.folio.rest.tools.utils.TenantLoading;
public class TenantRefAPI extends TenantAPI {
private static final Logger log = LoggerFactory.getLogger(TenantRefAPI.class);
@Override
public void postTenant(TenantAttributes ta, Map<String, String> headers,
Handler<AsyncResult<Response>> hndlr, Context cntxt) {
log.info("postTenant");
Vertx vertx = cntxt.owner();
super.postTenant(ta, headers, res -> {
if (res.failed()) {
hndlr.handle(res);
return;
}
TenantLoading tl = new TenantLoading();
tl.withKey("loadReference").withLead("ref-data")
.withIdContent()
.add("loan-policy-storage/loan-policies")
.add("request-policy-storage/request-policies")
.add("patron-notice-policy-storage/patron-notice-policies")
.add("staff-slips-storage/staff-slips")
.withIdRaw()
.add("circulation-rules-storage")
.withIdContent()
.add("cancellation-reason-storage/cancellation-reasons")
.withKey("loadSample").withLead("sample-data")
.add("loans", "loan-storage/loans")
.add("requests", "request-storage/requests")
.perform(ta, headers, vertx, res1 -> {
if (res1.failed()) {
hndlr.handle(io.vertx.core.Future.succeededFuture(PostTenantResponse
.respond500WithTextPlain(res1.cause().getLocalizedMessage())));
return;
}
hndlr.handle(io.vertx.core.Future.succeededFuture(PostTenantResponse
.respond201WithApplicationJson("")));
});
}, cntxt);
}
}