/**
  * Remove user from room's users
  *
  * @param roomId
  * @param userId
  * @return HttpEntity<Room> - HttpStatus.NO_CONTENT when all is ok
  */
 @RequestMapping(value = "/leave/{id}", method = RequestMethod.POST)
 public HttpEntity<Room> leaveRoom(@PathVariable("id") int roomId, @RequestBody int userId)
     throws ObjectNotFoundException {
   User user = userService.findOne(userId);
   roomService.removeUserFromRoom(roomId, user);
   return new ResponseEntity(HttpStatus.NO_CONTENT);
 }
  /**
   * Get rooms by userId. Only room owner can do this request.
   *
   * @param userId
   * @return HttpEntity<List<Room>> - all rooms that user takes part in
   */
  @RequestMapping(value = "/byUserId/{userId}", method = RequestMethod.GET)
  public HttpEntity<List<Room>> getRoomsByUserId(@PathVariable("userId") int userId)
      throws ObjectNotFoundException {
    UserResource currentUser = accessService.getCurrentUser();
    if (currentUser == null || currentUser.getId() != userId) {
      return new ResponseEntity(HttpStatus.FORBIDDEN);
    }

    List<Room> rooms = userService.findRoomsWithOwnersByUserId(userId);
    return new ResponseEntity(rooms, HttpStatus.OK);
  }
 /**
  * Add user to room's users
  *
  * @param roomId
  * @param userId
  * @return HttpEntity<Room> - room that user joined to
  */
 @RequestMapping(value = "/join/{id}", method = RequestMethod.POST)
 public HttpEntity<Room> joinRoom(@PathVariable("id") int roomId, @RequestBody int userId)
     throws AlreadyExistsException {
   Room room = roomService.findOne(roomId);
   User user = userService.findOne(userId);
   if (user == null || room == null || room.getType() == Room.CLOSE_TYPE) {
     return new ResponseEntity(HttpStatus.BAD_REQUEST);
   }
   room = roomService.joinRoom(roomId, user);
   return new ResponseEntity(room, HttpStatus.OK);
 }