private Supplier<List<Nab>> detailSupplier = Suppliers.memoizeWithExpiration(new DetailSupplier(), 1, TimeUnit.MINUTES);
@PostConstruct
void init() {
restHandler
.get(new Route("/admin/connected/infos") {
@Override
public void handle(Request request, Response response, Map<String, String> map) throws Exception {
long nabaztagRegistered = nabaztagDAO.count();
long users = userDAO.count();
Infos infos = new Infos(connectionManager.size(), awakeSupplier.get(), nabaztagRegistered, users);
response.writeJSON(infos);
}
})
.get(new Route("/admin/connected/infos/details") {
@Override
public void handle(Request request, Response response, Map<String, String> map) throws Exception {
response.writeJSON(detailSupplier.get());
}
})
.get(new Route("/admin/connected/list") {
@Override
public void handle(Request request, Response response, Map<String, String> map) throws Exception {
Token token = TokenUtil.decode(checkNotNull(request.getParamOrHeader("token")), Token.class);
User user = checkNotNull(userDAO.get(token.getUserId()));
if (!user.getPermissions().contains("admin"))