Package ru.kpekepsalt.ruvik.controller
Class ConversationController
- java.lang.Object
-
- ru.kpekepsalt.ruvik.controller.ConversationController
-
@RestController @RequestMapping("/api/v1/conversation") @Validated public class ConversationController extends Object
Controller for managing conversations
-
-
Constructor Summary
Constructors Constructor Description ConversationController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.http.ResponseEntity<ResponseDto<ConversationDto>>
acceptPendingSession(@Min(value=0L,message="Id must be greater than 0") Long id)
org.springframework.http.ResponseEntity<ResponseDto<List<ConversationDto>>>
acceptPendingSessions(@NotEmpty(message="List can\'t be null") Long[] ids)
org.springframework.http.ResponseEntity<ResponseDto<ConversationDto>>
createPendingSession(@NotBlank(message="User login can\'t be null") String login, SessionInitialInformationDto sessionInitialInformationDto)
org.springframework.http.ResponseEntity<ResponseDto<UserDto>>
findUserByLogin(@NotBlank(message="User login can\'t be null") String login)
org.springframework.http.ResponseEntity<ResponseDto<List<Message>>>
getNewMessages(@NotEmpty(message="List can\'t be null") List<ConversationAndMessageDto> data)
org.springframework.http.ResponseEntity<ResponseDto<List<Conversation>>>
getPendingConversations()
org.springframework.http.ResponseEntity<ErrorResponseDto<Exception>>
handleConstraintViolationException(javax.validation.ConstraintViolationException e)
org.springframework.http.ResponseEntity<ErrorResponseDto<Exception>>
handleDataValidityException(DataValidityException e)
-
-
-
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 initiationsessionInitialInformationDto
- 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)
-
handleDataValidityException
@ExceptionHandler(DataValidityException.class) public org.springframework.http.ResponseEntity<ErrorResponseDto<Exception>> handleDataValidityException(DataValidityException e)
-
-