KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.infoglue.cms.applications.common.VisualFormatter;
27 import org.infoglue.cms.controllers.kernel.impl.simple.ContentControllerProxy;
28 import org.infoglue.cms.entities.content.ContentVO;
29 import org.infoglue.cms.util.CmsPropertyHandler;
30 import org.infoglue.cms.util.ConstraintExceptionBuffer;
31
32
33 /**
34  * This action represents the last step in the create content wizard. It creates the content and does all other neccessairy steps
35  * defined by the requestor.
36  */

37
38 public class CreateContentWizardFinishAction extends CreateContentWizardAbstractAction
39 {
40     private ConstraintExceptionBuffer ceb = null;
41     private String JavaDoc returnAddress = "CreateContentWizardFinish.action";
42     private String JavaDoc refreshAddress = null;
43     private Integer JavaDoc contentId = null;
44     
45     public CreateContentWizardFinishAction()
46     {
47         this.ceb = new ConstraintExceptionBuffer();
48     }
49     
50     
51     public String JavaDoc doExecute() throws Exception JavaDoc
52     {
53         try
54         {
55             CreateContentWizardInfoBean createContentWizardInfoBean = getCreateContentWizardInfoBean();
56             
57             if(createContentWizardInfoBean.getParentContentId() == null)
58             {
59                 return "stateLocation";
60             }
61     
62             createContentWizardInfoBean.getContent().setCreator(this.getInfoGluePrincipal().getName());
63             this.ceb = createContentWizardInfoBean.getContent().getValueObject().validate();
64             
65             if(!this.ceb.isEmpty())
66             {
67                 return "inputContent";
68             }
69     
70             if(createContentWizardInfoBean.getContentVersions().size() == 0)
71             {
72                 String JavaDoc wysiwygEditor = CmsPropertyHandler.getWysiwygEditor();
73                 if(wysiwygEditor == null || wysiwygEditor.equalsIgnoreCase("") || wysiwygEditor.equalsIgnoreCase("HTMLArea"))
74                     return "inputContentVersions";
75                 else
76                     return "inputContentVersionsForFCKEditor";
77
78             }
79             //ceb.throwIfNotEmpty();
80

81             ContentVO contentVO = ContentControllerProxy.getController().acCreate(this.getInfoGluePrincipal(), createContentWizardInfoBean);
82             this.contentId = contentVO.getContentId();
83             
84             String JavaDoc returnAddress = createContentWizardInfoBean.getReturnAddress();
85             returnAddress = returnAddress.replaceAll("#entityId", this.contentId.toString());
86             returnAddress = returnAddress.replaceAll("#path", contentVO.getName());
87             
88             this.invalidateCreateContentWizardInfoBean();
89             
90             this.getResponse().sendRedirect(returnAddress);
91         }
92         catch(Exception JavaDoc e)
93         {
94             e.printStackTrace();
95         }
96         
97         return NONE;
98     }
99     
100     public void setParentContentId(Integer JavaDoc parentContentId)
101     {
102         getCreateContentWizardInfoBean().setParentContentId(parentContentId);
103     }
104
105     public Integer JavaDoc getParentContentId()
106     {
107         return getCreateContentWizardInfoBean().getParentContentId();
108     }
109
110     public void setRepositoryId(Integer JavaDoc repositoryId)
111     {
112         getCreateContentWizardInfoBean().setRepositoryId(repositoryId);
113     }
114
115     public Integer JavaDoc getRepositoryId()
116     {
117         return getCreateContentWizardInfoBean().getRepositoryId();
118     }
119
120     public void setContentTypeDefinitionId(Integer JavaDoc contentTypeDefinitionId)
121     {
122         getCreateContentWizardInfoBean().setContentTypeDefinitionId(contentTypeDefinitionId);
123     }
124
125     public Integer JavaDoc getContentTypeDefinitionId()
126     {
127         return getCreateContentWizardInfoBean().getContentTypeDefinitionId();
128     }
129     
130     public java.lang.String JavaDoc getName()
131     {
132         return getCreateContentWizardInfoBean().getContent().getName();
133     }
134
135     public String JavaDoc getPublishDateTime()
136     {
137         return new VisualFormatter().formatDate(getCreateContentWizardInfoBean().getContent().getPublishDateTime(), "yyyy-MM-dd HH:mm");
138     }
139         
140     public String JavaDoc getExpireDateTime()
141     {
142         return new VisualFormatter().formatDate(getCreateContentWizardInfoBean().getContent().getExpireDateTime(), "yyyy-MM-dd HH:mm");
143     }
144
145     public Boolean JavaDoc getIsBranch()
146     {
147         return getCreateContentWizardInfoBean().getContent().getIsBranch();
148     }
149             
150     public void setName(String JavaDoc name)
151     {
152         getCreateContentWizardInfoBean().getContent().setName(name);
153     }
154         
155     public void setPublishDateTime(String JavaDoc publishDateTime)
156     {
157         getCreateContentWizardInfoBean().getContent().setPublishDateTime(new VisualFormatter().parseDate(publishDateTime, "yyyy-MM-dd HH:mm"));
158     }
159
160     public void setExpireDateTime(String JavaDoc expireDateTime)
161     {
162         getCreateContentWizardInfoBean().getContent().setExpireDateTime(new VisualFormatter().parseDate(expireDateTime, "yyyy-MM-dd HH:mm"));
163     }
164  
165     public void setIsBranch(Boolean JavaDoc isBranch)
166     {
167         getCreateContentWizardInfoBean().getContent().setIsBranch(isBranch);
168     }
169
170     public ContentVO getContentVO()
171     {
172         return getCreateContentWizardInfoBean().getContent().getValueObject();
173     }
174
175     public void setContentVO(ContentVO contentVO)
176     {
177         getCreateContentWizardInfoBean().getContent().setValueObject(contentVO);
178     }
179
180     public void setReturnAddress(String JavaDoc returnAddress)
181     {
182         this.returnAddress = returnAddress;
183     }
184     
185     public String JavaDoc getReturnAddress()
186     {
187         return returnAddress;
188     }
189
190     public void setRefreshAddress(String JavaDoc refreshAddress)
191     {
192         getCreateContentWizardInfoBean().setReturnAddress(refreshAddress);
193     }
194     
195     public String JavaDoc getRefreshAddress()
196     {
197         return getCreateContentWizardInfoBean().getReturnAddress();
198     }
199
200     public Integer JavaDoc getContentId()
201     {
202         return this.contentId;
203     }
204
205 }
206
Popular Tags