/**
  * Saves user.
  *
  * @param user {@link IUser}
  * @return result of operation
  */
 public boolean save(IUser user) {
   boolean saved = false;
   if (user != null && user.getContact() != null) {
     // TODO refine it
     user.getContact().setConnection(connectionService.createConnection());
     saved = super.save(user);
   }
   return saved;
 }
 /** {@inheritDoc} */
 @Override
 public boolean logout(String name, String password) {
   boolean disconnected = false;
   IUser user = getByNameAndPassword(name, password);
   if (user != null) {
     if (user.getContact() != null && user.getContact().isOnline()) {
       user.getContact().setOnline(false);
       connectionService.delete(user.getContact().getConnection().getId());
       user.getContact().setConnection(null);
       contactService.update(user.getContact());
       disconnected = true;
     }
   }
   return disconnected;
 }
 @Override
 public IUser login(String name, String password) {
   IUser user = userRepository.findByNameAndPassword(name, password);
   if (user != null) {
     if (user.getContact() != null && user.getContact().getId() != null) {
       user.getContact().setOnline(true);
       IConnection connection = connectionService.createConnection();
       user.getContact().setConnection(connection);
       contactService.update(user.getContact());
     }
   } else {
     user = createInstance();
     user.getContact().setOnline(false);
   }
   return user;
 }