@RequestMapping(value={"/",""},method=RequestMethod.POST) @ResponseBody public RestWrapper update(@ModelAttribute("users") @Valid Users users,BindingResult bindingResult,Principal principal){
  RestWrapper restWrapper=null;
  if (bindingResult.hasErrors()) {
    BindingResultError bindingResultError=new BindingResultError();
    return bindingResultError.errorMessage(bindingResult);
  }
  try {
    String hashedPassword=DigestUtils.sha1Hex(users.getPassword());
    users.setPassword(hashedPassword);
    com.wipro.ats.bdre.md.dao.jpa.Users jpaUsers=new com.wipro.ats.bdre.md.dao.jpa.Users();
    jpaUsers.setPassword(hashedPassword);
    jpaUsers.setUsername(users.getUsername());
    jpaUsers.setEnabled((users.getEnabled() == 1) ? true : false);
    usersDAO.update(jpaUsers);
    restWrapper=new RestWrapper(users,RestWrapper.OK);
    LOGGER.info("Record with name:" + users.getUsername() + " updated in Users by User:"+ principal.getName()+ users);
  }
 catch (  Exception e) {
    LOGGER.error(e);
    restWrapper=new RestWrapper(e.getMessage(),RestWrapper.ERROR);
  }
  return restWrapper;
}

@ RequestMapping ( value = { "/" , "" } , method = RequestMethod . POST ) @ ResponseBody public RestWrapper update ( @ ModelAttribute ( "users" ) @ Valid Users users , BindingResult bindingResult , Principal principal ) { RestWrapper restWrapper = null ; if ( bindingResult . hasErrors ( ) ) { BindingResultError bindingResultError = new BindingResultError ( ) ; return bindingResultError . errorMessage ( bindingResult ) ; } try { String hashedPassword = DigestUtils . sha1Hex ( users . getPassword ( ) ) ; users . setPassword ( hashedPassword ) ; com . wipro . ats . bdre . md . dao . jpa . Users jpaUsers = new com . wipro . ats . bdre . md . dao . jpa . Users ( ) ; jpaUsers . setPassword ( hashedPassword ) ; jpaUsers . setUsername ( users . getUsername ( ) ) ; jpaUsers . setEnabled ( ( users . getEnabled ( ) == 1 ) ? true : false ) ; usersDAO . update ( jpaUsers ) ; restWrapper = new RestWrapper ( users , RestWrapper . OK ) ; LOGGER . info ( "Record with name:" + users . getUsername ( ) + " updated in Users by User:" + principal . getName ( ) + users ) ; } catch ( Exception e ) { LOGGER . error ( e ) ; restWrapper = new RestWrapper ( e . getMessage ( ) , RestWrapper . ERROR ) ; } return restWrapper ; }
this method calls updateusers and updates the values of the instance of users passed . it also validates the values passed .
