use of org.mx.error.UserInterfaceException in project main by JohnPeng739.
the class AccountManageResource method logs.
@Path("logs")
@POST
@AuthenticateAround(returnValueClass = PaginationDataVO.class)
public PaginationDataVO<List<OperateLogVO>> logs(Pagination pagination, @Context Request request) {
if (pagination == null) {
pagination = new Pagination();
}
try {
List<OperateLog> logs = accessor.list(pagination, OperateLog.class);
List<OperateLogVO> vos = OperateLogVO.transform(logs);
return new PaginationDataVO(pagination, vos);
} catch (UserInterfaceException ex) {
return new PaginationDataVO<>(ex);
} catch (Exception ex) {
if (logger.isErrorEnabled()) {
logger.error("List logs fail.", ex);
}
return new PaginationDataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
}
}
use of org.mx.error.UserInterfaceException 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));
}
}
use of org.mx.error.UserInterfaceException 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));
}
}
use of org.mx.error.UserInterfaceException 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));
}
}
use of org.mx.error.UserInterfaceException 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));
}
}
Aggregations