Search in sources :

Example 26 with UserInterfaceSystemErrorException

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

the class AccountManageResource method login.

@Path("login")
@POST
public DataVO<LoginHistoryVO> login(@Context Request request, @Context Response response, AuthenticateAccountPasswordVO vo) {
    sessionDataStore.setCurrentUserCode(vo.getAccountCode());
    String accountCode = vo.getAccountCode(), password = vo.getPassword();
    boolean forced = vo.isForcedReplace();
    try {
        LoginHistory loginHistory = accountManageService.login(accountCode, password, forced);
        LoginHistoryVO loginHistoryVO = LoginHistoryVO.transform(loginHistory);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(loginHistoryVO);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error(String.format("User[%s] login fail.", vo.getAccountCode()), ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : LoginHistory(org.mx.comps.rbac.dal.entity.LoginHistory) 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)

Example 27 with UserInterfaceSystemErrorException

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

the class AccreditManageResource method getAccredit.

@Path("accredits/{id}")
@GET
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<AccreditVO> getAccredit(@QueryParam("id") String id) {
    if (StringUtils.isBlank(id)) {
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_ILLEGAL_PARAM));
    }
    try {
        Accredit accredit = accessor.getById(id, Accredit.class);
        AccreditVO vo = AccreditVO.transform(accredit, true);
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Get accredit fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Accredit(org.mx.comps.rbac.dal.entity.Accredit) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) AccreditVO(org.mx.comps.rbac.rest.vo.AccreditVO) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Example 28 with UserInterfaceSystemErrorException

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

the class DepartmentManageResource method getDepartment.

@Path("departments/{id}")
@GET
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<DepartmentVO> getDepartment(@PathParam("id") String id) {
    try {
        Department department = accessor.getById(id, Department.class);
        DepartmentVO vo = DepartmentVO.transform(department, true);
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Get department fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Department(org.mx.comps.rbac.dal.entity.Department) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) DepartmentVO(org.mx.comps.rbac.rest.vo.DepartmentVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Example 29 with UserInterfaceSystemErrorException

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

the class PrivilegeManageResource method getPrivilege.

@Path("privileges/{id}")
@GET
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<PrivilegeVO> getPrivilege(@PathParam("id") String id) {
    try {
        Privilege privilege = accessor.getById(id, Privilege.class);
        PrivilegeVO vo = PrivilegeVO.transform(privilege, true);
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Get 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 30 with UserInterfaceSystemErrorException

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

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