use of org.thingsboard.server.controller.HttpValidationCallback in project thingsboard by thingsboard.
the class AccessValidator method validateEntityAndCallback.
public DeferredResult<ResponseEntity> validateEntityAndCallback(SecurityUser currentUser, Operation operation, EntityId entityId, ThreeConsumer<DeferredResult<ResponseEntity>, TenantId, EntityId> onSuccess, BiConsumer<DeferredResult<ResponseEntity>, Throwable> onFailure) throws ThingsboardException {
final DeferredResult<ResponseEntity> response = new DeferredResult<>();
validate(currentUser, operation, entityId, new HttpValidationCallback(response, new FutureCallback<DeferredResult<ResponseEntity>>() {
@Override
public void onSuccess(@Nullable DeferredResult<ResponseEntity> result) {
try {
onSuccess.accept(response, currentUser.getTenantId(), entityId);
} catch (Exception e) {
onFailure(e);
}
}
@Override
public void onFailure(Throwable t) {
onFailure.accept(response, t);
}
}));
return response;
}
Aggregations