KickJava   Java API By Example, From Geeks To Geeks.

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


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: SiteTreeResetTask.java 160543 2005-04-08 11:30:01Z andreas $ */
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.tools.ant.BuildException;
26
27 /**
28  * Ant task to reset the sitetree xml file
29  */

30 public class SiteTreeResetTask extends PublicationTask {
31     private String JavaDoc area;
32
33     /**
34      *
35      */

36     public SiteTreeResetTask() {
37         super();
38     }
39
40     /**
41      * @return string The area the sitetree belongs to.
42      */

43     public String JavaDoc getArea() {
44         return area;
45     }
46
47     /**
48      * @param string The area the sitetree belongs to.
49      */

50     public void setArea(String JavaDoc string) {
51         area = string;
52     }
53
54     /** (non-Javadoc)
55      * @see org.apache.tools.ant.Task#execute()
56      */

57     public void execute() throws BuildException {
58         try {
59             log("area : " + this.getArea());
60             Publication publication= getPublication();
61             SiteTree tree = publication.getTree(getArea());
62            
63             SiteTreeNode node = tree.getNode("/");
64             node.deleteChildren();
65             tree.save();
66             } catch (
67                 Exception JavaDoc e) {
68             throw new BuildException(e);
69         }
70     }
71
72 }
73
Popular Tags