当前位置: 首页>>代码示例>>Java>>正文


Java ResponseUtil类代码示例

本文整理汇总了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()));
}
 
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:27,代码来源:UserResource.java

示例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()));
}
 
开发者ID:IBM,项目名称:Microservices-with-JHipster-and-Spring-Boot,代码行数:27,代码来源:UserResource.java

示例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()));
}
 
开发者ID:ElectronicArmory,项目名称:Armory,代码行数:27,代码来源:UserResource.java

示例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()));
}
 
开发者ID:michaelhoffmantech,项目名称:patient-portal,代码行数:27,代码来源:UserResource.java

示例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()));
}
 
开发者ID:torgcrm,项目名称:TorgCRM-Server,代码行数:27,代码来源:UserResource.java

示例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()));
}
 
开发者ID:asanzdiego,项目名称:codemotion-2017-taller-de-jhipster,代码行数:27,代码来源:UserResource.java

示例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()));
}
 
开发者ID:pascalgrimaud,项目名称:qualitoast,代码行数:27,代码来源:UserResource.java

示例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()));
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:21,代码来源:AccountResource.java

示例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));
}
 
开发者ID:IBM,项目名称:Microservices-with-JHipster-and-Spring-Boot,代码行数:15,代码来源:UserResource.java

示例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()));
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:23,代码来源:UserResource.java

示例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));
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:14,代码来源:UserResource.java

示例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));
}
 
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:14,代码来源:TagResource.java

示例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));
}
 
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:14,代码来源:BlogResource.java

示例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));
}
 
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:14,代码来源:EntryResource.java

示例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));
}
 
开发者ID:Microsoft,项目名称:MTC_Labrat,代码行数:15,代码来源:InterventionResource.java


注:本文中的io.github.jhipster.web.util.ResponseUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。