Class PlaylistService

java.lang.Object
org.opencastproject.playlists.PlaylistService

public class PlaylistService extends Object
  • Field Details

    • persistence

      protected PlaylistDatabaseService persistence
      Persistent storage
    • securityService

      protected org.opencastproject.security.api.SecurityService securityService
      The security service
    • authorizationService

      protected org.opencastproject.security.api.AuthorizationService authorizationService
      The authorization service
  • Constructor Details

    • PlaylistService

      public PlaylistService()
  • Method Details

    • setPersistence

      public void setPersistence(PlaylistDatabaseService persistence)
      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

      public void activate(org.osgi.service.component.ComponentContext cc) throws Exception
      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 Playlist belonging to the id
      Throws:
      org.opencastproject.util.NotFoundException - If no playlist with the given id could be found
      IllegalStateException - If something went wrong in the database service
      org.opencastproject.security.api.UnauthorizedException - If the user does not have read access for the playlist
    • getPlaylists

      public List<Playlist> getPlaylists(int limit, int offset) throws IllegalStateException
      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:
      IllegalStateException
      org.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 - The Playlist to create or update with
      Returns:
      The updated Playlist
      Throws:
      IllegalStateException - If something went wrong in the database service
      org.opencastproject.security.api.UnauthorizedException - If the user does not have write access for an existing playlist
      IllegalArgumentException
    • 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.JsonProcessingException
      org.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 found
      IllegalStateException - If something went wrong in the database service
      org.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 modify
      playlistEntries - the new playlist entries
      Returns:
      Playlist with the new entries
      Throws:
      org.opencastproject.util.NotFoundException - If no playlist with the given id could be found
      IllegalStateException - If something went wrong in the database service
      org.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 identifier
      contentId - content (e.g. mediapacakge) identifier
      type - arbitrary string
      Returns:
      Playlist with the new entry
      Throws:
      org.opencastproject.util.NotFoundException - If no playlist with the given id could be found
      IllegalStateException - If something went wrong in the database service
      org.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 identifier
      entryId - The entry identifier
      Returns:
      Playlist without the entry
      Throws:
      org.opencastproject.util.NotFoundException - If no playlist with the given id could be found
      IllegalStateException - If something went wrong in the database service
      org.opencastproject.security.api.UnauthorizedException - If the user does not have write access for the playlist
    • enrich

      public JaxbPlaylist enrich(Playlist playlist)
      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.