KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > contenttool > actions > ViewContentTreeAction


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.contenttool.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 content tool.
33  *
34  * @author Mattias Bogeblad
35  */

36
37 public class ViewContentTreeAction extends InfoGlueAbstractAction implements ViewContentTreeActionInterface
38 {
39     private static final long serialVersionUID = 1L;
40     
41     private Integer JavaDoc repositoryId;
42     private Integer JavaDoc contentId;
43     private String JavaDoc tree;
44     private String JavaDoc hideLeafs;
45     private String JavaDoc bodyClass;
46     
47     public void setRepositoryId(Integer JavaDoc repositoryId)
48     {
49         this.repositoryId = repositoryId;
50     }
51
52     public Integer JavaDoc getRepositoryId()
53     {
54         return this.repositoryId;
55     }
56     
57     public void setContentId(Integer JavaDoc contentId)
58     {
59         this.contentId = contentId;
60     }
61
62     public Integer JavaDoc getContentId()
63     {
64         return this.contentId;
65     }
66
67     public void setHideLeafs(String JavaDoc hideLeafs)
68     {
69         this.hideLeafs = hideLeafs;
70     }
71
72     public String JavaDoc getHideLeafs()
73     {
74         return this.hideLeafs;
75     }
76     
77     public String JavaDoc doExecute() throws Exception JavaDoc
78     {
79         // Get / Set tree preferance
80
if (tree != null)
81         {
82             // This action was called with parameter to set tree preferance
83
// Add a cookie for the tree setting
84
Cookie JavaDoc t = new Cookie JavaDoc("tree", tree);
85             getResponse().addCookie(t);
86         }
87         else
88         {
89         // First try to get user cookie for tree-mode
90
Cookie JavaDoc[] cookies = getRequest().getCookies();
91             if(cookies != null)
92                 for (int i=0; i < cookies.length; i++)
93                 {
94                     if (cookies[i].getName().compareTo("tree") == 0)
95                         setTree(cookies[i].getValue());
96                 }
97         }
98
99         // If that fails, try global properties for default tree
100
if (tree == null)
101             setTree(CmsPropertyHandler.getTree());
102
103         // Still no tree, force applet version
104
if (tree == null)
105             setTree("applet");
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     public String JavaDoc getBodyClass()
129     {
130         return bodyClass;
131     }
132     
133     public void setBodyClass(String JavaDoc bodyClass)
134     {
135         this.bodyClass = bodyClass;
136     }
137 }
138
Popular Tags