Search in sources :

Example 11 with AuthenticateAround

use of org.mx.comps.jwt.AuthenticateAround in project main by JohnPeng739.

the class PrivilegeManageResource method savePrivilege.

@Path("privilege/{id}")
@DELETE
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<PrivilegeVO> savePrivilege(@QueryParam("userCode") String userCode, @PathParam("id") String id) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        Privilege privilege = accessor.remove(id, Privilege.class);
        PrivilegeVO vo = PrivilegeVO.transform(privilege, true);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Save privilege fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) PrivilegeVO(org.mx.comps.rbac.rest.vo.PrivilegeVO) Privilege(org.mx.comps.rbac.dal.entity.Privilege) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Example 12 with AuthenticateAround

use of org.mx.comps.jwt.AuthenticateAround in project main by JohnPeng739.

the class PrivilegeManageResource method privileges.

@Path("privileges")
@POST
@AuthenticateAround(returnValueClass = PaginationDataVO.class)
public PaginationDataVO<List<PrivilegeVO>> privileges(Pagination pagination) {
    if (pagination == null) {
        pagination = new Pagination();
    }
    try {
        List<Privilege> privileges = accessor.list(pagination, Privilege.class);
        List<PrivilegeVO> vos = PrivilegeVO.transform(privileges);
        return new PaginationDataVO<>(pagination, vos);
    } catch (UserInterfaceException ex) {
        return new PaginationDataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("List privileges fail.", ex);
        }
        return new PaginationDataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Pagination(org.mx.dal.Pagination) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) PrivilegeVO(org.mx.comps.rbac.rest.vo.PrivilegeVO) Privilege(org.mx.comps.rbac.dal.entity.Privilege) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Example 13 with AuthenticateAround

use of org.mx.comps.jwt.AuthenticateAround in project main by JohnPeng739.

the class RoleManageResource method saveRole.

@Path("roles/new")
@POST
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<RoleVO> saveRole(@QueryParam("userCode") String userCode, RoleInfoVO roleInfoVO) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        roleInfoVO.setId(null);
        Role role = roleManageService.saveRole(roleInfoVO.getRoleInfo());
        RoleVO vo = RoleVO.transform(role, true);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Save role fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Role(org.mx.comps.rbac.dal.entity.Role) RoleVO(org.mx.comps.rbac.rest.vo.RoleVO) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Example 14 with AuthenticateAround

use of org.mx.comps.jwt.AuthenticateAround in project main by JohnPeng739.

the class RoleManageResource method roles.

@Path("roles")
@POST
@AuthenticateAround(returnValueClass = PaginationDataVO.class)
public PaginationDataVO<List<RoleVO>> roles(Pagination pagination) {
    if (pagination == null) {
        pagination = new Pagination();
    }
    try {
        List<Role> roles = accessor.list(pagination, Role.class);
        List<RoleVO> vos = RoleVO.transform(roles);
        return new PaginationDataVO<>(pagination, vos);
    } catch (UserInterfaceException ex) {
        return new PaginationDataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("List roles fail.", ex);
        }
        return new PaginationDataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Role(org.mx.comps.rbac.dal.entity.Role) Pagination(org.mx.dal.Pagination) RoleVO(org.mx.comps.rbac.rest.vo.RoleVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Example 15 with AuthenticateAround

use of org.mx.comps.jwt.AuthenticateAround in project main by JohnPeng739.

the class UserManageResource method listUsersPagination.

@Path("users")
@POST
@AuthenticateAround(returnValueClass = PaginationDataVO.class)
public PaginationDataVO<List<UserVO>> listUsersPagination(Pagination pagination) {
    if (pagination == null) {
        pagination = new Pagination();
    }
    try {
        List<User> users = accessor.list(pagination, User.class);
        List<UserVO> userVOs = UserVO.transform(users);
        return new PaginationDataVO<>(pagination, userVOs);
    } catch (UserInterfaceException ex) {
        return new PaginationDataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("List users fail.", ex);
        }
        return new PaginationDataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Pagination(org.mx.dal.Pagination) User(org.mx.comps.rbac.dal.entity.User) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserVO(org.mx.comps.rbac.rest.vo.UserVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Aggregations

AuthenticateAround (org.mx.comps.jwt.AuthenticateAround)27 UserInterfaceException (org.mx.error.UserInterfaceException)27 UserInterfaceSystemErrorException (org.mx.error.UserInterfaceSystemErrorException)27 PaginationDataVO (org.mx.service.rest.vo.PaginationDataVO)27 DataVO (org.mx.service.rest.vo.DataVO)20 Pagination (org.mx.dal.Pagination)7 Account (org.mx.comps.rbac.dal.entity.Account)5 User (org.mx.comps.rbac.dal.entity.User)5 UserVO (org.mx.comps.rbac.rest.vo.UserVO)5 Accredit (org.mx.comps.rbac.dal.entity.Accredit)4 Role (org.mx.comps.rbac.dal.entity.Role)4 AccreditVO (org.mx.comps.rbac.rest.vo.AccreditVO)4 RoleVO (org.mx.comps.rbac.rest.vo.RoleVO)4 Department (org.mx.comps.rbac.dal.entity.Department)3 Privilege (org.mx.comps.rbac.dal.entity.Privilege)3 DepartmentVO (org.mx.comps.rbac.rest.vo.DepartmentVO)3 PrivilegeVO (org.mx.comps.rbac.rest.vo.PrivilegeVO)3 LoginHistory (org.mx.comps.rbac.dal.entity.LoginHistory)2 AccountVO (org.mx.comps.rbac.rest.vo.AccountVO)1 OperateLog (org.mx.dal.entity.OperateLog)1