Package org.opencastproject.playlists
Class PlaylistService
java.lang.Object
org.opencastproject.playlists.PlaylistService
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.opencastproject.security.api.AuthorizationServiceThe authorization serviceprotected PlaylistDatabaseServicePersistent storageprotected org.opencastproject.security.api.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, org.opencastproject.util.requests.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(org.opencastproject.security.api.AuthorizationService authorizationService) Callback for setting the authorization service.voidsetPersistence(PlaylistDatabaseService persistence) Callback to set the playlist databasevoidsetSecurityService(org.opencastproject.security.api.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
protected org.opencastproject.security.api.SecurityService securityServiceThe security service -
authorizationService
protected org.opencastproject.security.api.AuthorizationService authorizationServiceThe authorization service
-
-
Constructor Details
-
PlaylistService
public PlaylistService()
-
-
Method Details
-
setPersistence
Callback to set the playlist database- Parameters:
persistence- the playlist database
-
setSecurityService
public void setSecurityService(org.opencastproject.security.api.SecurityService securityService) OSGi callback to set the security service.- Parameters:
securityService- the securityService to set
-
setAuthorizationService
public void setAuthorizationService(org.opencastproject.security.api.AuthorizationService authorizationService) Callback for setting the authorization service.- Parameters:
authorizationService- the authorizationService to set
-
activate
- Throws:
Exception
-
getPlaylistById
public Playlist getPlaylistById(String id) throws org.opencastproject.util.NotFoundException, IllegalStateException, org.opencastproject.security.api.UnauthorizedException Returns a playlist from the database by its id- Parameters:
id- playlist id- Returns:
- The
Playlistbelonging to the id - Throws:
org.opencastproject.util.NotFoundException- If no playlist with the given id could be foundIllegalStateException- If something went wrong in the database serviceorg.opencastproject.security.api.UnauthorizedException- 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, org.opencastproject.util.requests.SortCriterion sortCriterion) throws IllegalStateException - Throws:
IllegalStateException
-
getAllForAdministrativeRead
public List<Playlist> getAllForAdministrativeRead(Date from, Date to, int limit) throws IllegalStateException, org.opencastproject.security.api.UnauthorizedException - Throws:
IllegalStateExceptionorg.opencastproject.security.api.UnauthorizedException
-
update
public Playlist update(Playlist playlist) throws IllegalStateException, org.opencastproject.security.api.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 serviceorg.opencastproject.security.api.UnauthorizedException- 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, org.opencastproject.security.api.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.JsonProcessingExceptionorg.opencastproject.security.api.UnauthorizedException
-
remove
public Playlist remove(String playlistId) throws org.opencastproject.util.NotFoundException, IllegalStateException, org.opencastproject.security.api.UnauthorizedException Deletes a playlist from the database- Parameters:
playlistId- The playlist identifier- Returns:
- The removed
Playlist - Throws:
org.opencastproject.util.NotFoundException- If no playlist with the given id could be foundIllegalStateException- If something went wrong in the database serviceorg.opencastproject.security.api.UnauthorizedException- If the user does not have write access for the playlist
-
updateEntries
public Playlist updateEntries(String playlistId, List<PlaylistEntry> playlistEntries) throws org.opencastproject.util.NotFoundException, IllegalStateException, org.opencastproject.security.api.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:
org.opencastproject.util.NotFoundException- If no playlist with the given id could be foundIllegalStateException- If something went wrong in the database serviceorg.opencastproject.security.api.UnauthorizedException- If the user does not have write access for the playlist
-
addEntry
public Playlist addEntry(String playlistId, String contentId, PlaylistEntryType type) throws org.opencastproject.util.NotFoundException, IllegalStateException, org.opencastproject.security.api.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:
org.opencastproject.util.NotFoundException- If no playlist with the given id could be foundIllegalStateException- If something went wrong in the database serviceorg.opencastproject.security.api.UnauthorizedException- If the user does not have write access for the playlist
-
removeEntry
public Playlist removeEntry(String playlistId, long entryId) throws org.opencastproject.util.NotFoundException, IllegalStateException, org.opencastproject.security.api.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:
org.opencastproject.util.NotFoundException- If no playlist with the given id could be foundIllegalStateException- If something went wrong in the database serviceorg.opencastproject.security.api.UnauthorizedException- 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.
-