Package org.opencastproject.playlists
Class PlaylistService
java.lang.Object
org.opencastproject.playlists.PlaylistService
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AuthorizationServiceThe authorization serviceprotected PlaylistDatabaseServicePersistent storageprotected SecurityServiceThe security service -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(org.osgi.service.component.ComponentContext cc) addEntry(String playlistId, String contentId, PlaylistEntryType type) Adds a new entry at the end of a playlist and persists itEnrich each entry of a playlist with information about the content.getAllForAdministrativeRead(Date from, Date to, int limit) Returns a playlist from the database by its idgetPlaylists(int limit, int offset) Get multiple playlists from the databasegetPlaylists(int limit, int offset, SortCriterion sortCriterion) Deletes a playlist from the databaseremoveEntry(String playlistId, long entryId) Removes an entry with the given id from the playlist and persists itvoidsetAuthorizationService(AuthorizationService authorizationService) Callback for setting the authorization service.voidsetPersistence(PlaylistDatabaseService persistence) Callback to set the playlist databasevoidsetSecurityService(SecurityService securityService) OSGi callback to set the security service.Persist a new playlist in the database or update an existing oneupdateEntries(String playlistId, List<PlaylistEntry> playlistEntries) Replaces the entries in the playlist with the given entriesupdateWithJson(String id, String json) Overwrite an existing playlist with a playlist in JSON format.
-
Field Details
-
persistence
Persistent storage -
securityService
The security service -
authorizationService
The authorization service
-
-
Constructor Details
-
PlaylistService
public PlaylistService()
-
-
Method Details
-
setPersistence
Callback to set the playlist database- Parameters:
persistence- the playlist database
-
setSecurityService
OSGi callback to set the security service.- Parameters:
securityService- the securityService to set
-
setAuthorizationService
Callback for setting the authorization service.- Parameters:
authorizationService- the authorizationService to set
-
activate
- Throws:
Exception
-
getPlaylistById
public Playlist getPlaylistById(String id) throws NotFoundException, IllegalStateException, UnauthorizedException Returns a playlist from the database by its id- Parameters:
id- playlist id- Returns:
- The
Playlistbelonging to the id - Throws:
NotFoundException- If no playlist with the given id could be foundIllegalStateException- If something went wrong in the database serviceUnauthorizedException- If the user does not have read access for the playlist
-
getPlaylists
Get multiple playlists from the database- Parameters:
limit- The maximum amount of playlists to get with one request.offset- The index of the first result to return.- Returns:
- A list of
Playlists - Throws:
IllegalStateException- If something went wrong in the database service
-
getPlaylists
public List<Playlist> getPlaylists(int limit, int offset, SortCriterion sortCriterion) throws IllegalStateException - Throws:
IllegalStateException
-
getAllForAdministrativeRead
public List<Playlist> getAllForAdministrativeRead(Date from, Date to, int limit) throws IllegalStateException, UnauthorizedException -
update
public Playlist update(Playlist playlist) throws IllegalStateException, UnauthorizedException, IllegalArgumentException Persist a new playlist in the database or update an existing one- Parameters:
playlist- ThePlaylistto create or update with- Returns:
- The updated
Playlist - Throws:
IllegalStateException- If something went wrong in the database serviceUnauthorizedException- If the user does not have write access for an existing playlistIllegalArgumentException
-
updateWithJson
public Playlist updateWithJson(String id, String json) throws com.fasterxml.jackson.core.JsonProcessingException, UnauthorizedException Overwrite an existing playlist with a playlist in JSON format. Only fields present in the JSON will be overwritten! Conversely, if a field is not present in the JSON, the field in the existing playlist will not change.- Parameters:
id- Identifier of the playlist to update.json- JSON containing data to update the playlist with.- Returns:
- The updated
Playlist - Throws:
com.fasterxml.jackson.core.JsonProcessingExceptionUnauthorizedException
-
remove
public Playlist remove(String playlistId) throws NotFoundException, IllegalStateException, UnauthorizedException Deletes a playlist from the database- Parameters:
playlistId- The playlist identifier- Returns:
- The removed
Playlist - Throws:
NotFoundException- If no playlist with the given id could be foundIllegalStateException- If something went wrong in the database serviceUnauthorizedException- If the user does not have write access for the playlist
-
updateEntries
public Playlist updateEntries(String playlistId, List<PlaylistEntry> playlistEntries) throws NotFoundException, IllegalStateException, UnauthorizedException Replaces the entries in the playlist with the given entries- Parameters:
playlistId- identifier of the playlist to modifyplaylistEntries- the new playlist entries- Returns:
Playlistwith the new entries- Throws:
NotFoundException- If no playlist with the given id could be foundIllegalStateException- If something went wrong in the database serviceUnauthorizedException- If the user does not have write access for the playlist
-
addEntry
public Playlist addEntry(String playlistId, String contentId, PlaylistEntryType type) throws NotFoundException, IllegalStateException, UnauthorizedException Adds a new entry at the end of a playlist and persists it- Parameters:
playlistId- The playlist identifiercontentId- content (e.g. mediapacakge) identifiertype- arbitrary string- Returns:
Playlistwith the new entry- Throws:
NotFoundException- If no playlist with the given id could be foundIllegalStateException- If something went wrong in the database serviceUnauthorizedException- If the user does not have write access for the playlist
-
removeEntry
public Playlist removeEntry(String playlistId, long entryId) throws NotFoundException, IllegalStateException, UnauthorizedException Removes an entry with the given id from the playlist and persists it- Parameters:
playlistId- The playlist identifierentryId- The entry identifier- Returns:
Playlistwithout the entry- Throws:
NotFoundException- If no playlist with the given id could be foundIllegalStateException- If something went wrong in the database serviceUnauthorizedException- If the user does not have write access for the playlist
-
enrich
Enrich each entry of a playlist with information about the content. Intended to be used by endpoints when returning information about a playlist. Currently only adds publication information for entries of type EVENT.- Parameters:
playlist- The playlist to enrich- Returns:
- The serialization class of the playlist, since the added information does not belong to the playlist itself.
-