Class AbstractWorkflowOperationHandler
- All Implemented Interfaces:
WorkflowOperationHandler
- Direct Known Subclasses:
AddCatalogWorkflowOperationHandler,AmberscriptAttachTranscriptionOperationHandler,AmberscriptStartTranscriptionOperationHandler,AnalyzeMediapackageWorkflowOperationHandler,AnalyzeTracksWorkflowOperationHandler,AssertWorkflowOperationHandler,AssetManagerDeleteWorkflowOperationHandler,AssetManagerSnapshotWorkflowOperationHandler,AssetManagerStorageMoveOperationHandler,AttachTranscriptionOperationHandler,ChangeTypeWorkflowOperationHandler,CleanupWorkflowOperationHandler,CloneWorkflowOperationHandler,CommentWorkflowOperationHandler,CompositeWorkflowOperationHandler,ConcatWorkflowOperationHandler,ConditionalConfigWorkflowOperationHandler,ConfigurableWorkflowOperationHandlerBase,CopyWorkflowOperationHandler,CoverImageWorkflowOperationHandlerBase,CropWorkflowOperationHandler,CutMarksToSmilWorkflowOperationHandler,DefaultsWorkflowOperationHandler,DemuxWorkflowOperationHandler,DuplicateEventWorkflowOperationHandler,EmailWorkflowOperationHandler,EncodeWorkflowOperationHandler,ExecuteManyWorkflowOperationHandler,ExecuteOnceWorkflowOperationHandler,ExportWorkflowPropertiesWOH,GoogleSpeechAttachTranscriptionOperationHandler,GoogleSpeechStartTranscriptionOperationHandler,HelloWorldWorkflowOperationHandler,HttpNotificationWorkflowOperationHandler,ImageConvertWorkflowOperationHandler,ImageToVideoWorkflowOperationHandler,ImageWorkflowOperationHandler,ImportWorkflowPropertiesWOH,IncidentCreatorWorkflowOperationHandler,IncludeWorkflowOperationHandler,IngestDownloadWorkflowOperationHandler,InspectWorkflowOperationHandler,LoggingWorkflowOperationHandler,MattermostNotificationWorkflowOperationHandler,MediaPackagePostOperationHandler,MetadataToAclWorkflowOperationHandler,MicrosoftAzureAttachTranscriptionOperationHandler,MicrosoftAzureStartTranscriptionOperationHandler,MultiEncodeWorkflowOperationHandler,MuxWorkflowOperationHandler,PartialImportWorkflowOperationHandler,PrepareAVWorkflowOperationHandler,ProbeResolutionWorkflowOperationHandler,ProcessSmilWorkflowOperationHandler,PublicationChannelToWorkspace,PublishEngageWorkflowOperationHandler,PublishOaiPmhWorkflowOperationHandler,PublishYouTubeWorkflowOperationHandler,RenameFilesWorkflowOperationHandler,RepublishOaiPmhWorkflowOperationHandler,ResumableWorkflowOperationHandlerBase,RetractEngageWorkflowOperationHandler,RetractOaiPmhWorkflowOperationHandler,RetractYouTubeWorkflowOperationHandler,SanitizeAdaptiveWorkflowOperationHandler,SegmentPreviewsWorkflowOperationHandler,SelectStreamsWorkflowOperationHandler,SelectVersionWorkflowOperationHandler,SeriesWorkflowOperationHandler,SilenceDetectionWorkflowOperationHandler,SpeechToTextAttachWorkflowOperationHandler,SpeechToTextWorkflowOperationHandler,StartTranscriptionOperationHandler,StartWorkflowWorkflowOperationHandler,StatisticsWriterWorkflowOperationHandler,SubtitleTimeshiftWorkflowOperationHandler,TagEngageWorkflowOperationHandler,TagWorkflowOperationHandler,TextAnalysisWorkflowOperationHandler,ThemeWorkflowOperationHandler,TimelinePreviewsWorkflowOperationHandler,TransferMetadataWorkflowOperationHandler,VideoGridWorkflowOperationHandler,VideoSegmenterWorkflowOperationHandler,WaveformWorkflowOperationHandler,WebvttToCutMarksWorkflowOperationHandler,ZipWorkflowOperationHandler
WorkflowOperationResult with the current mediapackage and WorkflowOperationResult.Action.CONTINUE.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumConfig for Tag Parsing operation -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe description of what this handler actually doesprotected StringThe ID of this operation handlerprotected ServiceRegistryOptional service registrystatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidactivate(org.osgi.service.component.ComponentContext cc) Activates this component with its properties once all of the collaborating services have been setprotected <T extends MediaPackageElement>
TapplyTargetTagsToElement(ConfiguredTagsAndFlavors.TargetTags targetTags, T element) Helper function that applies target tags to the given element, based on the type(s) of the tag(s)Converts a comma separated string into a set of values.protected WorkflowOperationResultcreateResult(MediaPackage mediaPackage, Map<String, String> properties, WorkflowOperationResult.Action action, long timeInQueue) Creates a result for the execution of this workflow operation handler.protected WorkflowOperationResultcreateResult(MediaPackage mediaPackage, WorkflowOperationResult.Action action) Creates a result for the execution of this workflow operation handler.protected WorkflowOperationResultcreateResult(MediaPackage mediaPackage, WorkflowOperationResult.Action action, long timeInQueue) Creates a result for the execution of this workflow operation handler.protected WorkflowOperationResultCreates a result for the execution of this workflow operation handler.voiddestroy(WorkflowInstance workflowInstance, JobContext context) Clean up after a workflow operation finishesbooleangetCfg(WorkflowInstance wi, String key) Deprecated.protected StringgetConfig(WorkflowInstance wi, String key) Get a mandatory configuration key.protected StringgetConfig(WorkflowInstance w, String key, String defaultValue) Get a configuration key.protected StringgetConfig(WorkflowOperationInstance woi, String key) Get a mandatory configuration key.Returns a description of what this handler does.protected StringgetFileNameFromElements(MediaPackageElement source, MediaPackageElement derived) Generates a filename using the base name of a source element and the extension of a derived element.getId()The identifier used to map a workflow operation to its handlergetOptConfig(WorkflowInstance wi, String key) Get an optional configuration key.getOptConfig(WorkflowOperationInstance woi, String key) Get an optional configuration key.protected ConfiguredTagsAndFlavorsgetTagsAndFlavors(WorkflowInstance workflow, AbstractWorkflowOperationHandler.Configuration srcTags, AbstractWorkflowOperationHandler.Configuration srcFlavors, AbstractWorkflowOperationHandler.Configuration targetTags, AbstractWorkflowOperationHandler.Configuration targetFlavors) Returns a ConfiguredTagsAndFlavors instance, which includes all specified source/target tags and flavors if they are valid Lists can be empty, if no values were specified!inthashCode()voidsetJobBarrierPollingInterval(long interval) Set the @link org.opencastproject.job.api.JobBarrier polling interval.voidsetServiceRegistry(ServiceRegistry serviceRegistry) Sets the service registry.skip(WorkflowInstance workflowInstance, JobContext context) Skips the workflow operation on thisWorkflowInstance.abstract WorkflowOperationResultstart(WorkflowInstance workflowInstance, JobContext context) Runs the workflow operation on thisWorkflowInstance.toString()protected JobBarrier.ResultwaitForStatus(long timeout, Job... jobs) Waits until all of the jobs have reached either one of these statuses:Job.Status.FINISHEDJob.Status.FAILEDJob.Status.DELETEDAfter that, the method returns with the actual outcomes of the jobs.protected JobBarrier.ResultwaitForStatus(Job... jobs) Waits until all of the jobs have reached either one of these statuses:Job.Status.FINISHEDJob.Status.FAILEDJob.Status.DELETEDAfter that, the method returns with the actual outcomes of the jobs.
-
Field Details
-
id
The ID of this operation handler -
description
The description of what this handler actually does -
serviceRegistry
Optional service registry -
TARGET_FLAVORS
- See Also:
-
TARGET_FLAVOR
- See Also:
-
TARGET_TAGS
- See Also:
-
TARGET_TAG
- See Also:
-
SOURCE_FLAVORS
- See Also:
-
SOURCE_FLAVOR
- See Also:
-
SOURCE_TAG
- See Also:
-
SOURCE_TAGS
- See Also:
-
-
Constructor Details
-
AbstractWorkflowOperationHandler
public AbstractWorkflowOperationHandler()
-
-
Method Details
-
activate
protected void activate(org.osgi.service.component.ComponentContext cc) Activates this component with its properties once all of the collaborating services have been set- Parameters:
cc- The component's context, containing the properties used for configuration
-
start
public abstract WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException Runs the workflow operation on thisWorkflowInstance. If the execution fails for some reason, this must throw aWorkflowOperationExceptionin order to handle the problem gracefully. Runtime exceptions will cause the entire workflow instance to fail.- Specified by:
startin interfaceWorkflowOperationHandler- Parameters:
workflowInstance- the workflow instancecontext- the job context- Returns:
- the
WorkflowOperationResultcontaining a potentially modified MediaPackage and whether to put the workflow instance into a wait state. - Throws:
WorkflowOperationException- If the workflow operation fails to execute properly, and the default error handling should be invoked.- See Also:
-
skip
public WorkflowOperationResult skip(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException Skips the workflow operation on thisWorkflowInstance. If the execution fails for some reason, this must throw aWorkflowOperationExceptionin order to handle the problem gracefully. Runtime exceptions will cause the entire workflow instance to fail.- Specified by:
skipin interfaceWorkflowOperationHandler- Parameters:
workflowInstance- the workflow instancecontext- the job context- Returns:
- TODO
- Throws:
WorkflowOperationException- If the workflow operation fails to execute properly, and the default error handling should be invoked.- See Also:
-
destroy
public void destroy(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException Clean up after a workflow operation finishes- Specified by:
destroyin interfaceWorkflowOperationHandler- Parameters:
workflowInstance- The workflow instancecontext- the job context- Throws:
WorkflowOperationException- If the workflow operation fails to clean up properly.- See Also:
-
asList
Converts a comma separated string into a set of values. Useful for converting operation configuration strings into multi-valued sets.- Parameters:
elements- The comma space separated string- Returns:
- the set of values
-
getFileNameFromElements
Generates a filename using the base name of a source element and the extension of a derived element.- Parameters:
source- the source media package elementderived- the derived media package element- Returns:
- the filename
-
getId
The identifier used to map a workflow operation to its handler- Specified by:
getIdin interfaceWorkflowOperationHandler- Returns:
- This handler's identifier
- See Also:
-
getDescription
Returns a description of what this handler does.- Specified by:
getDescriptionin interfaceWorkflowOperationHandler- Returns:
- The handler's description
- See Also:
-
createResult
Creates a result for the execution of this workflow operation handler.- Parameters:
action- the action to take- Returns:
- the result
-
createResult
protected WorkflowOperationResult createResult(MediaPackage mediaPackage, WorkflowOperationResult.Action action) Creates a result for the execution of this workflow operation handler.- Parameters:
mediaPackage- the modified mediapackageaction- the action to take- Returns:
- the result
-
createResult
protected WorkflowOperationResult createResult(MediaPackage mediaPackage, WorkflowOperationResult.Action action, long timeInQueue) Creates a result for the execution of this workflow operation handler.Since there is no way for the workflow service to determine the queuing time (e. g. waiting on services), it needs to be provided by the handler.
- Parameters:
mediaPackage- the modified mediapackageaction- the action to taketimeInQueue- the amount of time this handle spent waiting for services- Returns:
- the result
-
createResult
protected WorkflowOperationResult createResult(MediaPackage mediaPackage, Map<String, String> properties, WorkflowOperationResult.Action action, long timeInQueue) Creates a result for the execution of this workflow operation handler.Since there is no way for the workflow service to determine the queuing time (e. g. waiting on services), it needs to be provided by the handler.
- Parameters:
mediaPackage- the modified mediapackageproperties- the properties to add to the workflow instanceaction- the action to taketimeInQueue- the amount of time this handle spent waiting for services- Returns:
- the result
-
setServiceRegistry
Sets the service registry. This method is here as a convenience for developers that need the registry to do job waiting.- Parameters:
serviceRegistry- the service registry
-
waitForStatus
protected JobBarrier.Result waitForStatus(Job... jobs) throws IllegalStateException, IllegalArgumentException Waits until all of the jobs have reached either one of these statuses: After that, the method returns with the actual outcomes of the jobs.- Parameters:
jobs- the jobs- Returns:
- the jobs and their outcomes
- Throws:
IllegalStateException- if the service registry has not been setIllegalArgumentException- if the jobs collecion is eithernullor empty
-
waitForStatus
protected JobBarrier.Result waitForStatus(long timeout, Job... jobs) throws IllegalStateException, IllegalArgumentException Waits until all of the jobs have reached either one of these statuses: After that, the method returns with the actual outcomes of the jobs.- Parameters:
timeout- the maximum amount of time in milliseconds to waitjobs- the jobs- Returns:
- the jobs and their outcomes
- Throws:
IllegalStateException- if the service registry has not been setIllegalArgumentException- if the jobs collection is eithernullor empty
-
getCfg
Deprecated.Get a configuration option. -
getConfig
Get a mandatory configuration key. Values are returned trimmed.- Throws:
WorkflowOperationException- if the configuration key is either missing or empty
-
getConfig
Get a configuration key. Values are returned trimmed.- Parameters:
w- WorkflowInstance with current operationkey- Configuration key to check fordefaultValue- Value to return if key does not exists
-
getConfig
protected String getConfig(WorkflowOperationInstance woi, String key) throws WorkflowOperationException Get a mandatory configuration key. Values are returned trimmed.- Throws:
WorkflowOperationException- if the configuration key is either missing or empty
-
getOptConfig
Get an optional configuration key. Values are returned trimmed. -
getOptConfig
Get an optional configuration key. Values are returned trimmed. -
getTagsAndFlavors
protected ConfiguredTagsAndFlavors getTagsAndFlavors(WorkflowInstance workflow, AbstractWorkflowOperationHandler.Configuration srcTags, AbstractWorkflowOperationHandler.Configuration srcFlavors, AbstractWorkflowOperationHandler.Configuration targetTags, AbstractWorkflowOperationHandler.Configuration targetFlavors) throws WorkflowOperationException Returns a ConfiguredTagsAndFlavors instance, which includes all specified source/target tags and flavors if they are valid Lists can be empty, if no values were specified! This is to enable WOHs to individually check if a given tag/flavor was set. This also means that you should use Configuration.many as parameter, if a tag/flavor is optional.- Parameters:
srcTags- none, one or manysrcFlavors- none, one or manytargetTags- none, one or manytargetFlavors- none, one or many- Returns:
- ConfiguredTagsAndFlavors object including lists for the configured tags/flavors
- Throws:
WorkflowOperationException
-
applyTargetTagsToElement
protected <T extends MediaPackageElement> T applyTargetTagsToElement(ConfiguredTagsAndFlavors.TargetTags targetTags, T element) Helper function that applies target tags to the given element, based on the type(s) of the tag(s)- Parameters:
targetTags- The target tags to apply to the elementelement- The element the target tags are applied to- Returns:
- The element with the applied target tags
-
setJobBarrierPollingInterval
public void setJobBarrierPollingInterval(long interval) Set the @link org.opencastproject.job.api.JobBarrier polling interval.While waiting for other jobs to finish, the barrier will poll the status of these jobs until they are finished. To reduce load on the system, the polling is done only every x milliseconds. This interval defines the sleep time between these polls.
If most cases you want to leave this at its default value. It will make sense, though, to adjust this time if you know that your job will be exceptionally short. An example of this might be the unit tests where other jobs are usually mocked. But this setting is not limited to tests and may be a sensible options for other jobs as well.
- Parameters:
interval- the time in miliseconds between two polling operations- See Also:
-
hashCode
public int hashCode() -
equals
-
toString
-
getConfig(WorkflowInstance, String)orgetOptConfig(org.opencastproject.workflow.api.WorkflowInstance, String)