Search in sources :

Example 1 with PermissionNotFoundException

use of com.ganster.cms.core.exception.PermissionNotFoundException in project Ganster-CMS by Gangster-trio.

the class AllotGroupController method addGroup.

@RequestMapping("/add")
public void addGroup(@RequestParam(value = "UserId") Integer userId, @RequestParam(value = "GroupName") String groupName) {
    this.index();
    GroupExample groupExample = new GroupExample();
    groupExample.createCriteria().andGroupNameEqualTo(groupName);
    List<Group> groupList = groupService.selectByExample(groupExample);
    if (userId != null) {
        try {
            if (groupList == null) {
                RInformationUtil rInformationUtil = new RInformationUtil();
                rInformationUtil.dealInfromation(groupName);
                Group group = new Group();
                group.setGroupName(groupName);
                groupService.insert(group);
                groupService.addUserToGroup(userId, groupName);
            // groupService.addCategoryPermissionToGroup(groupName,"update:"+group.getGroupId());
            // groupService.addCategoryPermissionToGroup(groupName, "delete:" + group.getGroupId());
            // groupService.addCategoryPermissionToGroup(groupName,"find:"+group.getGroupId());
            } else {
                for (Group i : groupList) {
                    groupService.addUserToGroup(userId, i.getGroupName());
                }
            }
        } catch (UserNotFoundException e) {
            logger.info("用户未找到");
        } catch (GroupNotFountException e) {
            logger.info("用户组未找到");
        } catch (InformationException e) {
            logger.info("用户组信息不正确");
        } catch (PermissionNotFoundException e) {
            logger.info("用户组未找到");
        } catch (Exception e) {
            logger.info("信息错误");
        }
    }
}
Also used : UserNotFoundException(com.ganster.cms.core.exception.UserNotFoundException) InformationException(com.ganster.cms.auth.Exception.InformationException) Group(com.ganster.cms.core.pojo.Group) GroupNotFountException(com.ganster.cms.core.exception.GroupNotFountException) GroupExample(com.ganster.cms.core.pojo.GroupExample) RInformationUtil(com.ganster.cms.auth.util.RInformationUtil) PermissionNotFoundException(com.ganster.cms.core.exception.PermissionNotFoundException) GroupNotFountException(com.ganster.cms.core.exception.GroupNotFountException) PermissionNotFoundException(com.ganster.cms.core.exception.PermissionNotFoundException) UserNotFoundException(com.ganster.cms.core.exception.UserNotFoundException) InformationException(com.ganster.cms.auth.Exception.InformationException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with PermissionNotFoundException

use of com.ganster.cms.core.exception.PermissionNotFoundException in project Ganster-CMS by Gangster-trio.

the class AllotPermissionController method addPermission.

@RequestMapping("/add")
@RequiresPermissions("add")
public void addPermission(@RequestParam("GroupName") String groupName, @RequestParam("PermissionName") String permissionName) throws PermissionNotFoundException, GroupNotFountException {
    PermissionExample permissionExample = new PermissionExample();
    permissionExample.createCriteria().andPermissionNameEqualTo(permissionName);
    List<Permission> permissions = permissionService.selectByExample(permissionExample);
    if (permissions == null)
        throw new PermissionNotFoundException();
    for (Permission i : permissions) {
    // groupService.addCategoryPermissionToGroup(i.getPermissionName(),groupName);
    }
}
Also used : Permission(com.ganster.cms.core.pojo.Permission) PermissionNotFoundException(com.ganster.cms.core.exception.PermissionNotFoundException) PermissionExample(com.ganster.cms.core.pojo.PermissionExample) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

PermissionNotFoundException (com.ganster.cms.core.exception.PermissionNotFoundException)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 InformationException (com.ganster.cms.auth.Exception.InformationException)1 RInformationUtil (com.ganster.cms.auth.util.RInformationUtil)1 GroupNotFountException (com.ganster.cms.core.exception.GroupNotFountException)1 UserNotFoundException (com.ganster.cms.core.exception.UserNotFoundException)1 Group (com.ganster.cms.core.pojo.Group)1 GroupExample (com.ganster.cms.core.pojo.GroupExample)1 Permission (com.ganster.cms.core.pojo.Permission)1 PermissionExample (com.ganster.cms.core.pojo.PermissionExample)1 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)1