-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify PlaylistHelper#getUserPlaylist
- Loading branch information
Showing
4 changed files
with
17 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
package me.kavin.piped.utils; | ||
|
||
import me.kavin.piped.utils.obj.db.Playlist; | ||
import org.hibernate.Session; | ||
|
||
import me.kavin.piped.utils.obj.db.User; | ||
|
||
public class PlaylistHelpers { | ||
public static PlaylistResult getUserPlaylist(Session s, User user, String playlistId) { | ||
public static Playlist getUserPlaylist(Session s, User user, String playlistId) throws IllegalArgumentException { | ||
var playlist = DatabaseHelper.getPlaylistFromId(s, playlistId); | ||
|
||
if (playlist == null) | ||
return new PlaylistResult(null, "Playlist not found"); | ||
throw new IllegalArgumentException("Playlist not found"); | ||
|
||
if (playlist.getOwner().getId() != user.getId()) | ||
return new PlaylistResult(null, "You do not own this playlist"); | ||
throw new IllegalArgumentException("You do not own this playlist"); | ||
|
||
return new PlaylistResult(playlist, null); | ||
return playlist; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.