class FolderServiceImpl extends RemoteServiceServlet implements FolderService {

	@Override
	public void applyRights(GUIFolder folder, boolean subtree) throws ServerException {
		Session session = ServiceUtil.validateSession(getThreadLocalRequest());

		try {
			FolderDAO fdao = (FolderDAO) Context.get().getBean(FolderDAO.class);
			Folder f = fdao.findById(folder.getId());
			fdao.initialize(f);

			if (subtree) {
				/*
				 * Just apply the current security settings to the whole subtree
				 */
				FolderHistory history = new FolderHistory();
				history.setSession(session);
				history.setEvent(FolderEvent.PERMISSION.toString());

				fdao.applyRightToTree(folder.getId(), history);
			} else {
				saveRules(session, f, session.getUserId(), folder.getRights());
			}
		} catch (Throwable t) {
			ServiceUtil.throwServerException(session, log, t);
		}
	}

}