Search in sources :

Example 6 with UserInterfaceSystemErrorException

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

the class AccountManageResource method saveAccount.

@Path("accounts/{id}")
@PUT
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<AccountVO> saveAccount(@PathParam("id") String id, @QueryParam("userCode") String userCode, AccountInfoVO accountInfoVO) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        accountInfoVO.setId(id);
        Account account = accountManageService.saveAccount(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("Save 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) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Example 7 with UserInterfaceSystemErrorException

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

the class AccreditManageResource method deleteAccredit.

@Path("accredits/{id}")
@DELETE
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<AccreditVO> deleteAccredit(@QueryParam("userCode") String userCode, @PathParam("id") String id) {
    if (StringUtils.isBlank(userCode) || StringUtils.isBlank(id)) {
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_ILLEGAL_PARAM));
    }
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        Accredit accredit = accreditManageService.closeAccredit(id);
        AccreditVO vo = AccreditVO.transform(accredit, true);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Delete 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 8 with UserInterfaceSystemErrorException

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

the class AccreditManageResource method accredits.

@Path("accredits")
@POST
@AuthenticateAround(returnValueClass = PaginationDataVO.class)
public PaginationDataVO<List<AccreditVO>> accredits(Pagination pagination) {
    if (pagination == null) {
        pagination = new Pagination();
    }
    try {
        List<Accredit> accredits = accessor.list(pagination, Accredit.class);
        List<AccreditVO> list = AccreditVO.transform(accredits);
        return new PaginationDataVO<>(pagination, list);
    } catch (UserInterfaceException ex) {
        return new PaginationDataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("List accredits fail.", ex);
        }
        return new PaginationDataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Pagination(org.mx.dal.Pagination) Accredit(org.mx.comps.rbac.dal.entity.Accredit) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) AccreditVO(org.mx.comps.rbac.rest.vo.AccreditVO) 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 9 with UserInterfaceSystemErrorException

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

the class AccreditManageResource method newAccredit.

@Path("accredits/new")
@POST
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<AccreditVO> newAccredit(@QueryParam("userCode") String userCode, AccreditInfoVO accreditInfoVO) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        Accredit accredit = accreditManageService.accredit(accreditInfoVO.getAccreditInfo());
        AccreditVO vo = AccreditVO.transform(accredit, true);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Create 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) 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 10 with UserInterfaceSystemErrorException

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

the class DepartmentManageResource method deleteDepartment.

@Path("departments/{id}")
@DELETE
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<DepartmentVO> deleteDepartment(@QueryParam("userCode") String userCode, @PathParam("id") String id) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        Department department = accessor.remove(id, Department.class);
        DepartmentVO vo = DepartmentVO.transform(department, true);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Delete 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)

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