File tree Expand file tree Collapse file tree 1 file changed +3
-10
lines changed
lesson_26/api/java/api_app/src/main/java/com/codedifferently/lesson26/web Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change @@ -65,25 +65,18 @@ public ResponseEntity<MediaItemResponse> getItemById(@PathVariable UUID id) {
6565 }
6666
6767 @ DeleteMapping ("/items/{id}" )
68- public ResponseEntity <Void > deleteItem (@ PathVariable String id ) { // Takes String id
69- UUID itemUuid ;
70-
71- try {
72- itemUuid = UUID .fromString (id );
73- } catch (IllegalArgumentException e ) {
74- return ResponseEntity .badRequest ().build ();
75- }
68+ public ResponseEntity <Void > deleteItem (@ PathVariable UUID id ) {
7669
7770 Set <MediaItem > items = library .search (SearchCriteria .builder ().build ());
7871 MediaItem foundItem =
79- items .stream ().filter (item -> item .getId ().equals (itemUuid )).findFirst ().orElse (null );
72+ items .stream ().filter (item -> item .getId ().equals (id )).findFirst ().orElse (null );
8073
8174 if (foundItem == null ) {
8275 return ResponseEntity .notFound ().build ();
8376 }
8477
8578 try {
86- library .removeMediaItem (itemUuid , this .librarian );
79+ library .removeMediaItem (id , this .librarian );
8780 return ResponseEntity .noContent ().build ();
8881 } catch (MediaItemCheckedOutException ex ) {
8982 return ResponseEntity .status (HttpStatus .CONFLICT ).build ();
You can’t perform that action at this time.
0 commit comments