本文整理汇总了Java中io.github.jhipster.web.util.ResponseUtil类的典型用法代码示例。如果您正苦于以下问题:Java ResponseUtil类的具体用法?Java ResponseUtil怎么用?Java ResponseUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResponseUtil类属于io.github.jhipster.web.util包,在下文中一共展示了ResponseUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateUser
import io.github.jhipster.web.util.ResponseUtil; //导入依赖的package包/类
/**
* PUT /users : Updates an existing User.
*
* @param managedUserVM the user to update
* @return the ResponseEntity with status 200 (OK) and with body the updated user,
* or with status 400 (Bad Request) if the login or email is already in use,
* or with status 500 (Internal Server Error) if the user couldn't be updated
*/
@PutMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<UserDTO> updateUser(@Valid @RequestBody ManagedUserVM managedUserVM) {
log.debug("REST request to update User : {}", managedUserVM);
Optional<User> existingUser = userRepository.findOneByEmail(managedUserVM.getEmail());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "emailexists", "Email already in use")).body(null);
}
existingUser = userRepository.findOneByLogin(managedUserVM.getLogin().toLowerCase());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "userexists", "Login already in use")).body(null);
}
Optional<UserDTO> updatedUser = userService.updateUser(managedUserVM);
return ResponseUtil.wrapOrNotFound(updatedUser,
HeaderUtil.createAlert("userManagement.updated", managedUserVM.getLogin()));
}
示例2: updateUser
import io.github.jhipster.web.util.ResponseUtil; //导入依赖的package包/类
/**
* PUT /users : Updates an existing User.
*
* @param managedUserVM the user to update
* @return the ResponseEntity with status 200 (OK) and with body the updated user,
* or with status 400 (Bad Request) if the login or email is already in use,
* or with status 500 (Internal Server Error) if the user couldn't be updated
*/
@PutMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<UserDTO> updateUser(@RequestBody ManagedUserVM managedUserVM) {
log.debug("REST request to update User : {}", managedUserVM);
Optional<User> existingUser = userRepository.findOneByEmail(managedUserVM.getEmail());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "emailexists", "Email already in use")).body(null);
}
existingUser = userRepository.findOneByLogin(managedUserVM.getLogin().toLowerCase());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "userexists", "Login already in use")).body(null);
}
Optional<UserDTO> updatedUser = userService.updateUser(managedUserVM);
return ResponseUtil.wrapOrNotFound(updatedUser,
HeaderUtil.createAlert("userManagement.updated", managedUserVM.getLogin()));
}
示例3: updateUser
import io.github.jhipster.web.util.ResponseUtil; //导入依赖的package包/类
/**
* PUT /users : Updates an existing User.
*
* @param managedUserVM the user to update
* @return the ResponseEntity with status 200 (OK) and with body the updated user,
* or with status 400 (Bad Request) if the login or email is already in use,
* or with status 500 (Internal Server Error) if the user couldn't be updated
*/
@PutMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<UserDTO> updateUser(@RequestBody ManagedUserVM managedUserVM) {
log.debug("REST request to update User : {}", managedUserVM);
Optional<User> existingUser = userRepository.findOneByEmail(managedUserVM.getEmail());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "emailexists", "E-mail already in use")).body(null);
}
existingUser = userRepository.findOneByLogin(managedUserVM.getLogin().toLowerCase());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "userexists", "Login already in use")).body(null);
}
Optional<UserDTO> updatedUser = userService.updateUser(managedUserVM);
return ResponseUtil.wrapOrNotFound(updatedUser,
HeaderUtil.createAlert("userManagement.updated", managedUserVM.getLogin()));
}
示例4: updateUser
import io.github.jhipster.web.util.ResponseUtil; //导入依赖的package包/类
/**
* PUT /users : Updates an existing User.
*
* @param managedUserVM the user to update
* @return the ResponseEntity with status 200 (OK) and with body the updated user,
* or with status 400 (Bad Request) if the login or email is already in use,
* or with status 500 (Internal Server Error) if the user couldn't be updated
*/
@PutMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<UserDTO> updateUser(@Valid @RequestBody ManagedUserVM managedUserVM) {
log.debug("REST request to update User : {}", managedUserVM);
Optional<User> existingUser = userRepository.findOneByEmail(managedUserVM.getEmail());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "emailexists", "Email already in use")).body(null);
}
existingUser = userRepository.findOneByLogin(managedUserVM.getLogin().toLowerCase());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "userexists", "Login already in use")).body(null);
}
Optional<UserDTO> updatedUser = userService.updateUser(managedUserVM);
return ResponseUtil.wrapOrNotFound(updatedUser,
HeaderUtil.createAlert("A user is updated with identifier " + managedUserVM.getLogin(), managedUserVM.getLogin()));
}
示例5: updateUser
import io.github.jhipster.web.util.ResponseUtil; //导入依赖的package包/类
/**
* PUT /users : Updates an existing User.
*
* @param userDTO the user to update
* @return the ResponseEntity with status 200 (OK) and with body the updated user
* @throws EmailAlreadyUsedException 400 (Bad Request) if the email is already in use
* @throws LoginAlreadyUsedException 400 (Bad Request) if the login is already in use
*/
@PutMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<UserDTO> updateUser(@Valid @RequestBody UserDTO userDTO) {
log.debug("REST request to update User : {}", userDTO);
Optional<User> existingUser = userRepository.findOneByEmailIgnoreCase(userDTO.getEmail());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(userDTO.getId()))) {
throw new EmailAlreadyUsedException();
}
existingUser = userRepository.findOneByLogin(userDTO.getLogin().toLowerCase());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(userDTO.getId()))) {
throw new LoginAlreadyUsedException();
}
Optional<UserDTO> updatedUser = userService.updateUser(userDTO);
return ResponseUtil.wrapOrNotFound(updatedUser,
HeaderUtil.createAlert("A user is updated with identifier " + userDTO.getLogin(), userDTO.getLogin()));
}
示例6: updateUser
import io.github.jhipster.web.util.ResponseUtil; //导入依赖的package包/类
/**
* PUT /users : Updates an existing User.
*
* @param managedUserVM the user to update
* @return the ResponseEntity with status 200 (OK) and with body the updated user
* @throws EmailAlreadyUsedException 400 (Bad Request) if the email is already in use
* @throws LoginAlreadyUsedException 400 (Bad Request) if the login is already in use
*/
@PutMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<UserDTO> updateUser(@Valid @RequestBody ManagedUserVM managedUserVM) {
log.debug("REST request to update User : {}", managedUserVM);
Optional<User> existingUser = userRepository.findOneByEmailIgnoreCase(managedUserVM.getEmail());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
throw new EmailAlreadyUsedException();
}
existingUser = userRepository.findOneByLogin(managedUserVM.getLogin().toLowerCase());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
throw new LoginAlreadyUsedException();
}
Optional<UserDTO> updatedUser = userService.updateUser(managedUserVM);
return ResponseUtil.wrapOrNotFound(updatedUser,
HeaderUtil.createAlert("userManagement.updated", managedUserVM.getLogin()));
}
示例7: updateUser
import io.github.jhipster.web.util.ResponseUtil; //导入依赖的package包/类
/**
* PUT /users : Updates an existing User.
*
* @param userDTO the user to update
* @return the ResponseEntity with status 200 (OK) and with body the updated user
* @throws EmailAlreadyUsedException 400 (Bad Request) if the email is already in use
* @throws LoginAlreadyUsedException 400 (Bad Request) if the login is already in use
*/
@PutMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<UserDTO> updateUser(@Valid @RequestBody UserDTO userDTO) {
log.debug("REST request to update User : {}", userDTO);
Optional<User> existingUser = userRepository.findOneByEmailIgnoreCase(userDTO.getEmail());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(userDTO.getId()))) {
throw new EmailAlreadyUsedException();
}
existingUser = userRepository.findOneByLogin(userDTO.getLogin().toLowerCase());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(userDTO.getId()))) {
throw new LoginAlreadyUsedException();
}
Optional<UserDTO> updatedUser = userService.updateUser(userDTO);
return ResponseUtil.wrapOrNotFound(updatedUser,
HeaderUtil.createAlert("userManagement.updated", userDTO.getLogin()));
}
示例8: saveAccount
import io.github.jhipster.web.util.ResponseUtil; //导入依赖的package包/类
/**
* POST /account : update the current user information.
*
* @param user the current user information
* @return the ResponseEntity with status 200 (OK), or status 400 (Bad Request) or 500 (Internal
* Server Error) if the user couldn't be updated
*/
@PostMapping("/account")
@Timed
public ResponseEntity saveAccount(@Valid @RequestBody UserDTO user) {
user.getLogins().forEach(userLogin -> userLoginRepository.findOneByLoginIgnoreCaseAndUserIdNot(
userLogin.getLogin(), user.getId()).ifPresent(s -> {
throw new BusinessException(LOGIN_IS_USED_ERROR_TEXT);
}));
Optional<UserDTO> updatedUser = accountService.updateAccount(user);
updatedUser.ifPresent(userDTO -> produceEvent(userDTO, Constants.UPDATE_PROFILE_EVENT_TYPE));
return ResponseUtil.wrapOrNotFound(updatedUser,
HeaderUtil.createAlert("userManagement.updated", user.getUserKey()));
}
示例9: getUser
import io.github.jhipster.web.util.ResponseUtil; //导入依赖的package包/类
/**
* GET /users/:login : get the "login" user.
*
* @param login the login of the user to find
* @return the ResponseEntity with status 200 (OK) and with body the "login" user, or with status 404 (Not Found)
*/
@GetMapping("/users/{login:" + Constants.LOGIN_REGEX + "}")
@Timed
public ResponseEntity<UserDTO> getUser(@PathVariable String login) {
log.debug("REST request to get User : {}", login);
return ResponseUtil.wrapOrNotFound(
userService.getUserWithAuthoritiesByLogin(login)
.map(UserDTO::new));
}
示例10: updateUserLogins
import io.github.jhipster.web.util.ResponseUtil; //导入依赖的package包/类
/**
* PUT /user/logins : Updates an existing User logins.
* @param user the user to update
* @return the ResponseEntity with status 200 (OK) and with body the updated user, or with
* status 400 (Bad Request) if the login or email is already in use, or with status 500
* (Internal Server Error) if the user couldn't be updated
*/
@PutMapping("/users/logins")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<UserDTO> updateUserLogins(@Valid @RequestBody UserDTO user) {
user.getLogins().forEach(userLogin ->
userLoginRepository.findOneByLoginIgnoreCaseAndUserIdNot(userLogin.getLogin(), user.getId())
.ifPresent(s -> {
throw new BusinessException(Constants.LOGIN_IS_USED_ERROR_TEXT);
})
);
Optional<UserDTO> updatedUser = userService.updateUserLogins(user.getUserKey(), user.getLogins());
updatedUser.ifPresent(userDTO -> produceEvent(userDTO, Constants.UPDATE_PROFILE_EVENT_TYPE));
return ResponseUtil.wrapOrNotFound(updatedUser,
HeaderUtil.createAlert("userManagement.updated", user.getUserKey()));
}
示例11: getUser
import io.github.jhipster.web.util.ResponseUtil; //导入依赖的package包/类
/**
* GET /users/:userKey : get the "userKey" user.
*
* @param userKey the userKey of the user to find
* @return the ResponseEntity with status 200 (OK) and with body the "userKey" user, or with status 404 (Not Found)
*/
@GetMapping("/users/{userKey}")
@Timed
public ResponseEntity<UserDTO> getUser(@PathVariable String userKey) {
return ResponseUtil.wrapOrNotFound(
userService.findOneWithAuthoritiesAndLoginsByUserKey(userKey)
.map(UserDTO::new));
}
示例12: getTag
import io.github.jhipster.web.util.ResponseUtil; //导入依赖的package包/类
/**
* GET /tags/:id : get the "id" tag.
*
* @param id the id of the tag to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the tag, or with status 404 (Not Found)
*/
@GetMapping("/tags/{id}")
@Timed
public ResponseEntity<Tag> getTag(@PathVariable Long id) {
log.debug("REST request to get Tag : {}", id);
Tag tag = tagRepository.findOne(id);
return ResponseUtil.wrapOrNotFound(Optional.ofNullable(tag));
}
示例13: getBlog
import io.github.jhipster.web.util.ResponseUtil; //导入依赖的package包/类
/**
* GET /blogs/:id : get the "id" blog.
*
* @param id the id of the blog to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the blog, or with status 404 (Not Found)
*/
@GetMapping("/blogs/{id}")
@Timed
public ResponseEntity<Blog> getBlog(@PathVariable Long id) {
log.debug("REST request to get Blog : {}", id);
Blog blog = blogRepository.findOne(id);
return ResponseUtil.wrapOrNotFound(Optional.ofNullable(blog));
}
示例14: getEntry
import io.github.jhipster.web.util.ResponseUtil; //导入依赖的package包/类
/**
* GET /entries/:id : get the "id" entry.
*
* @param id the id of the entry to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the entry, or with status 404 (Not Found)
*/
@GetMapping("/entries/{id}")
@Timed
public ResponseEntity<Entry> getEntry(@PathVariable Long id) {
log.debug("REST request to get Entry : {}", id);
Entry entry = entryRepository.findOneWithEagerRelationships(id);
return ResponseUtil.wrapOrNotFound(Optional.ofNullable(entry));
}
示例15: getIntervention
import io.github.jhipster.web.util.ResponseUtil; //导入依赖的package包/类
/**
* GET /interventions/:id : get the "id" intervention.
*
* @param id the id of the interventionDTO to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the interventionDTO, or with status 404 (Not Found)
*/
@GetMapping("/interventions/{id}")
@Timed
public ResponseEntity<InterventionDTO> getIntervention(@PathVariable Long id) {
log.debug("REST request to get Intervention : {}", id);
Intervention intervention = interventionRepository.findOne(id);
InterventionDTO interventionDTO = interventionMapper.toDto(intervention);
return ResponseUtil.wrapOrNotFound(Optional.ofNullable(interventionDTO));
}