use of org.thingsboard.server.exception.ThingsboardException in project thingsboard by thingsboard.
the class BaseController method checkUserId.
User checkUserId(UserId userId) throws ThingsboardException {
try {
validateId(userId, "Incorrect userId " + userId);
User user = userService.findUserById(userId);
checkUser(user);
return user;
} catch (Exception e) {
throw handleException(e, false);
}
}
use of org.thingsboard.server.exception.ThingsboardException in project thingsboard by thingsboard.
the class BaseController method checkTenantId.
void checkTenantId(TenantId tenantId) throws ThingsboardException {
validateId(tenantId, INCORRECT_TENANT_ID + tenantId);
SecurityUser authUser = getCurrentUser();
if (authUser.getAuthority() != Authority.SYS_ADMIN && (authUser.getTenantId() == null || !authUser.getTenantId().equals(tenantId))) {
throw new ThingsboardException(YOU_DON_T_HAVE_PERMISSION_TO_PERFORM_THIS_OPERATION, ThingsboardErrorCode.PERMISSION_DENIED);
}
}
use of org.thingsboard.server.exception.ThingsboardException in project thingsboard by thingsboard.
the class BaseController method checkWidgetsBundleId.
WidgetsBundle checkWidgetsBundleId(WidgetsBundleId widgetsBundleId, boolean modify) throws ThingsboardException {
try {
validateId(widgetsBundleId, "Incorrect widgetsBundleId " + widgetsBundleId);
WidgetsBundle widgetsBundle = widgetsBundleService.findWidgetsBundleById(widgetsBundleId);
checkWidgetsBundle(widgetsBundle, modify);
return widgetsBundle;
} catch (Exception e) {
throw handleException(e, false);
}
}
Aggregations