Skip to content

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

Closed
wants to merge 2 commits into from

Conversation

dxsmith244
Copy link
Contributor

No description provided.

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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");
Copy link
Contributor

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();
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants