From 82e0121f57dfcf523d8a78c6f0d1706c9774a689 Mon Sep 17 00:00:00 2001 From: RandyCastr0 Date: Fri, 5 Apr 2024 19:20:03 +0000 Subject: [PATCH 01/10] feat: add delete item method --- .../lesson16/web/MediaItemsController.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java index cae5ff06..5731c9b9 100644 --- a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java +++ b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java @@ -4,10 +4,16 @@ import com.codedifferently.lesson16.library.Library; import com.codedifferently.lesson16.library.MediaItem; import com.codedifferently.lesson16.library.search.SearchCriteria; + import java.io.IOException; import java.util.List; import java.util.Set; +import java.util.UUID; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; @RestController @@ -27,4 +33,12 @@ public GetMediaItemsResponse getItems() { var response = GetMediaItemsResponse.builder().items(responseItems).build(); return response; } + + +@DeleteMapping("/items/{id}") + +public ResponseEntity deleteItem(@PathVariable("id") UUID id) { +library.removeMediaItem(id, librarian); +return ResponseEntity.noContent().build(); } +} \ No newline at end of file From 27e363b2c0a756eff894ffa066ea75e99c685e8a Mon Sep 17 00:00:00 2001 From: RandyCastr0 Date: Fri, 5 Apr 2024 20:34:02 +0000 Subject: [PATCH 02/10] chore: worked on postmapping --- .../lesson16/web/MediaItemsController.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java index 5731c9b9..ac731c7f 100644 --- a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java +++ b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java @@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; @RestController @@ -34,11 +36,21 @@ public GetMediaItemsResponse getItems() { return response; } + @DeleteMapping("/items/{id}") + public ResponseEntity deleteItem(@PathVariable("id") UUID id) { + library.removeMediaItem(id, librarian); + return ResponseEntity.noContent().build(); + } + +@PostMapping("/items/") +public CreateMediaItemResponse createItem(@RequestBody CreateMediaItemRequest request) { +MediaItem item = MediaItemRequest.asMediaItem(request.item); +library.addMediaItem( id, librarian); +return +} + + + -@DeleteMapping("/items/{id}") -public ResponseEntity deleteItem(@PathVariable("id") UUID id) { -library.removeMediaItem(id, librarian); -return ResponseEntity.noContent().build(); } -} \ No newline at end of file From 2072cb8006e9bd09888c37502cbf23852f8359b1 Mon Sep 17 00:00:00 2001 From: RandyCastr0 Date: Mon, 8 Apr 2024 14:59:01 +0000 Subject: [PATCH 03/10] chore: added getMediaItem and exception not found and return for post mapping --- .../lesson16/web/GetMediaItemsResponse.java | 1 + .../lesson16/web/MediaItemsController.java | 34 ++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/GetMediaItemsResponse.java b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/GetMediaItemsResponse.java index d0ed1173..9c0b1d5f 100644 --- a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/GetMediaItemsResponse.java +++ b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/GetMediaItemsResponse.java @@ -10,3 +10,4 @@ public class GetMediaItemsResponse { @Singular private List items; } + \ No newline at end of file diff --git a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java index ac731c7f..43452f95 100644 --- a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java +++ b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java @@ -4,12 +4,11 @@ import com.codedifferently.lesson16.library.Library; import com.codedifferently.lesson16.library.MediaItem; import com.codedifferently.lesson16.library.search.SearchCriteria; - import java.io.IOException; import java.util.List; import java.util.Set; import java.util.UUID; - +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -17,6 +16,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ResponseStatusException; @RestController public class MediaItemsController { @@ -36,21 +36,29 @@ public GetMediaItemsResponse getItems() { return response; } + @GetMapping("/items/:id") + public GetMediaItemsResponse getMediaItem(@PathVariable String id) { + Set items = library.search(SearchCriteria.builder().id(id).build()); + + if (items.isEmpty()) { + throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Media item not found"); + } + List responseItems = items.stream().map(MediaItemResponse::from).toList(); + var response = GetMediaItemsResponse.builder().items(responseItems).build(); + return response; + } + @DeleteMapping("/items/{id}") public ResponseEntity deleteItem(@PathVariable("id") UUID id) { library.removeMediaItem(id, librarian); return ResponseEntity.noContent().build(); } -@PostMapping("/items/") -public CreateMediaItemResponse createItem(@RequestBody CreateMediaItemRequest request) { -MediaItem item = MediaItemRequest.asMediaItem(request.item); -library.addMediaItem( id, librarian); -return -} - - - - - + @PostMapping("/items/") + public CreateMediaItemResponse postItem(@RequestBody CreateMediaItemRequest request) { + MediaItem item = MediaItemRequest.asMediaItem(request.getItem()); + library.addMediaItem(item, librarian); + var response = CreateMediaItemResponse.builder().item(MediaItemResponse.from(item)).build(); + return response; + } } From 49e089a65cfc4faced1747a75c1c2ec4d73366b9 Mon Sep 17 00:00:00 2001 From: RandyCastr0 Date: Mon, 8 Apr 2024 15:20:44 +0000 Subject: [PATCH 04/10] update: MediaItemsController file --- .../lesson16/web/MediaItemsController.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java index 43452f95..7d9660bc 100644 --- a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java +++ b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java @@ -1,13 +1,10 @@ package com.codedifferently.lesson16.web; -import com.codedifferently.lesson16.library.Librarian; -import com.codedifferently.lesson16.library.Library; -import com.codedifferently.lesson16.library.MediaItem; -import com.codedifferently.lesson16.library.search.SearchCriteria; import java.io.IOException; import java.util.List; import java.util.Set; import java.util.UUID; + import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -18,6 +15,11 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.server.ResponseStatusException; +import com.codedifferently.lesson16.library.Librarian; +import com.codedifferently.lesson16.library.Library; +import com.codedifferently.lesson16.library.MediaItem; +import com.codedifferently.lesson16.library.search.SearchCriteria; + @RestController public class MediaItemsController { private final Library library; From 4b5300c52e6bf2e17d1ad9c0d8c43d4ca4ce0d41 Mon Sep 17 00:00:00 2001 From: RandyCastr0 Date: Mon, 8 Apr 2024 15:45:59 +0000 Subject: [PATCH 05/10] trying to add is okay exception --- .../lesson16/web/GetMediaItemsResponse.java | 1 - .../lesson16/web/MediaItemsController.java | 15 +++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/GetMediaItemsResponse.java b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/GetMediaItemsResponse.java index 9c0b1d5f..d0ed1173 100644 --- a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/GetMediaItemsResponse.java +++ b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/GetMediaItemsResponse.java @@ -10,4 +10,3 @@ public class GetMediaItemsResponse { @Singular private List items; } - \ No newline at end of file diff --git a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java index 7d9660bc..a70c0995 100644 --- a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java +++ b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java @@ -1,13 +1,10 @@ package com.codedifferently.lesson16.web; -import java.io.IOException; -import java.util.List; -import java.util.Set; -import java.util.UUID; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; + import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -15,10 +12,15 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.server.ResponseStatusException; +import com.codedifferently.lesson16.library.Librarian; +import com.codedifferently.lesson16.library.Library; + import com.codedifferently.lesson16.library.Librarian; import com.codedifferently.lesson16.library.Library; import com.codedifferently.lesson16.library.MediaItem; import com.codedifferently.lesson16.library.search.SearchCriteria; +import com.codedifferently.lesson16.library.MediaItem; +import com.codedifferently.lesson16.library.search.SearchCriteria; @RestController public class MediaItemsController { @@ -39,17 +41,18 @@ public GetMediaItemsResponse getItems() { } @GetMapping("/items/:id") + public GetMediaItemsResponse getMediaItem(@PathVariable String id) { Set items = library.search(SearchCriteria.builder().id(id).build()); if (items.isEmpty()) { throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Media item not found"); - } + } else { List responseItems = items.stream().map(MediaItemResponse::from).toList(); var response = GetMediaItemsResponse.builder().items(responseItems).build(); return response; } - + } @DeleteMapping("/items/{id}") public ResponseEntity deleteItem(@PathVariable("id") UUID id) { library.removeMediaItem(id, librarian); From af94060d2f3b265347f7da83b0241eee7fb4002e Mon Sep 17 00:00:00 2001 From: RandyCastr0 Date: Tue, 9 Apr 2024 14:13:38 +0000 Subject: [PATCH 06/10] chore: trying to fix Bad Request error --- .../lesson16/web/MediaItemsController.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java index a70c0995..bda2eea3 100644 --- a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java +++ b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java @@ -1,10 +1,13 @@ package com.codedifferently.lesson16.web; +import java.io.IOException; +import java.util.List; +import java.util.Set; +import java.util.UUID; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; - import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -12,15 +15,10 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.server.ResponseStatusException; -import com.codedifferently.lesson16.library.Librarian; -import com.codedifferently.lesson16.library.Library; - import com.codedifferently.lesson16.library.Librarian; import com.codedifferently.lesson16.library.Library; import com.codedifferently.lesson16.library.MediaItem; import com.codedifferently.lesson16.library.search.SearchCriteria; -import com.codedifferently.lesson16.library.MediaItem; -import com.codedifferently.lesson16.library.search.SearchCriteria; @RestController public class MediaItemsController { @@ -41,18 +39,18 @@ public GetMediaItemsResponse getItems() { } @GetMapping("/items/:id") - public GetMediaItemsResponse getMediaItem(@PathVariable String id) { Set items = library.search(SearchCriteria.builder().id(id).build()); if (items.isEmpty()) { throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Media item not found"); } else { - List responseItems = items.stream().map(MediaItemResponse::from).toList(); - var response = GetMediaItemsResponse.builder().items(responseItems).build(); - return response; - } + List responseItems = items.stream().map(MediaItemResponse::from).toList(); + var response = GetMediaItemsResponse.builder().items(responseItems).build(); + return response; + } } + @DeleteMapping("/items/{id}") public ResponseEntity deleteItem(@PathVariable("id") UUID id) { library.removeMediaItem(id, librarian); @@ -65,5 +63,5 @@ public CreateMediaItemResponse postItem(@RequestBody CreateMediaItemRequest requ library.addMediaItem(item, librarian); var response = CreateMediaItemResponse.builder().item(MediaItemResponse.from(item)).build(); return response; - } +} } From 38f11c7414607f69d2ee7be7e5f1b7b15e8e8c29 Mon Sep 17 00:00:00 2001 From: RandyCastr0 Date: Tue, 9 Apr 2024 14:57:02 +0000 Subject: [PATCH 07/10] chore: deleted fornt foward slash --- .../lesson16/web/MediaItemsController.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java index bda2eea3..475e9125 100644 --- a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java +++ b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java @@ -1,10 +1,13 @@ package com.codedifferently.lesson16.web; +import com.codedifferently.lesson16.library.Librarian; +import com.codedifferently.lesson16.library.Library; +import com.codedifferently.lesson16.library.MediaItem; +import com.codedifferently.lesson16.library.search.SearchCriteria; import java.io.IOException; import java.util.List; import java.util.Set; import java.util.UUID; - import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -15,11 +18,6 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.server.ResponseStatusException; -import com.codedifferently.lesson16.library.Librarian; -import com.codedifferently.lesson16.library.Library; -import com.codedifferently.lesson16.library.MediaItem; -import com.codedifferently.lesson16.library.search.SearchCriteria; - @RestController public class MediaItemsController { private final Library library; @@ -57,11 +55,11 @@ public ResponseEntity deleteItem(@PathVariable("id") UUID id) { return ResponseEntity.noContent().build(); } - @PostMapping("/items/") + @PostMapping("/items") public CreateMediaItemResponse postItem(@RequestBody CreateMediaItemRequest request) { MediaItem item = MediaItemRequest.asMediaItem(request.getItem()); library.addMediaItem(item, librarian); var response = CreateMediaItemResponse.builder().item(MediaItemResponse.from(item)).build(); return response; -} + } } From c3c288583b269c1f8ee725f36376eb23866dc9ee Mon Sep 17 00:00:00 2001 From: RandyCastr0 Date: Wed, 10 Apr 2024 20:32:59 +0000 Subject: [PATCH 08/10] chore: added try catch for delete item and completed Not Found exception --- .../lesson16/web/MediaItemsController.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java index 475e9125..1fb194ca 100644 --- a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java +++ b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java @@ -1,13 +1,10 @@ package com.codedifferently.lesson16.web; -import com.codedifferently.lesson16.library.Librarian; -import com.codedifferently.lesson16.library.Library; -import com.codedifferently.lesson16.library.MediaItem; -import com.codedifferently.lesson16.library.search.SearchCriteria; import java.io.IOException; import java.util.List; import java.util.Set; import java.util.UUID; + import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -18,6 +15,13 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.server.ResponseStatusException; +import com.codedifferently.lesson16.library.Librarian; +import com.codedifferently.lesson16.library.Library; +import com.codedifferently.lesson16.library.MediaItem; +import com.codedifferently.lesson16.library.search.SearchCriteria; + +import jakarta.validation.Valid; + @RestController public class MediaItemsController { private final Library library; @@ -51,12 +55,20 @@ public GetMediaItemsResponse getMediaItem(@PathVariable String id) { @DeleteMapping("/items/{id}") public ResponseEntity deleteItem(@PathVariable("id") UUID id) { - library.removeMediaItem(id, librarian); - return ResponseEntity.noContent().build(); + try { + library.removeMediaItem(id, librarian); + return ResponseEntity.noContent().build(); + } catch (Exception e) { + return ResponseEntity.notFound().build(); + } } + /** + * @param request + * @return + */ @PostMapping("/items") - public CreateMediaItemResponse postItem(@RequestBody CreateMediaItemRequest request) { + public CreateMediaItemResponse postItem(@Valid @RequestBody CreateMediaItemRequest request) { MediaItem item = MediaItemRequest.asMediaItem(request.getItem()); library.addMediaItem(item, librarian); var response = CreateMediaItemResponse.builder().item(MediaItemResponse.from(item)).build(); From c5b0737210f9fbb4eebbe3d86d556f21d0858f42 Mon Sep 17 00:00:00 2001 From: RandyCastr0 Date: Fri, 12 Apr 2024 17:03:31 +0000 Subject: [PATCH 09/10] chore: update exception .isok --- .../lesson16/web/MediaItemsController.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java index 1fb194ca..28c4a0c5 100644 --- a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java +++ b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java @@ -41,18 +41,16 @@ public GetMediaItemsResponse getItems() { } @GetMapping("/items/:id") - public GetMediaItemsResponse getMediaItem(@PathVariable String id) { - Set items = library.search(SearchCriteria.builder().id(id).build()); + public ResponseEntity getMediaItem(@PathVariable String id) { + SearchCriteria criteria = SearchCriteria.builder().id(id.toString()).build(); + Set items = library.search(criteria); if (items.isEmpty()) { throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Media item not found"); - } else { - List responseItems = items.stream().map(MediaItemResponse::from).toList(); - var response = GetMediaItemsResponse.builder().items(responseItems).build(); - return response; + }else{ + return ResponseStatusException(HttpStatus.OK, "Media found"); } } - @DeleteMapping("/items/{id}") public ResponseEntity deleteItem(@PathVariable("id") UUID id) { try { From bfcf0f78d3c8b93f478ec6f5b027fe8cae4be724 Mon Sep 17 00:00:00 2001 From: RandyCastr0 Date: Fri, 12 Apr 2024 17:06:04 +0000 Subject: [PATCH 10/10] chore: ran gradlew spotless apply --- .../lesson16/web/MediaItemsController.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java index 28c4a0c5..d02a46c6 100644 --- a/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java +++ b/lesson_16/api/api_app/src/main/java/com/codedifferently/lesson16/web/MediaItemsController.java @@ -1,10 +1,14 @@ package com.codedifferently.lesson16.web; +import com.codedifferently.lesson16.library.Librarian; +import com.codedifferently.lesson16.library.Library; +import com.codedifferently.lesson16.library.MediaItem; +import com.codedifferently.lesson16.library.search.SearchCriteria; +import jakarta.validation.Valid; import java.io.IOException; import java.util.List; import java.util.Set; import java.util.UUID; - import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; @@ -15,13 +19,6 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.server.ResponseStatusException; -import com.codedifferently.lesson16.library.Librarian; -import com.codedifferently.lesson16.library.Library; -import com.codedifferently.lesson16.library.MediaItem; -import com.codedifferently.lesson16.library.search.SearchCriteria; - -import jakarta.validation.Valid; - @RestController public class MediaItemsController { private final Library library; @@ -47,10 +44,11 @@ public ResponseEntity getMediaItem(@PathVariable String id) { if (items.isEmpty()) { throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Media item not found"); - }else{ + } else { return ResponseStatusException(HttpStatus.OK, "Media found"); } } + @DeleteMapping("/items/{id}") public ResponseEntity deleteItem(@PathVariable("id") UUID id) { try {