KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.HashMap JavaDoc;
27 import java.util.Map JavaDoc;
28
29 import org.infoglue.cms.applications.common.VisualFormatter;
30 import org.infoglue.cms.controllers.kernel.impl.simple.SiteNodeController;
31 import org.infoglue.cms.controllers.usecases.structuretool.UpdateSiteNodeUCC;
32 import org.infoglue.cms.controllers.usecases.structuretool.UpdateSiteNodeUCCFactory;
33 import org.infoglue.cms.entities.structure.SiteNodeVO;
34 import org.infoglue.cms.entities.structure.SiteNodeVersionVO;
35 import org.infoglue.cms.util.ConstraintExceptionBuffer;
36
37 import com.opensymphony.module.propertyset.PropertySet;
38 import com.opensymphony.module.propertyset.PropertySetManager;
39
40  
41 /**
42   * This is the action-class for UpdateSiteNode
43   *
44   * @author Mattias Bogeblad
45   */

46 public class UpdateSiteNodeAction extends ViewSiteNodeAction //WebworkAbstractAction
47
{
48     private SiteNodeVO siteNodeVO;
49     private Integer JavaDoc siteNodeId;
50     private Integer JavaDoc repositoryId;
51     private Integer JavaDoc siteNodeTypeDefinitionId;
52     private String JavaDoc name;
53     private Boolean JavaDoc isBranch;
54     
55     private Integer JavaDoc isProtected;
56     private Integer JavaDoc disablePageCache;
57     private Integer JavaDoc disableEditOnSight;
58     private Integer JavaDoc disableLanguages;
59     private String JavaDoc contentType;
60     private String JavaDoc pageCacheKey;
61
62     private ConstraintExceptionBuffer ceb;
63     
64     public UpdateSiteNodeAction()
65     {
66         this(new SiteNodeVO());
67     }
68     
69     public UpdateSiteNodeAction(SiteNodeVO siteNodeVO)
70     {
71         this.siteNodeVO = siteNodeVO;
72         this.ceb = new ConstraintExceptionBuffer();
73     }
74     
75     public String JavaDoc doExecute() throws Exception JavaDoc
76     {
77         //try
78
//{
79
super.initialize(getSiteNodeId());
80             SiteNodeVO oldSiteNodeVO = SiteNodeController.getSiteNodeVOWithId(getSiteNodeId());
81
82             this.siteNodeVO.setCreatorName(this.getInfoGluePrincipal().getName());
83             this.siteNodeVO.setMetaInfoContentId(oldSiteNodeVO.getMetaInfoContentId());
84             ceb = this.siteNodeVO.validate();
85             
86             ceb.throwIfNotEmpty();
87
88             SiteNodeVersionVO siteNodeVersionVO = new SiteNodeVersionVO();
89             siteNodeVersionVO.setContentType(this.getContentType());
90             siteNodeVersionVO.setPageCacheKey(this.getPageCacheKey());
91             siteNodeVersionVO.setDisableEditOnSight(this.getDisableEditOnSight());
92             siteNodeVersionVO.setDisableLanguages(this.disableLanguages);
93             siteNodeVersionVO.setDisablePageCache(this.getDisablePageCache());
94             siteNodeVersionVO.setIsProtected(this.getIsProtected());
95             siteNodeVersionVO.setVersionModifier(this.getInfoGluePrincipal().getName());
96             
97             UpdateSiteNodeUCC updateSiteNodeUCC = UpdateSiteNodeUCCFactory.newUpdateSiteNodeUCC();
98             updateSiteNodeUCC.updateSiteNode(this.getInfoGluePrincipal(), this.siteNodeVO, this.siteNodeTypeDefinitionId, siteNodeVersionVO);
99             
100             String JavaDoc[] values = getRequest().getParameterValues("disabledLanguageId");
101             String JavaDoc valueString = "";
102             if(values != null)
103             {
104                 for(int i=0; i<values.length; i++)
105                 {
106                     if(i > 0)
107                         valueString = valueString + ",";
108                     valueString = valueString + values[i];
109                 }
110
111                 Map JavaDoc args = new HashMap JavaDoc();
112                 args.put("globalKey", "infoglue");
113                 PropertySet ps = PropertySetManager.getInstance("jdbc", args);
114
115                 ps.setString("siteNode_" + getSiteNodeId() + "_disabledLanguages", valueString);
116             }
117
118         //}
119
//catch(Exception e)
120
//{
121
// e.printStackTrace();
122
//}
123

124         return "success";
125     }
126
127     public String JavaDoc doSaveAndExit() throws Exception JavaDoc
128     {
129         doExecute();
130                         
131         return "saveAndExit";
132     }
133
134     public void setSiteNodeId(Integer JavaDoc siteNodeId)
135     {
136         this.siteNodeVO.setSiteNodeId(siteNodeId);
137     }
138
139     public java.lang.Integer JavaDoc getSiteNodeId()
140     {
141         return this.siteNodeVO.getSiteNodeId();
142     }
143
144     public java.lang.String JavaDoc getName()
145     {
146         return this.siteNodeVO.getName();
147     }
148  
149     public Boolean JavaDoc getIsBranch()
150     {
151         return this.siteNodeVO.getIsBranch();
152     }
153         
154     public void setName(java.lang.String JavaDoc name)
155     {
156         this.siteNodeVO.setName(name);
157     }
158     
159     public void setPublishDateTime(String JavaDoc publishDateTime)
160     {
161         this.siteNodeVO.setPublishDateTime(new VisualFormatter().parseDate(publishDateTime, "yyyy-MM-dd HH:mm"));
162     }
163
164     public void setExpireDateTime(String JavaDoc expireDateTime)
165     {
166         this.siteNodeVO.setExpireDateTime(new VisualFormatter().parseDate(expireDateTime, "yyyy-MM-dd HH:mm"));
167     }
168
169     public void setIsBranch(Boolean JavaDoc isBranch)
170     {
171         this.siteNodeVO.setIsBranch(isBranch);
172     }
173
174     public void setSiteNodeTypeDefinitionId(Integer JavaDoc siteNodeTypeDefinitionId)
175     {
176         this.siteNodeTypeDefinitionId = siteNodeTypeDefinitionId;
177     }
178
179     public java.lang.Integer JavaDoc getSiteNodeTypeDefinitionId()
180     {
181         return this.siteNodeTypeDefinitionId;
182     }
183     
184     public void setRepositoryId(Integer JavaDoc repositoryId)
185     {
186         this.repositoryId = repositoryId;
187     }
188
189     public Integer JavaDoc getRepositoryId()
190     {
191         return this.repositoryId;
192     }
193
194     public String JavaDoc getContentType()
195     {
196         return this.contentType;
197     }
198
199     public void setContentType(String JavaDoc contentType)
200     {
201         this.contentType = contentType;
202     }
203
204     public Integer JavaDoc getDisableEditOnSight()
205     {
206         return this.disableEditOnSight;
207     }
208
209     public void setDisableEditOnSight(Integer JavaDoc disableEditOnSight)
210     {
211         this.disableEditOnSight = disableEditOnSight;
212     }
213
214     public Integer JavaDoc getDisableLanguages()
215     {
216         return this.disableLanguages;
217     }
218
219     public void setDisableLanguages(Integer JavaDoc disableLanguages)
220     {
221         this.disableLanguages = disableLanguages;
222     }
223
224     public Integer JavaDoc getDisablePageCache()
225     {
226         return this.disablePageCache;
227     }
228
229     public void setDisablePageCache(Integer JavaDoc disablePageCache)
230     {
231         this.disablePageCache = disablePageCache;
232     }
233
234     public Integer JavaDoc getIsProtected()
235     {
236         return this.isProtected;
237     }
238
239     public void setIsProtected(Integer JavaDoc isProtected)
240     {
241         this.isProtected = isProtected;
242     }
243
244     public String JavaDoc getPageCacheKey()
245     {
246         return pageCacheKey;
247     }
248     
249     public void setPageCacheKey(String JavaDoc pageCacheKey)
250     {
251         this.pageCacheKey = pageCacheKey;
252     }
253 }
254
Popular Tags