Search in sources :

Example 31 with UserInterfaceSystemErrorException

use of org.mx.error.UserInterfaceSystemErrorException 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 32 with UserInterfaceSystemErrorException

use of org.mx.error.UserInterfaceSystemErrorException 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 33 with UserInterfaceSystemErrorException

use of org.mx.error.UserInterfaceSystemErrorException 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 34 with UserInterfaceSystemErrorException

use of org.mx.error.UserInterfaceSystemErrorException 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)

Example 35 with UserInterfaceSystemErrorException

use of org.mx.error.UserInterfaceSystemErrorException 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)

Aggregations

UserInterfaceSystemErrorException (org.mx.error.UserInterfaceSystemErrorException)40 UserInterfaceException (org.mx.error.UserInterfaceException)30 PaginationDataVO (org.mx.service.rest.vo.PaginationDataVO)30 AuthenticateAround (org.mx.comps.jwt.AuthenticateAround)27 DataVO (org.mx.service.rest.vo.DataVO)23 Account (org.mx.comps.rbac.dal.entity.Account)12 User (org.mx.comps.rbac.dal.entity.User)10 UserInterfaceRbacErrorException (org.mx.comps.rbac.error.UserInterfaceRbacErrorException)10 Role (org.mx.comps.rbac.dal.entity.Role)9 Accredit (org.mx.comps.rbac.dal.entity.Accredit)7 Pagination (org.mx.dal.Pagination)7 Department (org.mx.comps.rbac.dal.entity.Department)6 Privilege (org.mx.comps.rbac.dal.entity.Privilege)5 UserVO (org.mx.comps.rbac.rest.vo.UserVO)5 Date (java.util.Date)4 LoginHistory (org.mx.comps.rbac.dal.entity.LoginHistory)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