class UserGroupServiceImpl implements UserGroupService {

	@Override
	public void removeGroup(String groupId) {
		if (projectDAO.getProjectsWithEndpointStatusNotIn(UserInstanceStatus.TERMINATED,
				UserInstanceStatus.TERMINATING)
				.stream()
				.map(ProjectDTO::getGroups)
				.noneMatch(groups -> groups.contains(groupId))) {
			userRoleDao.removeGroup(groupId);
			userGroupDao.removeGroup(groupId);
		} else {
			throw new ResourceConflictException("Group can not be removed because it is used in some project");
		}
	}

}