Skip to content

Commit

Permalink
Fixed getting NPE when parsing tags
Browse files Browse the repository at this point in the history
  • Loading branch information
leingenm committed Oct 11, 2024
1 parent 4cfd021 commit d25cf15
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void handleVideosSavedEvent(VideosSavedEvent event) {

private Video addOrUpdateVideoData(VideoDto dto, Video video) {
if (video.getVideoData() == null) {
var videoData = new VideoData(dto.title(), dto.description(), dto.channelName(), tagsToString(dto));
var videoData = new VideoData(dto.title(), dto.description(), dto.channelName(), this.getTags(dto));
video.setVideoData(videoData);
video.getVideoData().setVideo(video);
} else if (hasVideoDataChanged(video.getVideoData(), dto)) {
Expand All @@ -64,14 +64,18 @@ private boolean hasVideoDataChanged(VideoData videoData, VideoDto dto) {
return !Objects.equals(videoData.getTitle(), dto.title())
|| !Objects.equals(videoData.getDescription(), dto.description())
|| !Objects.equals(videoData.getChannelName(), dto.channelName())
|| !Objects.equals(videoData.getTags(), dto.tags() != null ? tagsToString(dto) : null);
|| !Objects.equals(videoData.getTags(), this.getTags(dto));
}

private void updateVideoData(VideoData videoData, VideoDto videoDto) {
videoData.setTitle(videoDto.title());
videoData.setDescription(videoDto.description());
videoData.setChannelName(videoDto.channelName());
videoData.setTags(videoDto.tags() != null ? tagsToString(videoDto) : null);
videoData.setTags(this.getTags(videoDto));
}

private String getTags(VideoDto dto) {
return dto.tags() != null ? tagsToString(dto) : null;
}

private String tagsToString(VideoDto videoDto) {
Expand Down

0 comments on commit d25cf15

Please sign in to comment.