KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > publishingtool > actions > ViewPublishingToolToolBarAction


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.publishingtool.actions;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.HashMap JavaDoc;
28 import java.util.List JavaDoc;
29
30 import org.apache.log4j.Logger;
31 import org.infoglue.cms.applications.common.ImageButton;
32 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction;
33 import org.infoglue.cms.controllers.kernel.impl.simple.RepositoryController;
34 import org.infoglue.cms.entities.management.RepositoryVO;
35 import org.infoglue.cms.util.CmsPropertyHandler;
36
37 /**
38  * This class implements the action class for the framed page in the management tool.
39  *
40  * @author Mattias Bogeblad
41  */

42
43 public class ViewPublishingToolToolBarAction extends InfoGlueAbstractAction
44 {
45     private final static Logger logger = Logger.getLogger(ViewPublishingToolToolBarAction.class.getName());
46
47     private static final long serialVersionUID = 1L;
48
49     private String JavaDoc title = "";
50     private String JavaDoc name = "";
51     private String JavaDoc toolbarKey = "";
52     private String JavaDoc url = "";
53     
54     //All id's that are used
55
private Integer JavaDoc repositoryId = null;
56     private Integer JavaDoc systemUserId = null;
57     private Integer JavaDoc roleId = null;
58     private Integer JavaDoc languageId = null;
59     private Integer JavaDoc functionId = null;
60     private Integer JavaDoc serviceDefinitionId = null;
61     private Integer JavaDoc availableServiceBindingId = null;
62     private Integer JavaDoc siteNodeTypeDefinitionId = null;
63     
64     private static HashMap JavaDoc buttonsMap = new HashMap JavaDoc();
65         
66     public String JavaDoc doExecute() throws Exception JavaDoc
67     {
68         return "success";
69     }
70
71     public Integer JavaDoc getRepositoryId()
72     {
73         return this.repositoryId;
74     }
75
76     public void setRepositoryId(Integer JavaDoc repositoryId)
77     {
78         this.repositoryId = repositoryId;
79     }
80
81     public Integer JavaDoc getSystemUserId()
82     {
83         return this.systemUserId;
84     }
85
86     public void setSystemUserId(Integer JavaDoc systemUserId)
87     {
88         this.systemUserId = systemUserId;
89     }
90
91     public Integer JavaDoc getLanguageId()
92     {
93         return this.languageId;
94     }
95
96     public void setLanguageId(Integer JavaDoc languageId)
97     {
98         this.languageId = languageId;
99     }
100
101     public Integer JavaDoc getRoleId()
102     {
103         return this.roleId;
104     }
105
106     public void setRoleId(Integer JavaDoc roleId)
107     {
108         this.roleId = roleId;
109     }
110
111     public Integer JavaDoc getFunctionId()
112     {
113         return this.functionId;
114     }
115
116     public void setFunctionId(Integer JavaDoc functionId)
117     {
118         this.functionId = functionId;
119     }
120
121     public Integer JavaDoc getServiceDefinitionId()
122     {
123         return this.serviceDefinitionId;
124     }
125
126     public void setServiceDefinitionId(Integer JavaDoc serviceDefinitionId)
127     {
128         this.serviceDefinitionId = serviceDefinitionId;
129     }
130
131     public Integer JavaDoc getAvailableServiceBindingId()
132     {
133         return this.availableServiceBindingId;
134     }
135
136     public void setAvailableServiceBindingId(Integer JavaDoc availableServiceBindingId)
137     {
138         this.availableServiceBindingId = availableServiceBindingId;
139     }
140
141     public Integer JavaDoc getSiteNodeTypeDefinitionId()
142     {
143         return this.siteNodeTypeDefinitionId;
144     }
145
146     public void setSiteNodeTypeDefinitionId(Integer JavaDoc siteNodeTypeDefinitionId)
147     {
148         this.siteNodeTypeDefinitionId = siteNodeTypeDefinitionId;
149     }
150
151     public String JavaDoc getTitle()
152     {
153         return this.title;
154     }
155     
156     public void setTitle(String JavaDoc title)
157     {
158         this.title = title;
159     }
160
161     public String JavaDoc getName()
162     {
163         return this.name;
164     }
165     
166     public void setName(String JavaDoc name)
167     {
168         this.name = name;
169     }
170     
171     public String JavaDoc getToolbarKey()
172     {
173         return this.toolbarKey;
174     }
175
176     public void setToolbarKey(String JavaDoc toolbarKey)
177     {
178         this.toolbarKey = toolbarKey;
179     }
180
181     public void setUrl(String JavaDoc url)
182     {
183         this.url = url;
184     }
185     
186     public String JavaDoc getUrl()
187     {
188         return this.url;
189     }
190
191     public List JavaDoc getButtons()
192     {
193         logger.info("Title:" + this.title);
194         
195         if(this.toolbarKey.equalsIgnoreCase("publications"))
196             return getPublicationsButtons();
197                     
198         return null;
199     }
200     
201     
202     private List JavaDoc getPublicationsButtons()
203     {
204         List JavaDoc buttons = new ArrayList JavaDoc();
205         buttons.add(new ImageButton(true, "javascript:submitToPreview();", getLocalizedString(getSession().getLocale(), "images.publishingtool.buttons.previewContent"), "tool.publishtool.preview.header", "Preview marked versions"));
206         buttons.add(new ImageButton(true, "javascript:submitToCreate();", getLocalizedString(getSession().getLocale(), "images.publishingtool.buttons.createEdition"), "tool.publishtool.createEdition.header", "Create a new edition of the marked versions"));
207         buttons.add(new ImageButton(true, "javascript:submitToUnpublish('publication');", getLocalizedString(getSession().getLocale(), "images.publishingtool.buttons.unpublishEdition"), "tool.publishtool.unpublishEdition.header", "Unpublish the marked edition and send the versions back to publishable state"));
208         buttons.add(new ImageButton(true, "javascript:submitToDeny();", getLocalizedString(getSession().getLocale(), "images.publishingtool.buttons.denyPublishing"), "tool.publishtool.denyPublication.header", "Deny the checked items from publication"));
209         
210         try
211         {
212             RepositoryVO repositoryVO = RepositoryController.getController().getRepositoryVOWithId(this.repositoryId);
213
214             String JavaDoc repositoryName = repositoryVO.getName();
215             String JavaDoc dnsName = repositoryVO.getDnsName();
216
217             String JavaDoc previewUrl = null;
218             
219             String JavaDoc keyword = "preview=";
220             int startIndex = (dnsName == null) ? -1 : dnsName.indexOf(keyword);
221             if(startIndex != -1)
222             {
223                 int endIndex = dnsName.indexOf(",", startIndex);
224                 if(endIndex > -1)
225                     dnsName = dnsName.substring(startIndex, endIndex);
226                 else
227                     dnsName = dnsName.substring(startIndex);
228
229                 previewUrl = dnsName.split("=")[1] + CmsPropertyHandler.getComponentRendererUrl().replaceAll("Working", "Preview") + "ViewPage.action";
230             }
231             else
232             {
233                 previewUrl = CmsPropertyHandler.getStagingDeliveryUrl();
234             }
235
236             buttons.add(new ImageButton(true, "javascript:openPopup('" + previewUrl + "?repositoryName=" + repositoryName + "', 'StagingPreview', 'width=800,height=600,resizable=yes,toolbar=yes,scrollbars=yes,status=yes,location=yes,menubar=yes');", getLocalizedString(getSession().getLocale(), "images.publishingtool.buttons.previewEnvironment"), "tool.publishtool.previewEnvironment.header"));
237         }
238         catch(Exception JavaDoc e)
239         {
240             e.printStackTrace();
241         }
242         
243         return buttons;
244     }
245
246
247 }
248
Popular Tags