1 /*
2 * Licensed to The Apereo Foundation under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work for additional
4 * information regarding copyright ownership.
5 *
6 *
7 * The Apereo Foundation licenses this file to you under the Educational
8 * Community License, Version 2.0 (the "License"); you may not use this file
9 * except in compliance with the License. You may obtain a copy of the License
10 * at:
11 *
12 * http://opensource.org/licenses/ecl2.txt
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 * License for the specific language governing permissions and limitations under
18 * the License.
19 *
20 */
21
22 package org.opencastproject.workflow.api;
23
24 import org.opencastproject.job.api.JobContext;
25
26 /**
27 * Handler for workflow operations.
28 */
29 public interface WorkflowOperationHandler {
30
31 /**
32 * The identifier used to map a workflow operation to its handler
33 *
34 * @return This handler's identifier
35 */
36 String getId();
37
38 /**
39 * Returns a description of what this handler does.
40 *
41 * @return The handler's description
42 */
43 String getDescription();
44
45 /**
46 * Runs the workflow operation on this {@link WorkflowInstance}. If the execution fails for some reason, this must
47 * throw a {@link WorkflowOperationException} in order to handle the problem gracefully. Runtime exceptions will cause
48 * the entire workflow instance to fail.
49 *
50 * @param workflowInstance
51 * the workflow instance
52 * @param context
53 * the job context
54 * @return the {@link WorkflowOperationResult} containing a potentially modified MediaPackage and whether to put the
55 * workflow instance into a wait state.
56 *
57 * @throws WorkflowOperationException
58 * If the workflow operation fails to execute properly, and the default error handling should be invoked.
59 */
60 WorkflowOperationResult start(WorkflowInstance workflowInstance, JobContext context)
61 throws WorkflowOperationException;
62
63 /**
64 * Skips the workflow operation on this {@link WorkflowInstance}. If the execution fails for some reason, this must
65 * throw a {@link WorkflowOperationException} in order to handle the problem gracefully. Runtime exceptions will cause
66 * the entire workflow instance to fail.
67 *
68 * @param workflowInstance
69 * the workflow instance
70 * @param context
71 * the job context
72 * @return TODO
73 * @throws WorkflowOperationException
74 * If the workflow operation fails to execute properly, and the default error handling should be invoked.
75 */
76 WorkflowOperationResult skip(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException;
77
78 /**
79 * Clean up after a workflow operation finishes
80 *
81 * @param workflowInstance
82 * The workflow instance
83 * @param context
84 * the job context
85 * @throws WorkflowOperationException
86 * If the workflow operation fails to clean up properly.
87 */
88 void destroy(WorkflowInstance workflowInstance, JobContext context) throws WorkflowOperationException;
89
90 }