use of org.craftercms.studio.api.v1.exception.security.UserNotFoundException in project studio by craftercms.
the class GroupServiceInternalImpl method removeGroupMembers.
@Override
public void removeGroupMembers(long groupId, List<Long> userIds, List<String> usernames) throws GroupNotFoundException, UserNotFoundException, ServiceLayerException {
if (!groupExists(groupId, StringUtils.EMPTY)) {
throw new GroupNotFoundException("No group found for id '" + groupId + "'");
}
List<User> users = userServiceInternal.getUsersByIdOrUsername(userIds, usernames);
Map<String, Object> params = new HashMap<>();
params.put(USER_IDS, users.stream().map(User::getId).collect(Collectors.toList()));
params.put(GROUP_ID, groupId);
try {
groupDao.removeGroupMembers(params);
} catch (Exception e) {
throw new ServiceLayerException("Unknown database error", e);
}
}
use of org.craftercms.studio.api.v1.exception.security.UserNotFoundException in project studio by craftercms.
the class GroupServiceInternalImpl method addGroupMembers.
@Override
public List<User> addGroupMembers(long groupId, List<Long> userIds, List<String> usernames) throws GroupNotFoundException, UserNotFoundException, ServiceLayerException {
if (!groupExists(groupId, StringUtils.EMPTY)) {
throw new GroupNotFoundException("No group found for id '" + groupId + "'");
}
List<User> users = userServiceInternal.getUsersByIdOrUsername(userIds, usernames);
Map<String, Object> params = new HashMap<>();
params.put(USER_IDS, users.stream().map(User::getId).collect(Collectors.toList()));
params.put(GROUP_ID, groupId);
try {
groupDao.addGroupMembers(params);
return users;
} catch (Exception e) {
throw new ServiceLayerException("Unknown database error", e);
}
}
use of org.craftercms.studio.api.v1.exception.security.UserNotFoundException in project studio by craftercms.
the class UserServiceInternalImpl method deleteUsers.
@RetryingOperation
@Override
public void deleteUsers(List<Long> userIds, List<String> usernames) throws UserNotFoundException, ServiceLayerException {
List<User> users = getUsersByIdOrUsername(userIds, usernames);
Map<String, Object> params = new HashMap<>();
params.put(USER_IDS, users.stream().map(User::getId).collect(Collectors.toList()));
try {
userDao.deleteUsers(params);
} catch (Exception e) {
throw new ServiceLayerException("Unknown database error", e);
}
}
Aggregations