Class ConversationController


  • @RestController
    @RequestMapping("/api/v1/conversation")
    @Validated
    public class ConversationController
    extends Object
    Controller for managing conversations
    • Constructor Detail

      • ConversationController

        public ConversationController()
    • Method Detail

      • getPendingConversations

        @GetMapping("/pending")
        public org.springframework.http.ResponseEntity<ResponseDto<List<Conversation>>> getPendingConversations()
        Returns:
        List of pending conversations
      • findUserByLogin

        @GetMapping("/initiate/{login}")
        public org.springframework.http.ResponseEntity<ResponseDto<UserDto>> findUserByLogin​(@PathVariable("login") @NotBlank(message="User login can\'t be null")
                                                                                             @NotBlank(message="User login can\'t be null") String login)
        Parameters:
        login - User login to find
        Returns:
        HTTP 200 - User information HTTP 400 - Request error HTTP 404 - User with given login not found
      • createPendingSession

        @PostMapping("/initiate/{login}")
        public org.springframework.http.ResponseEntity<ResponseDto<ConversationDto>> createPendingSession​(@PathVariable("login") @NotBlank(message="User login can\'t be null")
                                                                                                          @NotBlank(message="User login can\'t be null") String login,
                                                                                                          @RequestBody
                                                                                                          SessionInitialInformationDto sessionInitialInformationDto)
                                                                                                   throws DataValidityException
        Parameters:
        login - User login to conversation initiation
        sessionInitialInformationDto - Session information for initiation
        Returns:
        HTTP 200 - Initiated conversation data HTTP 400 - Request error HTTP 404 - User with given login not found HTTP 302 - Session has been already initiated
        Throws:
        DataValidityException
      • acceptPendingSessions

        @PostMapping("/initiate/accept")
        public org.springframework.http.ResponseEntity<ResponseDto<List<ConversationDto>>> acceptPendingSessions​(@RequestBody @NotEmpty(message="List can\'t be null")
                                                                                                                 @NotEmpty(message="List can\'t be null") Long[] ids)
        Parameters:
        ids - Identifiers of sessions to accept
        Returns:
        HTTP 200 - List of accepted conversations
      • acceptPendingSession

        @PostMapping("/initiate/{id}/accept")
        public org.springframework.http.ResponseEntity<ResponseDto<ConversationDto>> acceptPendingSession​(@PathVariable("id") @Min(value=0L,message="Id must be greater than 0")
                                                                                                          @Min(value=0L,message="Id must be greater than 0") Long id)
                                                                                                   throws DataValidityException
        Parameters:
        id - Identifier of session to accept
        Returns:
        HTTP 200 - Accepted conversation data
        Throws:
        DataValidityException - if conversation data is invalid HTTP 400 - Request error HTTP 202 - Session has been already established HTTP 302 - COnversation already created
      • getNewMessages

        @PostMapping("/message/new")
        public org.springframework.http.ResponseEntity<ResponseDto<List<Message>>> getNewMessages​(@RequestBody @NotEmpty(message="List can\'t be null")
                                                                                                  @NotEmpty(message="List can\'t be null") List<ConversationAndMessageDto> data)
        Parameters:
        data - List of conversations and messages offset
        Returns:
        HTTP 200 - List of new messages starting from given offset
      • handleConstraintViolationException

        @ExceptionHandler(javax.validation.ConstraintViolationException.class)
        public org.springframework.http.ResponseEntity<ErrorResponseDto<Exception>> handleConstraintViolationException​(javax.validation.ConstraintViolationException e)