Class SchedulerServiceImpl

java.lang.Object
org.opencastproject.elasticsearch.index.rebuild.AbstractIndexProducer
org.opencastproject.scheduler.impl.SchedulerServiceImpl
All Implemented Interfaces:
IndexProducer, SchedulerService, org.osgi.service.cm.ManagedService

public class SchedulerServiceImpl extends AbstractIndexProducer implements SchedulerService, org.osgi.service.cm.ManagedService
Implementation of SchedulerService.
  • Field Details

    • lastModifiedCache

      protected com.google.common.cache.Cache<String,String> lastModifiedCache
      The last modified cache
  • Constructor Details

    • SchedulerServiceImpl

      public SchedulerServiceImpl()
  • Method Details

    • addSchedulerUpdateHandler

      public void addSchedulerUpdateHandler(SchedulerUpdateHandler handler)
      OSGi callback to add an update handler.
      Parameters:
      handler -
    • removeSchedulerUpdateHandler

      public void removeSchedulerUpdateHandler(SchedulerUpdateHandler handler)
    • setPersistence

      public void setPersistence(SchedulerServiceDatabase persistence)
      OSGi callback to set Persistence Service.
      Parameters:
      persistence -
    • setSeriesService

      public void setSeriesService(SeriesService seriesService)
      OSGi callback for setting Series Service.
      Parameters:
      seriesService -
    • setSecurityService

      public void setSecurityService(SecurityService securityService)
      OSGi callback to set security service.
      Parameters:
      securityService -
    • setAssetManager

      public void setAssetManager(AssetManager assetManager)
      OSGi callback to set the asset manager.
      Parameters:
      assetManager -
    • setWorkspace

      public void setWorkspace(Workspace workspace)
      OSGi callback to set the workspace.
      Parameters:
      workspace -
    • setAuthorizationService

      public void setAuthorizationService(AuthorizationService authorizationService)
      OSGi callback to set the authorization service.
      Parameters:
      authorizationService -
    • setOrgDirectoryService

      public void setOrgDirectoryService(OrganizationDirectoryService orgDirectoryService)
      OSGi callback to set the organization directory service.
      Parameters:
      orgDirectoryService -
    • setIndex

      public void setIndex(ElasticsearchIndex index)
      OSgi callback to set the Elasticsearch index.
      Parameters:
      index - the Elasticsearch index.
    • addCatalogUIAdapter

      public void addCatalogUIAdapter(EventCatalogUIAdapter catalogUIAdapter)
      OSGi callback to add EventCatalogUIAdapter instance.
    • removeCatalogUIAdapter

      public void removeCatalogUIAdapter(EventCatalogUIAdapter catalogUIAdapter)
      OSGi callback to remove EventCatalogUIAdapter instance.
    • activate

      public void activate(org.osgi.service.component.ComponentContext cc) throws Exception
      Activates Scheduler Service.
      Parameters:
      cc - ComponentContext
      Throws:
      Exception
    • updated

      public void updated(Dictionary<String,?> properties) throws org.osgi.service.cm.ConfigurationException
      Specified by:
      updated in interface org.osgi.service.cm.ManagedService
      Throws:
      org.osgi.service.cm.ConfigurationException
    • addEvent

      public void addEvent(Date startDateTime, Date endDateTime, String captureAgentId, Set<String> userIds, MediaPackage mediaPackage, Map<String,String> wfProperties, Map<String,String> caMetadata, com.entwinemedia.fn.data.Opt<String> schedulingSource) throws UnauthorizedException, SchedulerException
      Description copied from interface: SchedulerService
      Creates new event using specified mediapackage, workflow configuration and capture agent configuration. The mediapackage id is used as the event's identifier. Default capture agent properties are created from agentId and DublinCore. Following values are generated:
      • event.title (mapped from dc:title)
      • event.series (mapped from mediaPackage#getSeries())
      • event.location (mapped from captureAgentId)
      Specified by:
      addEvent in interface SchedulerService
      Parameters:
      startDateTime - the event start time (the start date must be before the end date)
      endDateTime - the event end time (the end date must be after the start date)
      captureAgentId - the capture agent id
      userIds - the list of user identifiers of speakers/lecturers
      mediaPackage - the mediapackage
      wfProperties - the workflow configuration
      caMetadata - the capture agent configuration
      schedulingSource - the optional scheduling source from which the event comes from
      Throws:
      UnauthorizedException - if the caller is not authorized to take this action
      SchedulerException - if creating new events failed
    • addMultipleEvents

      public Map<String,net.fortuna.ical4j.model.Period> addMultipleEvents(net.fortuna.ical4j.model.property.RRule rRule, Date start, Date end, Long duration, TimeZone tz, String captureAgentId, Set<String> userIds, MediaPackage templateMp, Map<String,String> wfProperties, Map<String,String> caMetadata, com.entwinemedia.fn.data.Opt<String> schedulingSource) throws UnauthorizedException, SchedulerConflictException, SchedulerException
      Description copied from interface: SchedulerService
      Creates a group of new event using specified mediapackage, workflow configuration and capture agent configuration. The mediapackage id is used as the event's identifier. Default capture agent properties are created from agentId and DublinCore. Following values are generated:
      • event.title (mapped from dc:title)
      • event.series (mapped from mediaPackage#getSeries())
      • event.location (mapped from captureAgentId)
      Specified by:
      addMultipleEvents in interface SchedulerService
      Parameters:
      rRule - the RRule for the events to schedule
      start - the start date for the recurrence
      end - the end date for the recurrence
      duration - the duration of the events
      tz - the TimeZone for the events
      captureAgentId - the capture agent id
      userIds - the list of user identifiers of speakers/lecturers
      templateMp - the mediapackage to base the events on
      wfProperties - the workflow configuration
      caMetadata - the capture agent configuration
      schedulingSource - the optional scheduling source from which the event comes from
      Returns:
      A Map of mediapackage ID and Period where the event occurs
      Throws:
      UnauthorizedException - if the caller is not authorized to take this action
      SchedulerConflictException - if there are conflicting events
      SchedulerException - if creating new events failed
    • updateEvent

      public void updateEvent(String mpId, com.entwinemedia.fn.data.Opt<Date> startDateTime, com.entwinemedia.fn.data.Opt<Date> endDateTime, com.entwinemedia.fn.data.Opt<String> captureAgentId, com.entwinemedia.fn.data.Opt<Set<String>> userIds, com.entwinemedia.fn.data.Opt<MediaPackage> mediaPackage, com.entwinemedia.fn.data.Opt<Map<String,String>> wfProperties, com.entwinemedia.fn.data.Opt<Map<String,String>> caMetadata) throws NotFoundException, UnauthorizedException, SchedulerException
      Description copied from interface: SchedulerService
      Updates event with specified ID and check for conflicts. Default capture agent properties are created from DublinCore. Following values are generated:
      • event.title (mapped from dc:title)
      • event.series (mapped from mediaPackage#getSeries())
      • event.location (mapped from captureAgentId)
      Specified by:
      updateEvent in interface SchedulerService
      Parameters:
      mpId - the optional event identifier
      startDateTime - the optional event start time
      endDateTime - the optional event end time
      captureAgentId - the optional capture agent id
      userIds - the optional list of user identifiers of speakers/lecturers
      mediaPackage - the optional mediapackage to update
      wfProperties - the optional workflow configuration to update
      caMetadata - the optional capture configuration to update
      Throws:
      NotFoundException - if event with specified ID cannot be found
      UnauthorizedException - if the current user is not authorized to perform this action
      SchedulerException - if exception occurred
    • updateEvent

      public void updateEvent(String mpId, com.entwinemedia.fn.data.Opt<Date> startDateTime, com.entwinemedia.fn.data.Opt<Date> endDateTime, com.entwinemedia.fn.data.Opt<String> captureAgentId, com.entwinemedia.fn.data.Opt<Set<String>> userIds, com.entwinemedia.fn.data.Opt<MediaPackage> mediaPackage, com.entwinemedia.fn.data.Opt<Map<String,String>> wfProperties, com.entwinemedia.fn.data.Opt<Map<String,String>> caMetadata, boolean allowConflict) throws NotFoundException, UnauthorizedException, SchedulerException
      Description copied from interface: SchedulerService
      Updates event with specified ID and possibly checking for conflicts. Default capture agent properties are created from DublinCore. Following values are generated:
      • event.title (mapped from dc:title)
      • event.series (mapped from mediaPackage#getSeries())
      • event.location (mapped from captureAgentId)
      Specified by:
      updateEvent in interface SchedulerService
      Parameters:
      mpId - the event identifier
      startDateTime - the optional event start time
      endDateTime - the optional event end time
      captureAgentId - the optional capture agent id
      userIds - the optional list of user identifiers of speakers/lecturers
      mediaPackage - the optional mediapackage to update
      wfProperties - the optional workflow configuration to update
      caMetadata - the optional capture configuration to update
      allowConflict - the flag to ignore conflict checks
      Throws:
      NotFoundException - if event with specified ID cannot be found
      UnauthorizedException - if the current user is not authorized to perform this action
      SchedulerException - if exception occurred
    • removeEvent

      public void removeEvent(String mediaPackageId) throws NotFoundException, SchedulerException
      Description copied from interface: SchedulerService
      Removes event with specified ID.
      Specified by:
      removeEvent in interface SchedulerService
      Parameters:
      mediaPackageId - the event identifier
      Throws:
      NotFoundException - if event with specified ID cannot be found
      SchedulerException - if exception occurred
    • getMediaPackage

      public MediaPackage getMediaPackage(String mediaPackageId) throws NotFoundException, SchedulerException
      Description copied from interface: SchedulerService
      Retrieves mediapackage associated with specified event ID.
      Specified by:
      getMediaPackage in interface SchedulerService
      Parameters:
      mediaPackageId - ID of event for which mediapackage will be retrieved
      Returns:
      MediaPackage for specified event
      Throws:
      NotFoundException - if event with specified ID cannot be found
      SchedulerException - if exception occurred
    • getDublinCore

      public DublinCoreCatalog getDublinCore(String mediaPackageId) throws NotFoundException, SchedulerException
      Description copied from interface: SchedulerService
      Retrieves dublin core catalog associated with specified event ID.
      Specified by:
      getDublinCore in interface SchedulerService
      Parameters:
      mediaPackageId - ID of event for which DublinCore will be retrieved
      Returns:
      DublinCoreCatalog for specified event
      Throws:
      NotFoundException - if event with specified ID cannot be found
      SchedulerException - if exception occurred
    • getTechnicalMetadata

      public TechnicalMetadata getTechnicalMetadata(String mediaPackageId) throws NotFoundException, UnauthorizedException, SchedulerException
      Description copied from interface: SchedulerService
      Retrieves the technical metadata associated with specified event ID.
      Specified by:
      getTechnicalMetadata in interface SchedulerService
      Parameters:
      mediaPackageId - ID of event for which technical metadata will be retrieved
      Returns:
      TechnicalMetadata for specified event
      Throws:
      NotFoundException - if event with specified ID cannot be found
      SchedulerException - if exception occurred
      UnauthorizedException
    • getWorkflowConfig

      public Map<String,String> getWorkflowConfig(String mediaPackageId) throws NotFoundException, SchedulerException
      Description copied from interface: SchedulerService
      Retrieves workflow configuration associated with specified event ID.
      Specified by:
      getWorkflowConfig in interface SchedulerService
      Parameters:
      mediaPackageId - ID of event for which workflow configuration will be retrieved
      Returns:
      configuration of the workflow
      Throws:
      NotFoundException - if event with specified ID cannot be found
      SchedulerException - if exception occurred
    • getCaptureAgentConfiguration

      public Map<String,String> getCaptureAgentConfiguration(String mediaPackageId) throws NotFoundException, SchedulerException
      Description copied from interface: SchedulerService
      Retrieves capture agent configuration for specified event.
      Specified by:
      getCaptureAgentConfiguration in interface SchedulerService
      Parameters:
      mediaPackageId - ID of event for which capture agent configuration will be retrieved
      Returns:
      configurations of capture agent
      Throws:
      NotFoundException - if event with specified ID cannot be found
      SchedulerException - if exception occurred
    • getEventCount

      public int getEventCount() throws SchedulerException
      Description copied from interface: SchedulerService
      Returns the number of scheduled events.
      Specified by:
      getEventCount in interface SchedulerService
      Returns:
      the number of scheduled events
      Throws:
      SchedulerException - if exception occurred
    • search

      public List<MediaPackage> search(com.entwinemedia.fn.data.Opt<String> captureAgentId, com.entwinemedia.fn.data.Opt<Date> startsFrom, com.entwinemedia.fn.data.Opt<Date> startsTo, com.entwinemedia.fn.data.Opt<Date> endFrom, com.entwinemedia.fn.data.Opt<Date> endTo) throws SchedulerException
      Description copied from interface: SchedulerService
      Retrieves all events matching given filter.
      Specified by:
      search in interface SchedulerService
      Parameters:
      captureAgentId - the capture agent id filter
      startsFrom - the start from date filter
      startsTo - the start to date filter
      endFrom - the end from date filter
      endTo - the end to date filter
      Returns:
      a MediaPackage list of matching events
      Throws:
      SchedulerException - if exception occurred
    • getCurrentRecording

      public com.entwinemedia.fn.data.Opt<MediaPackage> getCurrentRecording(String captureAgentId) throws SchedulerException
      Description copied from interface: SchedulerService
      Retrieves the currently active recording for the given capture agent (if any).
      Specified by:
      getCurrentRecording in interface SchedulerService
      Parameters:
      captureAgentId - The id of the agent to get the current recording of.
      Returns:
      The currently active recording or none, if agent is currently idle
      Throws:
      SchedulerException - In case the current recording cannot be retrieved.
    • getUpcomingRecording

      public com.entwinemedia.fn.data.Opt<MediaPackage> getUpcomingRecording(String captureAgentId) throws SchedulerException
      Description copied from interface: SchedulerService
      Retrieves the upcoming recording for the given capture agent (if any).
      Specified by:
      getUpcomingRecording in interface SchedulerService
      Parameters:
      captureAgentId - The id of the agent to get the upcoming recording of.
      Returns:
      The cupcoming recording or none, if there is none.
      Throws:
      SchedulerException - In case the upcoming recording cannot be retrieved.
    • findConflictingEvents

      public List<MediaPackage> findConflictingEvents(String captureDeviceID, Date startDate, Date endDate) throws SchedulerException
      Description copied from interface: SchedulerService
      Returns list of all conflicting events, i.e. all events that ends after start date and begins before end date.
      Specified by:
      findConflictingEvents in interface SchedulerService
      Parameters:
      captureDeviceID - capture device ID for which conflicting events are searched for
      startDate - start date of conflicting period
      endDate - end date of conflicting period
      Returns:
      a MediaPackage list of all conflicting events
      Throws:
      SchedulerException - if exception occurred
    • findConflictingEvents

      public List<MediaPackage> findConflictingEvents(String captureAgentId, net.fortuna.ical4j.model.property.RRule rrule, Date start, Date end, long duration, TimeZone tz) throws SchedulerException
      Description copied from interface: SchedulerService
      Returns list of all conflicting events. Conflicting periods are calculated based on recurrence rule, start date, end date and duration of each conflicting period.
      Specified by:
      findConflictingEvents in interface SchedulerService
      Parameters:
      captureAgentId - capture agent ID for which conflicting events are searched for
      rrule - recurrence rule
      start - beginning of period
      end - ending of period
      duration - duration of each period
      tz - the time zone of the capture agent
      Returns:
      a MediaPackage list of all conflicting events
      Throws:
      SchedulerException - if exception occurred
    • getCalendar

      public String getCalendar(com.entwinemedia.fn.data.Opt<String> captureAgentId, com.entwinemedia.fn.data.Opt<String> seriesId, com.entwinemedia.fn.data.Opt<Date> cutoff) throws SchedulerException
      Description copied from interface: SchedulerService
      Generates calendar for specified capture agent.
      Specified by:
      getCalendar in interface SchedulerService
      Parameters:
      captureAgentId - capture agent id filter
      seriesId - series id filter
      cutoff - cutoff date filter
      Returns:
      generated calendar
      Throws:
      SchedulerException - if exception occurred
    • getScheduleLastModified

      public String getScheduleLastModified(String captureAgentId) throws SchedulerException
      Description copied from interface: SchedulerService
      Returns hash of last modification of event belonging to specified capture agent.
      Specified by:
      getScheduleLastModified in interface SchedulerService
      Parameters:
      captureAgentId - the capture agent identifier
      Returns:
      the last modification hash
      Throws:
      SchedulerException - if exception occurred
    • removeScheduledRecordingsBeforeBuffer

      public void removeScheduledRecordingsBeforeBuffer(long buffer) throws SchedulerException
      Description copied from interface: SchedulerService
      Remove all of the scheduled events before a buffer.
      Specified by:
      removeScheduledRecordingsBeforeBuffer in interface SchedulerService
      Parameters:
      buffer - The number of seconds before now that defines a cutoff for events, if they have their end time before this cutoff they will be removed
      Throws:
      SchedulerException
    • updateRecordingState

      public boolean updateRecordingState(String id, String state) throws NotFoundException, SchedulerException
      Description copied from interface: SchedulerService
      Updates the state of a recording with the given state, if it exists.
      Specified by:
      updateRecordingState in interface SchedulerService
      Parameters:
      id - The id of the recording in the system.
      state - The state to set for that recording. This should be defined from Recording.
      Throws:
      NotFoundException - if the recording with the given id has not been found
      SchedulerException
    • getRecordingState

      public Recording getRecordingState(String id) throws NotFoundException, SchedulerException
      Description copied from interface: SchedulerService
      Gets the state of a recording, if it exists.
      Specified by:
      getRecordingState in interface SchedulerService
      Parameters:
      id - The id of the recording.
      Returns:
      The state of the recording, or null if it does not exist. This should be defined from Recording.
      Throws:
      NotFoundException - if the recording with the given id has not been found
      SchedulerException
    • removeRecording

      public void removeRecording(String id) throws NotFoundException, SchedulerException
      Description copied from interface: SchedulerService
      Removes a recording from the system, if the recording exists.
      Specified by:
      removeRecording in interface SchedulerService
      Parameters:
      id - The id of the recording to remove.
      Throws:
      NotFoundException - if the recording with the given id has not been found
      SchedulerException
    • getKnownRecordings

      public Map<String,Recording> getKnownRecordings() throws SchedulerException
      Description copied from interface: SchedulerService
      Gets the state of all recordings in the system.
      Specified by:
      getKnownRecordings in interface SchedulerService
      Returns:
      A map of recording-state pairs.
      Throws:
      SchedulerException
    • repopulate

      public void repopulate(IndexRebuildService.DataType type) throws IndexRebuildException
      Description copied from interface: IndexProducer
      Re-add the data of this service to the index.
      Specified by:
      repopulate in interface IndexProducer
      Parameters:
      type - Limit the data added to the index. Use ALL to re-index all data.
      Throws:
      IndexRebuildException
    • getService

      public IndexRebuildService.Service getService()
      Description copied from interface: IndexProducer
      Get the service that implements IndexProducer.
      Specified by:
      getService in interface IndexProducer
      Returns:
      service The service that implements IndexProducer.
    • getSecurityService

      public SecurityService getSecurityService()