class SecurityServiceImpl extends RemoteServiceServlet implements SecurityService {

	@Override
	public void deleteGroup(long groupId) throws ServerException {
		Session session = ServiceUtil.checkMenu(getThreadLocalRequest(), Menu.SECURITY);

		try {
			UserDAO userDao = (UserDAO) Context.get().getBean(UserDAO.class);
			GroupDAO groupDao = (GroupDAO) Context.get().getBean(GroupDAO.class);
			Group grp = groupDao.findById(groupId);
			groupDao.initialize(grp);
			for (User user : grp.getUsers()) {
				user.removeGroup(groupId);
				userDao.store(user);
			}
			groupDao.delete(groupId);
		} catch (Throwable t) {
			ServiceUtil.throwServerException(session, log, t);
		}
	}

}