KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > cms > workflow > WorkflowDocument


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 /* $Id: WorkflowDocument.java 43036 2004-05-21 13:20:46Z andreas $ */
19
20 package org.apache.lenya.cms.workflow;
21
22 import org.apache.lenya.cms.publication.Document;
23 import org.apache.lenya.workflow.Event;
24 import org.apache.lenya.workflow.Situation;
25 import org.apache.lenya.workflow.WorkflowException;
26 import org.apache.lenya.workflow.impl.WorkflowImpl;
27 import org.apache.lenya.workflow.impl.WorkflowInstanceImpl;
28
29 public class WorkflowDocument extends WorkflowInstanceImpl {
30     
31     /**
32      * Create a new <code>WorkflowDocument</code>
33      *
34      * @param document the document
35      *
36      * @throws WorkflowException if an error occurs
37      */

38     protected WorkflowDocument(Document document) throws WorkflowException {
39         assert document != null;
40         this.document = document;
41     }
42
43     private Document document;
44
45     /**
46      * Returns the document of this WorkflowDocument object.
47      * @return A document object.
48      */

49     public Document getDocument() {
50         return document;
51     }
52
53     /**
54      * DOCUMENT ME!
55      *
56      * @param situation DOCUMENT ME!
57      * @param eventName DOCUMENT ME!
58      *
59      * @throws WorkflowException DOCUMENT ME!
60      */

61     public void invoke(Situation situation, String JavaDoc eventName)
62         throws WorkflowException {
63         assert eventName != null;
64
65         Event event = ((WorkflowImpl) getWorkflow()).getEvent(eventName);
66         invoke(situation, event);
67     }
68
69     /** (non-Javadoc)
70      * @see org.apache.lenya.workflow.impl.WorkflowInstanceImpl#getWorkflow(java.lang.String)
71      */

72     protected WorkflowImpl getWorkflow(String JavaDoc workflowName)
73         throws WorkflowException {
74         assert workflowName != null && !"".equals(workflowName);
75         WorkflowImpl workflow = (WorkflowImpl) WorkflowFactory.buildWorkflow(document.getPublication(),
76                 workflowName);
77
78         return workflow;
79     }
80 }
81
Popular Tags