public String allocateRoleResourceAction() {
   String result = null;
   String resourceStr = (String) SpringFacesUtil.getRequestParameter("resourceStr");
   IRoleResourceService<RoleResource, String> objService =
       objService =
           (IRoleResourceService<RoleResource, String>)
               SpringFacesUtil.getSpringBean(
                   PlatformSpringBeanConstants.ROLE_RESOURCE_SERVICE_BEAN_NAME);
   objService.setEntityClass(RoleResource.class);
   objService.setPKClass(String.class);
   // 删除当前用户角色关联
   if (null != this.getCurrentRoleId() && !("".equals(this.getCurrentRoleId()))) {
     List<RoleResource> roleResources = objService.findBy("roleId", this.getCurrentRoleId());
     for (RoleResource roleRes : roleResources) {
       objService.removeById(roleRes.getId());
     }
   }
   // 保存新的用户角色关联
   if (!(resourceStr.isEmpty())) {
     RoleResource newObj = null;
     String[] resources = resourceStr.split(",");
     for (int i = 0; i < resources.length; i++) {
       if (!(resources[i].isEmpty())) {
         newObj = new RoleResource();
         newObj.setRoleId(this.getCurrentRoleId());
         newObj.setResourceId(new Long(resources[i]));
         try {
           EntityDataUtil<RoleResource, String> currUtil =
               new EntityDataUtil<RoleResource, String>();
           currUtil.setCreatePropertyValue(newObj);
         } catch (Exception e) {
           return result;
         } finally {
           // do nothing;//关闭session的时候还会报,并且在session那里抓取了所有的Exception。
         }
         // save
         objService.save(newObj);
       }
     }
   }
   this.setAction(PlatformConstants.ACTION_EMPTY_TYPE);
   return result;
 }
 private void operateFor(List<AuthorityResources> treeInfoList, List<RoleResource> roleResources) {
   AuthorityResources treeInfo = null;
   Map<Long, RoleResource> roleResourceMap = new HashMap<Long, RoleResource>();
   if (null != roleResources && !(roleResources.isEmpty())) {
     Iterator<RoleResource> it = roleResources.iterator();
     RoleResource roleResource = null;
     while (it.hasNext()) {
       roleResource = it.next();
       roleResourceMap.put(roleResource.getResourceId(), roleResource);
     }
   }
   if (null != treeInfoList && !(treeInfoList.isEmpty())) {
     boolean checked = false;
     for (int i = 0; i < treeInfoList.size(); i++) {
       treeInfo = (AuthorityResources) treeInfoList.get(i);
       if (null != roleResourceMap.get(treeInfo.getId())) {
         checked = true;
       } else {
         checked = false;
       }
       treeInfo.setChecked(checked);
     }
   }
 }