Skip to content

Commit

Permalink
Add ResourceNotFoundException throws clause
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonandre committed Jan 13, 2025
1 parent 31d46f6 commit ca56aa2
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import ca.gc.aafc.agent.api.entities.AgentIdentifierType;
import ca.gc.aafc.agent.api.mapper.AgentIdentifierTypeMapper;
import ca.gc.aafc.dina.dto.JsonApiDto;
import ca.gc.aafc.dina.exception.ResourceNotFoundException;
import ca.gc.aafc.dina.jsonapi.JsonApiDocument;
import ca.gc.aafc.dina.repository.DinaRepositoryV2;
import ca.gc.aafc.dina.security.DinaAuthenticatedUser;
Expand Down Expand Up @@ -66,7 +67,7 @@ public AgentIdentifierTypeRepository(
}

@GetMapping(AgentIdentifierTypeDto.TYPENAME + "/{id}")
public ResponseEntity<RepresentationModel<?>> handleFindOne(@PathVariable UUID id, HttpServletRequest req) {
public ResponseEntity<RepresentationModel<?>> handleFindOne(@PathVariable UUID id, HttpServletRequest req) throws ResourceNotFoundException {
String queryString = decodeQueryString(req);

JsonApiDto<AgentIdentifierTypeDto> jsonApiDto = getOne(id, queryString);
Expand Down Expand Up @@ -98,7 +99,7 @@ public ResponseEntity<RepresentationModel<?>> handleFindAll(HttpServletRequest r
@PostMapping(AgentIdentifierTypeDto.TYPENAME)
@Transactional
public ResponseEntity<RepresentationModel<?>> handleCreate(@RequestBody
EntityModel<AgentIdentifierTypeDto> postedEntity) {
EntityModel<AgentIdentifierTypeDto> postedEntity) throws ResourceNotFoundException {
if(postedEntity.getContent() == null) {
return ResponseEntity.badRequest().build();
}
Expand Down Expand Up @@ -126,7 +127,7 @@ public ResponseEntity<RepresentationModel<?>> handleCreate(@RequestBody
@PatchMapping(AgentIdentifierTypeDto.TYPENAME + "/{id}")
@Transactional
public ResponseEntity<RepresentationModel<?>> handleUpdate(@RequestBody JsonApiDocument partialPatchDto,
@PathVariable UUID id) {
@PathVariable UUID id) throws ResourceNotFoundException {

// Sanity check
if (!Objects.equals(id, partialPatchDto.getId())) {
Expand All @@ -147,7 +148,7 @@ public ResponseEntity<RepresentationModel<?>> handleUpdate(@RequestBody JsonApiD

@DeleteMapping(AgentIdentifierTypeDto.TYPENAME + "/{id}")
@Transactional
public ResponseEntity<RepresentationModel<?>> handleDelete(@PathVariable UUID id) {
public ResponseEntity<RepresentationModel<?>> handleDelete(@PathVariable UUID id) throws ResourceNotFoundException {
delete(id);
return ResponseEntity.noContent().build();
}
Expand Down

0 comments on commit ca56aa2

Please sign in to comment.