use of org.mx.comps.rbac.rest.vo.UserVO in project main by JohnPeng739.
the class UserManageResource method listUsersPagination.
@Path("users")
@POST
@AuthenticateAround(returnValueClass = PaginationDataVO.class)
public PaginationDataVO<List<UserVO>> listUsersPagination(Pagination pagination) {
if (pagination == null) {
pagination = new Pagination();
}
try {
List<User> users = accessor.list(pagination, User.class);
List<UserVO> userVOs = UserVO.transform(users);
return new PaginationDataVO<>(pagination, userVOs);
} catch (UserInterfaceException ex) {
return new PaginationDataVO<>(ex);
} catch (Exception ex) {
if (logger.isErrorEnabled()) {
logger.error("List users fail.", ex);
}
return new PaginationDataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
}
}
use of org.mx.comps.rbac.rest.vo.UserVO 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));
}
}
use of org.mx.comps.rbac.rest.vo.UserVO 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));
}
}
use of org.mx.comps.rbac.rest.vo.UserVO 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));
}
}
use of org.mx.comps.rbac.rest.vo.UserVO 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));
}
}
Aggregations