Search in sources :

Example 1 with InformationException

use of com.ganster.cms.auth.Exception.InformationException in project Ganster-CMS by Gangster-trio.

the class AllotGroupController method updateGroup.

@RequestMapping("/update")
public int updateGroup(@RequestParam(value = "Group") Group group) {
    this.index();
    List<String> permissionName = this.getPermissionName("group", "updategroup");
    Subject subject = SecurityUtils.getSubject();
    for (String i : permissionName) {
        if (subject.isPermitted(i)) {
            PInformationUtil pInformationUtil = new PInformationUtil();
            try {
                pInformationUtil.dealInfromation(i);
                Group needUpdateGroup = groupService.selectByPrimaryKey(Integer.parseInt(pInformationUtil.getId()));
                if (needUpdateGroup.getGroupId().equals(group.getGroupId())) {
                    return groupService.updateByPrimaryKey(group);
                } else
                    continue;
            } catch (InformationException e) {
                logger.info("权限信息异常");
            }
        }
    }
    return 0;
}
Also used : InformationException(com.ganster.cms.auth.Exception.InformationException) Group(com.ganster.cms.core.pojo.Group) Subject(org.apache.shiro.subject.Subject) PInformationUtil(com.ganster.cms.auth.util.PInformationUtil) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with InformationException

use of com.ganster.cms.auth.Exception.InformationException 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 3 with InformationException

use of com.ganster.cms.auth.Exception.InformationException in project Ganster-CMS by Gangster-trio.

the class PInformationUtil method dealInfromation.

public void dealInfromation(String permissionInformation) throws InformationException {
    PInformationUtil pInformationUtil = new PInformationUtil();
    String[] dealResult = permissionInformation.split(":");
    if (dealResult.length <= 2) {
        permissionname = dealResult[0];
        logger.info("---------------------------------------------------" + permissionname + "-----------------------------------");
        id = dealResult[1];
        logger.info("----------------------------------" + id + "-------------------------------------------");
        pInformationUtil.setId(id);
        pInformationUtil.setPermissionname(permissionname);
    } else
        throw new InformationException();
}
Also used : InformationException(com.ganster.cms.auth.Exception.InformationException)

Example 4 with InformationException

use of com.ganster.cms.auth.Exception.InformationException in project Ganster-CMS by Gangster-trio.

the class AllotGroupController method deleteGroup.

@RequestMapping("/delete")
public int deleteGroup(@RequestParam(value = "GroupId") Integer groupId) {
    this.index();
    Subject subject = SecurityUtils.getSubject();
    List<String> permissionName = this.getPermissionName("group", "delectgroup");
    for (String i : permissionName) {
        if (subject.isPermitted(i)) {
            PInformationUtil pInformationUtil = new PInformationUtil();
            try {
                pInformationUtil.dealInfromation(i);
                Group group = groupService.selectByPrimaryKey(Integer.parseInt(pInformationUtil.getId()));
                if (group.getGroupId().equals(groupId)) {
                    return groupService.deleteByPrimaryKey(groupId);
                } else
                    continue;
            } catch (InformationException e) {
                logger.info("权限信息异常");
            }
        }
    }
    return 0;
}
Also used : InformationException(com.ganster.cms.auth.Exception.InformationException) Group(com.ganster.cms.core.pojo.Group) Subject(org.apache.shiro.subject.Subject) PInformationUtil(com.ganster.cms.auth.util.PInformationUtil) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with InformationException

use of com.ganster.cms.auth.Exception.InformationException in project Ganster-CMS by Gangster-trio.

the class AllotGroupController method findGroups.

@RequestMapping("/find")
public List<Group> findGroups() {
    this.index();
    List<Group> groupList = new ArrayList<>();
    Subject subject = SecurityUtils.getSubject();
    List<String> permissionName = this.getPermissionName("group", "findgroup");
    for (String i : permissionName) {
        if (subject.isPermitted(i)) {
            PInformationUtil pInformationUtil = new PInformationUtil();
            try {
                pInformationUtil.dealInfromation(i);
                Group group = groupService.selectByPrimaryKey(Integer.parseInt(pInformationUtil.getId()));
                if (group == null)
                    break;
                groupList.add(group);
            } catch (InformationException e) {
                logger.info("权限信息异常");
            }
        }
    }
    return groupList;
}
Also used : InformationException(com.ganster.cms.auth.Exception.InformationException) Group(com.ganster.cms.core.pojo.Group) ArrayList(java.util.ArrayList) Subject(org.apache.shiro.subject.Subject) PInformationUtil(com.ganster.cms.auth.util.PInformationUtil) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

InformationException (com.ganster.cms.auth.Exception.InformationException)5 Group (com.ganster.cms.core.pojo.Group)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 PInformationUtil (com.ganster.cms.auth.util.PInformationUtil)3 Subject (org.apache.shiro.subject.Subject)3 RInformationUtil (com.ganster.cms.auth.util.RInformationUtil)1 GroupNotFountException (com.ganster.cms.core.exception.GroupNotFountException)1 PermissionNotFoundException (com.ganster.cms.core.exception.PermissionNotFoundException)1 UserNotFoundException (com.ganster.cms.core.exception.UserNotFoundException)1 GroupExample (com.ganster.cms.core.pojo.GroupExample)1 ArrayList (java.util.ArrayList)1