-
Notifications
You must be signed in to change notification settings - Fork 26
feat: adds new methods for MediaItemsController.java for lesson 26 #679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Set<MediaItem> item = library.search(SearchCriteria.builder().id(id.toString()).build()); | ||
if (item.isEmpty()) { | ||
return ResponseEntity.notFound().build(); | ||
} else if (!test1.contains(item.iterator().next()) || item.iterator().next() == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you doing this? Doesn't seem necessary at all. My guess is removing this code (and test1
) above won't change your results at all.
public ResponseEntity<?> postItems(@RequestBody CreateMediaItemRequest requestBody) { | ||
List<String> errorsList = new ArrayList<>(); | ||
MediaItemRequest request = requestBody.getItem(); | ||
if (requestBody.getItem() == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't need any of this validation code if you just use the @Valid
attribute on the requestBody
argument.
Set<MediaItem> items = library.search(SearchCriteria.builder().id(id.toString()).build()); | ||
Optional<MediaItem> matchedItem = | ||
items.stream().filter(item -> item.getId().equals(id)).findFirst(); | ||
System.out.println("items"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debugging statements.
Set<MediaItem> items = library.search(SearchCriteria.builder().build()); | ||
if (items.isEmpty()) { | ||
ResponseEntity.noContent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, should return GetMediaItmesResponse
with an empty list of items. Anything else would be unexpected and unusual.
No description provided.