Search in sources :

Example 31 with UserInterfaceException

use of org.mx.error.UserInterfaceException in project main by JohnPeng739.

the class UserManageResource method saveUser.

@Path("users/{userId}")
@PUT
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<UserVO> saveUser(@QueryParam("userCode") String userCode, @PathParam("userId") String userId, UserInfoVO userInfoVO) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        userInfoVO.setId(userId);
        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("Save 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 32 with UserInterfaceException

use of org.mx.error.UserInterfaceException in project main by JohnPeng739.

the class UserManageResource method getUser.

@Path("users/{id}")
@GET
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<UserVO> getUser(@PathParam("id") String id) {
    try {
        User user = accessor.getById(id, User.class);
        UserVO userVO = UserVO.transform(user);
        return new DataVO<>(userVO);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Get 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

UserInterfaceException (org.mx.error.UserInterfaceException)32 UserInterfaceSystemErrorException (org.mx.error.UserInterfaceSystemErrorException)30 PaginationDataVO (org.mx.service.rest.vo.PaginationDataVO)30 AuthenticateAround (org.mx.comps.jwt.AuthenticateAround)27 DataVO (org.mx.service.rest.vo.DataVO)24 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 Department (org.mx.comps.rbac.dal.entity.Department)4 Privilege (org.mx.comps.rbac.dal.entity.Privilege)4 Role (org.mx.comps.rbac.dal.entity.Role)4 AccreditVO (org.mx.comps.rbac.rest.vo.AccreditVO)4 DepartmentVO (org.mx.comps.rbac.rest.vo.DepartmentVO)4 PrivilegeVO (org.mx.comps.rbac.rest.vo.PrivilegeVO)4 RoleVO (org.mx.comps.rbac.rest.vo.RoleVO)4 LoginHistory (org.mx.comps.rbac.dal.entity.LoginHistory)3 Test (org.junit.Test)1 AccountVO (org.mx.comps.rbac.rest.vo.AccountVO)1