KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > contenttool > wizards > actions > CreateContentWizardChooseParentAction


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.wizards.actions;
25
26 import java.net.URLEncoder JavaDoc;
27 import java.util.List JavaDoc;
28
29 import org.infoglue.cms.applications.contenttool.actions.ViewContentTreeActionInterface;
30 import org.infoglue.cms.controllers.kernel.impl.simple.RepositoryController;
31 import org.infoglue.cms.entities.content.ContentVO;
32 import org.infoglue.cms.entities.management.RepositoryVO;
33 import org.infoglue.cms.exception.Bug;
34 import org.infoglue.cms.exception.ConstraintException;
35 import org.infoglue.cms.exception.SystemException;
36 import org.infoglue.cms.util.ConstraintExceptionBuffer;
37
38 /**
39  * This action represents a tree where the user can select where to save his new content.
40  */

41
42 public class CreateContentWizardChooseParentAction extends CreateContentWizardAbstractAction implements ViewContentTreeActionInterface
43 {
44     //Used by the tree only
45
private Integer JavaDoc contentId;
46     private String JavaDoc tree;
47     private String JavaDoc hideLeafs;
48     private Integer JavaDoc siteNodeId;
49     private Integer JavaDoc languageId;
50     private String JavaDoc componentId;
51     private String JavaDoc propertyName;
52     private String JavaDoc refreshAddress;
53     private String JavaDoc showSimple;
54     
55     private Integer JavaDoc parentContentId;
56     private Integer JavaDoc repositoryId;
57     private ConstraintExceptionBuffer ceb;
58     
59     private String JavaDoc returnAddress;
60     private String JavaDoc[] allowedContentTypeIds = null;
61     
62     private List JavaDoc repositories;
63     
64     public CreateContentWizardChooseParentAction()
65     {
66         this(new ContentVO());
67     }
68     
69     public CreateContentWizardChooseParentAction(ContentVO contentVO)
70     {
71         this.ceb = new ConstraintExceptionBuffer();
72     }
73
74     public String JavaDoc doExecute() throws Exception JavaDoc
75     {
76         this.repositories = RepositoryController.getController().getAuthorizedRepositoryVOList(this.getInfoGluePrincipal(), false);
77
78         return "success";
79     }
80     
81     public Integer JavaDoc getTopRepositoryId() throws ConstraintException, SystemException, Bug
82     {
83         Integer JavaDoc topRepositoryId = null;
84
85         if (repositoryId != null)
86             topRepositoryId = repositoryId;
87
88         if(repositories.size() > 0)
89         {
90             topRepositoryId = ((RepositoryVO)repositories.get(0)).getRepositoryId();
91         }
92     
93         return topRepositoryId;
94     }
95   
96     public void setHideLeafs(String JavaDoc hideLeafs)
97     {
98         this.hideLeafs = hideLeafs;
99     }
100
101     public String JavaDoc getHideLeafs()
102     {
103         return this.hideLeafs;
104     }
105
106     public String JavaDoc getTree()
107     {
108         return tree;
109     }
110
111     public void setTree(String JavaDoc tree)
112     {
113         this.tree = tree;
114     }
115
116     public void setParentContentId(Integer JavaDoc parentContentId)
117     {
118         this.parentContentId = parentContentId;
119     }
120
121     public Integer JavaDoc getParentContentId()
122     {
123         return this.parentContentId;
124     }
125
126     public void setRepositoryId(Integer JavaDoc repositoryId)
127     {
128         this.repositoryId = repositoryId;
129     }
130
131     public Integer JavaDoc getRepositoryId()
132     {
133         try
134         {
135             if(this.repositoryId == null)
136             {
137                 this.repositoryId = (Integer JavaDoc)getHttpSession().getAttribute("repositoryId");
138                     
139                 if(this.repositoryId == null)
140                 {
141                     this.repositoryId = getTopRepositoryId();
142                     getHttpSession().setAttribute("repositoryId", this.repositoryId);
143                 }
144             }
145         }
146         catch(Exception JavaDoc e)
147         {
148         }
149             
150         return repositoryId;
151     }
152
153     public void setContentId(Integer JavaDoc contentId)
154     {
155         this.contentId = contentId;
156     }
157
158     public Integer JavaDoc getContentId()
159     {
160         return this.contentId;
161     }
162     
163     public String JavaDoc getReturnAddress()
164     {
165         return returnAddress;
166     }
167
168     public void setReturnAddress(String JavaDoc string)
169     {
170         returnAddress = string;
171     }
172
173     public String JavaDoc getAllowedContentTypeIdsAsUrlEncodedString() throws Exception JavaDoc
174     {
175         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
176         
177         for(int i=0; i<allowedContentTypeIds.length; i++)
178         {
179             if(i > 0)
180                 sb.append("&");
181             
182             sb.append("allowedContentTypeIds=" + URLEncoder.encode(allowedContentTypeIds[i], "UTF-8"));
183         }
184
185         return sb.toString();
186     }
187
188     public String JavaDoc[] getAllowedContentTypeIds()
189     {
190         return allowedContentTypeIds;
191     }
192     
193     public void setAllowedContentTypeIds(String JavaDoc[] allowedContentTypeIds)
194     {
195         this.allowedContentTypeIds = allowedContentTypeIds;
196     }
197
198     public List JavaDoc getRepositories()
199     {
200         return repositories;
201     }
202
203     public String JavaDoc getComponentId()
204     {
205         return componentId;
206     }
207
208     public void setComponentId(String JavaDoc componentId)
209     {
210         this.componentId = componentId;
211     }
212
213     public Integer JavaDoc getLanguageId()
214     {
215         return languageId;
216     }
217
218     public void setLanguageId(Integer JavaDoc languageId)
219     {
220         this.languageId = languageId;
221     }
222
223     public String JavaDoc getPropertyName()
224     {
225         return propertyName;
226     }
227
228     public void setPropertyName(String JavaDoc propertyName)
229     {
230         this.propertyName = propertyName;
231     }
232
233     public String JavaDoc getRefreshAddress()
234     {
235         return refreshAddress;
236     }
237
238     public String JavaDoc getEncodedRefreshAddress() throws Exception JavaDoc
239     {
240         return URLEncoder.encode(refreshAddress, "UTF-8");
241     }
242
243     public void setRefreshAddress(String JavaDoc refreshAddress)
244     {
245         this.refreshAddress = refreshAddress;
246     }
247
248     public String JavaDoc getShowSimple()
249     {
250         return showSimple;
251     }
252
253     public void setShowSimple(String JavaDoc showSimple)
254     {
255         this.showSimple = showSimple;
256     }
257
258     public Integer JavaDoc getSiteNodeId()
259     {
260         return siteNodeId;
261     }
262
263     public void setSiteNodeId(Integer JavaDoc siteNodeId)
264     {
265         this.siteNodeId = siteNodeId;
266     }
267
268 }
269
Popular Tags