KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > structuretool > actions > ViewSiteNodeTreeAction


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.cms.applications.structuretool.actions;
25
26 import javax.servlet.http.Cookie JavaDoc;
27
28 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction;
29 import org.infoglue.cms.util.CmsPropertyHandler;
30
31 /**
32  * This class implements the action class for the menu in the siteNode tool.
33  *
34  * @author Mattias Bogeblad
35  */

36
37 public class ViewSiteNodeTreeAction extends InfoGlueAbstractAction
38 {
39     private static final long serialVersionUID = 1L;
40    
41     private Integer JavaDoc repositoryId;
42     private Integer JavaDoc siteNodeId;
43     private String JavaDoc tree;
44     private String JavaDoc hideLeafs;
45     
46     public void setRepositoryId(Integer JavaDoc repositoryId)
47     {
48         this.repositoryId = repositoryId;
49     }
50
51     public Integer JavaDoc getRepositoryId()
52     {
53         return this.repositoryId;
54     }
55     
56     public void setSiteNodeId(Integer JavaDoc siteNodeId)
57     {
58         this.siteNodeId = siteNodeId;
59     }
60
61     public Integer JavaDoc getSiteNodeId()
62     {
63         return this.siteNodeId;
64     }
65     
66     public void setHideLeafs(String JavaDoc hideLeafs)
67     {
68         this.hideLeafs = hideLeafs;
69     }
70
71     public String JavaDoc getHideLeafs()
72     {
73         return this.hideLeafs;
74     }
75     
76     public String JavaDoc doExecute() throws Exception JavaDoc
77     {
78         // Get / Set tree preferance
79
if (tree != null)
80         {
81             // This action was called with parameter to set tree preferance
82
// Add a cookie for the tree setting
83
Cookie JavaDoc t = new Cookie JavaDoc("tree", tree);
84             getResponse().addCookie(t);
85         }
86         else
87         {
88         // First try to get user cookie for tree-mode
89
Cookie JavaDoc[] cookies = getRequest().getCookies();
90             if(cookies != null)
91                 for (int i=0; i < cookies.length; i++)
92                 {
93                     if (cookies[i].getName().compareTo("tree") == 0)
94                         setTree(cookies[i].getValue());
95                 }
96         }
97
98         // If that fails, try global properties for default tree
99
if (tree == null)
100             setTree(CmsPropertyHandler.getTree());
101
102         // Still no tree, force applet version
103
if (tree == null)
104             setTree("applet");
105         
106         
107         return "success";
108     }
109                
110     /**
111      * Returns the tree.
112      * @return String
113      */

114     public String JavaDoc getTree()
115     {
116         return tree;
117     }
118
119     /**
120      * Sets the tree.
121      * @param tree The tree to set
122      */

123     public void setTree(String JavaDoc tree)
124     {
125         this.tree = tree;
126     }
127
128 }
129
Popular Tags