Search in sources :

Example 1 with ControllerNotFoundException

use of com.bigcrowd.noticeBoard.services.exceptions.ControllerNotFoundException in project Notice-Board by FulvioFPimentel.

the class SupportController method save.

@PostMapping
public ResponseEntity<SupportDTO> save(@RequestBody SupportSaveDTO dto) {
    try {
        SupportDTO entity = supportService.saveSupport(dto);
        URI uri = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}").buildAndExpand(entity.getId()).toUri();
        return ResponseEntity.created(uri).body(entity);
    } catch (RuntimeException e) {
        throw new ControllerNotFoundException("Not Found");
    }
}
Also used : ControllerNotFoundException(com.bigcrowd.noticeBoard.services.exceptions.ControllerNotFoundException) SupportDTO(com.bigcrowd.noticeBoard.dto.SupportDTO) URI(java.net.URI) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

SupportDTO (com.bigcrowd.noticeBoard.dto.SupportDTO)1 ControllerNotFoundException (com.bigcrowd.noticeBoard.services.exceptions.ControllerNotFoundException)1 URI (java.net.URI)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1