use of org.thingsboard.server.extensions.api.exception.InternalErrorException in project thingsboard by thingsboard.
the class ValidationCallback method onSuccess.
@Override
public void onSuccess(PluginContext ctx, ValidationResult result) {
ValidationResultCode resultCode = result.getResultCode();
if (resultCode == ValidationResultCode.OK) {
action.accept(ctx);
} else {
Exception e;
switch(resultCode) {
case ENTITY_NOT_FOUND:
e = new EntityNotFoundException(result.getMessage());
break;
case UNAUTHORIZED:
e = new UnauthorizedException(result.getMessage());
break;
case ACCESS_DENIED:
e = new AccessDeniedException(result.getMessage());
break;
case INTERNAL_ERROR:
e = new InternalErrorException(result.getMessage());
break;
default:
e = new UnauthorizedException("Permission denied.");
break;
}
onFailure(ctx, e);
}
}
Aggregations