KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > cms > ant > DocumentOperationTask


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: DocumentOperationTask.java 160149 2005-04-05 09:51:54Z michi $ */
19
20 package org.apache.lenya.cms.ant;
21
22 import org.apache.lenya.cms.publication.Publication;
23 import org.apache.lenya.cms.publication.SiteTree;
24 import org.apache.lenya.cms.publication.SiteTreeNode;
25 import org.apache.lenya.cms.publication.SiteTreeNodeVisitor;
26 import org.apache.tools.ant.BuildException;
27
28 /**
29  * Abstract base class for Ant tasks, which implements the SiteTreeNodeVisitor
30  * to call an operation for a document.
31  * (Visitor pattern)
32  */

33 public abstract class DocumentOperationTask extends PublicationTask implements SiteTreeNodeVisitor {
34
35         private String JavaDoc firstarea;
36         private String JavaDoc firstdocumentid;
37
38     /**
39      *
40      */

41     public DocumentOperationTask() {
42         super();
43     }
44
45
46     /**
47      * @return String The area of the source.
48      */

49     public String JavaDoc getFirstarea() {
50         return firstarea;
51     }
52
53     /**
54      * @return String The document-id corresponding to the source.
55      */

56     public String JavaDoc getFirstdocumentid() {
57         return firstdocumentid;
58     }
59
60     /**
61      * @param string The area of the source.
62      */

63     public void setFirstarea(String JavaDoc string) {
64         firstarea = string;
65     }
66
67     /**
68      * @param string The document-id corresponding to the source.
69      */

70     public void setFirstdocumentid(String JavaDoc string) {
71         firstdocumentid = string;
72     }
73
74     /**
75      * To be overriden.
76      * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
77      */

78     public abstract void visitSiteTreeNode(SiteTreeNode node);
79
80     /**
81      * @see org.apache.tools.ant.Task#execute()
82      **/

83     public void execute() throws BuildException {
84         try {
85             log("document-id for the source" + this.getFirstdocumentid());
86             log("area for the source" + this.getFirstarea());
87
88             Publication publication= getPublication();
89             SiteTree tree = publication.getTree(getFirstarea());
90             SiteTreeNode node = tree.getNode(getFirstdocumentid());
91
92             node.acceptSubtree(this);
93         } catch (Exception JavaDoc e) {
94             throw new BuildException(e);
95         }
96 }
97
98
99 }
100
Popular Tags