use of io.lumeer.engine.api.event.ReloadGroups in project engine by Lumeer.
the class UserFacade method setUserGroups.
public void setUserGroups(String organizationId, String userId, Set<String> groups) {
permissionsChecker.checkGroupsHandle();
checkOrganizationPermissions(organizationId, RoleType.UserConfig);
groupDao.deleteUserFromGroups(userId);
groupDao.addUserToGroups(userId, groups);
permissionsChecker.getPermissionAdapter().invalidateUserCache();
if (reloadGroupsEvent != null) {
reloadGroupsEvent.fire(new ReloadGroups(organizationId));
}
}
use of io.lumeer.engine.api.event.ReloadGroups in project engine by Lumeer.
the class PusherFacade method reloadGroups.
public void reloadGroups(@Observes final ReloadGroups reloadGroups) {
if (isEnabled()) {
try {
ObjectWithParent object = new ObjectWithParent(getAppId(), reloadGroups.getOrganizationId(), reloadGroups.getOrganizationId());
Organization organization = organizationDao.getOrganizationById(reloadGroups.getOrganizationId());
Set<String> users = resourceAdapter.getOrganizationReaders(organization);
List<Event> events = users.stream().map(userId -> new Event(eventChannel(userId), Group.class.getSimpleName() + RELOAD_EVENT_SUFFIX, object)).collect(Collectors.toList());
sendNotificationsBatch(events);
} catch (Exception e) {
log.log(Level.WARNING, "Unable to send push notification: ", e);
}
}
}
Aggregations