@Override
 public User create(final UserCreateForm form) {
   final User user =
       new User(
           "",
           "",
           "",
           form.getLogin(),
           new BCryptPasswordEncoder().encode(form.getPassword()),
           form.getEmail(),
           true,
           form.getRole());
   // user.setEmail(form.getEmail());
   // user.setPassword(new
   // BCryptPasswordEncoder().encode(form.getPassword()));
   // user.setRole(form.getRole());
   return userRepository.save(user);
 }
 @Override
 public Collection<User> getAllUsers() {
   LOGGER.debug("Getting all users");
   return userRepository.findAll(new Sort("email"));
 }
 @Override
 public Optional<User> getUserByLogin(final String login) {
   LOGGER.debug("Getting user by login={}", login);
   return userRepository.findOneByLogin(login);
 }
 @Override
 public Optional<User> getUserByEmail(final String email) {
   LOGGER.debug("Getting user by email={}", email.replaceFirst("@.*", "@***"));
   return userRepository.findOneByEmail(email);
 }
 @Override
 public Optional<User> getUserById(final long id) {
   LOGGER.debug("Getting user={}", id);
   return Optional.ofNullable(userRepository.findOne(id));
 }