View Javadoc
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  import java.util.Map;
27  
28  /**
29   * A {@link WorkflowOperationHandler} that is allowed to return Action.PAUSE to pause (and later resume) a workflow.
30   */
31  public interface ResumableWorkflowOperationHandler extends WorkflowOperationHandler {
32  
33    /**
34     * Continues a suspended {@link WorkflowInstance}. If the execution fails for some reason, this must throw a
35     * {@link WorkflowOperationException} in order to handle the problem gracefully. Runtime exceptions will cause the
36     * entire workflow instance to fail.
37     *
38     * If the workflow instance is not in a suspended state, this method should throw an {@link IllegalStateException}.
39     *
40     * @param workflowInstance
41     *          The workflow instance
42     * @param context
43     *          the job context
44     * @param properties
45     *          The properties added while the operation was on hold
46     * @return the result of this operation
47     * @throws WorkflowOperationException
48     *           If the workflow operation fails to execute properly.
49     */
50    WorkflowOperationResult resume(WorkflowInstance workflowInstance, JobContext context, Map<String, String> properties)
51            throws WorkflowOperationException;
52  
53    /**
54     * Whether this operation handler will always pause. The workflow service may give preferential dispatching to
55     * operations that are guaranteed to pause.
56     *
57     * @return whether this handler always pauses
58     */
59    boolean isAlwaysPause();
60  
61    /**
62     * Gets the URL for the user interface for resuming the workflow.
63     *
64     * @param workflowInstance
65     *          The workflow instance
66     * @return The URL for the user interface
67     * @throws WorkflowOperationException
68     *           If the url to the hold state ui can't be created
69     */
70    String getHoldStateUserInterfaceURL(WorkflowInstance workflowInstance) throws WorkflowOperationException;
71  
72    /**
73     * Returns the title for the link to this operations hold state UI.
74     *
75     * @return title to be displayed
76     */
77    String getHoldActionTitle();
78  
79  }