Class WorkflowServiceRemoteImpl
java.lang.Object
org.opencastproject.serviceregistry.api.RemoteBase
org.opencastproject.workflow.remote.WorkflowServiceRemoteImpl
- All Implemented Interfaces:
WorkflowService
An implementation of the workflow service that communicates with a remote workflow service via HTTP.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.opencastproject.serviceregistry.api.RemoteBase
RemoteBase.HttpClientClosingInputStream -
Field Summary
Fields inherited from class org.opencastproject.serviceregistry.api.RemoteBase
client, elementsFromHttpResponse, remoteServiceManager, serviceTypeFields inherited from interface org.opencastproject.workflow.api.WorkflowService
JOB_TYPE, WORKFLOW_OPERATION_PROPERTY -
Constructor Summary
Constructors -
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 id) 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.voidsetRemoteServiceManager(ServiceRegistry remoteServiceManager) Sets the remote service manager.voidSets the trusted http clientstart(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 userMethods inherited from class org.opencastproject.serviceregistry.api.RemoteBase
closeConnection, getResponse, getResponse, runRequest
-
Constructor Details
-
WorkflowServiceRemoteImpl
public WorkflowServiceRemoteImpl()
-
-
Method Details
-
setTrustedHttpClient
Sets the trusted http client- Overrides:
setTrustedHttpClientin classRemoteBase- Parameters:
client-
-
setRemoteServiceManager
Sets the remote service manager.- Overrides:
setRemoteServiceManagerin classRemoteBase- Parameters:
remoteServiceManager-
-
getWorkflowDefinitionById
public WorkflowDefinition getWorkflowDefinitionById(String id) throws WorkflowDatabaseException, NotFoundException Returns theWorkflowDefinitionidentified byname.- Specified by:
getWorkflowDefinitionByIdin interfaceWorkflowService- 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- See Also:
-
getWorkflowById
public WorkflowInstance getWorkflowById(long id) throws WorkflowDatabaseException, NotFoundException Gets aWorkflowInstanceby its ID.- Specified by:
getWorkflowByIdin interfaceWorkflowService- 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 identifier- See Also:
-
getWorkflowInstancesByMediaPackage
public List<WorkflowInstance> getWorkflowInstancesByMediaPackage(String mediaPackageId) throws WorkflowDatabaseException Description copied from interface:WorkflowServiceReturns all workflows associated with the given mediapackage Current user needs permission to the mediapackage- Specified by:
getWorkflowInstancesByMediaPackagein interfaceWorkflowService- Parameters:
mediaPackageId- the identifier of the mediapackage- Returns:
- a
ListofWorkflowInstance - Throws:
WorkflowDatabaseException
-
getRunningWorkflowInstanceByMediaPackage
public Optional<WorkflowInstance> getRunningWorkflowInstanceByMediaPackage(String mediaPackageId, String action) throws WorkflowException Description copied from interface:WorkflowServiceReturns theWorkflowInstancecurrently running on the given mediaPackage- Specified by:
getRunningWorkflowInstanceByMediaPackagein interfaceWorkflowService- Parameters:
mediaPackageId- the identifier of the mediaPackageaction- necessary permissions for the workflowInstance- Returns:
- An
Optionalcontaining the currently runningWorkflowInstance - Throws:
WorkflowException
-
mediaPackageHasActiveWorkflows
public boolean mediaPackageHasActiveWorkflows(String mediaPackageId) throws WorkflowDatabaseException Description copied from interface:WorkflowServiceChecks if there is at least one workflow currently running on the given mediapackage- Specified by:
mediaPackageHasActiveWorkflowsin interfaceWorkflowService- Parameters:
mediaPackageId- the identifier of the mediapackage- Returns:
- Whether there is a workflow active on the mediapackage
- Throws:
WorkflowDatabaseException
-
userHasActiveWorkflows
Description copied from interface:WorkflowServiceChecks if there is at least one workflow currently running started by the given user- Specified by:
userHasActiveWorkflowsin interfaceWorkflowService- Parameters:
userId- the identifier of the user- Returns:
- Whether there is a workflow active started by the user
- Throws:
WorkflowDatabaseException
-
start
public WorkflowInstance start(WorkflowDefinition workflowDefinition, MediaPackage mediaPackage, Map<String, String> properties) throws WorkflowDatabaseExceptionCreates a new workflow instance and starts the workflow.- Specified by:
startin interfaceWorkflowService- 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 persistence- See Also:
-
start
public WorkflowInstance start(WorkflowDefinition workflowDefinition, MediaPackage mediaPackage, Long parentWorkflowId, Map<String, String> properties) throws WorkflowDatabaseException, NotFoundExceptionCreates a new workflow instance and starts the workflow.- Specified by:
startin interfaceWorkflowService- 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:
WorkflowDatabaseException- if there is a problem storing the workflow instance in persistenceNotFoundException- if the parent workflow does not exist- See Also:
-
start
public WorkflowInstance start(WorkflowDefinition workflowDefinition, MediaPackage mediaPackage) throws WorkflowDatabaseException Creates a new workflow instance and starts the workflow.- Specified by:
startin interfaceWorkflowService- 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 persistence- See Also:
-
countWorkflowInstances
Gets the total number of workflows that have been created to date.- Specified by:
countWorkflowInstancesin interfaceWorkflowService- Returns:
- The number of workflow instances, regardless of their state
- Throws:
WorkflowDatabaseException- if there is a problem accessing the workflow instances in persistence- See Also:
-
countWorkflowInstances
public long countWorkflowInstances(WorkflowInstance.WorkflowState state) throws WorkflowDatabaseException Gets the total number of workflows that have been created to date and that match the workflow state which might benull.- Specified by:
countWorkflowInstancesin interfaceWorkflowService- 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- See Also:
-
stop
public WorkflowInstance stop(long workflowInstanceId) throws WorkflowDatabaseException, NotFoundException Stops a running workflow instance.- Specified by:
stopin interfaceWorkflowService- Parameters:
workflowInstanceId- the workflow instance identifier- Returns:
- the workflow instance
- Throws:
NotFoundException- if no running workflow with this identifier existsWorkflowDatabaseException- See Also:
-
suspend
public WorkflowInstance suspend(long workflowInstanceId) throws WorkflowDatabaseException, NotFoundException Temporarily suspends a started workflow instance.- Specified by:
suspendin interfaceWorkflowService- Parameters:
workflowInstanceId- the workflow instance identifier- Returns:
- the workflow instance
- Throws:
NotFoundException- if no running workflow with this identifier existsWorkflowDatabaseException- See Also:
-
resume
public WorkflowInstance resume(long workflowInstanceId) throws NotFoundException, UnauthorizedException, WorkflowException, IllegalStateException Resumes a suspended workflow instance.- Specified by:
resumein interfaceWorkflowService- Parameters:
workflowInstanceId- the workflow instance identifier- Returns:
- the workflow instance
- Throws:
NotFoundException- if no paused workflow with this identifier existsUnauthorizedException- if the current user does not have read permissions on the workflow instance's mediapackage.WorkflowException- if there is a problem processing the workflowIllegalStateException- if the workflow with this identifier is not in the paused state- See Also:
-
resume
public WorkflowInstance resume(long workflowInstanceId, Map<String, String> properties) throws NotFoundException, UnauthorizedException, WorkflowException, IllegalStateExceptionResumes a suspended workflow instance, applying new properties to the workflow.- Specified by:
resumein interfaceWorkflowService- 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 existsUnauthorizedException- if the current user does not have read permissions on the workflow instance's mediapackage.WorkflowException- if there is a problem processing the workflowIllegalStateException- if the workflow with this identifier is not in the paused state- See Also:
-
update
Updates the given workflow instance with regard to the media package, the properties and the operations involved.- Specified by:
updatein interfaceWorkflowService- Parameters:
workflowInstance- the workflow instance- Throws:
WorkflowDatabaseException- if there is a database problem processing the workflow- See Also:
-
remove
Permanently removes a workflow instance. Only workflow instances with stateWorkflowInstance.WorkflowState.SUCCEEDED,WorkflowInstance.WorkflowState.STOPPEDorWorkflowInstance.WorkflowState.FAILEDmay be removed.- Specified by:
removein interfaceWorkflowService- 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 found- See Also:
-
remove
public void remove(long workflowInstanceId, boolean force) throws WorkflowDatabaseException, NotFoundException Permanently removes a workflow instance. Option to remove a workflow instance regardless of its status.- Specified by:
removein interfaceWorkflowService- 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 found- See Also:
-
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.- Specified by:
listAvailableWorkflowDefinitionsin interfaceWorkflowService- Returns:
- The list of currently available workflow definitions, sorted by title
- Throws:
WorkflowDatabaseException- if there is a problem storing the registered workflow definitions- See Also:
-
addWorkflowListener
Adds a workflow listener to be notified when workflows are updated.- Specified by:
addWorkflowListenerin interfaceWorkflowService- Parameters:
listener- the workflow listener to add- See Also:
-
removeWorkflowListener
Removes a workflow listener.- Specified by:
removeWorkflowListenerin interfaceWorkflowService- Parameters:
listener- the workflow listener to remove- See Also:
-
cleanupWorkflowInstances
public void cleanupWorkflowInstances(int lifetime, WorkflowInstance.WorkflowState state) throws WorkflowDatabaseException, UnauthorizedException Description copied from interface:WorkflowServiceStarts a cleanup of workflow instances with a given lifetime and a specific state- Specified by:
cleanupWorkflowInstancesin interfaceWorkflowService- Parameters:
lifetime- minimum lifetime of the workflow instancesstate- state of the workflow instances- Throws:
WorkflowDatabaseExceptionUnauthorizedException
-
getWorkflowStateMappings
- Specified by:
getWorkflowStateMappingsin interfaceWorkflowService- Returns:
- All configured workflow state mappings
-