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) {
65
65
}
66
66
67
67
@ 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 ) {
76
69
77
70
Set <MediaItem > items = library .search (SearchCriteria .builder ().build ());
78
71
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 );
80
73
81
74
if (foundItem == null ) {
82
75
return ResponseEntity .notFound ().build ();
83
76
}
84
77
85
78
try {
86
- library .removeMediaItem (itemUuid , this .librarian );
79
+ library .removeMediaItem (id , this .librarian );
87
80
return ResponseEntity .noContent ().build ();
88
81
} catch (MediaItemCheckedOutException ex ) {
89
82
return ResponseEntity .status (HttpStatus .CONFLICT ).build ();
You can’t perform that action at this time.
0 commit comments