/**
* 保存模块级权限
*/
public String save() {
Group mao = entityDao.get(Group.class, getLong("group.id"));
MenuProfile menuProfile = (MenuProfile) entityDao.get(MenuProfile.class, getLong("menuProfileId"));
Set<Resource> newResources = CollectUtils.newHashSet(entityDao.get(Resource.class,
StrUtils.splitToLong(get("resourceId"))));
// 管理员拥有的菜单权限和系统资源
User manager = entityDao.get(User.class, getUserId());
Set<Menu> mngMenus = null;
Set<Resource> mngResources = CollectUtils.newHashSet();
if (isAdmin()) {
mngMenus = CollectUtils.newHashSet(menuProfile.getMenus());
} else {
mngMenus = CollectUtils.newHashSet(menuService.getMenus(menuProfile, (User) manager));
}
for (final Menu m : mngMenus) {
mngResources.addAll(m.getResources());
}
newResources.retainAll(mngResources);
authorityService.authorize(mao, newResources);
authorityManager.refreshGroupAuthorities(new GrantedAuthorityBean(mao.getName()));
Action redirect = Action.to(this).method("edit");
redirect.param("group.id", mao.getId()).param("menuProfileId", menuProfile.getId());
String displayFreezen = get("displayFreezen");
if (null != displayFreezen) {
redirect.param("displayFreezen", displayFreezen);
}
return redirect(redirect, "info.save.success");