Package org.opencastproject.workflow.api
Interface WorkflowService
- All Known Implementing Classes:
WorkflowServiceImpl,WorkflowServiceRemoteImpl
public interface WorkflowService
Manages
WorkflowDefinitions and WorkflowInstances.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringIdentifier for workflow jobsstatic final StringThe service registration property we use to identify which workflow operation aWorkflowOperationHandlershould handle. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddWorkflowListener(WorkflowListener listener) Adds a workflow listener to be notified when workflows are updated.voidcleanupWorkflowInstances(int lifetime, WorkflowInstance.WorkflowState state) Starts a cleanup of workflow instances with a given lifetime and a specific statelongGets the total number of workflows that have been created to date.longGets the total number of workflows that have been created to date and that match the workflow state which might benull.getRunningWorkflowInstanceByMediaPackage(String mediaPackageId, String action) Returns theWorkflowInstancecurrently running on the given mediaPackagegetWorkflowById(long workflowId) Gets aWorkflowInstanceby its ID.Returns theWorkflowDefinitionidentified byname.getWorkflowInstancesByMediaPackage(String mediaPackageId) Returns all workflows associated with the given mediapackage Current user needs permission to the mediapackageGets the list of available workflow definitions.booleanmediaPackageHasActiveWorkflows(String mediaPackageId) Checks if there is at least one workflow currently running on the given mediapackagevoidremove(long workflowInstanceId) Permanently removes a workflow instance.voidremove(long workflowInstanceId, boolean force) Permanently removes a workflow instance.voidremoveWorkflowListener(WorkflowListener listener) Removes a workflow listener.resume(long workflowInstanceId) Resumes a suspended workflow instance.Resumes a suspended workflow instance, applying new properties to the workflow.start(WorkflowDefinition workflowDefinition, MediaPackage mediaPackage) Creates a new workflow instance and starts the workflow.start(WorkflowDefinition workflowDefinition, MediaPackage mediaPackage, Long parentWorkflowId, Map<String, String> properties) Creates a new workflow instance and starts the workflow.start(WorkflowDefinition workflowDefinition, MediaPackage mediaPackage, Map<String, String> properties) Creates a new workflow instance and starts the workflow.stop(long workflowInstanceId) Stops a running workflow instance.suspend(long workflowInstanceId) Temporarily suspends a started workflow instance.voidupdate(WorkflowInstance workflowInstance) Updates the given workflow instance with regard to the media package, the properties and the operations involved.booleanuserHasActiveWorkflows(String userId) Checks if there is at least one workflow currently running started by the given user
-
Field Details
-
WORKFLOW_OPERATION_PROPERTY
The service registration property we use to identify which workflow operation aWorkflowOperationHandlershould handle.- See Also:
-
JOB_TYPE
Identifier for workflow jobs- See Also:
-
-
Method Details
-
addWorkflowListener
Adds a workflow listener to be notified when workflows are updated.- Parameters:
listener- the workflow listener to add
-
removeWorkflowListener
Removes a workflow listener.- Parameters:
listener- the workflow listener to remove
-
getWorkflowDefinitionById
WorkflowDefinition getWorkflowDefinitionById(String id) throws WorkflowDatabaseException, NotFoundException Returns theWorkflowDefinitionidentified byname.- Parameters:
id- the workflow definition id- Returns:
- the workflow
- Throws:
WorkflowDatabaseException- if there is a problem accessing the workflow definitionNotFoundException- if there is no registered workflow definition with this identifier
-
getWorkflowById
WorkflowInstance getWorkflowById(long workflowId) throws WorkflowDatabaseException, NotFoundException, UnauthorizedException Gets aWorkflowInstanceby its ID.- Returns:
- the workflow instance
- Throws:
WorkflowDatabaseException- if there is a problem accessing the workflow instance from persistenceNotFoundException- if there is no workflow instance with this identifierUnauthorizedException- if the current user does not have read permissions on the workflow instance's mediapackage.
-
start
WorkflowInstance start(WorkflowDefinition workflowDefinition, MediaPackage mediaPackage, Map<String, String> properties) throws WorkflowDatabaseException, WorkflowParsingException, UnauthorizedExceptionCreates a new workflow instance and starts the workflow.- Parameters:
workflowDefinition- the workflow definitionmediaPackage- the mediapackage to processproperties- any properties to apply to the workflow definition- Returns:
- The new workflow instance
- Throws:
WorkflowDatabaseException- if there is a problem storing the workflow instance in persistenceWorkflowParsingException- if there is a problem parsing or serializing workflow entitiesUnauthorizedException
-
start
WorkflowInstance start(WorkflowDefinition workflowDefinition, MediaPackage mediaPackage, Long parentWorkflowId, Map<String, String> properties) throws WorkflowDatabaseException, WorkflowParsingException, UnauthorizedException, NotFoundException, IllegalStateExceptionCreates a new workflow instance and starts the workflow.- Parameters:
workflowDefinition- the workflow definitionmediaPackage- the mediapackage to processparentWorkflowId- An existing workflow to associate with the new workflow instanceproperties- any properties to apply to the workflow definition- Returns:
- The new workflow instance
- Throws:
NotFoundException- if the parent workflow does not existWorkflowDatabaseException- if there is a problem storing the workflow instance in persistenceWorkflowParsingException- if there is a problem parsing or serializing workflow entitiesIllegalStateException- if there is currently a workflow active on the media packageUnauthorizedException- if the current user does not havePermissions.Action.WRITEon the media package.
-
start
WorkflowInstance start(WorkflowDefinition workflowDefinition, MediaPackage mediaPackage) throws WorkflowDatabaseException, WorkflowParsingException, UnauthorizedException Creates a new workflow instance and starts the workflow.- Parameters:
workflowDefinition- the workflow definitionmediaPackage- the mediapackage to process- Returns:
- The new workflow instance
- Throws:
WorkflowDatabaseException- if there is a problem storing the workflow instance in persistenceWorkflowParsingException- if there is a problem parsing or serializing workflow entitiesUnauthorizedException
-
countWorkflowInstances
Gets the total number of workflows that have been created to date.- Returns:
- The number of workflow instances, regardless of their state
- Throws:
WorkflowDatabaseException- if there is a problem accessing the workflow instances in persistence
-
countWorkflowInstances
Gets the total number of workflows that have been created to date and that match the workflow state which might benull.- Parameters:
state- the workflow state- Returns:
- The number of workflow instances, regardless of their state
- Throws:
WorkflowDatabaseException- if there is a problem accessing the workflow instances in persistence
-
stop
WorkflowInstance stop(long workflowInstanceId) throws WorkflowException, NotFoundException, UnauthorizedException Stops a running workflow instance.- Parameters:
workflowInstanceId- the workflow instance identifier- Returns:
- the workflow instance
- Throws:
NotFoundException- if no running workflow with this identifier existsWorkflowException- if there is a problem processing the workflowUnauthorizedException- if the current user does not have read permissions on the workflow instance's mediapackage.
-
remove
void remove(long workflowInstanceId) throws WorkflowDatabaseException, WorkflowParsingException, NotFoundException, UnauthorizedException, WorkflowStateException Permanently removes a workflow instance. Only workflow instances with stateWorkflowInstance.WorkflowState.SUCCEEDED,WorkflowInstance.WorkflowState.STOPPEDorWorkflowInstance.WorkflowState.FAILEDmay be removed.- Parameters:
workflowInstanceId- the workflow instance identifier- Throws:
WorkflowDatabaseException- if there is a problem writing to the databaseNotFoundException- if no workflow instance with the given identifier could be foundUnauthorizedException- if the current user does not have write permissions on the workflow instanceWorkflowStateException- if the workflow instance is in a disallowed stateWorkflowParsingException
-
remove
void remove(long workflowInstanceId, boolean force) throws WorkflowDatabaseException, WorkflowParsingException, NotFoundException, UnauthorizedException, WorkflowStateException Permanently removes a workflow instance. Option to remove a workflow instance regardless of its status.- Parameters:
workflowInstanceId- the workflow instance identifierforce- remove the workflow instance no matter the status- Throws:
WorkflowDatabaseException- if there is a problem writing to the databaseNotFoundException- if no workflow instance with the given identifier could be foundUnauthorizedException- if the current user does not have write permissions on the workflow instanceWorkflowStateException- if the workflow instance is in a disallowed stateWorkflowParsingException
-
suspend
WorkflowInstance suspend(long workflowInstanceId) throws WorkflowException, NotFoundException, UnauthorizedException Temporarily suspends a started workflow instance.- Parameters:
workflowInstanceId- the workflow instance identifier- Returns:
- the workflow instance
- Throws:
NotFoundException- if no running workflow with this identifier existsWorkflowException- if there is a problem processing the workflowUnauthorizedException- if the current user does not have read permissions on the workflow instance's mediapackage.
-
resume
WorkflowInstance resume(long workflowInstanceId) throws NotFoundException, WorkflowException, IllegalStateException, UnauthorizedException Resumes a suspended workflow instance.- Parameters:
workflowInstanceId- the workflow instance identifier- Returns:
- the workflow instance
- Throws:
NotFoundException- if no paused workflow with this identifier existsWorkflowException- if there is a problem processing the workflowIllegalStateException- if the workflow with this identifier is not in the paused stateUnauthorizedException- if the current user does not have read permissions on the workflow instance's mediapackage.
-
resume
WorkflowInstance resume(long workflowInstanceId, Map<String, String> properties) throws NotFoundException, WorkflowException, IllegalStateException, UnauthorizedExceptionResumes a suspended workflow instance, applying new properties to the workflow.- Parameters:
workflowInstanceId- the workflow to resumeproperties- the properties to apply to the resumed workflow- Returns:
- the workflow instance
- Throws:
NotFoundException- if no workflow with this identifier existsWorkflowException- if there is a problem processing the workflowIllegalStateException- if the workflow with this identifier is not in the paused stateUnauthorizedException- if the current user does not have read permissions on the workflow instance's mediapackage.
-
update
void update(WorkflowInstance workflowInstance) throws WorkflowDatabaseException, UnauthorizedException Updates the given workflow instance with regard to the media package, the properties and the operations involved.- Parameters:
workflowInstance- the workflow instance- Throws:
WorkflowDatabaseException- if there is a database problem processing the workflowUnauthorizedException- if the current user does not have read permissions on the workflow instance's mediapackage.
-
listAvailableWorkflowDefinitions
Gets the list of available workflow definitions. In order to be "available", a workflow definition must be registered and must have registered workflow operation handlers for each of the workflow definition's operations.- Returns:
- The list of currently available workflow definitions, sorted by title
- Throws:
WorkflowDatabaseException- if there is a problem storing the registered workflow definitions
-
cleanupWorkflowInstances
void cleanupWorkflowInstances(int lifetime, WorkflowInstance.WorkflowState state) throws WorkflowDatabaseException, UnauthorizedException Starts a cleanup of workflow instances with a given lifetime and a specific state- Parameters:
lifetime- minimum lifetime of the workflow instancesstate- state of the workflow instances- Throws:
WorkflowDatabaseExceptionUnauthorizedException
-
getWorkflowStateMappings
- Returns:
- All configured workflow state mappings
-
mediaPackageHasActiveWorkflows
Checks if there is at least one workflow currently running on the given mediapackage- Parameters:
mediaPackageId- the identifier of the mediapackage- Returns:
- Whether there is a workflow active on the mediapackage
- Throws:
WorkflowDatabaseException
-
userHasActiveWorkflows
Checks if there is at least one workflow currently running started by the given user- Parameters:
userId- the identifier of the user- Returns:
- Whether there is a workflow active started by the user
- Throws:
WorkflowDatabaseException
-
getWorkflowInstancesByMediaPackage
List<WorkflowInstance> getWorkflowInstancesByMediaPackage(String mediaPackageId) throws WorkflowDatabaseException, UnauthorizedException Returns all workflows associated with the given mediapackage Current user needs permission to the mediapackage- Parameters:
mediaPackageId- the identifier of the mediapackage- Returns:
- a
ListofWorkflowInstance - Throws:
WorkflowDatabaseExceptionUnauthorizedException
-
getRunningWorkflowInstanceByMediaPackage
Optional<WorkflowInstance> getRunningWorkflowInstanceByMediaPackage(String mediaPackageId, String action) throws WorkflowException, UnauthorizedException, WorkflowDatabaseException Returns theWorkflowInstancecurrently running on the given mediaPackage- Parameters:
mediaPackageId- the identifier of the mediaPackageaction- necessary permissions for the workflowInstance- Returns:
- An
Optionalcontaining the currently runningWorkflowInstance - Throws:
WorkflowExceptionWorkflowDatabaseExceptionUnauthorizedException
-