Search in sources :

Example 21 with AuthenticateAround

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

the class RoleManageResource method getRole.

@Path("roles/{id}")
@GET
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<RoleVO> getRole(@PathParam("id") String id) {
    try {
        Role role = accessor.getById(id, Role.class);
        RoleVO vo = RoleVO.transform(role, true);
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Get 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 22 with AuthenticateAround

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

the class RoleManageResource method deleteRole.

@Path("roles/{id}")
@DELETE
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<RoleVO> deleteRole(@QueryParam("userCode") String userCode, @PathParam("id") String id) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        Role role = accessor.remove(id, Role.class);
        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("Delete 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 23 with AuthenticateAround

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

the class UserManageResource method allocateAccount.

@Path("users/{userId}/allocate")
@POST
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<AccountVO> allocateAccount(@QueryParam("userCode") String userCode, @PathParam("userId") String userId, AccountInfoVO accountInfoVO) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        accountInfoVO.setOwnerId(userId);
        Account account = userManageService.allocateAccount(accountInfoVO.getAccountInfo());
        AccountVO accountVO = AccountVO.transform(account, true);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(accountVO);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Allocate account fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Account(org.mx.comps.rbac.dal.entity.Account) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AccountVO(org.mx.comps.rbac.rest.vo.AccountVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Example 24 with AuthenticateAround

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

the class UserManageResource method newUser.

@Path("users/new")
@POST
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<UserVO> newUser(@QueryParam("userCode") String userCode, UserInfoVO userInfoVO) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        userInfoVO.setId(null);
        User user = userManageService.saveUser(userInfoVO.getUserInfo());
        UserVO userVO = UserVO.transform(user);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(userVO);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Create a user fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : User(org.mx.comps.rbac.dal.entity.User) UserVO(org.mx.comps.rbac.rest.vo.UserVO) 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 25 with AuthenticateAround

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

the class UserManageResource method deleteUser.

@Path("users/{userId}")
@DELETE
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<UserVO> deleteUser(@QueryParam("userCode") String userCode, @PathParam("userId") String userId) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        User user = accessor.remove(userId, User.class);
        UserVO userVO = UserVO.transform(user);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(userVO);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Delete user fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : User(org.mx.comps.rbac.dal.entity.User) UserVO(org.mx.comps.rbac.rest.vo.UserVO) 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)

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